akhauriyash/Code-Regression huggingface dataset:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    edge = [[] for i in range(N)]
    e_index = []
    for i in range(N-1):
        a,b = MI_()
        edge[a].append(b)
        edge[b].append(a)
        e_index.append((a,b))
    queue = deque()
    queue.append((0,0))
    ans_col = {}
    visited = set()
    K=1
    while queue:
        from_,col = queue.popleft()
        if from_ in visited:
            continue
        visited.add(from_)
        now = 1
        for to in edge[from_]:
            if to in visited:
                continue
            if now == col:
                now += 1
            ans_col[from_,to] = now
            ans_col[to,from_] = now
            queue.append((to,now))
            K = max(now,K)
            now += 1
    print(K)
    for a,b in e_index:
        print(ans_col[a,b])

if __name__ == '__main__':
    main()

Measured memory_bytes: 106656
while x = gets.split()
  a = x[0].to_i
  b = x[1].to_i
  if a == 0 && b == 0
    break
  end
  if a > b
    puts "#{b}"+" "+"#{a}"
  elsif a == b
    puts "#{a}"+" "+"#{b}"
  else
    puts "#{a}"+" "+"#{b}"
  end
end

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

int main(void){

char moji[3];
int tmp;

scanf("%s",moji);

if(strlen(moji)==3){
  tmp=moji[0];
  moji[0]=moji[2];
  moji[2]=tmp;
}
printf("%s",moji);
return 0;
}


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

const int M=3005;
double p[M];
double dp[M][M/2];
// after i there are j tail

int main()
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf",&p[i]);
	int half=n/2;
	dp[1][0]=p[1];
	if(1<=half)
		dp[1][1]=1.0-p[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=i&&j<=half;j++)
		{
			dp[i][j]=0;
			// head
			if(j<i)
				dp[i][j]=dp[i-1][j]*p[i];
			// tail
			if(j>=1)
				dp[i][j]+=dp[i-1][j-1]*(1.0-p[i]);
		}
	}
	double ans=0;
	for(int i=0;i<=half;i++)
		ans+=dp[n][i];
	printf("%.11f\n",ans);
	return 0;
}

Measured memory_bytes: 34304
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,v,p;cin >> n >> m >> v >> p;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end(),greater<int>());
  int l=p-1,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(mid<=p-1){
      l=mid;
      continue;
    }
    long long sum=0;
    for(int i=0;i<n;i++){
      if(i<p-1||i>=mid){
        sum+=m;
      }
      else{
        if(a[mid]+m>=a[i]){
          sum+=min(m,a[mid]+m-a[i]);
        }
        else{
          sum=0;
          break;
        }
      }
    }
    if(sum>=m*v){
      l=mid;
    }
    else{
      r=mid;
    }
  }
  cout << l+1 << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rg register long long
#define inf 21474899993647
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define ll long long
#define maxn 100005
#define endl "\n"
#define   N 6000
const double eps=1e-8;
using namespace std;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<48||ch>57)
    {
        if(ch=='-')
            w=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        s=(s<<1)+(s<<3)+(ch^48);
        ch=getchar();
    }
    return s*w;
}
inline void write(ll x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+48);
}

int main()
{
   ll a;
   cin>>a;
   double sum=0;
   for(rg i=1;i<=a;i++)
   {
       double x;
       cin>>x;
       sum+=(1.0)/x;
   }
   cout<<1.0/sum<<endl;
    return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int d, n; cin >> d >> n;
    ll k = 1;
    REP(i, 0, d){
        k *= 100;
    }
    if(n == 100){
        cout << k * (n+1) << endl;
    }else{
        cout << k * n << endl;
    }
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int par[100001];
int root(int x){
	if(par[x]==x){
		return x;
	}
	else{
		par[x]=root(par[x]);
		return par[x];
	}
}
bool same(int x,int y){
	return root(x)==root(y);
}
void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(root(x)==root(y)) return;
	par[x]=y;
}
int main(){
	int N,M;
	scan(N);scan(M);
	int p[100000];
	pint x[100000];
	int samesum=0;
	rep(i,N){
		scan(p[i]);
		par[p[i]]=p[i];
	}
	rep(i,M){
		int x1,x2;
		scan(x1);scan(x2);
		unite(p[x1-1],p[x2-1]);
	}
	rep(i,N){
		if(same(p[i],i+1))  samesum++;
	}
	prin(samesum);

	return 0;
}


Measured memory_bytes: 1024
alist = list(map(int,input().split()))

cand = []
for i in range(alist[0]+1):
  a = []
  a.append(i)
  a.append(alist[0]-i)
  cand.append(a)

ans = 'No'
for item in cand:
  c = 2 * item[0] + 4 * item[1]
  if c == alist[1]:
    ans = 'Yes'


print(ans)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
void counting_sort(vector<int>&A,vector<int>&B,int k,int N){
  vector<int>C(k+1);
  for(int i=0;i<N;i++)C[A[i]]++;
  for(int i=1;i<=k;i++)C[i]=C[i]+C[i-1];
  for(int i=N-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
}
int main(void){
  int N;
  cin>>N;
  vector<int>A(N),B(N);
  int k=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    k=max(A[i],k);
  }
  counting_sort(A,B,k,N);
  for(int i=0;i<N;i++)cout<<B[i]<<" \n"[i==N-1];
  return 0;
}



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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s;
    cin >> s;
    int n = s.size();
    
    irep(i, 1<<(n-1)) {
        ll sum = 0;
        string ans;
        irep(j, n) {
            int op = 1;
            string op_str = "+";
            if(j>0 && i & (1 << (j-1))) {
                op *= -1;
                op_str = "-";
            }
            sum += op * (s[j]-'0');
            if(j > 0) {
                ans += op_str;
            }
            ans += s[j];
        }
        if(sum == 7) {
            cout << ans << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[100005];
int dfs(int x,vector<vector<int>> &ki) {
    if(dp[x] != -1) {
        return dp[x];
    }
    int res = 0;
    for(int i = 0; i < ki[x].size(); i++) {
        res = max(res,dfs(ki[x][i],ki)+1);
    }
    return dp[x] = res;
}
int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>ki(N);
    for(int i = 0; i < M; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        ki[x].push_back(y);
    }
    for(int i = 0; i < N; i++) {
        dp[i] = -1;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans,dfs(i,ki));
    }
    cout << ans << endl;
}


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

long long ex_gcd(long long a, long long b, long long& x, long long& y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	long long ans = ex_gcd(b, a % b, x, y);
	long long tmp = x;
	x = y;
	y = tmp - a / b * y;
	return ans;
}

long long mod_inverse(long long a, long long m)
{
	long long x, y;
	ex_gcd(a, m, x, y);
	return (x % m + m) % m;
}


int main()
{
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	const long long M = 998244353;
	long long res = 0;
	vector<long long> C(k + 1, 0);
	C[0] = 1;
	for (int i = 1; i <= k; i++) {
		long long vi = mod_inverse(i, M);
		C[i] = C[i - 1] * (n - i) %M * vi % M;
	}
	vector<long long> P(k + 1, 0);
	P[k] = 1;
	for (int i = 0; i < n - 1 - k; i++) {
		P[k] = (P[k] * (m - 1)) % M;
	}
	for (int i = k - 1; i >= 0; i--) {
		P[i] = (P[i + 1] * (m - 1)) % M;
	}

	for (int i = 0; i <= k; i++) {
		res = (res + C[i] * m % M * P[i] % M) % M;
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6348
gene = ['A','C','G','T']

n,q = map(int,input().split())
s = input()
l_r = []
for _ in range(q):
    l_r.append(list(map(int,input().split())))
imos = [0]*n
csum = [0]*n

for i in range(1,n):
    if s[i] == 'C' and s[i-1] == 'A':
        imos[i] += 1

for i in range(1,n):
    csum[i] = csum[i-1] + imos[i]

for l,r in l_r:
    print(csum[r-1]-csum[l-1])

Measured memory_bytes: 33040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;



int main(){
	int n;
	int m,s,c;
	while(cin>>n && n>0){
		vector<pair<pair<int,int>,int>  > v(n,mp(mp(0,0),0));
		for(int i=0; i<n; i++){
			cin>>c;
			v[i].se=c;
			for(int j=0; j<4; j++){
				cin>>m>>s;
				v[i].fi.se+=s;
				v[i].fi.fi+=(m+v[i].fi.se/60);
				v[i].fi.se%=60;
			}
		}
		sort(all(v));
		cout<<v[0].se<<endl;
		cout<<v[1].se<<endl;
		cout<<v[n-2].se<<endl;

		// cout<<endl;
		// for(int i=0; i<n; i++){
		// 	cout<<v[i].se<<" "<<v[i].fi<<endl;
		// }
	}
}

Measured memory_bytes: 1256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[1005];
stack<int>alive;
vector<int>ans;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int mx = -inf, id = -1;
	rep(i, n) {
		mx = max(mx, a[i]);
		if (mx == a[i])id = i;
	}
	if (mx <= 0) {
		cout << mx << endl << n - 1 << endl;
		rep(i, id)cout << 1 << endl;
		n -= id;
		while (n != 1) {
			cout << n << endl; n--;
		}
		return 0;
	}
	int es = 0, os = 0;
	rep(i, n) {
		if (i & 1) {
			if (a[i] > 0)es += a[i];
		}
		else {
			if (a[i] > 0)os += a[i];
		}
	}
	if (es > os) {
		cout << es << endl;
		rep(i, n) {
			if ((i & 1) && a[i] > 0)alive.push(i);
		}
	}
	else {
		cout << os << endl;
		rep(i, n) {
			if (!(i & 1) && a[i] > 0)alive.push(i);
		}
	}
	int ntop = alive.top();
	while (n != ntop + 1) {
		ans.push_back(n);
		n--;
	}

	while (alive.size() != 1) {
		int x = alive.top();
		alive.pop();
		int s = alive.top();
		while (x - s != 2) {
			ans.push_back(x-1);
			x -= 2;
			n -= 2;
		}
		ans.push_back(x);
	}
	ntop = alive.top();
	rep(i, ntop)ans.push_back(1);
	cout << ans.size() << endl;
	rep(i, ans.size())cout << ans[i] << endl;
}


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

using namespace std;

int main(){
    int A,B,K,C;
    int j=0;
    vector<int> vec(110);
    cin >> A >> B >> K;

    if(A>B){
        C=A;
        A=B;
        B=C;
    }
    for(int i=A;i>0;i--){
        if(A%i==0 && B%i==0){
            vec.at(j) = i;
            j++;
       }
    }
    cout << vec.at(K-1) << endl;

}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Counting of Trees
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 998244353;

/* typedef */

typedef long long ll;

/* global variables */

int dns[MAX_N];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

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

  int maxd = 0;
  for (int i = 0; i < n; i++) {
    int di;
    scanf("%d", &di);
    if (i == 0 && di != 0) {
      puts("0");
      return 0;
    }
    dns[di]++;
    if (maxd < di) maxd = di;
  }
  //printf("maxd=%d\n", maxd);

  if (dns[0] != 1) {
    puts("0");
    return 0;
  }

  int cnt = 1;
  for (int d = 1; d < maxd; d++)
    cnt = (ll)cnt * powmod(dns[d], dns[d + 1]) % MOD;

  printf("%d\n", cnt);
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N;
	cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	ans = -LINF;
	FOR(i, 0, N) {
		FOR(j, i + 1, N) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    
    n, k = map(int, input().split())
    
    fact = [1] * 2010
    inv = [1] * 2010
    for i in range(1, 2010):
        fact[i] = (i * fact[i - 1]) % 1000000007
        inv[i] = pow(fact[i], 1000000005, 1000000007)
    
    for j in range(1, k + 1):
        if n + 1 < k + j:
            print(0)
        else:
            ans = (fact[k - 1] * fact[n - k + 1] * inv[j - 1] * inv[k - j] * inv[j] * inv[n - k - j + 1]) % 1000000007
            print(ans)
    
    return 0

main()

Measured memory_bytes: 3444
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

const double kEps = 1e-10;

int dcmp(double x) {
  if (fabs(x) < kEps) return 0;
  return x < 0 ? -1 : 1;
}

struct Vector {
  double x, y;
  Vector() {}
  Vector(double x, double y): x(x), y(y) {}
  // Vector(const Point & p1, const Point & p2): x(p2.x - p1.x), y(p2.y - p1.y) {}
  Vector(const Vector & v);

  double Norm() const { return hypot(x, y); }
  double NormSquared() const { return x * x + y * y; }
  Vector Normalize() const {
    return *this / this->Norm();
  }
  Vector operator-() const {
    return Vector(-x, -y);
  }
  Vector operator+(const Vector & rhs) const {
    return Vector(x + rhs.x, y + rhs.y);
  }
  Vector operator-(const Vector & rhs) const {
    return *this + (-rhs);
  }
  Vector operator*(const double rhs) const {
    return Vector(rhs * x, rhs * y);
  }
  Vector operator/(const double rhs) const {
    return *this * (1.0 / rhs);
  }
  double Dot(const Vector & rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  double Cross(const Vector & rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  bool operator==(const Vector & rhs) const {
    return dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) == 0;
  }
  bool operator<(const Vector & rhs) const {
    return dcmp(x - rhs.x) < 0 || (dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) < 0);
  }
};

struct Point {
  Point() {}
  Point(double x, double y): x(x), y(y) {}
  Point(const Point & p);

  double x, y;

  Point operator-() {
    return Point(-x, -y);
  }
  Point operator+(const Vector & rhs) const {
    return Point(x + rhs.x, y + rhs.y);
  }
  Point operator-(const Vector & rhs) const {
    return *this + (-rhs);
  }
  bool operator==(const Point & rhs) const {
    return dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) == 0;
  }
  bool operator<(const Point & rhs) const {
    return dcmp(x - rhs.x) < 0 || (dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) < 0);
  }
};

struct Line {
  Line() {}
  Line(const Point & p1, const Point & p2): p1(p1), p2(p2) {}
  Line(double x1, double y1, double x2, double y2): p1(x1, y1), p2(x2, y2) {}
  Line(const Line & l);

  Point p1, p2;
};

ostream & operator<<(ostream & os, const Point & p) {
  os << p.x << " " << p.y;
  return os;
}

ostream & operator<<(ostream & os, const Vector & v) {
  os << v.x << " " << v.y;
  return os;
}

Point Reflection(const Point & p, const Line & l) {
  Vector v0(p.x - l.p1.x, p.y - l.p1.y);
  Vector v(l.p2.x - l.p1.x, l.p2.y - l.p1.y);
  auto perpendicular = v * (v.Dot(v0) / v.NormSquared()) - v0;
  return p + perpendicular * 2;
}

int main(int argc, char const *argv[]) {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Line l(x1, y1, x2, y2);

  int q;
  cin >> q;
  for (unsigned i = 0; i < q; ++i) {
    double x0, y0;
    cin >> x0 >> y0;
    Point p(x0, y0);
    cout << fixed << setprecision(10) << Reflection(p, l) << endl;
  }
  return 0;
}

Measured memory_bytes: 3284
nim,mike = map(int,input().split())

array = list(map(int,input().split()))

counter = 0
for i in range(40,-1,-1):
    if counter | (1 << i) > mike:
        continue
    cnt = 0
    for j in range(nim):
        if array[j] & (1 << i) == 0:
            cnt += 1
    
    if cnt > nim - cnt:
        counter = counter | (1 << i)

result = 0
for i in range(nim):
    result += counter ^ array[i]

print(result)

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int all_xor = 0;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    all_xor = all_xor xor a.at(i);
  }
//  cout << all_xor << endl;
  int ans;
  for(int i=0;i<N;i++){
    ans = all_xor xor a.at(i);
    cout << ans << endl;
  }
}

Measured memory_bytes: 4048
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(declaim (type fixnum n m x))
(defvar n (read))
(defvar m (read))
(defvar x (read))

(defstruct book
  (price 0 :type fixnum)
  (effect (make-array m :element-type 'fixnum)
	  :type (simple-array fixnum)))

(defvar *books* (make-array n :element-type 'book))
(dotimes (i n)
  (let ((b (make-book)))
    (setf (book-price b) (read))
    (dotimes (j m)
      (setf (aref (book-effect b) j) (read)))
    (setf (aref *books* i) b)))
    
(defvar *t* (make-array (expt 2 n)
			:initial-element nil
			:element-type 'boolean))

(defun total-price (bs)
  (declare (type fixnum bs))
  (loop for b = 1 then (ash b 1)
	for bi = 0 then (1+ bi)
	while (< bi n)
	when (/= (logand b bs) 0) sum (book-price (aref *books* bi))))

(declaim (inline valid-combination))
(defun valid-combination (i)
  (declare (type fixnum i))
  (dotimes (mi m)
    (if (> x (loop for b = 1 then (ash b 1)
		for bi = 0 then (1+ bi)
		while (< b (expt 2 n))
		when (/= 0 (logand b i))
		sum (aref (book-effect (aref *books* bi)) mi)))
	(return-from valid-combination nil)))
  t)

(defvar ok-books nil)
(dotimes (item (expt 2 n))
  (when (valid-combination item)
    (push item ok-books)))

(princ (if ok-books
	   (apply #'min (mapcar #'total-price ok-books))
	 "-1"))


Measured memory_bytes: 25388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vl fac, finv, inv;

void com_init(const int MAX) {
  fac.resize(MAX);  fac[0] = fac[1] = 1;
  finv.resize(MAX); finv[0] = finv[1] = 1;
  inv.resize(MAX);  inv[1] = 1;
  for (int i=2; i<MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll combination(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main() {
  int n; cin >> n;
  vi arr(n+1);
  rep(i,n+1) cin >> arr[i];
  
  com_init(n+5);

  int dist;
  map<int, int> counter;
  rep(i,n+1) {
    if (counter.count(arr[i])) {
      dist = i - counter[arr[i]];
      break;
    }

    counter[arr[i]] = i;
  }
  
  vl ans(n+1);
  rep(r,n+1) ans[r] = combination(n+1, r+1);
  rep(r,n+1-dist) (ans[r] += MOD - combination(n-dist, r)) %= MOD;
  rep(i,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 9472
import itertools

A = [int(input())for i in range(0,5,1)]

ans = 10**10
for Atmp in list(itertools.permutations(A)):
    time = 0
    for i in range(0,5,1):
        if time%10 != 0:
            time += (10-time%10)
        time += Atmp[i]
    ans = min(ans,time)
print(ans)


Measured memory_bytes: 62084
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,d=0,n,min=100000,k,ans=0;
    string s,s2;
    cin >> n >> k;
    VI m(n);
    for (int i=0;i<n;i++){
        cin >> m[i];
        c += m[i];
        if(min >= m[i]){
            min = m[i];
        }
    }
    k -= c;
    ans = k/min;
    cout << n+ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    float r; cin >> r;
    nout(2*r*3.1415);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
	int n,i,ans = 0;
	cin >> n;
	int a[n], b[n], c[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = 0; i < n; i++){
		cin >> b[i];
	}
	for(i = 0; i < n - 1; i++){
		cin >> c[i];
	}

	for(i = 0; i < n; i++){
		ans = ans + b[a[i]-1];
		if(i >= 1){
			if(a[i] - 1 == a[i-1]){
				ans = ans + c[a[i-1]-1];
			}
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#define  pb push_back
#define  mod 1000000007
using namespace std;
vector <vector <int>> adj;
vector <int> c;
int n, k;

void dfs (int cur, int prev)
{
	int temp;
	if(cur == 1) temp = k-1;
	else temp = k-2;
	
	for(int i : adj[cur])
	{
		if(i != prev)
		{
			c[i] = temp;
			temp--;
			dfs(i, cur);
		}
	}
}
int main() {
	int a, b;
	cin >> n >> k;
	adj.resize(n+1);
	c.resize(n+1);
	for(int i = 1; i < n; i++)
	{
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	c[1] = k;
	dfs(1, 0);
	long long ans = 1;
	for(int i = 1; i < n+1; i++)
	{
		ans = (ans * (c[i]%mod) )%mod;
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 9600
import java.io.*;
public class Main{
	public static void main(String [] args) throws  IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		double r=Double.parseDouble(br.readLine());
		System.out.printf("%.6f %.6f",r*r*Math.PI,2*r*Math.PI);
		
	}}

Measured memory_bytes: 17032
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;
    long long A[200000];
    long long sum[200001];
    long long res=0;
    cin >> N;
    sum[0]=0;
    for (int i = 0; i < N;  i++) {
        cin >>A[i];
        sum[i+1]=sum[i]+A[i];
    }
    
    sort(sum,sum+N+1);
    long long count=0;
    
    for (int i = 0; i < N; i++) {
        if(sum[i]==sum[i+1]){
            count++;
        }else if(count>0){
            res+=count*(count+1)/2;
            count=0;
        }else{
            count=0;
        }
        if(i==N-1){
            res+=count*(count+1)/2;
        }
    }
    
    cout <<res<< endl;
}

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

int main(){
  	int n,a[100000],memo = 0;
  	cin >> n;
  
  	rep(i,0,n) cin >> a[i];
  
  	rep(i,1,n+1){
      memo = a[memo]-1;
      if(memo+1 == 2){
        cout << i << endl;
        return 0;
      }
    }
  
  	cout << "-1" << endl;
    
  	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define MAX_N 10000

int main(){
  int p[MAX_N] = {};
  p[0] = p[1] = 1;
  for(int i = 2; i <= MAX_N / 2; i++)
    if(!p[i])
      for(int j = i+i; j <= MAX_N; j+=i) p[j] = 1;

  vector<int>sp;
  rep(i, MAX_N) if(!p[i]) sp.push_back(i);
  //  rep(i, sp.size()) printf("%d ", sp[i]); puts("");
  int n;
  while(scanf("%d", &n) && n){
    int res = 0;

    rep(i, sp.size()){
      int s = 0;
      for(int j = i; j < sp.size(); j++){
	s += sp[j];
	if(s == n){ res++; break;}
      }
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,a[101],sum=0,sum1=0,sum2=0;
    int i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int k=sum/n;
    int l=k+1;
    for(i=0;i<n;i++)
    {
        sum1+=((a[i]-k)*(a[i]-k));
        sum2+=((a[i]-l)*(a[i]-l));
    }
    cout<<min(sum1,sum2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
mint C(int n, int a) {
    mint x = 1;
    mint y = 1;
    rep(i, a) {
        x *= n - i;
        y *= a - i;
    }
    return x / y;
}
int main(void) {
    int n, a, b; cin >> n >> a >> b;
    mint all(2);
    mint ans = all.pow(n) - C(n, a) - C(n, b) -1;
    cout << ans.x;
}



Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let array = Array.init n @@ fun _ -> Scanf.scanf " %d" Fun.id in
  Array.sort compare array;
  let k_array = Array.sub array 0 k in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) 0 k_array 
    

Measured memory_bytes: 4032
N = int(input())
if N == 1 :
    print(1)
    exit()
ans = 0
cmax= 0

for i in range(1,N+1) :
    c = 0
    k = i
    while k % 2 == 0 :
        c += 1
        k = k / 2
        if  c > cmax :
            cmax = c
            ans = i

print(ans)

Measured memory_bytes: 3060
#include <vector>
#include <iostream>
using namespace std;
//Using recursion
int cost(int h1, int h2){
    int val = h1-h2;
    if(val<0)
    {
        return(-val);
    }
    return(val);
}
int min(int val1, int val2)
{
    if(val1<val2){
        return(val1);
    }
    return(val2);
}


int main(){
    int n;
    cin >> n;
    vector<int> heights;
    vector<int> costAt;
    for(int i =0; i<n; i++)
    {
        int num;
        cin >> num;
        heights.push_back(num);
        costAt.push_back(0);
    }
    costAt[0] = 0;
    costAt[1] = cost(heights.at(1), heights.at(0));
    for(int i =2; i<n; i++)
    {

        costAt[i] = min(costAt.at(i-1)+cost(heights.at(i),heights.at(i-1)),costAt.at(i-2)+cost(heights.at(i),heights.at(i-2)));

    }
    cout << costAt.at(n-1)<< endl;
    
}

Measured memory_bytes: 1276
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

long long bins (long long k, long long l, long long r){
    long long q = (r+l) / 2;
    long long qq = r * r;
    if (r - l <= 1){
        if (qq >= k){
            return l;
        }
        else{
            return r;
        }
    }
    else{
        qq = q*q;
        if (qq >= k){
            return bins (k, l, q-1);
        }
        else {
            return bins (k, q, r);
        }
    }
}

int main() {
    long long n,a,b;
    cin >> n;
    vector <long long> ans;
    for (int i = 0; i<n; i++){
        cin >> a >> b;
        long long k = min (a,b);
        long long q = max (a,b);
        a = k;
        b = q;
        if (b - a <= 1){
            ans.push_back(2*(a-1));
        }
        else{
            k = a*b;
            q = bins (k, a, b);
            long long ss = min (a,b);
            long long k1, k2;
            k2 = 2*(ss-1);
            k1 = 2*(ss-1);
            k1 += 2*(q - a);
            if (q * (q+1) < k){
                k2 += 2*(min ((q-a),(b-q-1))) + 1;
            }
            ss = max(k1, k2);
            ans.push_back(ss);
        }
    }
    for (int i = 0; i<ans.size(); i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

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

int memo[100001];

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    sort(v.begin(), v.end());
    for(int i=0; i<n; ++i) {
        int x = v[i];
        memo[x]++;
        memo[x+1]++;
        memo[x-1]++;
    }
    int ans = -1;
    for(int i=0; i<100001; ++i) ans = max(ans, memo[i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
s = gets.chomp
n = s.size
(0...n-1).each do |i|
  if s[i] == s[i+1]
    puts "#{i+1} #{i+2}"
    exit
  end
end

(0...n-2).each do |i|
  if s[i] == s[i+1]
    puts "#{i+1} #{i+2}"
    exit
  elsif s[i+1] == s[i+2]
    puts "#{i+2} #{i+3}"
    exit
  elsif s[i+2] == s[i]
    puts "#{i+1} #{i+3}"
    exit
  end
end
puts '-1 -1'

Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(string, S);
    CIN(ll, K);

    string ans = "";
    for (int i = 0; i < K; i++) {
        if ( S[i] != '1' ) {
            ans = S[i];
            break;
        }
    }
    if ( ans.length() == 0 ) {
        ans = S[K-1];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main() { 
	    
	    int n;
	    cin >> n;
	    int arr[4][13]={{}};
	    char a;
	    int b;
	    for(int i=0;i<n ; i++){
	    	cin >> a >>b;
	    	switch(a){
	    	case 'S':
	    		arr[0][b-1]=1;
	    		break;
	    	case 'H':
	    		arr[1][b-1]=1;
	    		break;
	    	case 'C':
	    		arr[2][b-1]=1;
	    		break;
	    	case 'D':
	    		arr[3][b-1]=1;
	    		break;	
	    	}
	    }

	    for(int i=0;i<52;i++){
	    	switch(i/13){
	    		case 0:
	    		if(arr[0][i%13] ==0)
	    			cout<< "S" << " " << i+1 << endl;
	    		break;
	    		case 1:
	    		if(arr[1][i%13] ==0)
	    			cout<< "H" << " " << i%13+1 << endl;
	    		break;
	    		case 2:
	    		if(arr[2][i%13] ==0)
	    			cout<< "C" << " " << i%13+1 << endl;
	    		break;
	    		case 3:
	    		if(arr[3][i%13] ==0)
	    			cout<< "D" << " " << i%13+1 << endl;
	    		break;	

	    	}
	    }

	  
	    


	    return 0;
	}


Measured memory_bytes: 3080
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    s = input()
    print(s[0:3])

main()


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b[a],color[9]={0},m=0,n=0;
    for(int i=0;i<a;i++) cin>>b[i];
    for(int i=0;i<a;i++){
        if(1<=b[i]&&b[i]<=399) {color[0]++;}
        else if(400<=b[i]&&b[i]<=799) {color[1]++;}
        else if(800<=b[i]&&b[i]<=1199) {color[2]++;}
        else if(1200<=b[i]&&b[i]<=1599) {color[3]++;}
        else if(1600<=b[i]&&b[i]<=1999) {color[4]++;}
        else if(2000<=b[i]&&b[i]<=2399) {color[5]++;}
        else if(2400<=b[i]&&b[i]<=2799) {color[6]++;}
        else if(2800<=b[i]&&b[i]<=3199) {color[7]++;}
        else if(3200<=b[i]) {color[8]++;}
    }
    for(int i=0;i<8;i++){
        if(color[i]>0){
            m++;
            n++;
        }
    }
    m=m+color[8];
    if(n==0&&color[8]!=0) n=1;
    cout<<n<<" "<<m<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <typename T = int>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> dat;
    F func;
    T UNIT;

    SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        // full binary tree: num of leaves = n = 2^k >= n_
        while (n < n_)
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
    }
    SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        while (n < v_.size())
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
        for (int i = 0; i < v_.size(); ++i) {
            dat[n - 1 + i] = v_[i];
        }
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int k, T a) {
        // leaves are at index n-1 to 2*n-2
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            // k -> parent node
            k = (k - 1) / 2;
            // func(child nodes)
            dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    T query(int a, int b, T k, int l, int r) {
        if (r <= a || b <= l)
            return UNIT;
        if (a <= l && r <= b)
            return dat[k];
        else {
            T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return func(vl, vr);
        }
    }
    // get result of func() in [a, b)
    T query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
    int n;
    cin >> n;
    vl h(n), a(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    auto f = [](ll x, ll y) { return max(x, y); };
    SegmentTree<ll> tr(n + 1, f, 0);
    for (int i = 1; i <= n; ++i) {
        int hh = h[i - 1];
        ll asum = tr.query(0, hh);
        tr.update(hh, asum + a[i - 1]);
    }
    cout << tr.query(0, n + 1) << "\n";
    return 0;
}

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

int main()
{
	string s1, com, s2;
	int n,a,b;

	cin >> s1 >> n;
	for ( int i = 0; i < n; i++ )
	{
		cin >> com >> a >> b;
		if ( com == "print" )
			{
				cout << s1.substr(a, b-a+1) <<endl;
			}	
		else if ( com == "replace" )
		{
			cin >> s2;
			s1 = s1.replace(a, b-a+1, s2);
		}
		else if ( com == "reverse" )
			{
				string s3 = s1.substr(a, b-a+1);
				int m = s3.size();
				for (int k = 0; k < m; k++)
				{
					s1[a+k] = s3[m-1-k];
				}
			}
		}
	return 0;
}


Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	map<string, int>mp;
	rep (i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << mp.size() << endl;
	return 0;
}

Measured memory_bytes: 19224
#include <iostream>

using namespace std;

int ans[3][3];

int main() {
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            for (int k = 0; k <= 100; k++) {
                ans[0][0] = a;
                ans[0][1] = b;
                ans[1][1] = c;
                ans[1][2] = i;
                ans[2][2] = j;
                ans[2][0] = k;
                int sum = a + c + ans[2][2];
                ans[0][2] = sum - a - b;
                ans[1][0] = sum - a - ans[2][0];
                ans[2][1] = sum - b - c;
                
                bool ok = true;
                for (int l = 0; l < 3; l++) {
                    if (ans[l][0] + ans[l][1] + ans[l][2] != sum) {
                        ok = false;
                    }
                }
                for (int l = 0; l < 3; l++) {
                    if (ans[0][l] + ans[1][l] + ans[2][l] != sum) {
                        ok = false;
                    }
                }
                if (ans[0][0] + ans[1][1] + ans[2][2] != sum) {
                    ok = false;
                }
                if (ans[2][0] + ans[1][1] + ans[0][2] != sum) {
                    ok = false;
                }
                if (ok) {
                    for (int l = 0; l < 3; l++) {
                        for (int m = 0; m < 3; m++) {
                            if(m != 0) cout << " ";
                            cout << ans[l][m];
                        }
                        cout << endl;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		Integer[][] array = new Integer[n][m];
		for(int i=0;m>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		for(int i=0;n>i;i++) {
			for(int j=0;m>j;j++) {
				int a = sc.nextInt();
				array[i][j]=a;
			}
		}
		int count=0;
		for(int i=0;n>i;i++) {
			int keisan=0;
			for(int j=0;m>j;j++) {
				keisan=keisan+list.get(j)*array[i][j];
			}
			if(keisan+c>0)
				count++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const pii INI = {INT_MAX, -1};

struct dat {
    int from, to, num;
};

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

    int N, Q;
    cin >> N >> Q;
    vector<dat> ST(N);
    for (int i = 0; i < N; ++i) {
        cin >> ST[i].from >> ST[i].to >> ST[i].num;
        ST[i].from -= ST[i].num;
        ST[i].to -= ST[i].num;
    }

    auto cmp = [](dat &a, dat &b) {
        return a.from < b.from;
    };
    sort(ST.begin(), ST.end(), cmp);

    int idx = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push({INT_MAX, INT_MAX});
    for (int i = 0; i < Q; ++i) {
        int D;
        cin >> D;
        while (idx < N && ST[idx].from <= D) {
            que.push({ST[idx].num, ST[idx].to});
            idx++;
        }
        while (que.top().second <= D)
            que.pop();
        cout << (que.top().first < INT_MAX ? que.top().first : -1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 5360
#include<stdio.h>
int main()
{
	long n,m,i,s=0,h;

	scanf("%ld%ld",&n,&m);

	long a[m];

	for(i=0;i<m;i++)
		scanf("%ld",&a[i]);
	for(i=0;i<m;i++)
		s+=a[i];
	h=n-s;
	if(h>=0)
		printf("%ld",h);
	else
		printf("-1");
	return 0;
}

Measured memory_bytes: 1796
import numpy as np

D=int(input())#365
c=list(map(int,input().split()))
s=np.array([])
last_day=np.zeros(26)
now_day=np.zeros(26)

now_satice=0
for i in range(1,D+1):
  s=np.array(input().split(), dtype=np.int64)
  sc_mul=s*c
  max_space=np.argmax(sc_mul)
  last_day[max_space]=i
  now_day=np.full(26, i)
  down=c*(now_day-i*last_day)
  now_satice+=sc_mul[max_space]-down.sum()
  #print(down.sum())
  print(max_space+1)
  #print(now_satice)
  #print(sc_mul)
  #print((i+10)%26+1)

Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
int high,low,n;
inline string GET(int ask)
{
	printf("%d\n",ask);
	fflush(stdout);
	string s;
	cin>>s;
	return s;
}
int main()
{
	string s;
	cin>>n;
	string A=GET(0);
	if(A=="Vacant")return 0;
	string B=GET(n-1);
	if(B=="Vacant")return 0;
	high=n-2,low=1;
	while(high>=low)
	{
		int mid=(high+low)/2;
		s=GET(mid);
		if(s=="Vacant")return 0;
		if(mid%2==0)
			if(s==A)
				low=mid+1;
			else
				high=mid-1;
		else
			if(s==B)
				low=mid+1;
			else
				high=mid-1;
	}
	return 0;
}

Measured memory_bytes: 852