akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<char> s(n),t(n);
  rep(i,n){
    cin>>s[i];
  }
  rep(i,n){
    cin>>t[i];

  }
  string res="";
  rep(i,n){
    res+=s[i];
    res+=t[i];
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i,n) for(ll i = 0;i < (ll)(n);i++)
#define INF 1000000001
#define MAXN 20001
#define MAXM 101
int main()
{
    char c[3][3];
    REP(i,3){
        REP(j,3){
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;


    return 0;
}
/*
    REP(i,a){
        REP(j,b){

        }
    }
    */



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

using namespace std;

int main() {
  int N;
  string s;
  int Y = 0;
  cin >> N;
  for (int i=0; i < N; i++) {
    cin >> s;
    if (s == "Y") {
      Y = 1;
      break;
    }
  }

  if (Y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int a, b,MAXX=0;
	cin >> a >> b;
	for (int i = 0; i < 2;i++) {
		if (a > b) {
			MAXX = MAXX + a;
			a--;
		}
		else if (b>a) {
			MAXX = MAXX + b;
			b--;
		}
		else {
			MAXX = MAXX+a;
			a--;
		}
	}
	cout << MAXX << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<long long, long long>
#define f first
#define s second
#define debug cout<<"here\n" 
#define MOD 1000000009

const int MAXN = 1e6 +15;
 
using namespace std;

int spf[MAXN];
int A[MAXN];
bool vis[MAXN];

void solve(){   
    int n; cin>>n;
    for(int i=0; i<n; i++) cin>>A[i];
    int g = __gcd(A[0],A[1]);
    for(int i=2; i<n; i++){
        g = __gcd(g,A[i]);
    }
    if(g != 1){
        cout<<"not coprime";
        return;
    }
    for(int i=2; i<= 1000000; i++){
        spf[i] = i;
    }
    for(int i=2; (ll)i*i <= 1000000; i++){
        if(spf[i] == i){
            for(int j=i*i; j<=1000000; j+=i){
                if(spf[j] == j) spf[j] = i;
            }
        }
    }

    spf[1] = 1;

    for(int i=0; i<n; i++){
        int x = A[i];
        while(x != 1){
            int y = spf[x];
            if(vis[y]){
                cout<<"setwise coprime";
                return;
            }
            while(x%y ==0) x /= y;
            vis[y] = 1;
        }
    }
    cout<<"pairwise coprime";
    

}
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);    
    cout<<fixed<<setprecision(12);

    int t =1; //cin>>t;
    for(int i=1; i<= t; i++){
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

typedef long long int ll;

using namespace std;

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
	
	ll k,n;
	cin>>k>>n;
	if(k*500>=n)
	{
		cout<<"Yes\n";

	}
	else
		cout<<"No\n";


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i;
	while(scanf("%d",&n)!=EOF)
	{
		int sum=1;
		for(i=0;i<n;i++)
		{
		  sum=n*n*n;	
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int H[N];
  int max = 0;
  int cnt = 0;
  REP(i, N) {
    cin >> H[i];
    if (max <= H[i]) {
      cnt++;
      max = H[i];
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
from copy import copy
import random
random.seed(1)
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,40001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 300-(298*k/40000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

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

int main()
{
    int n;
    cin >> n;
    int nn = n;
    int s = 0;
    while (nn)
    {
        s += nn % 10;
        nn /= 10;
    }
    if (n % s == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

#define int long long

int32_t main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  cout<<max(max(a*c,a*d),max(b*c,b*d));
  
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;

	string ans;
	for (char c : S) {
		if (c == '0' || c == '1') ans.push_back(c);
		else if (c == 'B' && !ans.empty()) ans.pop_back();
	}

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a,b;
	cin>>a>>b;
	if(b>=a){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
}


Measured memory_bytes: 3688
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(input())
        for j in range(m):
            x, y = map(int, input().split())
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h, u = set(), set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        for k in list(h):
            h |= A[k-1][1]
            u |= A[k-1][0]
        if not (h & u):
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;

    while(1)
    {
        scanf("%d %c %d", &a, &op, &b);

        switch(op)
        {
            case '+': printf("%d\n", a + b); break;
            case '-': printf("%d\n", a - b); break;
            case '*': printf("%d\n", a * b); break;
            case '/': printf("%d\n", a / b); break;
            case '?': return 0;
        }
    }
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    int ans = 0;
    IN(int, n);
    vector<int> a(n);
    int b;
    vector<int> c(n-1);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, n){
        cin >> b;
        ans += b;
    }
    REP(i, n-1){
        cin >> c[i];
    }
    REP(i, n-1){
        if(a[i]+1 == a[i+1]){
            ans += c[a[i]-1];
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(int, char**) {
    int K,S;
    int wayNum = 0;
    cin >> K >> S;
    

    for(int i = 0 ; i <= K; i++)
    {
        for(int j = 0 ; j <= K; j++)
        {
            int z = S - i - j;
            if(z >= 0 and z <= K) wayNum++;
            
        }
    }

    cout << wayNum;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int k, x; cin >> k >> x;
    if(k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s_set = set(s)
t_set = set(t)
ans = 0
for i in s_set:
    p = s.count(i)
    q = t.count(i)
    ans = max(ans,p-q)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
bitset <2000010> b;
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	int n,sum=0; sc(n);
	b[0]=1;
	while (n--)
	{
		int x; sc(x);
		sum+=x;
		b|=b<<x;
	}
	for (int i=(sum+1)/2; i<=sum; i++)
		if (b[i]) return pr(i),0;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int ans = 1;
	for (int i = 0;i < a;i++) {
		if (ans < b) {
			ans *= 2;
		}
		else ans += b;
	}
	cout << ans;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    L = max(K, max(A), 1).bit_length()
    k = [0 for i in range(L)]
    i = 0
    while K:
        k[i] += K & 1
        i += 1
        K >>= 1
    b = [0 for i in range(L)]
    for a in A:
        i = 0
        x = a
        while x:
            b[i] += x & 1
            i += 1
            x >>= 1
    k = k[::-1]
    b = b[::-1]
    # dp[i][1]: 上位iビットがKと等しいときの最大値
    # dp[i][0]: 上位iビットがKより小さいときの最大値
    dp = [[0, 0] for i in range(L+1)]
    nonzero = False
    for i in range(L):
        if k[i] == 1:
            dp[i+1][1] = (dp[i][1] << 1) + (N-b[i])
            if nonzero:
                dp[i+1][0] = max((dp[i][1] << 1) + b[i], (dp[i][0] << 1) + max(b[i], N-b[i]))
            else:
                dp[i+1][0] = (dp[i][1] << 1) + b[i]
            nonzero = True
        else:
            dp[i+1][1] = (dp[i][1] << 1) + b[i]
            dp[i+1][0] = (dp[i][0] << 1) + max(b[i], N-b[i]) if nonzero else 0
    return max(dp[L][1], dp[L][0])


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 14148
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = sum(a)
y = b[-1]
ans = x + y
for i in range(n - 1):
    x -= a[-i - 1]
    y += b[-i - 2]
    ans = max(ans, x + y)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int a,b,c; cin >> a >> b >> c;
	int cnt=0;
	if(a%2==0)cnt++;
	if(b%2==0)cnt++;
	if(c%2==0)cnt++;
	if(cnt<=1){
		cout << "Hom" << endl;
	}
	else{
		cout << "Tem" << endl;
	}
	return 0;
}


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

int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  int k;
  cin >> k;
  while (k > 0 && r >= g) {
    k--;
    g *= 2;
  }
  while (k > 0 && g >= b) {
    k--;
    b *= 2;
  }
  cout << (b > g && g > r ? "Yes" : "No") << endl;
}


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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
    if (vs.empty()) return os << "[]";
    os << "[" << vs[0];
    for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
    return os << "]";
}

const int INF = 1<<28;

namespace {
    int W;
    vector<int> A;
    void input() {
        cin >> W;
        A.clear(); A.resize(W);
        for (int i = 0; i < W; i++) cin >> A[i];
    }

    struct S {
        int x;
        int t;
        S() {}
        S(int x, int t) : x(x), t(t) {}
    };

    const int INT = 1<<28;

    void solve() {
        queue<S> Q;
        vector<int> D(W, 0);
        for (int i = 0; i < W; i++) {
            if (A[i] == 0) {
                D[i] = INF;
                Q.push(S(i, INF));
            }
        }
        while (!Q.empty()) {
            S c = Q.front(); Q.pop();
            for (int dx = -1; dx <= 1; dx += 2) {
                int nx = c.x + dx;
                if (nx < 0 || nx >= W) continue;
                int nt;
                if (A[nx] < 0) {
                    nt = min(c.t - 1, -A[nx]);
                } else {
                    nt = c.t - 1;
                }
                if (D[nx] < nt) {
                    D[nx] = nt;
                    Q.push(S(nx, nt));
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < W; i++) {
            if (A[i] > 0) {
                ans += min(A[i], D[i]);
            }
        }
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 2588
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int A,B,C;
 cin >> A >> B >> C;
 
  bool flag = false;
  for(int i =0 ;i<101;i++){
    if((A*i)%B==C){
      flag = true;
      break;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
    
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try {
      char[] str = reader.readLine().toCharArray();

      for (int i = 0; i < str.length; i++) {
        if (Character.isUpperCase(str[i])) {
          System.out.print(Character.toLowerCase(str[i]));
        }
        else if (Character.isLowerCase(str[i])) {
          System.out.print(Character.toUpperCase(str[i]));
        }
        else {
          System.out.print(str[i]);
        }
      }
      System.out.println();
    }
    catch (IOException e) {
      System.out.println(e);
    }
  }
}

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

int main(){
    //1,0,-1
    //k枚選ぶ
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int sum = 0;
    int count = 0;
    
    while(count < k){

        if(count < a){
            sum += 1;  
        }else if(count >= a && count < (a+b) ){ 
            sum += 0;
        }else if( count >= (a+b) && count < (a+b+c) ){
            sum += -1;
        }

        count++;
        
    }

    std::cout << sum << endl;




    return 0;
}

Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	counts := [51]int{}
	patties := [51]int{}

	counts[0] = 1
	patties[0] = 1
	for i := 1; i <= 50; i++ {
		counts[i] = counts[i-1]*2 + 3
		patties[i] = patties[i-1]*2 + 1
	}

	var eats func(n, x int) int
	eats = func(n, x int) int {
		if n == 0 {
			if x <= 0 {
				return 0
			}
			return 1
		}

		count := counts[n]
		mid := count/2 + 1
		if mid <= x {
			return eats(n-1, x-mid) + patties[n-1] + 1
		}

		return eats(n-1, x-1)
	}

	ans := eats(n, x)
	fmt.Println(ans)
}


Measured memory_bytes: 1852
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n;
    cin >> n;

    vs64 cnt(n + 1, 0);
    for (s64 x = 1; x * x <= n; ++x)
    {
        for (s64 y = 1; y * y <= n; ++y)
        {
            for (s64 z = 1; z * z <= n; ++z)
            {
                s64 calc = x * x + y * y + z * z + x * y + y * z + z * x;
                if (calc <= n)
                {
                    ++cnt[calc];
                }
            }
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        cout << cnt[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3600
def sum_N(a:int):
    sum = 0
    while a > 0:
        sum += a % 10
        a = a // 10
    return sum

N = int(input())
ans = []
for i in range(1, N):
    j = N - i
    ans.append(sum_N(i) + sum_N(j))
print(min(ans))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;

  ll cnt = ceil((double)n / min({a, b, c, d, e}));
  cout << cnt + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, m, ans = 0;
    cin >> n >> m;

    vector<int> a(n), b(n);
    REP(i,n) cin >> a[i] >> b[i];

    vector<vector<int>> D(m+1);
    REP(i,n) if(a[i] <= m) D[m-a[i]].push_back(b[i]);

    priority_queue<int> pq;
    for (int i = m; i >= 0; i--) {
        for(auto x:D[i]) pq.push(x);
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll n;
vvll G;

ll solve(ll i){
 vll d(n,inf);
  d[i]=0;
  queue<ll> q;
  q.push(i);
  ll res=0;
  while(q.size()){
   ll p=q.front();
    q.pop();
    chmax(res,d[p]+1);
    for(auto x:G[p]){
      if(d[x]!=inf) continue;
      d[x]=d[p]+1;
      q.push(x);
    }
  }
  rep(i,0,n){
  for(auto j:G[i]) if(abs(d[i]-d[j])!=1) return -1;
    }
  return res;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  cin >> n;
  G.resize(n);
  rep(i,0,n){
   string a;
    cin >> a;
    rep(j,0,n) if(a[j]=='1') G[i].eb(j);
  }
  
  ll ans=-1;
  rep(i,0,n) chmax(ans,solve(i));
  cout << ans << endl;
}  

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << max(0LL,(a - 2*b));
}

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

int main(void){
	int N=0,M=0;
	int min=0,max=0;
	int i=0;
	int *L;
  	int *R;
	scanf("%d %d",&N,&M);
	L=(int*)malloc(sizeof(int)*M);
	R=(int*)malloc(sizeof(int)*M);
  
	scanf("%d %d",&L[0],&R[0]);
  
	min=L[0],max=R[0];
	for(i=1;i<M;i++){
		scanf("%d %d",&L[i],&R[i]);
		if(L[i]>min)min=L[i];
		if(R[i]<max)max=R[i];
	}
  
	if(max<min){
		printf("0");
	}
	else if(max-min+1>=N){
		printf("%d",N);
	}
	else{
		printf("%d",max-min+1);
	}
	return 0;
}


Measured memory_bytes: 896
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cell::{RefCell, RefMut};
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

const l: usize = 26;

#[derive(Default, Debug)]
struct Node {
    is_leaf: bool,
    nleafs: usize,
    counts: [usize; l],
    children: BTreeMap<u8, Box<Node>>,
    seen: bool,
}

fn add_count(node: &mut Node) {
    for (k, v) in &mut node.children {
        add_count(v);
        let vn = v.nleafs + if v.is_leaf { 1 } else { 0 };
        node.nleafs += vn;
        for i in 0..l {
            if i != *k as usize {
                node.counts[i] += v.counts[i];
            } else {
                node.counts[i] += vn;
            }
        }
    }
}

fn count(node: &Node) -> usize {
    let mut ret = 0;
    for (k, v) in &node.children {
        if v.is_leaf {
            let pret = node.counts[*k as usize] - 1;
            ret += pret;
            if pret > 0 {
                // debug!("{:?} {:?}", (k, pret), node); // DEBUG
            }
        }
        ret += count(v);
    }
    ret
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut root = Node {
        is_leaf: false,
        counts: [0; 26],
        children: BTreeMap::new(),
        nleafs: 0,
        seen: false,
    };
    for _ in 0..n {
        let s: Vec<_> = it.next().unwrap().bytes().rev().collect();
        let mut cur = &mut root;
        for (i, c) in s.iter().enumerate() {
            let k = c - b'a';
            cur = cur.children.entry(k).or_default();
            if i == s.len() - 1 {
                cur.is_leaf = true;
            }
        }
    }
    add_count(&mut root);
    assert_eq!(root.nleafs, n);
    debug!("{:?}", root); // DEBUG
    println!("{}", count(&root));
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 554820
import math


def main(N, D, lines):
    count = 0
    for line in lines:
        d = math.sqrt(line[0] ** 2 + line[1] ** 2)

        if d <= D:
            count += 1
    print(count)


[N, D] = map(int, input().split())
lines = []
for i in range(N):
    lines.append(list(map(int, input().split())))
main(N, D, lines)


Measured memory_bytes: 45472
n, k, q = map(int, input().split())
candis = [k] * n
candis = list(map(lambda x: x - q, candis))
for _ in range(q):
    candis[int(input()) - 1] += 1
for score in candis:
    if score <= 0:
        print("No")
    else:
        print("Yes")


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

using namespace std;

typedef long long ll;

int main () {
  string s;
  cin >> s;

  ll bc = 0;
  ll ans = 0;
  for (char c : s) {
    if (c == 'B') bc++;
    else ans += bc;
  }

  cout << ans << endl;
}


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

int main() {
    int n;
    cin>>n;
    int cnt = 19;
    int lo = 1, hi = n + 1;
    cout<<0<<"\n"<<flush;
    string cur, old;
    cin>>old;
    while(cnt-- && old != "Vacant") {
        int mid = (lo + hi + 1)/2;
        cout<<mid - 1<<"\n"<<flush;
        cin>>cur;
        if(cur == "Vacant")
            break;
        if((cur != old && (mid - lo)&1) ||
                (cur == old && !((mid - lo)&1))) {
            lo = mid;
            old = cur;
        }
        else {
            hi = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 852
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int a, b;
    cin >> a >> b;
    rep(t, 30000) {
        if (t * 8 / 100 == a && t * 10 / 100 == b) {
            print(t);
            return 0;
        }
    }

    print(-1);

    return 0;
}



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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

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

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

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

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    long a = s.filter!(c => c == '+').count();
    long b = s.filter!(c => c == '-').count();
    writeln(a - b);
}


Measured memory_bytes: 256
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )

main :: IO ()
main = do
  xs <- map (read . return) <$> getLine
  putYN $ (sum xs) `mod` (9 :: Int) == 0

putYN :: Bool -> IO ()
putYN True  = putStrLn "Yes"
putYN False = putStrLn "No"

Measured memory_bytes: 11932
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 100000000

using namespace std;

using P = pair<int,int>;

// 各点への最短経路 dijkstra
long d[10];  //頂点kから各点への距離
vector<P> G[10]; //隣接行列
int n; 
void dijkstra(int k) { //Gは隣接行列 G[i][j].firstが距離, secondが向かう頂点名, kはスタートする頂点
    fill(d, d+n, INF); d[k] = 0;
    priority_queue< P, vector<P>, greater<P> > que;
    que.push(P(0, k));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int now = p.second;
        if (d[now] < p.first) continue;
        for (auto g:G[now]) {
            int to = g.second;
            long newd = g.first + d[now];
            if (d[to] > newd) {
                d[to] = newd;
                que.push(P(d[to], to));
            }
        }
    }
}

int main() {
    n = 10;
    int h, w;
    cin >>  h >> w;
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            int c; cin >> c;
            if (i == j) continue;
            G[j].push_back({c, i});
        }
    }
    dijkstra(1);
    int sum=0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            int a; cin >> a;
            if (a < 0) continue;
            sum += d[a];
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 256
import fractions
N, M = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for x in a:
    lcm = (lcm*x) // fractions.gcd(lcm, x)
ans = (M // lcm)
if M % lcm >= (lcm//2):
    ans += 1
x = a[0]
k = 0
while(x % 2 == 0):
    x = x // 2
    k += 1

for x in a[1:]:
    count = 0
    while(x % 2 == 0):
        x = x // 2
        count += 1
    if k == count:
        continue
    else:
        ans = 0


print(ans)


Measured memory_bytes: 16280
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const double pi=acos(-1.0);
int main()
{
	double a=(double)(read()),b=(double)(read()),x=(double)(read());
	if(x/a/a/b<0.5)
	{
		double s=x/a;
		printf("%.10lf\n",atan(b*b/2/s)/pi*180.0);
	}
	else
	{
		double s=a*b-x/a;
		printf("%.10lf\n",atan(2*s/a/a)/pi*180.0);
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct p
{
    char s[20];
    int score;
    int num;
}a[200];
int cmp(p a,p b)
{
    if(strcmp(a.s,b.s)==0)
    {
        return a.score>b.score;
    }
    else
        if(strcmp(a.s,b.s)<0)
        return 1;
    return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s%d",a[i].s,&a[i].score);
        a[i].num=i+1;
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
        printf("%d\n",a[i].num);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
#include <fstream>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    long long u = a.size(), v = b.size();
    for( int i = 0; i < u + v; i++)
    {
        if( i % 2 == 0) printf("%c", a[i / 2]);
        else printf("%c", b[( i - 1) / 2]);
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

var dp [100][100]int

func printslice(h int, w int){
	for i:=0 ; i<h ; i++ {
		for j:=0 ; j<w;j++ {
			fmt.Printf("%d ",dp[i][j])
		}
		fmt.Println("")
	}
}

func dynamic(s [][]int, h int, w int){
	//引数：ルート(0:black,1:white),調べるポイント
	//返り値：DP
//fmt.Println(h,w)
//printslice(h+1,w+1)
	height := len(s)-1
	width := len(s[0])-1
//printslice(height+1,width+1)
	if h != height {
		down := dp[h+1][w]
		if w != width {
			right := dp[h][w+1]
			if right == -1{
//fmt.Println("search : ",h,w+1)
				dynamic(s,h,w+1)
				right = dp[h][w+1]
			}
			if down == -1{
//fmt.Println("search : ",h+1,w)
				dynamic(s,h+1,w)
				down = dp[h+1][w]
			}

			if s[h][w] == 0 {
				if s[h][w+1] == 1{
				//黒から白へ
					right++
				}
				if s[h+1][w] == 1{
					down++
				}
			}
			if right <= down {
				dp[h][w] = right

			} else {
				dp[h][w] = down
			}
		} else {
			if down == -1 {
				dynamic(s,h+1,w)
				down = dp[h+1][w]
			}
			if s[h][w] == 0 && s[h+1][w] == 1{
				down++
			}
			dp[h][w] = down
		}
	} else {
		if w == width {
			if s[h][w] == 0 {
				dp[h][w] = 1
			} else {
				dp[h][w] = 0
			}
		} else {
			right := dp[h][w+1]
			if right == -1{
				dynamic(s,h,w+1)
				right = dp[h][w+1]
			}
			if s[h][w] == 0 && s[h][w+1] == 1{
				right++
			}
			dp[h][w] = right
		}
	}
}

func main(){
	var h,w int
	var r string
	//var s [][]int
	//var temp []int
	fmt.Scan(&h,&w)
	s := make([][]int,h)
	for i:=0 ; i<h ; i++ {
		fmt.Scan(&r)
		var temp []int
		for j:=0 ; j<w ; j++{
			if r[j:j+1] == "." {
				temp = append(temp,1)
			} else {
				temp = append(temp,0)
			}
		}
		s[i] = temp
	}
	for i:=0 ; i<h ; i++ {
		for j:=0 ; j<w ; j++{
			dp[i][j] = -1
		}
	}
	//fmt.Println(dynamic(s,0,0))
	dynamic(s,0,0)
//printslice(h,w)
	fmt.Println(dp[0][0])
}


Measured memory_bytes: 896
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val k = sc.nextInt()
    val s = sc.nextLine()
    if (s.length <= k) {
        println(s)
    } else {
        println(s.take(k) + "...")
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 35768
from collections import Counter
from math import factorial
N=int(input())
L=[]
Lappend=L.append
ans=0
for _ in range(N):
    s=list(input())
    s.sort()
    Lappend("".join(s))
C=Counter(L)
for i in C.values():
    if i==1:pass
    elif i==2:ans+=1
    else:
        ans+=((factorial(i)//factorial(i-2))//factorial(2))
print(ans)

Measured memory_bytes: 19728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = 2147483647;
const ll LLINF = 1LL<<60;



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

int n;
cin >> n;
int a;
deque<int> b;
if((n+2)%2==0){//odd
    rep(i,n){
        cin >> a;
        if((i+2)%2==1){//even
            b.push_front(a);
        }else{//odd
            b.push_back(a);
        }
    }
}else{
    rep(i,n){
        cin >> a;
        if((i+2)%2==1){
            b.push_back(a);
        }else{
            b.push_front(a);
        }
    }
}
rep(i,n) cout << b[i] << " ";

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 3072
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:(i64,i64)});
    list.into_iter()
        .max_by_key(|&(a, _)| a)
        .map(|(a, b)| a + b)
        .unwrap()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\n4 7\n2 9\n6 2" => "8",
    test2: "5\n1 10\n3 6\n5 2\n4 4\n2 8" => "7",
    test3: "2\n1 1000000000\n1000000000 1" => "1000000001",
}


Measured memory_bytes: 12540
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i*i<=n;i++){
        if(i*i<=n)ans=max(ans,i*i);
    }
    cout<<ans<<enl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 200010
#define MOD 1000000007

vector<int> g[N];
int visited[N] = {}, a[N] = {}, ans[N];
void dfs(int n, int val)
{  
   visited[n] = 1;
   ans[n] = val + a[n];
   for(auto e : g[n])
      if(!visited[e])
         dfs(e, val + a[n]);

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
   cout.precision(10);
   int n, q;
   cin >> n >> q;
   int a1, b, p, x;
   for (int i = 0; i < n -1; ++i)
   {
      cin >> a1 >> b;
      g[a1].pb(b);
      g[b].pb(a1);
   }

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

   dfs(1, 0);

   for(int i = 1; i <= n; ++i)
      cout << ans[i] << " ";
   return 0;	
}

      // while(b)
      // {
      //    if(b & 1)
      //    {
      //       an = (an * a);
            
      //       if(an > 1e18) 
      //          an /= 1e18;
      //    }
      //    a = (a * a);
      //    if(a > 1e18)
      //       a /= 1e18;
      //    b >>= 1;
      // }


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

int main(){
  char S[11];
  int L;
  int c=0;
  scanf("%s",S);
  L=strlen(S);
  
  if(L%2==0){
    for(int i=0;i<L;i+=2){
      if(!(S[i]=='h' && S[i+1]=='i')){
        c=1;
        break;
      }
    }
  }else{
    c=1;
  }
  if(c==0)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut ans = 0;
    for _ in 0..n {
        ans += read::<usize>() - 1
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352