akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

typedef
tree<
	pair<int, int>,
	null_type,
	less<pair<int, int>>,
	rb_tree_tag,
	tree_order_statistics_node_update>
ordered_set;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

int main()
{
    IOS;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
}     

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

using namespace std;
long long a[200010]={0},s[200010]={0};
long long n,k;
int main()
{
	long long MAXN=0;
	s[0]=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s[i]=s[i-1]+a[i];
	}
	for(int i=k;i<=n;i++)
	{
		MAXN=max(MAXN,s[i]-s[i-k]);
	}
	float LKL=(MAXN+k)/2.00;
	printf("%.8f",LKL);
	
	return 0;
 } 

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>

#define FOR(n) for(int i=0;i<(n);++i)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef pair<int,int> P;
typedef pair<P, P> PP;
typedef long long ll;
int H,W;
char S[110][110];
int num[26];
vector<int> restChars;
int main() {
  scanf("%d%d", &H, &W);
  FOR(H) {
    scanf("%s", S[i]);
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      num[S[i][j]-'a']++;
    }
  }
  int numOdds=0;
  for(int i=0;i<26;++i) {
    if (num[i]%2==1) {
      numOdds++;
    }
  }
  if (H%2==1 && W%2==1) {
    if (numOdds!=1) {
      goto Nope;
    }
  } else {
    if (numOdds>=1) {
      goto Nope;
    }
  }
  for(int i=0;i<26;++i) {
    if (num[i]/2>0) {
      restChars.push_back(num[i] / 2);
    }
  }
  for(int i=0;i<H/2;++i) {
    int rest=W;
    while(rest>0) {
      int trest=rest;
      if (rest % 2 == 1) {
        int t=0;
        for(int j=0;j<restChars.size();++j) {
          if (restChars[j]%2==1) {
            t=j;
          }
        }
        rest--;
        restChars[t]--;
      } else {
        for(int j=0;j<restChars.size();++j) {
          if (restChars[j]>1) {
            int toDec;
            if (restChars[j]%2==0) {
              toDec=restChars[j];
            } else {
              toDec=restChars[j]-1;
            }
            if (toDec>rest) {
              toDec=rest;
            }
            rest-=toDec;
            restChars[j]-=toDec;
          }
        }
      }
      vector<int> temp;
      for(int j=0;j<restChars.size();++j) {
        if(restChars[j]>0)temp.push_back(restChars[j]);
      }
      restChars=temp;
      if (rest==trest) {
        goto Nope;
      }
    }
  }
  printf("Yes\n");
  return 0;
  Nope:
  printf("No\n");
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
N=input()
K=int(input())
km = len(N)
res = 0
if int(N)<=1000:
    for i in range(int(N)):
        c = Counter(str(i+1))
        if len(str(i+1)) - c['0']==K:
            res += 1
    print(res)
    exit()
d = [[0]*3 for _ in range(100001)]
for i in range(100000):
    d[i+1] = d[i][:]
    c = Counter(str(i+1))
    k=len(str(i+1)) - c['0']
    if k<=3:
        d[i+1][k-1] += 1
def rec(n,k):
    re = 0
    if int(n)<100000:
        re = 0
        return d[int(n)][k-1]
    if k==1:
        n = str(int(n))
        return 9*(len(n)-1)+int(n[0])
    t = ''.join(['9']*(len(n)-1))
    t2 = t
    w = (int(n[0])-1)
    if n[0] == '0':
        t2 = n[1:]
        w = 0
    return rec(t2, k) + w*rec(t2, k-1) + rec(str(int(n[1:])), k-1)
print(rec(N,K))


Measured memory_bytes: 15724
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;

    int ans = 0;
    string t = "";
    for(int i = 0; i < s.size(); i++)
    {
        t += s[i];
        if((int)t.size() < 2) continue;
        char a = t[(int)t.size() - 2];
        char b = t.back();
        if(a != b)
        {
            t.pop_back();
            t.pop_back();
            ans += 2;
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections;
using System.Linq;

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Read();
		var b = Read();

		var m = 1 << 30;
		for (int x = 0; x < (1 << n); x++)
		{
			var bx = new BitArray(new[] { x });
			var c = new (int, bool)[n];
			for (int i = 0; i < n; i++)
				c[i] = (bx[i] ? b[i] : a[i], bx[i]);
			m = Math.Min(m, Swap(c));
		}
		Console.WriteLine(m == 1 << 30 ? -1 : m);

		int Swap((int v, bool rev)[] c)
		{
			var g = Array.ConvertAll(c, _ => _.v);
			Array.Sort(g);
			var u = new bool[n];

			var map = new int[n];
			for (int i = 0; i < n; i++)
			{
				map[i] = -1;
				for (int j = 0; j < n; j++)
				{
					if (u[j] || g[i] != c[j].v || (i - j) % 2 != 0 != c[j].rev) continue;
					u[j] = true;
					map[i] = j;
					break;
				}
				if (map[i] == -1) return 1 << 30;
			}

			var t = 0;
			for (int i = 0; i < n; i++)
				for (int j = i + 1; j < n; j++)
					if (map[i] > map[j]) t++;
			return t;
		}
	}
}


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


int Partition(int *A, int p, int r)
{
	int x;
	int i, j, k;


	x = A[r];
	i = p - 1;

	for(j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			if(i != j){
				A[i] ^= A[j];
				A[j] ^= A[i];
				A[i] ^= A[j];
			}
		}
	}

	A[i + 1] ^= A[r];
	A[r] ^= A[i + 1];
	A[i + 1] ^= A[r];

	return i + 1;
}


int main()
{
	int n;
	int *box;
	int partition_n;
	int i;


	scanf("%d", &n);

	box = (int *)malloc(sizeof(int) * n);

	for(i = 0; i < n; i++)
		scanf("%d", &box[i]);


	// 分割処理
	partition_n = Partition(box, 0, n - 1);

	// 表示
	for(i = 0; i < n; i++){
		if(i == partition_n)
			printf("[");
		printf("%d", box[i]);
		if(i == partition_n)
			printf("]");
		if(i != n - 1)
			printf(" ");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2160
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	for i in range(ord('z')-ord('a')+1):
		cc = chr(ord('a')+i)
		pre=-100
		for ci, c in enumerate(s):
			if c != cc:
				pre -= 1
			elif pre >= -2:
				print(ci+pre+1, ci+1)
				return 
			else:
				pre = -1
			#pa((cc,c,pre,ci))
	print(-1,-1)
	return 
	
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 73436
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;

  std::map<ll, ll> ma;
  for (ll i = 0; i < N; i++) {
    ll a;
    std::cin >> a;
    ma[a]++;
  }

  std::vector<ll> va;
  for (auto p : ma) {
    if (p.second >= 4) {
      va.push_back(p.first);
      va.push_back(p.first);
    } else if (p.second >= 2) {
      va.push_back(p.first);
    }
  }
  std::sort(va.begin(), va.end(), std::greater<>());

  if (va.size() < 2) {
    print(0);
  } else {
    print(va[0] * va[1]);
  }
  return 0;
}


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

int main() {
    int n, A = 0, B = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    for(int i = 0; i < n; ++i) {
        if(i%2) B += a[n-i-1];
        else A += a[n-i-1];
    }
    cout << A - B << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Max = 5e2 + 5, Mod = 1e9 + 7;

int main()
{
	int n, pre = -1e7;
	int ans = 0, cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (x > pre)
			cnt = 0;
		else cnt++;
		ans = max(ans, cnt);
		pre = x;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std ;

const int N = 1e5 + 5  ;

int a[N] ;
int d[N] ;

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

    int n , k;
    cin >> n >>k;


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


    for(int i =0 ; i <=n ; ++i )
    {
        d[i] =INT_MAX ;
    }
    d[0] = 0 ;
    for(int i = 0 ; i < n-1 ; ++i )
    {
       for(int j =1 ; j <= k ;++j)
       {
           if(i+j <n)
           {
               d[i+j] = min(d[i+j] , d[i] + abs(a[i+j] - a[i])) ;

           }

       }

    }

    cout << d[n-1] << endl ;



}


Measured memory_bytes: 5196
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

const int N = 4000 + 7;

int n, m;
int x[N], y[N];
std::set<int> s[N];
int z[N];
int p;

std::vector<int> e[N];
int f[N], d[N];
int dfn[N], dfc;
void dfs(int s) {
	std::sort(e[s].begin(), e[s].end());
	if (f[s]) e[s].erase(std::lower_bound(e[s].begin(), e[s].end(), f[s]));
	dfn[++dfc] = s;
	for (auto t : e[s]) f[t] = s, d[t] = d[s] + 1, dfs(t);
}

int vf[N];
int getvf(int x) {
	return vf[x] == x ? x : vf[x] = getvf(vf[x]);
}
void merge(int x, int y) {
	vf[getvf(x)] = getvf(y);
}

int exist(int x, int y) {
	return s[x].find(y * 2) != s[x].end() || s[x].find(y * 2 + 1) != s[x].end();
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);
	
	scanf("%d%d", &n, &m);
	for (int i = 1, u, v; i < n; ++i)
		scanf("%d%d", &u, &v), e[u].push_back(v), e[v].push_back(u);
	dfs(1);

	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", x + i, y + i);
		for (int u = x[i], v = y[i]; u != v; )
			d[u] > d[v] ? (s[u].insert(i * 2), u = f[u]) : (s[v].insert(i * 2 + 1), v = f[v]);
	}
	for (int i = 1; i <= m * 2; ++i) vf[i] = i;

	for (int i = 1; i <= n; ++i)
		p += std::min(2, int(s[dfn[i]].size()));
	for (int i = n, j, k, l; i; --i) {
		if (s[dfn[i]].size() < 2 || z[dfn[i]]) continue;
		j = *s[dfn[i]].begin();
		k = *++s[dfn[i]].begin();
		l = (j ^ k) & 1 ^ 1;
		for (int q = 1; q <= n; ++q)
			if (exist(q, j / 2) && exist(q, k / 2))
				s[q].erase(j), s[q].erase(j ^ 1), s[q].erase(k), s[q].erase(k ^ 1), z[q] = 1;
		for (int q = 1; q <= n; ++q) {
			if (s[q].find(j) != s[q].end())
				s[q].erase(j), s[q].insert(k / 2 * 2 + (j & 1 ^ l));
			if (s[q].find(j ^ 1) != s[q].end())
				s[q].erase(j ^ 1), s[q].insert(k / 2 * 2 + (j & 1 ^ 1 ^ l));
		}
		merge(k / 2, j / 2 + m * l),
		merge(k / 2 + m, j / 2 + m * (l ^ 1));
	}

	printf("%d\n", p);
	for (int i = 1; i <= m; ++i) {
		if (getvf(1) != getvf(i) && getvf(1) != getvf(i + m)) merge(1, i);
		getvf(1) == getvf(i) ? printf("%d %d\n", x[i], y[i]) : printf("%d %d\n", y[i], x[i]);
	}
	return 0;
}

Measured memory_bytes: 56704
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll M;
ll A[101010],S[101010];

ll ret;
map<ll,ll> mp;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	mp[0]=1;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i];
		ret+=mp[S[i+1]%M];
		
		mp[S[i+1]%M]++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

long long int L,R;

int main(void) {
  cin >> L >> R;
  
  int max = 2020;
  
  /*差が2019以上なら答えは0*/
  if(R-L>=2019){
    cout << 0 << endl;
    return 0;
  }

  for(long long int i=L; i<R; i++){
    for(long long int j=i+1; j<=R; j++){
      
      long long int x = i%2019;
      long long int y = j%2019;
      long long int z = x*y%2019;
      
      if(z<max) max=z;
      
    }
  }
  if(max==2020)max=0;
  
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

vector<vector<int> > G, T;

void build(int a, int p) {
	for (int i = 0;i < G[a].size();i++) {
		if (G[a][i] == p) continue;
		T[a].push_back(G[a][i]);
		build(G[a][i], a);
	}
	return;
}

int cal(int x) {
	int nim = 0;
	for (int i = 0;i < T[x].size();i++) nim ^= cal(T[x][i]);
	nim++;
    return nim;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    G.resize(N);
    T.resize(N);
    for (int i = 1;i < N;i++) {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    build(0, -1);
    int nim = 0;
    for (int i = 0;i < T[0].size();i++) {
    	nim ^= cal(T[0][i]);
    }
    if (nim) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,l,n,m;
  cin>>n;
  for(i=1;i<=9;i++)
  {
    if(n%i==0)
    {
      j=n/i;
      if(1<=j&&j<=9)
      {
        cout<<"Yes";
        return 0;
      }
    }
  }
    cout<<"No";
    return 0;
  }
    

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;


int main() {
  int N;
  cin >> N;
  vector<int> AN(N);
  REP(n,N){
    int tmp;
    cin >> tmp;
    AN[n] = tmp;
  }


  ll ans = 0;
  int sum = 0;
  int l, r;
  l = 0;
  r = 0;
  for (l=0; l < N; l++){
    while(r < N && ((sum ^ AN[r]) == (sum + AN[r])) ){
      sum += AN[r];
      r += 1;
    }
    ans += (r-l);
    if (l==r){
      r+=1;
    } else{
       sum -= AN[l];
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 4048
import java.awt.geom.Point2D;
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ2021();
	}
	class AOJ2021{
		int N,M,L,K,A,H;
		final int INF=1<<28;
		AOJ2021(){
			while(true){
				N=sc.nextInt(); M=sc.nextInt(); L=sc.nextInt();
				K=sc.nextInt(); A=sc.nextInt(); H=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			int[][] map=new int[N][N];
			for(int i=0; i<N; ++i)for(int j=0; j<N; ++j)	map[i][j]=INF;
			int[] list=new int[L+2];
			list[0]=A; list[L+1]=H;
			for(int i=0; i<L; ++i)	list[i+1]=sc.nextInt();
			for(int i=0; i<K; ++i){
				int x=sc.nextInt(),y=sc.nextInt(),t=sc.nextInt();
				map[x][y]=t;
				map[y][x]=t;
			}
			for(int j=0; j<N; ++j)for(int i=0; i<N; ++i)for(int k=0; k<N; ++k)	map[i][k]=min(map[i][k], map[i][j]+map[j][k]);
			ArrayList<ArrayList<Edge>> map2=new ArrayList<ArrayList<Edge>>(L+2);
			for(int i=0; i<L+2; ++i)	map2.add(new ArrayList<Edge>());
			for(int f=0; f<L+2; ++f)for(int t=f+1; t<L+2; ++t)if(map[list[f]][list[t]]<INF){
				map2.get(f).add(new Edge(t, map[list[f]][list[t]]));
				map2.get(t).add(new Edge(f, map[list[t]][list[f]]));
			}
			
			PriorityQueue<State> open=new PriorityQueue<State>();
			open.add(new State(0,M,0));
			int[][] closed=new int[L+2][M+1];
			for(int i=0; i<L+2; ++i)for(int j=0; j<=M; ++j)	closed[i][j]=INF;
			closed[0][M]=0;
			
			int ans=INF;
			while(!open.isEmpty()){
				State now=open.poll();
				if(now.p==L+1){
					ans=now.t;
					break;
				}
				for(Edge e:map2.get(now.p))if(e.t<=M){
					int nr=(now.r>=e.t? now.r-e.t: 0),
						nt=(now.r>=e.t? e.t: e.t+(e.t-now.r))+now.t;
					if(closed[e.p][nr]<=nt)	continue;
					open.add(new State(e.p, nr, nt));
					closed[e.p][nr]=nt;
				}
			}
			System.out.println((ans>=INF? "Help!": ans));
		}
		class Edge{
			int p,t;
			Edge(int p,int t){
				this.p=p;	this.t=t;
			}
		}
		class State implements Comparable<State>{
			int p,r,t;
			State(int p,int r,int t){
				this.p=p;	this.r=r;	this.t=t;
			}
			@Override public int compareTo(State o){
				return this.t-o.t;
			}
		}
	}
}

Measured memory_bytes: 97712
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double a, b, c, C, S, L, h;
    cin >> a >> b >> C;
    S = a * b * sin(C*M_PI/180) / 2;
    c = sqrt(a * a + b * b - 2 * a * b* cos(C*M_PI/180));
    L = a + b + c;
    h = 2 * S / a;
    
    printf("%.8f\n %.8f\n %.8f\n", S, L, h);
    
    return 0;
}


Measured memory_bytes: 3532
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    vector<int> a(3);
    int d;
    REP(i, 3) cin >> a[i];
    cin >> d;

    if (d >= abs(a[2] - a[0]) ||
        (d >= abs(a[2] - a[1]) && d >= abs(a[1] - a[0])))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

sum = 0
for n_i in range(1, n + 1):
	n_orders_sum = 0
	for n_order_i in str(n_i):
		n_orders_sum += int(n_order_i)
	if a <= n_orders_sum and n_orders_sum <= b:
		sum += n_i
print(sum)


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> H( N );
	for( int i = 0; i < N; i++ ) {
		cin >> H[i];
	}
	vector<priority_queue<int>> g( N );
	for( int i = 0; i < M; i++ ) {
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		g[A].push( H[B] );
		g[B].push( H[A] );
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int h = H[i];
		if( g[i].size() == 0 || h > g[i].top() ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, top, a[MAXN];
pair <int, int> s[MAXN];
bool check(int p) {
	if (p == 1) {
		bool ans = true;
		for (int i = 1; i <= n; i++)
			ans &= a[i] > a[i - 1];
		return ans;
	}
	top = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= a[i - 1]) {
			while (top >= 1 && s[top].first > a[i]) top--;
			int pos = a[i];
			while (top >= 1) {
				if (s[top].first == pos) {
					s[top].second++;
					if (s[top].second == p) {
						top--;
						pos--;
					} else {
						pos = -1;
						break;
					}
				} else {
					s[++top] = make_pair(pos, 1);
					pos = -1; break;
				}
			}
			if (pos == 0) return false;
			else if (pos != -1) s[++top] = make_pair(pos, 1);
		}
	}
	return true;
}
int main() {
	read(n); int l = 1, r = n;
	for (int i = 1; i <= n; i++)
		read(a[i]);
	while (l < r) {
		int mid = (l + r) / 2;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;
int a[111111];
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	rep(i,k)ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
n=int(input())
p=[int(i) for i in input().split()]
x=[i for i in range(1,n+1)]
if p==x:
    print('YES')
else:
    cnt=0
    for i in range(n):
        if x[i]!=p[i]:
            cnt+=1
    if cnt==2:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

vector<string> res;

void dfs(int pos, vector<bool> rule, string s) {
	if(pos == s.size()) {
		if(find(ALL(res), s) == res.end()) res.push_back(s);
		return;
	}	
	if(s[pos] == 'a' || rule[s[pos] - 'a' - 1]) {
		dfs(pos + 1, rule, s);
	}
	if(!rule[s[pos] - 'a'] && s[pos] != 'z') {
		string tmp  = s;
		tmp[pos] = tmp[pos] + 1;
		rule[s[pos] - 'a'] = true;
		dfs(pos + 1, rule, tmp);
	}		
	return;
}

int main() {
	string s;
	while(cin >> s) {
		if(s == "#") break;
		res.clear();
		vector<bool> rule(26, false);
		
		dfs(0, rule, s);
		
		cout << res.size() << endl;
		if(res.size() <= 10) {
			for(int i = 0; i < res.size(); ++i) {
				cout << res[i] << endl;
			}
		} else {
			for(int i = 0; i < 5; ++i) {
				cout << res[i] << endl;
			}

			int n = res.size();
			for(int i = n - 5; i < n; ++i) {
				cout << res[i] << endl; 
			}
		}
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

string s;

int main()
{
	cin>>s;
	if(s.size()%2==1) puts("No");
	else
	{
		bool ok=true;
		for(int i=0;i<s.size();i+=2)
		{
			if(s[i]!='h'||s[i+1]!='i')
			{
				ok=false;
				break;
			}
		}
		puts(ok ? "Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,x,m,a,i,b,c,tot1=0,tot2=0;
	cin >> n >> m >> x ;
	for (int i=1;i<=m;i++){
		cin >> a;
		if (a>x){
			tot1 =tot1 + 1;
		}else if (a<x){
			tot2 = tot2 + 1;
		}
	}if (tot1 < tot2){
		cout << tot1;
	}else {
		cout << tot2;
	}
}


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

int main() {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  long long sum=0;
  for(int i=0;i<N;i++){
    if(i-K>=0 && T.at(i) == T.at(i-K)){
      T.at(i)='a';
      continue;
    }
    if(T.at(i) =='r')sum += P;
    if(T.at(i) =='s')sum += R;
    if(T.at(i) =='p')sum += S;
  }
   cout << sum;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            System.out.println((n / 500) * 1000 + ((n % 500) / 5) * 5);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int x;
	cin>>x;
	int k=360/gcd(360,x);
	cout<<k;
	return 0;
} 

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string a, b;
  cin >> a >> b;

  string add = a + b;
  int num = stoi(add);

  for (int i = 1; i * i <= num; ++i) {
    if (i * i == num) {
      cout << "Yes" << "\n";
      return 0;
    }
  }

  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int A, B, C;

    cin >> A >> B >> C;

    if((A==B&&B!=C) || (A!=B&&B==C) || (A==C&&B!=C)){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(void) {
    ll X;
    cin >> X;

    ll sum = 0, i = 0;
    while (sum < X) {
        i++;
        sum += i;
    }

    cout << i << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    printf("%d\n", a * b);
  } else {
    printf("%d\n", -1);
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();

		int sum = 0;

		for (int i = 0 ;i < N.length() ;i++ ) {
			sum += Integer.parseInt(N.substring(i,i+1));
		}

		System.out.println(sum%9 == 0?"Yes":"No");
	}
}


Measured memory_bytes: 49716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type card struct {
	label string
	value int
}

// ----- Merge Sort -----
const max = 1000000001

var count = 0

func merge(as []card, bs []card) []card {
	var result []card
	as = append(as, card{value: max})
	bs = append(bs, card{value: max})
	i := 0
	j := 0
	for {
		if i == len(as)-1 && j == len(bs)-1 {
			break
		}
		count++
		if as[i].value <= bs[j].value {
			if as[i].value < max {
				result = append(result, as[i])
				i++
			}
		} else {
			if bs[j].value < max {
				result = append(result, bs[j])
				j++
			}
		}
	}
	return result
}

func mergeSort(xs []card) []card {
	if len(xs) == 1 {
		return xs
	}
	m := len(xs) / 2
	var as = make([]card, len(xs[:m]))
	copy(as, xs[:m])
	var bs = make([]card, len(xs[m:]))
	copy(bs, xs[m:])
	return merge(mergeSort(as), mergeSort(bs))
}

// ----------

// ----- Quick Sort -----
func partition(xs []card, p int, r int) int {
	x := xs[r]
	as := xs[:r]
	i := p - 1 // 前パーティションの最後の要素のポインタ
	j := p
	for j < len(as) {
		target := as[j]
		if target.value <= x.value {
			i++
			as[j] = as[i]
			as[i] = target
		}
		j++
	}
	xs[r] = xs[i+1]
	xs[i+1] = x
	return i + 1
}

func quickSort(l []card, p int, r int) {
	if p < r {
		q := partition(l, p, r)
		quickSort(l, p, q-1)
		quickSort(l, q+1, r)
	}
}

// ----------

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func nextStr(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	l := make([]card, n)
	for i := 0; i < n; i++ {
		l[i] = card{
			label: nextStr(sc),
			value: nextInt(sc),
		}
	}
	origin := make([]card, n)
	copy(origin, l)

	quickSort(l, 0, n-1)
	l2 := mergeSort(origin)

	count := 0
	for i := range l {
		if l[i] == l2[i] {
			count++
		} else {
			break
		}
	}
	if count == n {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
	for _, x := range l {
		fmt.Printf("%s %d\n", x.label, x.value)
	}
}



Measured memory_bytes: 20632
import java.util.Scanner;
public class Main {
	int as,kl,o,n,m,hun,p;
	String op;
	Scanner sc = new Scanner(System.in);
	public void solve() {	
n=sc.nextInt();
if(n>=30) {
	System.out.println("Yes");
}else {
	System.out.println("No");
}

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

Measured memory_bytes: 35704
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}
int main(){
  int n;
  scanf("%d", &n);
  int l[2*n];
  int i;
  for(i=0;i<2*n;i++){
    scanf("%d",&l[i]);
  }
  qsort(l, 2*n, sizeof(int), compare);
  int ans = 0;
  for(i=0;i<n;i++){
    ans += l[2*i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#pragma warning(disable: 4996)
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <numeric>
#include <queue>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int V, E;
	int t_1, t_2, t_3;
	int w = 0, dist = 1000000;
	cin >> V >> E;
	for (int i = 0; i < E; i++)
	{
		cin >> t_1 >> t_2 >> t_3;
		if (t_1 == 1 && t_3 < dist) {
			w = t_2; dist = t_3;
		}
		if (t_2 == 1 && t_3 < dist) {
			w = t_1; dist = t_3;
		}
	}
	
	int tmp;
	for (int i = 0; i < V; i++) cin >> tmp;

	int T;
	cin >> T;
	int p = 1;
	string verdict;
	int na;
	int ne, pu;
	while (T > 0) {
		if (T < dist) {
			for (int i = 0; i < T; i++) {
				cin >> ne;
				for (int j = 0; j < ne; j++) {
					cin >> tmp; cin >> tmp;
				}
				cin >> pu;
				for (int j = 0; j < pu; j++) {
					cin >> tmp;
				}
				cout << -1 << endl;
				cout << flush;
				cin >> verdict;
				if (verdict == "NG") exit(0);
				cin >> na;
				for (int j = 0; j < na; j++) cin >> tmp;
			}
			T = 0;
		}
		if (p == 1) {
			for (int i = 0; i < dist; i++) {
				cin >> ne;
				for (int j = 0; j < ne; j++) {
					cin >> tmp; cin >> tmp;
				}
				cin >> pu;
				for (int j = 0; j < pu; j++) {
					cin >> tmp;
				}
				cout << w << endl;
				cout << flush;
				cin >> verdict;
				if (verdict == "NG") exit(0);
				cin >> na;
				for (int j = 0; j < na; j++) cin >> tmp;
			}
			p = 2;
			T -= dist;
		}
		if (p == 2) {
			for (int i = 0; i < dist; i++) {
				cin >> ne;
				for (int j = 0; j < ne; j++) {
					cin >> tmp; cin >> tmp;
				}
				cin >> pu;
				for (int j = 0; j < pu; j++) {
					cin >> tmp;
				}
				cout << 1 << endl;
				cout << flush;
				cin >> verdict;
				if (verdict == "NG") exit(0);
				cin >> na;
				for (int j = 0; j < na; j++) cin >> tmp;
			}
			p = 1;
			T -= dist;
		}
	}
	return 0;
}

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

using static Input;
using static Util;
class Program
{
    static int M;
    static int D;
    static void INPUT()
    {
        M = NextInt();
        D = NextInt();
    }
    static void OUTPUT()
    {
        int ans = 0;
        for (int m = 1; m <= M; m++)
        {
            for (int d = 22; d <= D; d++)
            {
                if (d % 10 != 1 && m == (d % 10) * (d / 10))
                    ans++;
            }
        }
        Console.WriteLine(ans);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
        M = 15;
        D = 40;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
    public static IEnumerable<int> Prime(int n)
    {
        int i = 2;
        int tmp = n;

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;
    }
}




Measured memory_bytes: 13268
N = gets.to_i
s = gets.chomp
Q = gets.to_i

class SegmentTree
  def initialize(arr)
    @size = 1 << (arr.length-1).bit_length
    @tree = Array.new(@size*2+1,0)
    init(arr)
  end
  
  def init(arr)
    arr.each.with_index do |v, i|
      set(v,@size+i-1)
    end
    (@size - 2).downto(0) do |i|
      merge(i)
    end
  end

  # ここを実装する
  def set(v,i)
    @tree[i] = 1 << (v.ord - 'a'.ord)
  end

  # ここも実装する
  def merge_f(a,b)
    a | b
  end
  
  def merge(i)
    @tree[i] = merge_f(@tree[i * 2 + 1], @tree[i * 2 + 2])
  end
  
  def update(v,i)
    i = @size + i - 1
    set(v,i)
    while 0 < i
      i = (i - 1) / 2
      merge(i)
    end
  end
  
  def query(a,b)
    query_(a,b,0,0,@size)
  end
  
  def query_(a,b,k,l,r)
    return 0 if r <= a || b <= l
    return @tree[k] if a <= l && r <= b
    mid = (l+r)/2
    vl = query_(a, b, k * 2 + 1, l, mid)
    vr = query_(a, b, k * 2 + 2, mid, r)
    merge_f(vl,vr)
  end
end

st = SegmentTree.new(s.chars)

$<.read.split.each_slice(3).each do |a, b, c|
  if a == '1'
    st.update(c,b.to_i-1)
  else
    p st.query(b.to_i - 1, c.to_i).to_s(2).count('1')
  end
end


Measured memory_bytes: 63776
#include<cstdio>
#include<algorithm>
#include<set>

using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n;
P f[300001];
int k[300001];

bool C(int num){
	multiset<int> S;
	ll sum=0;
	for(int i=n-1;i>=0;i--){
		sum+=f[i].second;
		S.insert(f[i].second);
		if(S.size()<num)continue;
		if(S.size()>num){
			sum-=*S.rbegin();
			S.erase(--S.end());
		}
		if((ll)num*f[i].first>=sum)return true;
	}
	return false;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&f[i].second,&f[i].first);
	}
	sort(f,f+n);
	int lb=0,ub=n+1;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(C(mid))lb=mid;
		else ub=mid;
	}
	printf("%d\n",lb);
	return 0;
}

Measured memory_bytes: 17328
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int x = sc.nextInt();
    
    while (true) {
      boolean isPrime = true;
      for (int i = 2; i <= Math.sqrt(x); i++) {
        if (x % i == 0) {
          isPrime = false;
          break;
        } 
      }
      if (isPrime) {
        os.println(x);
        return;
      }
      x++;
    }
  }
}

Measured memory_bytes: 23252
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
string s;
int main(){
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b.at(i);
    vector<int> a(n);
    a.at(0) = b.at(0);

    rep(i, n - 1) {
        if (a.at(i) > b.at(i)) a.at(i) = b.at(i);
        for (int j = a.at(i); j <= b.at(i); j++) {
            a.at(i + 1) = j;
        }
    }

    ll ans = 0;
    rep(i, n) {
        ans += a.at(i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <list>
#include <vector>
#include <queue>
#include <bitset>

typedef long long ll;
#define nn cout << '\n'
#define rep(n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i <n; i++)
#define rd(n) ll n; cin >> n;
#define rd(n,k) ll n,k; cin >> n >> k;
#define rd(a,b,c,d) ll a,b,c,d; cin >> a>> b >> c >> d;

using namespace std;


void testcase() {
	for (int i = 1; i < 6; i++) {
		int x; cin >> x;
		if (x != i) {
			cout << i;
		}
	}

}


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

	int x = 1;
	rep(x) {
		testcase();
		nn;

	}
	return 0;
}

/*

*/

Measured memory_bytes: 3596
n = int(input())
L = list(map(int,input().split()))
L.append(float('inf'))
cur = L[0]
now = 0
ans = 0
for i in range(1,n+1):
  if cur >= L[i]:
    now += 1
    cur = L[i]
  else:
    ans = max(now,ans)
    now = 0
    cur = L[i]
print(ans)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<int> Solve() {
  int n;
  cin >> n;
  vector<int> xs(n);
  vector<pair<int, int>> pos_val_pairs;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    xs[i]--;
    pos_val_pairs.push_back({xs[i], i});
  }
  sort(pos_val_pairs.begin(), pos_val_pairs.end());

  vector<int> ys(n * n, -1);
  int cur = 0;
  auto put_fn = [&](int val) {
    while (ys[cur] >= 0) cur++;
    ys[cur] = val;
  };

  for (const auto [pos, val] : pos_val_pairs) {
    for (int i = 0; i < val; i++) {
      put_fn(val);
    }
    if (ys[pos] >= 0) return vector<int>();
    ys[pos] = val;
  }

  cur = 0;
  for (const auto [pos, val] : pos_val_pairs) {
    for (int i = 0; i < n - 1 - val; i++) {
      put_fn(val);
    }
  }

  for (int k = 0; k < n; k++) {
    vector<int> ps;
    for (int i = 0; i < n * n; i++) {
      if (ys[i] == k) {
        ps.push_back(i);
      }
    }
    if (ps[k] != xs[k]) return vector<int>();
  }

  return ys;
}

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

  vector<int> ys = Solve();
  if (ys.empty()) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 0; i < ys.size(); i++) {
      if (i > 0) cout << " ";
      cout << ys[i] + 1;
    }
    cout << endl;
  }
}

Measured memory_bytes: 4240
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var s = Console.ReadLine();
		int a = h[1] - 1, b = h[2] - 1, c = h[3] - 1, d = h[4] - 1;

		if (c < d)
		{
			Console.WriteLine(s.IndexOf("##", a, d - a) == -1 ? "Yes" : "No");
		}
		else
		{
			Console.WriteLine(s.IndexOf("##", a, c - a) == -1 && s.IndexOf("...", b - 1, d - b + 3) != -1 ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 14176
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	long long int n,dr,ir;
	cin>>n>>dr;
	long long int ans = dr + (100*(10-n));
	if(n>=10)
		cout<<dr<<endl;
	else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var list = new List<int>() {int.Parse(input[0]), int.Parse(input[1]) , int.Parse(input[2]) };
            list.Sort();
            var s = list[2].ToString() + list[1].ToString();
            Console.WriteLine(int.Parse(s) + list[0]);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define nn 100008
#define ll long long
ll n,m,pos[nn],dif[nn];
ll ck;
ll ct[nn];
ll res[nn],cx[nn];
ll c[nn],d[nn];
void mul(ll a[],ll b[])
{
	for(int i=1;i<n;i++) c[i]=i;
	for(int i=1;i<n;i++) c[i]=a[i];
	for(int i=1;i<n;i++) d[i]=c[b[i]];
	for(int i=1;i<n;i++) a[i]=d[i];
}
void qpow()
{
	while(ck)
	{
		if(ck&1) mul(res,cx);
		mul(cx,cx);ck=ck/2;
	}
}
int main()
{
	scanf("%lld",&n);for(int i=1;i<=n;i++) scanf("%lld",&pos[i]);
	for(int i=2;i<=n;i++) dif[i-1]=pos[i]-pos[i-1],cx[i-1]=res[i-1]=i-1;
	scanf("%lld%lld",&m,&ck);
	while(m--)
	{
		ll x;scanf("%lld",&x);
		swap(cx[x-1],cx[x]);
	}
	
	qpow();
	
	ll ct=pos[1];
	for(int i=1;i<=n;i++) printf("%lld\n",ct),ct+=dif[res[i]];
	return 0; 
}

Measured memory_bytes: 6784
s = input()

if s == "abc":
    print("Yes")

elif s == "acb":
    print("Yes")

elif s == "bac":
    print("Yes")

elif s == "bca":
    print("Yes")

elif s == "cab":
    print("Yes")

elif s == "cba":
    print("Yes")

elif s == "abc":
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <cstring>
#include <map>
#include <queue>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
char s1[15], s2[15], s[15];
int main(){
	scanf("%s", s1);
	scanf("%s", s2);
	int A, B;
	scanf("%d %d", &A, &B);
	scanf("%s", s);
	if(!strcmp(s1, s))
		printf("%d %d\n", A-1, B);
	else printf("%d %d\n", A, B-1);
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    string s,ss;
    int cnt=0,i,j;
    cin>>s>>ss;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=ss[i])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3920
L=int(input());S=bin(L);N=len(S)-2;print(N,2*N+S.count("1")-3)
for i in range(N-1):
 print(i+1,i+2,0);print(i+1,i+2,2**i)
 if S[N+1-i]=="1":L-=2**i;print(i+1,N,L)

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

int main() {
    int n;
    std::cin >> n;
	int p[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
	    if( (p[i - 1] - p[i]) * (p[i] - p[i + 1]) >= 0) ans++;
	}
	
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int ta[100005];
int mo[100005];
int se[100005];
int n,m;

main(){
  int i,j;
  int now;
  int p;
  long long int ans=0;


  cin >> n >> m;
  for(i=0;i<n-1;i++){
    scanf("%d",&ta[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d",&mo[i]);
  }


  p=0;
  for(i=0;i<m;i++){
    if(mo[i]>0){
      se[p]++;
      p+=mo[i];
      se[p]--;
    }
    else{
      se[p]--;
      p+=mo[i];
      se[p]++;
    }
  }


  now=0;
  for(i=0;i<n;i++){
    se[i]+=now;
    now=se[i];
    ans+=se[i]*ta[i];
    ans%=100000;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2044
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int x = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();

	if(a>=b){
		System.out.println("delicious");
	}else if((a<b)&&((b-a)<=x)){
		System.out.println("safe");
	}else {
		System.out.println("dangerous");
	}
	}
}


Measured memory_bytes: 21972