akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, txt;
    int n;
    cin >> s;
    n = s.size();
    int sum = 0;
    for (int bit = 0; bit < 1 << (n - 1); bit++) {
        int sum = s[0] - '0';
        txt = s[0];
        for (int j = 0; j < n - 1; j++) {
            int a = s[j + 1] - '0';
            if (bit & (1 << j)) {
                sum += a;
                txt += "+";
                txt += s[j + 1];
            } else {
                sum -= a;
                txt += "-";
                txt += s[j + 1];
            }
        }
        if (sum== 7) {
            cout << txt << "=7" << endl;
            return 0;
        } else {
            sum = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      /* printf */
#include <cmath>       /* sin */
#include <iomanip>

#define PI 3.14159265
using namespace std;

int main ()
{

  int a, b, C;

  cin >> a >> b >> C;

  double x = cos (C * PI/180)	* b;
  double h = sin (C * PI/180) * b;
  double S = a * h / 2;
  double length = sqrt(pow((a-x), 2) + pow(h, 2));
  cout << fixed << setprecision(6) << S << endl;
  cout << a + b + length << endl;
  cout << h << endl;

  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
//const long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,k;cin>>n>>k;
    if(n<=2){cout<<0<<endl;return 0;}
    int a[13][7];
    rep(i,0,12)rep(j,0,6)a[i][j]=7*i+j+1;
    ll s[11];memset(s,0,sizeof(s));
    rep(i,0,10){
        rep(z,0,4){
            ll sum=0;
            rep(j,0,2)rep(l,0,2){
                sum+=a[i+j][z+l];
            }
            if(sum%11==k)s[i]++;
        }
        if(i!=10)s[i+1]=s[i];
    }
    
    ll m=(n-3)/11;
    ll p=(n-3)%11;
    ll ans=m*s[10]+s[p];
    cout<<ans<<endl;
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  	int K;
	string S;
  	cin >> K >> S;
  	if(S.size() <= K){
    	cout << S << endl;
    }else{
    	for(int i=0; i<K; i++){
        	cout << S[i];
        }
      	cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */
int n, a, b;
void in(){
    cin >> n >> a >> b;
}

void solve(){


    cout << min(a, b) << " ";

    if(a + b > n){
        cout << abs(n - (a + b));
    }else{
        cout << 0;
    }
    cout << endl;


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i + 1 == a[a[i] - 1]) sum++;
    }
    cout << sum  / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

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(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {


	int a;

	cin >> a;

	cout << a + a * a + a * a * a << endl;

	return 0;
}

Measured memory_bytes: 3592
def main():
    import sys
    input = sys.stdin.readline
    a, b = map(int, input().rstrip('\n').split())
    s = input().rstrip('\n')
    ls = list("1234567890")
    for i in range(len(s)):
        if i < a:
            if s[i] not in ls:
                print("No")
                exit()
        elif i == a:
            if s[i] != "-":
                print("No")
                exit()
        elif b <= i:
            if s[i] not in ls:
                print("No")
                exit()
    print("Yes")


if __name__ == '__main__':
    main()


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

using ull = unsigned long long;
using ll = long long;

template<class T>           //自定义读入函数
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>        //自定义写入函数
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }   //自定义比较函数
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }   //自定义比较函数

#define For(i, a, b) for (int i = (a); i <= (b); ++i)   //从小到大重复
#define Rep(i, a, b) for (int i = (a); i >= (b); --i)   //从大到小重复
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)                  //内存复制


#if 1

void addNum(int num, priority_queue<ll, vector<ll>, greater<ll> >& maxheap, priority_queue<ll>& minheap) {
        if (maxheap.size() > minheap.size()) {
            maxheap.push(num);
            minheap.push(maxheap.top());
            maxheap.pop();
        }
        else {
            minheap.push(num);
            maxheap.push(minheap.top());
            minheap.pop();
        }
    }

int main()
{
	priority_queue<ll> minMin, minMax;
	priority_queue<ll, vector<ll>, greater<ll> > maxMin, maxMax;
	int N;
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++)
	{
		ll min, max;
		scanf("%lld %lld", &min, &max);
		addNum(min, maxMin, minMin);
		addNum(max, maxMax, minMax);
	}
	ll result = 0;
	if(N == 1)
		result = minMax.top() - minMin.top() + 1;
	else if(N == 0)
		result = 0;
	else if(N & 1)
	{
		ll myMin = maxMin.top(), myMax = maxMax.top();
		result = (myMax - myMin + 1);
	}
	else
		result = (minMax.top() + maxMax.top()) - (minMin.top() + maxMin.top()) + 1;
	cout << result << endl;
	return 0;
}

#endif

#if 0

int main()
{
	int n ;
	cin >> n ;
	vector<long long> small ;
	vector<long long>large  ;
	for (int i = 0 ; i < n ; ++i) {
		long long a , b ;
		cin >> a >> b  ;
		small.push_back(a) ;
		large.push_back(b) ;
	}
 
	sort(small.begin() , small.end()) ;
	sort(large.begin() , large.end()) ;
	if (n % 2 == 1) {
		long long d = large[(n) / 2] - small[(n) / 2] + 1 ;
		cout << d << endl ;
	}
	else {
		long long a, b ;
		a = small[n / 2 - 1] +  small[n / 2 ]   ;
 
		b = large[n / 2 - 1]  + large[n / 2] ;
		cout << b - a + 1 << endl ;
	}
	return 0;
}

#endif

Measured memory_bytes: 6648
#include <stdio.h>

int main(void)
{
	double weight;
	
	while (scanf("%lf",&weight) != EOF){
		if (weight > 91.00){
			printf("heavy\n");
		}
		else if (weight > 81.00){
			printf("light heavy\n");
		}
		else if (weight > 75.00){
			printf("middle\n");
		}
		else if (weight > 69.00){
			printf("light middle\n");
		}
		else if (weight > 64.00){
			printf("welter\n");
		}
		else if (weight > 60.00){
			printf("light welter\n");
		}
		else if (weight > 57.00){
			printf("light\n");
		}
		else if (weight > 54.00){
			printf("feather\n");
		}
		else if (weight > 51.00){
			printf("bantam\n");
		}
		else if (weight > 48.00){
			printf("fly\n");
		}
		else {
			printf("light fly\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
import java.io.*;
import java.lang.reflect.Array;
import java.nio.channels.ScatteringByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	  Scanner sc = new Scanner(System.in);
    	  String A = sc.next();
    	  String B = sc.next();
    	  String C = sc.next();
    	  
    	  if (A.charAt(A.length() -1) == B.charAt(0) && B.charAt(B.length() -1) == C.charAt(0)){
    		  System.out.println("YES");
    	  } else {
    		  System.out.println("NO");
    	  }
    	  
    }
    
}
    

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

using namespace std;

int main()
{
    string s;
    int K;
    cin >> s >> K;
    const int L = s.length();
    for (auto& x : s) {
        x -= 'a';
    }

    int M = K;
    for (int i = 0; i < L - 1; ++i) {
        if (s[i] == 0) {
            continue;
        }
        int d = 26 - s[i];
        if (M >= d) {
            s[i] = 0;
            M -= d;
        }
    }

    s.back() = (s.back() + M % 26) % 26;
    for (auto& x : s) {
        x += 'a';
    }
    cout << s << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

struct Edge{
	int to; ll dist;
	Edge(){}
	Edge(int to,ll dist):to(to),dist(dist){}
};

template <class E>
using Graph = vector<vector<E>>;
 
template<class D, D INF>
struct Dijkstra {
    vector<D> res; //res[i] = sからiまでの最短距離
    
    template<class E>
    Dijkstra(const Graph<E> &g, int s) {
        int V = (int)g.size();
        res = vector<D>(V, INF);
        
        using P = pair<D, int>;
        priority_queue<P, vector<P>, greater<P>> q;
        q.push(P(0, s));
        res[s] = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();
            if (res[p.second] < p.first) continue;
            for (E e: g[p.second]) {
                if (p.first+e.dist < res[e.to]) {
                    res[e.to] = p.first+e.dist;
                    q.push(P(res[e.to], e.to));
                }
            }
        }
    }
};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	int s,t; cin >> s >> t;
	s--; t--;
	Graph<Edge> g(n);
	vector<int> d(n);
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	for(int i=0;i<m;i++){
		int l,r; cin >> l >> r ;
		l--; r--;
		g[l].push_back(Edge(r,d[r]));
	}
	for(int i=0;i<n-1;i++){
		g[i+1].push_back(Edge(i,0));
	}
	Dijkstra<ll,(ll)1e15> di(g,s);
	if(di.res[t]==1e15){
		cout << -1 << endl;
	}
	else{
		cout << di.res[t] << endl;
	}
	return 0;
}


Measured memory_bytes: 14160
# include <bits/stdc++.h>//B 超时 
using namespace std;
int a,ans;
int Min=10000000;
int main()
{
	int n,p;
	cin>>n;
	while(n--)
	{
		//cin>>a;
		scanf("%d",&a);
		if(a<Min) Min=a;
		if(a<=Min) ans++;
	}
	/*for(int i=1;i<=n;i++)
	{
		for(int j=i;j>=1;j--)
		{
			 p=0;
			if(a[i]>a[j])
			{
				p=1;
				break;
			}
		}
		if(p==0) ans++;
	}*/
	//cout<<ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
S = input()
 
MOD = 10**9+7
 
dp = [[0]*13 for _ in range(len(S) + 1)]
 
 
dp[0][0] = 1
 
for index in range(len(S)):
    s = S[index]
    if s == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i +  pre_index * 10 ) % 13
                dp[index+1][next_i] += dp[index][pre_index] 
                dp[index+1][next_i] %= MOD

    else:
        for pre_index in range(13):
            i = int(s)
            next_i = (i +  pre_index  * 10) % 13
            dp[index+1][next_i] += dp[index][pre_index] 
            dp[index+1][next_i] %= MOD
 
 
 
print(dp[len(S)][5])


Measured memory_bytes: 61788
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fail return puts("-1"), 0

const int N = 1e5 + 5;

int n, idx, lstRoot;
char s[N];

void printTree(int sz) {
	int rt = ++idx;
	if (lstRoot) printf("%d %d\n", rt, lstRoot);
	lstRoot = rt;
	for (int i = 1; i < sz; i++) {
		printf("%d %d\n", rt, ++idx);
	}
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (s[1] == '0' || s[n] == '1') fail;
	for (int i = 1; n - i > i; i++) {
		if (s[i] != s[n - i]) fail;
	}
	int lst = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] == '1') {
			int sz = i - lst;
			lst = i;
			printTree(sz);
		}
	}
	printTree(n - lst);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,c,ans=0;cin>>n;
  vector<int> b(n);
  rep(i,n)cin>>b[i];
  sort(b.begin(),b.end());
  rep(i,n) ans += b[i];
  cout << ans - (b[b.size()-1]/2) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i;
    char N[3];
    
    scanf("%s", N);

    for (i = 0; i < 3; i++) {
        if (N[i] == '7') {
            printf("Yes");
            return 0;
        }
    }

    printf("No");
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	double L;
	cin >>L;
	double V=L*L*L/27.0;
	cout <<fixed <<setprecision(10) <<V <<endl;
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll N;
    cin >> N;
    ll x = 800 * N;
    ll y = N / 15 * 200;
    cout << x - y << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)


N = int(input())						# 5

a = int(input())
for _ in range(N-1):
	a = lcm(a, int(input()))


print(a)


Measured memory_bytes: 2940
#include<stdio.h>

int millenium(int, int, int);

int main()
{
	int i, N, y, m, d;
	
	scanf("%d", &N);
	
	for(i = 0; i < N; i++)
	{
		scanf("%d%d%d", &y, &m, &d);
		
		printf("%d\n", millennium(y, m, d));
	}
	
	return 0;
}

int millennium(int year, int manth, int day)
{
	int result, i;
	
	result = 0;
	
	if(year % 3 == 0)
	{
		result += (10 - manth) * 20 + 20 - day + 1;
	}
	else
	{
		result += 1 - day;
		
		i = 0;
		while((manth + i) < 11)
		{
			result += 19 + (manth + i) % 2;
			
			i++;
		}
	}
	
	i = 1;
	while((year + i) < 1000)
	{
		result += 20 * 10;
		
		if((year + i) % 3 != 0)
		{
			result -= 5;
		}
		
		i++;
	}
	
	return result;
}

Measured memory_bytes: 596
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        Arrays.sort(a);

        int l = 0;
        for (int i = n - 1; i > n - 1 - k; i--) {
            l += a[i];
        }

        out.println(l);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21332
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  int q;
  cin >> q;
  for (int z = 0; z < q; z++) {
    int c, a, n;
    cin >> c >> a >> n;
    int res = 0;
    for (int i = 1; i < 1001; i++) {
      if (c < i) break;
      int count = 0;
      int b = c - i;
      if (a >= n) {
	count += n;
	count += min(b, a-n);
	b -= a-n;
	count += max(0, b/2);
      } else {
	count += a;
	count += b/2;
      }
      res = max(res, min(i,count));
    }
    cout << res << endl;
  }
}

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

int main() {
	unsigned long long n, a, b;
	cin >> n;
	cin >> a;
	cin >> b;
	unsigned long long dist = b - a, sum = a + b - 1;
	cout
			<< ((dist % 2 == 0) ? (dist / 2) :
				(sum < n) ? (sum / 2) : (n - sum / 2)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
int h[n];
for(int i=0;i<n;i++)
cin>>h[i];
vector<int> ans(n,INT_MAX);
ans[0]=0;
for(int i=0;i<n;i++){
 for(int j=i+1;j<=i+k;j++){
   if(j>=n)
     break;
   ans[j]=min(ans[j],ans[i]+abs(h[j]-h[i]));
 }
}
cout<<ans[n-1]<<"\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	

int t[201][201];


ll gcd(ll a,ll b){
	if(a==0){
		t[a][b]=b;
		return b;
	}
	if(t[a][b]!=-1){
		return t[a][b];
	}
	else{
		t[a][b]=gcd(b%a,a);
		return t[a][b];
	}
}

ll gcd3(ll a,ll b,ll c){
	return gcd(gcd(a,b),c);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	ci(n);
	memset(t,-1,sizeof(t));
	ll sum=0;
	fok(i,1,n+1){
		fok(j,1,n+1){
			fok(k,1,n+1){
				sum+=(gcd3(i,j,k));
			}
		}
	}
	co(sum);
}


Measured memory_bytes: 3768
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


import sys

readline = sys.stdin.buffer.readline

N, Q = map(int, readline().split())
tree = UnionFind(N)
res = []
for _ in range(Q):
    t, u, v = map(int, readline().split())
    if t:
        res.append(int(tree.is_connected(u, v)))
    else:
        tree.unite(u, v)
print("\n".join(map(str, res)))


Measured memory_bytes: 19060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    string ans;
    if(A%2==0 || B%2==0) ans = "No";
    else ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	cin >> n;
	cout << 48 - n << endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+5;
int dp[MAX],h[MAX];
int n;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)    cin>>h[i];

    for(int i=1;i<n;i++)
        {
            dp[i]=dp[i-1]+(abs(h[i]-h[i-1]));
                if(i>1)
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));

        }

   //     for(int i=0;i<n;i++)    cout<<dp[i]<<" ";
        cout<<dp[n-1];
}


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

LL n,m;
const LL mod=1000000007ll;

LL jie_cheng(LL n)
{
    LL ans=1;
    for(int i=2;i<=n;i++)
        ans=ans*i%mod;
    return ans;
}

int main()
{
    while(cin>>n>>m)
    {
        if(n<m) swap(n,m);
        if(n-m>=2) cout<<0<<endl;
        else if(n-m==1) cout<<jie_cheng(m)*jie_cheng(n)%mod<<endl;
        else cout<<jie_cheng(m)*jie_cheng(n)*2%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>
#include <map>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

template<size_t N>
class UnionFind {
    int par[N];
public:
    UnionFind() {
        for (int n = 0; n < N; n++) par[n] = n;
    }
    int root(int x) {
        if (par[x] == x) return x;
        else return par[x] = root(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 (x == y) return;
        par[x] = y;
    }
};

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

    int N;
    cin>>N;
    using pos = pair<ll, ll>;
    vector<pos> po(N+1);
    map<ll, vector<int>> xs, ys;
    for (int n = 1; n <= N; n++) {
        int x, y;
        cin>>x>>y;
        po[n] = make_pair(x, y);
        xs[x].push_back(n);
        ys[y].push_back(n);
    }

    UnionFind<100001> uf;
    multimap<ll, pos> dst;
    for (auto it = begin(xs); it != end(xs); it++) {
        if (++it == end(xs)) break;
        ll nx = it->first;
        auto& ns = it->second;
        ll px = (--it)->first;
        auto& ps = it->second;
        int root = ns.front();
        for (int n : ns) uf.unite(root, n);
        root = ps.front();
        for (int p : ps) uf.unite(root, p);
        for (int n : ns) {
            for (int p : ps) {
                dst.insert(make_pair(min(nx-px, abs(po[n].second-po[p].second)), make_pair(n, p)));
                break;
            }
            break;
        }
    }
    for (auto it = begin(ys); it != end(ys); it++) {
        if (++it == end(ys)) break;
        ll ny = it->first;
        auto& ns = it->second;
        ll py = (--it)->first;
        auto& ps = it->second;
        int root = ns.front();
        for (int n : ns) uf.unite(root, n);
        root = ps.front();
        for (int p : ps) uf.unite(root, p);
        for (int n : ns) {
            for (int p : ps) {
                dst.insert(make_pair(min(ny-py, abs(po[n].first-po[p].first)), make_pair(n, p)));
                break;
            }
            break;
        }
    }

    int cost = 0;
    for (auto&& d : dst) {
        if (uf.same(d.second.first, d.second.second)) continue;
        else {
            cost += d.first;
            uf.unite(d.second.first, d.second.second);
        }
    }

    cout<<cost<<endl;

    return 0;
}

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

#define ll long long int

	
	
int main(){
		string s;
		cin>>s;
		
		int arr[26] = {};
		
		for(int i=0;i<s.length();i++){
				arr[s[i] - 'a']++;
		}
		bool flag= true;
		for(int i=0;i<26;i++){
				if(arr[i] % 2 == 1)
					flag = false;
		}
		
		if(flag)
			cout<<"Yes";
		else
			cout<<"No";
}




Measured memory_bytes: 256
def resolve():
    n = int(input())
    a = list(map(lambda num: int(num) - 1, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    res = 0
    for i in range(n):
        dish = a[i]
        res += b[dish]
        if i < n-1 and a[i] + 1 == a[i+1]:
            res += c[a[i]]

    print(res)



resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int H, W,N;
int field[305][305];
int field2[305][305];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};


void dfs(int x, int y, int h) {
    field[x][y] = 0;
    rep(i,4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(0 <= nx and nx < H and 0 <= ny and ny < W and field[nx][ny] > h) dfs(nx, ny, h);
    }
    return ;
}

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

    int h, w;
    while(cin >> h >> w) {
        if(h == 0 and w == 0) return 0;
        rep(i,h) {
            if(i == 0 or i == h - 1) {
                rep(j,w) cout << '#';
                cout << endl;
            }
            else {
                rep(j,w) {
                    if(j == 0 or j == w -1 ) cout << '#';
                    else cout << '.';
                    if(j == w - 1) cout << endl;
                }
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3056
from bisect import bisect_left, bisect_right
N, *A = map(int, open(0).read().split())
for i in range(N):
  A[i] -= i+1

A.sort()
L = bisect_left(A,0)
R = bisect_right(A,0)
ans = 0
if L>N-L:
  l = 2*L-N
  n = l//2+1 if l%2!=0 else l//2
  c = A[L-n]
  for i in range(N):
    ans += abs(A[i]-c)
elif R<N-R:
  r = N-2*R
  n = r//2+1 if r%2!=0 else r//2
  c = A[R+n-1]
  for i in range(N):
    ans += abs(A[i]-c)
else:
  for i in range(N):
    ans += abs(A[i])
print(ans)

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

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

    int n;
    int min = 1000000000;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int a, temp = 0;
      cin >> a;
      while (a % 2 == 0) {
        temp++;
        a /= 2;
      }
      if (min > temp)
        min = temp;
    }

    cout << min << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector a(n+1,0);
    for (int i=0; i<n; i++) cin >> a[i];
    long ans = 0;
    for (int i=0; i<n; i++) {
        if (a[i]%2 && a[i+1]) ans++,a[i+1]--;
        ans += a[i] / 2;
        a[i] %= 2;
    }


    cout << ans << endl;
}


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

int main() {
    int64_t n, m;
    cin >> n >> m;
    
    priority_queue<int64_t> q;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        q.push(a);
    }

    int count = 0;
    while(count < m) {
        int v = q.top();
        q.pop();
        v /= 2;
        q.push(v);
        count++;
    }

    int64_t ans = 0;
    for(int i = 0; i < n; i++) {
        int v = q.top();
        q.pop();
        ans += v;
    }
    cout << ans << endl;

    return 0;
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int num = 0;
    string result = "";
    REP(i, (1 << s.size())){
        char c = s[0];
        num = atoi(&c);
        result = c;
        REP(j, s.size() - 1){
            if (i & (1 << j)){
                result += "-";
                c = s[j+1];
                num -= atoi(&c);
            }else{
                result += "+";
                c = s[j+1];
                num += atoi(&c);
            }
            result += s[j+1];
        }
        if (num == 7){
            break;
        }
    }
    cout << result + "=7" << endl;
}

Measured memory_bytes: 256
"""

普通に端っこを基準にして、貪欲的に爆弾をおいていく方法を考えるのがよさそう。
座標圧縮したうえで、遅延セグ木で各座標に蓄積しているダメージを管理しておけばよい。
一番左端のやつの体力を削れるだけの爆弾を設置してみる:O(1)
次の左端になるモンスターの位置(体力が1以上あるモンスターのなかで一番左端のやつの座標)を探す。これはO(logN)かかる。
このサイクルをモンスターが全滅するまで行うので、O(N)サイクル回す。したがって全体でO(NlogN)
"""
from math import ceil
class lazySegTree:
    def __init__(self,n):
        self.end_leave = 2**(n.bit_length()+1)
        self.tree = [0]*(2*self.end_leave)
        self.lazy = [0]*(2*self.end_leave)

    def gindex(self,left,right):
        #leftとrightの真上にあるノードを返す
        left = left + self.end_leave
        right = right + self.end_leave
        left >>= 1
        while left:
            yield left
            left >>= 1

        right >>= 1
        while right:
            yield right
            right >>= 1

    def add(self,left,right,x):
        L = left + self.end_leave
        R = right + self.end_leave
        while L < R:
            if L&1:
                self.lazy[L] += x
                self.tree[L] += x
                L += 1
            if R&1:
                R -= 1
                self.lazy[R] += x
                self.tree[R] += x
            L >>= 1
            R >>= 1
        for i in self.gindex(left,right):
            self.tree[i] = max(self.tree[i*2],self.tree[i*2+1])+self.lazy[i]
    
    def propagates(self,*ids):
        for i in reversed(ids):
            self.lazy[i*2] += self.lazy[i]
            self.lazy[i*2+1] += self.lazy[i]
            self.tree[i*2] += self.lazy[i]
            self.tree[i*2+1] += self.lazy[i]
            self.lazy[i] = 0

    def get(self,left,right):
        self.propagates(*self.gindex(left,right))
        L = left + self.end_leave
        R = right + self.end_leave
        res = 0
        while L < R:
            if L&1:
                res = max(res,self.tree[L])
                L += 1
            if R&1:
                R -= 1
                res = max(res,self.tree[R])
            L >>= 1
            R >>= 1
        return res
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort()
compSet = []
for x,h in XH:
    compSet.append(x)
    compSet.append(x+2*D)
compSet.sort()
compSet = sorted(set(compSet))
compDic = {x:i for i,x in enumerate(compSet)}

LST = lazySegTree(len(compDic))
ans = 0
for x,h in XH:
    compX = compDic[x]
    h -= LST.get(compX,compX+1)
    if h > 0:
        bomb = ceil(h/A)
        ans += bomb
        damage = bomb*A
        compRight = compDic[x+2*D]
        LST.add(compX,compRight+1,damage)
print(ans)



Measured memory_bytes: 221708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel A(N); rep(i,N) cin >> A[i];
    if(A[0] != 0) { cout << -1 << endl; return 0; }

    ll ans = 0LL;
    for(int i = N-1; i >= 1; i--) {
        if(A[i-1] + 1 < A[i]) { cout << -1 << endl; return 0; }
        else if(A[i-1] + 1 > A[i]) ans += A[i];
        else  ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
x = input()
y=0
if len(x) % 2 == 1:
    y = 1
    
for i in range(len(x)):
    if i % 2 == 0 :
        if x[i] != 'h':
            y=1
            break
    elif i % 2 ==1:
        if x[i] != 'i':
            y=1
            break

if y ==0:
    print("Yes")
elif y ==1:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   string s;
   cin>>s;
   int cnt=0;
   for(int i=0;i<s.size();i++){
      if(s[i]=='x')cnt++;
   }
   if(cnt>=8)cout<<"NO"<<endl;
   else cout<<"YES"<<endl;
}

   


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    Vi x(n);
    rp(i,n) cin >> x[i];
    ll sum=0;
    rp(i,n){
        sum += min(abs(x[i]),abs(k-x[i]));
    }
    sum *= 2;
    print(sum);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;

int main(){
  double r, S, l;
  scanf("%lf", &r);
  S = pow(r, 2.0) * 3.141592653589;
  l = 2.0 * r * 3.141592653589;
  printf("%lf %lf\n", S, l);
  return 0;
}



Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s1,s2;
	cin>>s1;
	cin>>s2;
	int n1=s1.size();
	int n2=s2.size();
	int dp[n1+1][n2+1];
	dp[0][0]=0;
	for(int i=1;i<=n1;i++){
		dp[i][0]=0;
	}
	for(int i=1;i<=n2;i++){
		dp[0][i]=0;
	}
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if (s1[i-1]==s2[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	//for(int i=0;i<=n1;i++){
	//	for(int j=0;j<=n2;j++){
	//		cout<<dp[i][j]<<" ";
	//	}
	//	cout<<"\n";
	//}
	string s="";
	int i=n1,j=n2;
	while (dp[i][j]){
		if(dp[i][j]==dp[i][j-1]){
			j-=1;
		}
		else if(dp[i][j]==dp[i-1][j]){
			i-=1;
		}
		else{
			s=s1[i-1]+s;
			i-=1;
			j-=1;
		}
	}
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 38760
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; ll W; cin >> N >> W; ll w[N], v[N], z[N];
  rep(i, N){
    cin >> w[i] >> v[i];
    z[i]=w[i]- w[0];
  }
  ll dp[110][110][310] = {}; 
  rep(i, N){
    rep(j, N){
      rep(k, 301){
        if(k>=z[j]) dp[i+1][j+1][k] = max(dp[i][j][k-z[j]]+v[j], dp[i+1][j][k]);
        else dp[i+1][j+1][k] = dp[i+1][j][k];
      }
    }
  }
  ll ans = 0;
  rep(i, N+1){
    rep(j, N){
      if(W-i*w[0]>=0) ans = max(ans, dp[i][N][min(W-i*w[0], (ll)300)]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 29568
//By Don4ick
#include <bits/stdc++.h>

const int N = (int)1005;

using namespace std;

bool win[N][N];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	long long x, y;
	cin >> x >> y;
	if (abs(x - y) > 1ll)
		cout << "Alice" << endl;
	else
		cout << "Brown" << endl; 
	return 0;
}




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

namespace Buttons
{ 
    class Program
    {
        static void Main(string[] args)
        {
            int button1 = 0;
            int button2 = 0;
            string temp = Console.ReadLine();
            string[] inp = temp.Split(' ');
            button1 = Convert.ToInt16(inp[0]);
            button2 = Convert.ToInt16(inp[1]);
            if (button1 > button2)
            {
                Console.WriteLine(2 * button1 - 1);
            }
            if (button1 == button2)
            {
                Console.WriteLine(2*button1);
            }
            if (button1 < button2)
            {
                Console.WriteLine(2 * button2 - 1);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int a[1003];
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 2 * n; ++ i)
        cin >> a[i];
    sort(a + 1, a + 1 + 2 * n);
    int ans = 0;
    for (int i = 1; i <= 2 * n; i += 2)
        ans += min(a[i], a[i + 1]);
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
      a
    } else {
      gcd(b, a % b)
    }
  }
  

fn main() {
    let k: u64 = input();
    let mut sum = 0;
    for a in 0..k {
        for b in 0..k {
            for c in 0..k {
                sum += gcd(gcd(a+1, b+1), c+1);
            }
        }
    }
    println!("{}", sum);
}


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

int main()
{
    int N, L;
    cin >> N >> L;

    vector<string> vec(N);

    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    for (int i = 0; i < N; i++)
    {
        cout << vec.at(i);
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string N;
    cin >> N;
    if(N[0] == N[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    int A; cin >> A;
    int B; cin >> B;
    int C; cin >> C;
    int X; cin >> X;
    int Y; cin >> Y;

    int min_price = 1 << 30;
    rrep(i, 0, max(X, Y)) {
        int price = 2 * C * i + max(0, A * (X - i)) + max(0, B * (Y - i));
        min_price = min(min_price, price);
    }

    cout << min_price << endl;
    return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
y = y // 1000

for a in range(n+1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 0 <= b and 0 <= c and a * 10 + b * 5 + c == y:
        print(a,b,c)
        exit(0)
else:
    print(-1,-1,-1)

Measured memory_bytes: 9192