akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  
  // string s;
  // s = "1111111111111111111111111111111111111111";
  // cout << log2(1000000000000) << endl;
  // cout << s.size() << endl;

  int h,n;
  cin >> h >> n;
  int dp[h+2];
  
  set<pair<int,int>> s;

  for(int i = 0;i<n;i++){
    int x,y;
    cin >> x >> y;
    s.insert({x,y});
  }

  for(int i = 0;i<=h;i++){
    dp[i] = 1e16;
  }
  dp[h] = 0;

  for(int i = h;i>=0;i--){
    for(auto j:s){
      int x = max(i - j.first, 0LL);

      dp[x] = min(dp[x], dp[i] + j.second);
    }
  }

  cout << dp[0] << endl;
  return 0;
}
    
  


Measured memory_bytes: 384
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ld  double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);


int main() {
    HabdModeActive
    int n, e;
    cin >> n >> e;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    ll mx = 0;
    for (int i = 0; i <= e; i++) {
        ll num = e - i;
        for (int j = 0; j <= num && j <= n; j++) {
            ll f = num - j;
            priority_queue<ll> q;
            ll sum = 0;
            for (int k = n - 1; k >= 0 && k >= j && f > 0; k--, f--) {
                sum += arr[k];
                q.push(-arr[k]);
            }
            for (int k = 0; k < j && k < n; k++) {
                sum += arr[k];
                q.push(-arr[k]);
            }
            ll v = i;
            while (v--) {
                if (q.size() > 0 && q.top() > 0) {
                    sum += q.top();
                    q.pop();
                } else {
                    break;
                }
            }
            mx = max(sum, mx);
        }
    }
    cout<<mx<<endl;

    return 0;
}
/*
 * int n, e;
    cin >> n >> e;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    ll mx = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j >= 0; j--) {
            for (int k = n - 1; k > i; k--) {
                for (int r = k; k < n; k++) {
                    priority_queue<ll> q;
                    ll sum = 0;
                    ll op = e;
                    for (int g = 0; g <= i && op > 0; g++, op--)
                        sum += arr[g], q.push(-arr[g]);
                    for (int g = 0; g <= j && op > 0; g++, op--) {
                        if (q.top() < 0) {
                            e--;
                            sum += q.top();
                            q.pop();
                        }
                    }

                    for (int g = n - 1; g >= k && op > 0; g--, op--)
                        sum += arr[g], q.push(-arr[g]);
                    for (int g = n-1; g >= r && op > 0; g--, op--) {
                        if (q.top() < 0) {
                            e--;
                            sum += q.top();
                            q.pop();
                        }
                    }
                    mx = max(sum, mx);
                }
            }
        }
    }
 */

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

int main() {
    //
    long long num;
    long long cnt = 0;
    long long Max1 = 0;
    long long Max2 = 0;

    cin >> num;

    vector<long long> vec(num);

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

    sort(vec.begin(), vec.end(), greater<int>());

    int index = 0;
    bool chk = false;
    for (int i = 0; i < num-1; i++) {
        if (chk == false) {
            chk = true;
            cnt += vec.at(index);
            index++;
        }else{
            chk = false;
            cnt += vec.at(index);
        }
    }
    /*
        for (int i = 1; i < num; i++) {
            if (Max1 == 0 && Max2 == 0) {
                Max1 = vec.at(i);
                cnt += vec.at(i - 1);
                continue;
            } else if (Max2 == 0) {
                cnt += vec.at(i - 1);
                Max2 = vec.at(i);
                continue;
            } else {
                if (Max1 <= Max2) {
                    cnt += Max2;
                    Max2 = vec.at(i);
                }else{
                    cnt += Max1;
                    Max1 = vec.at(i);
                }
            }
        }
        */

    cout << cnt;
    //
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define REP(i, n) for (int i{ 0 }; i < n; ++i)
#define REP2(i, s, n) for (int i{ s }; i < n; ++i)
#define DREP(i, n) for (int i{ n - 1 }; i <= 0; --i)
#define repa(arr) for (auto& e : arr)
#define DEB(x) (std::cerr << __LINE__ << ": x = " << x << std::endl)
#define DEBa(x) repa(x) DEB(e)

using namespace std;

int main() {
    string S;
    cin >> S;
    cout << S;
    if ( S[S.size() - 1] == 's')
        cout << "es" << endl;
    else
        cout << 's' << endl;

}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

    intmax_t N;
    cin >> N;

    intmax_t minv = LLONG_MAX;
    for (intmax_t i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            intmax_t tmp = N / i;
            minv = min(minv, (i - 1) + (tmp - 1));
        }
    }

    cout << minv << "\n";

    return 0;
}


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

int x;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> x;
    cout << 1 -x  << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,k,m,num,count,len;
	char words[201],stack[201];
	while(1)
	{
		scanf("%s",words);
		if(!strcmp(words,"-")){break;}
		i=0;
		while(1)
		{		
			if(words[i]=='\0'){break;}
			i++;
		}
		scanf("%d",&m);
		count=0;
		for(j=0;j<m;j++)
		{
			scanf("%d",&num);
			count+=num;
		}
		for(j=0;j<201;j++){stack[j]='\0';}
		len=(count%i)*sizeof(char);
		strcpy(stack,words+len);
		for(j=0;j<len;j++){stack[j+i-len]=words[j];}
		printf("%s\n",stack);
	}


	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	vector<int> a(n);
	deque<ll> q;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i % 2 == 0) {
			q.push_back(a[i]);
		}
		else {
			q.push_front(a[i]);
		}
	}
	if (n % 2 == 0) for (int i = 0; i < n; i++) {
		cout << q[i];
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
	else for (int i = n - 1; i >= 0; i--) {
		cout << q[i] << endl;
		if (i < n - 1) cout << " ";
		else cout << endl;
	}
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    bool answer=false;

    for (int i=0;i<n;i++) {
        char s;
        cin>>s;
        if(s=='Y'){
            cout<<"Four"<<endl;
            answer=true;
            break;
        }
    }
    if(answer==false){
        cout<<"Three"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
int selectionSort(int A[],int N);
int main()
{
    int A[MAX],N;
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    selectionSort(A,N);
    return 0;
}




int selectionSort(int A[], int N){
    int count = 0;
    for(int i=0; i<=N-1; i++){
        
         int minj = i;
         
         for(int j=i; j<=N-1; j++){
             
            if(A[j] < A[minj]) minj =j;
         }
         if(A[i]!=A[minj]) count++;
             
            int v;
            v = A[i];
            A[i] = A[minj];
            A[minj] = v;

         
         
    }
    for(int i=0; i<N; i++){
        if(i>0) cout<<" ";
        cout<<A[i];
    }
    cout<<"\n";
    cout << count<< endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int  main(){
    int n;
    map<string,int> m;
    string x;
    cin>> n;
    for(int i =0; i<n; i++){
        cin>>x;
        m[x]++;
    }
    cout<<"AC x "<<m["AC"]<<"\nWA x "<<m["WA"]<<"\nTLE x "<<m["TLE"]<<"\nRE x "<<m["RE"];
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  /*
  test();
  return 0;
  */

  long K, a, b;
  cin >> K;
  long n = K / 50;
  long r = K % 50;
  long base = 50 + n - 1;

  // cout << base << " " << n << " " << r << endl;
  vector<long> sequence;
  sequence.reserve(50);
  for (int i = 0; i < 50; ++i) {
    if (r > 0) {
      sequence.push_back(i < (50 - r) ? (base - r) : (base + 1));
    } else {
      sequence.push_back(base);
    }
  }
  cout << sequence.size() << endl;
  bool first = true;
  for (auto n: sequence) {
    if (first) {
      first = false;
    } else {
      cout << " ";
    }
    cout << n;
  }
  cout << endl;

  // long k = trace(sequence);
  // if (k != K) cout << "WA: " << K << " vs. " << k << endl;
  return 0;
}

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

long long a, b, c;

int main()
{
	cin>>a>>b>>c;
	long long x = c-a-b;
	if(x<=0) cout<<"No"<<endl;
	else if(4*a*b<x*x) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

#define MAX 100001
#define MOD 1000000007

typedef struct list
{
  int node;
  struct list *next;
} list;

list *graph[MAX];             // 木のグラフ
int painted[MAX] = {0};       // 頂点が塗られていれば1,塗られてなければ0
int colors;										// 色の数

void AddEdge(int node1, int node2)
{
  list *new1 = (list *)malloc(sizeof(list *));
  list *new2 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new2->node = node1;
  new1->next = graph[node1];
  new2->next = graph[node2];
  graph[node1] = new1;
  graph[node2] = new2;
}


long long int Dfs(int node, int parent)
{
	painted[node] = 1;
	int n = colors - 1 - painted[parent];
	list *child = graph[node];

	int num = 0;
	long long int ans = 1;
	while (child != NULL)
	{
		if (child->node != parent) {
			ans = (ans * (n - num++)) % MOD;
			ans = (ans * Dfs(child->node, node)) % MOD;
		}
		child = child->next;
	}
	return ans;
}


int main(void)
{
  int n, a, b;
  scanf("%d %d", &n, &colors);

  int ni;
  for (ni = 0; ni <= n; ni++)
    graph[ni] = NULL;
  for (ni = 1; ni < n; ni++)
  {
    scanf("%d %d", &a, &b);
    AddEdge(a, b);
  }
	AddEdge(0, 1);

	long long int ans;
	ans = (colors * Dfs(1, 0)) % MOD;
	printf("%lld\n", ans);
  return 0;
}


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

uint32_t fib(uint32_t n, std::vector<uint32_t>& result) {
  if (n == 0 || n == 1) return 1;
  if (result[n - 1] != 0) return result[n - 1];
  result[n - 1] = fib(n - 1, result) + fib(n - 2, result);
  return result[n - 1];
}

int main() {
  uint32_t n = 0;
  std::cin >> n;

  std::vector<uint32_t> result(n, 0);
  std::cout << fib(n, result) << std::endl;
  return 0;
}


Measured memory_bytes: 3100
//Counter-Clockwise
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    return s.p1 + (base * (dot(base, p - s.p1) / base.norm()));
}

Point reflect(Segment s, Point p) {
    return p + (project(s, p) - p) * 2;
}

enum {
    COUNTER_CLOCKWISE = 1,
    CLOCKWISE = -1,
    ONLINE_BACK = 2,
    ONLINE_FRONT = -2,
    ON_SEGMENT = 0
};

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > ESP) return COUNTER_CLOCKWISE;
    else if (cross(a, b) < -ESP) return CLOCKWISE;
    else if (dot(a, b) < -ESP) return ONLINE_BACK;
    else if (a.norm() < b.norm()) return ONLINE_FRONT;
    else return ON_SEGMENT;
}

bool intersect(Point p0, Point p1, Point p2, Point p3) {
    return (ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 && ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0);
}

bool intersect(Segment s1, Segment s2) {
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

Point getCrossPoint(Segment s1, Segment s2) {
    Vector base = s1.p2 - s1.p1;
    double d1 = fabs(cross(base, s2.p1 - s1.p1)) / base.abs();
    double d2 = fabs(cross(base, s2.p2 - s1.p1)) / base.abs();
    return s2.p1 + (s2.p2 - s2.p1) * (d1 / (d1 + d2));
}

int main() {
    int q;
    double x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Segment s1 = Segment(Point(x0, y0), Point(x1, y1));
        Segment s2 = Segment(Point(x2, y2), Point(x3, y3));
        Point x = getCrossPoint(s1, s2);
        cout << setprecision(15) << x.x << " " << x.y << endl;
    }
}


Measured memory_bytes: 3288
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>
 
using namespace std;


int main(){
    int K;
    cin >> K;
    if(K % 2 == 0 or K % 5 == 0){
        cout << -1;
        return 0;;
    }
    int current = 7;
    int counter = 1;
    while(current % K != 0){
        current = (current * 10 + 7) % K;
        counter++;
    }
    cout << counter;
}


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


int main(){
   int N;
   std::cin >> N;
   int A[N];
   int max = 0;
   int submax = 0;
   int index = -1;
   for(int i=0; i<N; ++i){
      std::cin >> A[i];
      if(max<A[i]){
	 submax = max;
	 max = A[i];
	 index = i;
      }else if(submax<A[i]){
	 submax = A[i];
      }
   }
   for(int i=0; i<N; ++i){
      if(i==index) std::cout << submax << std::endl;
      else std::cout << max << std::endl;
   }
   return 0;
}


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

using T = long double;
const T INF = 1e10;
const T EPS = 1e-10;
const T PI = acos(-1.0);
T torad(int deg) {return (T)(deg) * PI / 180;}
T todeg(T ang) {return ang * 180 / PI;}
template <typename T> inline bool eq(T p, T q) { return abs(p - q) < EPS; }
inline int sgn(T x) { return (EPS < x) - (x < -EPS); }

/* Point */
using Point = complex<T>;
#define x real()
#define y imag()
inline T dot(Point v, Point w) { return (conj(v) * w).x; }
inline T cross(Point v, Point w) { return (conj(v) * w).y; }
inline T orient(Point a, Point b, Point c) { return cross(b - a, c - a); }
inline Point unit(Point v) { return v / abs(v); }
inline Point rot(Point p, T a) { return p * polar(T(1), a); }
inline Point rot90(Point p) { return {-p.y, p.x}; }
bool cmpX(const Point& a, const Point& b) { return a.x != b.x ? a.x < b.x : a.y < b.y; }
bool cmpY(const Point& a, const Point& b) { return a.y != b.y ? a.y < b.y : a.x < b.x; }
namespace std {
    istream& operator>>(istream &is, Point &p) { T xx, yy; is >> xx >> yy; p = Point(xx, yy); return is; }
    bool operator < (const Point &a, const Point &b) { return cmpX(a, b); }
}

/* Line */
struct Line : array<Point, 2> {
    Point v; T c;
    Line() = default;
    explicit Line(Point a, Point b) : array<Point, 2>({a, b}), v(b - a), c(cross(v, a)) {}
    T side(Point p) { return cross(v, p) - c; }
    Point proj(Point p) { return p - rot90(v) * side(p) / norm(v); }
    Point refl(Point p) { return p - rot90(v) * T(2) * side(p) / norm(v); }
    bool onLine(Point p) { return abs(side(p)) < EPS; }
    bool onSegment(Point p) { return onLine(p) && dot(this->operator[](0) - p, this->operator[](1) - p) <= EPS; }
    friend istream& operator>>(istream &is, Line &l) { Point p, q; is >> p >> q; l = Line(p, q); return is; }
    friend ostream& operator<<(ostream &os, const Line &l) { return os << '{' << l[0] << ", " << l[1] << '}'; }
};

/* Circle */
struct Circle : Point {
    T r;
    Circle() = default;
    Circle(Point p, T r) : Point(p), r(r) {}
    friend istream& operator>>(istream &is, Circle& c) { Point p; T r; is >> p >> r; c = Circle(p, r); return is; }
    friend ostream& operator<<(ostream &os, const Circle &c) { return os << '(' << c.x << ", " << c.y << ", " << c.r << ')'; }
};

bool is_convex(vector<Point> &ps) {
    bool pos = false, neg = false;
    for (int i = 0, n = ps.size(); i < n; ++i) {
        int o = orient(ps[i], ps[(i + 1) % n], ps[(i + 2) % n]);
        if (o > 0) pos = true;
        if (o < 0) neg = true;
    }
    return !(pos && neg);
}

int main() {
    string s;
    while (getline(cin, s)) {
        s = "," + s;
        stringstream ss(s);
        vector<Point> ps(4);
        for (int i = 0; i < 4; ++i) {
            char c;
            T xx, yy;
            ss >> c >> xx >> c >> yy;
            ps[i] = Point(xx, yy);
        }
        cout << (is_convex(ps) ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int n,k,i,sum = 0;
	cin >> n >> k;
	int l[n];
	for(i = 0; i < n; i++)
		cin >> l[i];

	sort(l,l+n,greater<int>() );

	for(i = 0; i < k; i++)
		sum += l[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] ar)
	{
		Scanner sc = new Scanner(System.in);

		sc.next();
		int n = 0;
		int max = 0;
		String s = sc.next();

		for (int i = 0; i < s.length(); ++i)
		{
			if ('I' ==  s.charAt(i))
			{
				++n;

				max = Math.max(max, n);
			}
			else
			{
				--n;
			}
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 23892
//
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<ll> ax(X);
    vector<ll> by(Y);
    vector<ll> cz(Z);
    for(auto&& a:ax){ cin>>a; }
    for(auto&& b:by){ cin>>b; }
    for(auto&& c:cz){ cin>>c; }
    //半分列挙
    vector<ll> abw(X*Y);
    REP(x,X){
        REP(y,Y){
            abw.at(y*X+x) = ax.at(x) + by.at(y);
        }
    }
    sort(abw.begin(),abw.end(),greater<ll>());
    sort(cz.begin(),cz.end(),greater<ll>());

    vector<ll> tt;
    tt.reserve(K*K);
    REP(i,min<ll>(K,abw.size())){
        REP(j,min<ll>(K,cz.size())){
            tt.emplace_back(abw.at(i)+cz.at(j));
        }
    }

    sort(tt.begin(),tt.end(),greater<ll>());
    REP(i,K){
        cout<<tt.at(i)<<endl;
    }
    return 0;
}

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

int main() {
  string s;
  int c=0, ans=0;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    for(int j = i; j < s.size(); j++) {
      if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') c++;
      else break;
    }
    if(c > ans) ans = c;
    c=0;
  }
  cout << ans;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        k: usize,
    }

    println!("{}", (max(max(a,b),c) as i64) * (2_i64.pow(k as u32)-1) + ((a+b+c) as i64));

}


Measured memory_bytes: 2164
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include <algorithm>
#include <utility>

using namespace std;
int main(){
    long H, W, N;
    cin >> H;
 	cin >> W;
    cin >> N;
  
  	if (N == 0){
      long sumZero = (H-2) * (W-2);
      cout << sumZero << endl;
      for (int i = 1; i < 10; i++){
        cout << 0 << endl;
      }
      
      return 0;
    }
    int a[N] = {};
    int b[N] = {};
    map<pair<int, int>, long> countSum;
  
    for (int i = 0; i < N; i++){
      cin >> a[i];
      cin >> b[i];
    }
  
  	for (int i = 0; i < N; i++){
      int startX = max(a[i]-2, 1);
      int startY = max(b[i]-2, 1);
      int endX = a[i];
      int endY = b[i];
      for(int x = startX; x <= endX; x++){
        for(int y = startY; y <= endY; y++){
          if (x <= H-2 && y <= W-2){
            pair<int, int> p(x, y);
            auto itr = countSum.find(p);        
            if( itr != countSum.end() ) {
                countSum[p]++;
            } 
            else {
                countSum[p] = 1;
            }
          }
        }
      }
    }
    
  	long sum[10] = {};
  	for(auto itr = countSum.begin(); itr != countSum.end(); itr++) {
       sum[itr->second]++;
    }
  	
  	sum[0] = (H-2) * (W-2);
    for (int i = 1; i < 10; i++){
      sum[0] -= sum[i];
    }
  
  	for(int i= 0; i < 10; i++){
    	cout << sum[i] << endl;
    }
}


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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;
const long long   INF = 1e9;

int n;
vector <int> primes;

bool isPrime(int num){
	if(num == 1)return false;
	for(int i=2; i*i <= n ;i++){
		if(num%i == 0)return false;
	}
	return true;
}

void genPrime(){
     
     for(int i=2;i<=1000;i++){
            if(isPrime(i))primes.pb(i) ;
     }
}    
 

void solve(){
    cin >> n;
    int freq[1001];
    memset(freq,0,sizeof(freq));
    for(int i = 2;i <= n;i++){
	    int j = 0;
            int num = i;
	    while(j < primes.size()){
		     int cnt = 0;
                     while(num%primes[j] == 0){
			     num/=primes[j];
			     cnt++;
		     }
                     freq[primes[j]] += cnt;
		     j++;
	    }
	    if(num != 1)freq[i]++;
    }
    ll ans = 1;
    for(int i=2;i<=n;i++){
	    if(freq[i])ans = (ans*(freq[i] + 1))%mod;
    }
    cout<<ans<<"\n";
}


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


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	string a = "ABC";
	int ans = 0;
	FOR(i, 0, SZ(s) - 2) if (s.substr(i, 3) == a) ans++;
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
/*input
5
9 5 6 8 4
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 4;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int n, mm = 0, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a >= mm) {
      mm = a;
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
} 

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u)
    a--;
  else
    b--;
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<int>
#define rs resize
ll modexp(ll a,ll b){ ll res = 1;  while(b>0){  if(b&1)  res = (res*a)%mod;  a = (a*a)%mod;  b/=2;  }  return res; }
int main()
{
   std::ios::sync_with_stdio(false);
   ll a,b;
   char c;
   cin>>a>>c>>b;
   cout<<(c == '+' ? a + b : a - b);
   return 0;
}


Measured memory_bytes: 256
def solve():
    S = list(input())
    i = 0
    ans = [0] * len(S)

    r_cnt = 0
    while i < len(S) - 1:
        l_cnt = 0
        r_cnt += 1
        if S[i] + S[i+1] == "RL" or i == len(S) -1:
            ans[i] += r_cnt // 2
            ans[i+1] += r_cnt // 2
            if r_cnt % 2 != 0:
                ans[i] += 1
                
            r_cnt = 0
            j = i+1
            while j != len(S) and S[j] == "L":
                l_cnt += 1
                j += 1
            else:
                ans[i] += l_cnt // 2
                ans[i+1] += l_cnt // 2
                if l_cnt % 2 != 0:
                    ans[i+1] += 1
            i = j-1
        i += 1
    
    print(*ans)

if __name__ == '__main__':
    solve()

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> a, r, memo;
  Solver(LL n) : n(n), a(n), r(n, -1), memo(200001, -1){};

  void solve() {
    bool ok = false;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      a[i]--;
      if (a[i] == 0) ok = true;
    }
    if (!ok) {
      cout << -1 << endl;
      return;
    }
    DBG(a)
    for (int i = n - 1; i >= 0; --i) {
      memo[a[i]] = i;
      if (memo[a[i] + 1] >= 0) {
        r[i] = memo[a[i] + 1];
      }
    }
    DBG(r)
    int p = 0;
    while (a[p] != 0) p++;
    int len = 0;
    DBG(p)
    while (p >= 0) {
      p = r[p];
      len++;
    }
    cout << n - len << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 2560
function main(input) {
  let s = input.trim();
  let table = {};
  for (let i = "a".charCodeAt(0); i <= "z".charCodeAt(0); i++) {
    let c = String.fromCharCode(i);
    table[c] = 0;
  }
  for (let i = 0; i < s.length; i++) {
    let c = s[i].toLowerCase();
    if (c in table) {
      table[c] += 1;
    } else {
      table[c] = 1;
    }
  }
  for (let i = "a".charCodeAt(0); i <= "z".charCodeAt(0); i++) {
    let c = String.fromCharCode(i);
    console.log(c + " : " + String(table[c]));
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int gcd(int a, int b)
{
    int a2 = (a>=b)? a:b;
    int b2 = (a<b)? a:b;
    int r = a2 % b2;
    if(r == 0)
        return b2;
    else
        return gcd(b2,r);
}

int main(void){
    // Your code here!
    int N;
    long sum = 0;
    
    scanf("%d",&N);
    //printf("%d\n", gcd(200, 45));
    
    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            for(int k = 1; k <= N; k++)
            {
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    
    printf("%ld\n",sum);
}


Measured memory_bytes: 3824
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<iomanip>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0.0;
    int t = 0;
    for(int i = n; i >= 1; i--){
        while(i * (1 << t) < k){t++;}
        ans += 1.0 / n / (1 << t);
    }
    cout << setprecision(13) << ans << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    sum ^= a.at(i);
  }
  
  for(int i = 0; i < n; i++){
    int now = sum ^ a.at(i);
    cout << now << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4044
import fractions
from functools import reduce


def main():

    N = int(input())
    A = [int(a) for a in input().split()]

    gcds_r = [1] * N
    gcds_r[0] = A[0]
    for n in range(1, N):
        gcds_r[n] = fractions.gcd(gcds_r[n-1], A[n])

    gcds_l = [1] * N
    gcds_l[-1] = A[-1]
    for n in range(N-1)[::-1]:
        gcds_l[n] = fractions.gcd(gcds_l[n+1], A[n])

    max_gcd = 1
    for n in range(1, N-1):
        max_gcd = max(max_gcd, fractions.gcd(gcds_r[n-1], gcds_l[n+1]))

    max_gcd = max(max_gcd, gcds_l[1], gcds_r[N-2])

    print(max_gcd)  


main()


Measured memory_bytes: 16160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  long long X,Y;
  cin >> X >> Y;
  long long p = X;
  long long count = 0;
  while(p <= Y){
    count++;
    p = p*2;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}


void run(){
  int n,m,q;
  cin>>n>>m>>q;
  vi l(m),r(m);
  rep(i,m){
    cin>>l[i]>>r[i];
  }
  vvi a(n+1,vi(n+1));
  rep(i,m){
    a[l[i]][r[i]]++;
  }
  rep(i,n+1){
    rep(j,n){
      a[i][j+1]+=a[i][j];
    }
  }
  while(q--){
    int x,y;
    cin>>x>>y;
    int ans=0;
    REP(i,x,y){
      ans+=a[i][y]-a[i][x-1];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int main()
{
    int n,i;
    cin>>n;
    int arr[n+2];
    for(i=1;i<=n;i++) cin>>arr[i];

    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);

    for(i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
// エラストテネスの篩
const int NMAX = 1e+5+1;
int prime[NMAX];
void Sieve(){
  rep(i,NMAX) prime[i] = true;
  prime[0] = prime[1] = false;
  for(int i=2;i<NMAX;++i){
    if(prime[i]){
      int j = i*2;
      while(j<=NMAX){
	prime[j] = false;
	j += i;
      }
    }
  }
}
int main()
{
  int q;cin >> q;
  vector<int> l(q),r(q);
  rep(i,q) cin >> l[i] >> r[i];
  Sieve();
  vector<int> sum(1e+5+2);
  sum[0] = 0;
  rep(i,NMAX){
    if(i%2==1){
      if(prime[i]&&prime[(i+1)/2]){
	sum[i+1] = sum[i] + 1;
	continue;
      }
    }
    sum[i+1] = sum[i];
  }
  rep(i,q) cout << sum[r[i]+1]-sum[l[i]] << "\n";
  
  return 0;
}


Measured memory_bytes: 2176
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {
    
    int n;
    while(cin >> n, n) {
        map< int, vector< int > > sum;
        for(int i = 0; i < n; i++) {
            int m, a, b; cin >> m >> a >> b;
            sum[a].push_back(m);
            sum[b].push_back(-m);
        }
    
        int now = 0, broken = 0;
        foreach(sum, it) {
            for(int i = 0 ; i < it->sc.size(); i++) {
                now += it->sc[i];
            }
            if(now > 150) {
                broken = 1;
                break;
            }
        }
        if(broken) cout << "NG" << endl;
        else cout << "OK" << endl;
    }
}

Measured memory_bytes: 1228
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<ctime>
#include<map>
#include<cmath>
#include<deque>
#define M 310
//#define min(x , y) (x) < (y) ? (x) : (y)
//#define max(x , y) (x) > (y) ? (x) : (y)
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int a[M][M] , num[M] , ans = inf , n , m;
bool use[M];
int main(){
//	 	freopen("A.out" , "w" , stdout);
 //	freopen("c1.in" , "r" , stdin);
 	scanf("%d%d" , &n , &m);
 	for (int i = 1 ; i <= n ; ++i)
 		for (int j = 1 ; j <= m ; ++j)
 			scanf("%d" , a[i] + j);
 	for (int i = 1 ; i <= m ; ++i){
 		int peo = 0 , now = 0;
 		for (int j = 1 ; j <= n ; ++j){
 			int p = 0;
 			for (int k = 1 ; k <= m ; ++k){
 				if (!use[a[j][k]]){
 					p = a[j][k];
 					break;
 				}
 			}
 			++num[p];
 			if (num[p] > peo) peo = num[p] , now = p;
 		}
 		ans = min (ans , peo) , use[now] = 1;
 		memset(num , 0 , sizeof(num));
 	}
 	printf ("%d" , ans);
 	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin >> n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;++i)cin >>b[i];
  int sum = b[0];
  for(int i=0;i<n-2;++i){
    sum += min(b[i], b[i+1]);
  }
  sum += b[n-2];
  cout << sum << endl;
  return 0;
}

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

int main() {
  int N,A=0;
  cin >> N;
  vector<int>a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
   sort(a.begin(), a.end()); 
   reverse(a.begin(), a.end());
  for(int i=0; i<N; i++){
    if(i%2 == 0){
      A += a.at(i);
    }
    else{
      A -= a.at(i);
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 3632
#if 0
????????£?????????????´?1??????
pdf??????????????????????????????????????????????????§?????????????????????
???????????§??????????????§?????????????????°?????????????????£??¨????????§?????????
??¢?????\????????????????????????????????£??¨??????????????????
#endif

#include <iostream>
#include <queue>
using namespace std;
class pos
{
	public:
	int x;
	int y;
	pos(int,int);
};

pos::pos(int a,int b)
{
	x=a;y=b;
}

int main()
{
	int w,h;
	int g[21][21];
/*	for(int i=0;i<21;i++)
		for(int j=0;j<21;j++)
			g[i][j]=-1;
*/	while(1)
	{
		cin>>w>>h;
		if(w==0&&h==0) break;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				g[i][j]=-1;
		int psx,psy;
		bool visited[21][21];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
			{
				char s;
				cin>>s;
				switch(s)
				{
					case '.':
						g[i][j]=0;break;
					case '#':
						g[i][j]=1;break;
					case '@':
						g[i][j]=2;psx=i;psy=j;break;
				}
				visited[i][j]=false;
			}

/*		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
				cout<<g[i][j];
			cout<<endl;
		}
*/
		int num=0;
		queue<pos> Q;
		Q.push(pos(psx,psy));
		num++;
		visited[psx][psy]=true;
		while(!Q.empty())
		{
			pos now=Q.front();
			Q.pop();
	
			for(int i=-1;i<=1;i+=2)
			{
				int newx=now.x+i;
				int newy=now.y;
				if(newx>=0&&newx<h&&newy>=0&&newy<w&&g[newx][newy]==0&&visited[newx][newy]==false)
				{
					Q.push(pos(newx,newy));		
					num++;
					visited[newx][newy]=true;
				}
			}
			for(int i=-1;i<=1;i+=2)
			{                
				int newx=now.x;
				int newy=now.y+i;
				if(newx>=0&&newx<h&&newy>=0&&newy<w&&g[newx][newy]==0&&visited[newx][newy]==false)
				{
					Q.push(pos(newx,newy));
					num++;
					visited[newx][newy]=true;
				}
			}

		}
		cout<<num<<endl;
								


	}
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		char stamps[] = new char[n];
		sc.close();
		stamps = str.toCharArray();
		int count = 0;
		int point = 1;
		while (point < n) {
			if (stamps[point] != stamps[point - 1]) {
				count++;
				point += 2;
			} else {
				point++;
			}
			if (point > n) {
				break;
			}

		}
		System.out.println(count);
	}
}



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

int main() {
  int n;
  cin >> n;
  vector<int> A(n), B(n);
  rep(i, n) {
    cin >> A[i];
    B[i] = A[i];
  }

  sort(B.begin(), B.end());
  int R = B[n/2 - 1];
  int L = B[n/2];
  rep(i, n) {
    if (A[i] <= R) cout << L << endl;
    else cout << R << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 10002
struct edge {
  int s,t,w;
};
int p[MAX];
int root(int x){
    if(p[x]==x)return x;
    return p[x] = root(p[x]);
}

priority_queue <edge, vector<edge>,greater<edge> > que;
bool operator > (const edge a,const edge b){return a.w>b.w;};

int main(){
  int v,e,s,t,w,rs,rt,res=0;
  edge tmp;
  cin>>v>>e;
  for(int i=1;i<v+1;i++)p[i]=i;
  for (int i=0;i<e;i++){
    cin>>tmp.s>>tmp.t>>tmp.w;
    que.push(tmp);
  }
  while(!que.empty()){
    s = que.top().s;
    t = que.top().t;
    w = que.top().w;
    que.pop();
    rs=root(s);
    rt=root(t);
    if(rs==rt)continue;
    p[rs] = rt;
    res += w;
  }
  cout<<res<<endl;
  return 0;
}


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

int main(){
	char X[110];
	int n;
	scanf("%d",&n);
	scanf("%s",X);
	int num=strlen(X);
	if(num<=n){
		printf("%s",X);
		return 0;
	}
	else{
		for(int i=0;i<n;++i){
			printf("%c",X[i]);
		}
		printf("...");
	}
}

Measured memory_bytes: 3728
def calc(a)
  stack = []
  symbol = '+-*/'
  a.each do |e|
    if symbol.include?(e)
      a, b = stack.pop(2)
      aque =
      case e
      when '+' then a + b
      when '-' then a - b
      when '*' then a * b
      when '/' then a / b
      end
      stack << aque
    else
      stack << e.to_i
    end
  end
  stack[0]
end

p calc(gets.split)

Measured memory_bytes: 8604
n = int(input())

a = n % 10
b = ((n-a) //10) % 10
c = (n-b-a) //100

d = 0
e = 0
f = 0

if a == 1:
  d = 9
else:
  d=1
if b == 1:
  e = 9
else:
  e=1
if c == 1:
  f = 9
else:
  f=1
  
print(d + e*10 + f*100)

Measured memory_bytes: 40024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

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

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N, D, len, x, y, cnt = 0;
    cin >> N >> D;
    D = D * D;
    REP(i, N){
        cin >> x >> y;
        len = x * x + y * y;
        if(len <= D) cnt ++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL n;
  cin >> n;
  LL x;
  cin >> x;
  vector<LL> d(n+1),p(n+1);
  d[0]=p[0]=1;
  for(int i=0;i<n;i++) d[i+1]=2*d[i]+3;
  for(int i=0;i<n;i++) p[i+1]=2*p[i]+1;
  LL ans=0;
  LL now=n;
  while(x>0){
    if(now==0&&x==1){
      ans++;
      break;
    }
    if(x<=1){
      break;
    }else if(x<=d[now-1]+1){
      x-=1;
      now--;
    }else if(x<=d[now-1]+2){
      ans+=p[now-1]+1;
      break;
    }else if(x<=2*d[now-1]+2){
      x-=d[now-1]+2;
      ans+=p[now-1]+1;
      now--;
    }else{
      ans+=p[now];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  map<int, int> mp;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    int v1 = i - x;
    int v2 = i + x;
    ans += mp[v1];
    mp[v2]++;
  }
  cout << ans << '\n';
  rtn 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;
    string s; cin >> s;

    for (int i = 0; i < n; ++i) {
        string s1;
        string s2;

        for (int k = 0; k <= i; ++k) {
            s1 += s[k];
        }

        for (int j = i+1; j < n; ++j) {
            s2 += s[j];
        }

        if (s1 == s2) {
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

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

    int *dp = new int[s.size()+1];
    int cnt = 0;
    int max = -1;

    for(int i = 0 ; i < s.size(); ++i ) {
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        } else {
            cnt = 0;
        }
        dp[i] = 0;
        if(max < cnt) {
            max = cnt;
        }
    }

    std::cout << max << std::endl;

    return 0;
}

Measured memory_bytes: 256
int main()
{
	int a,b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a>=b){
		d=b;
		b=a;
		a=d;
	}
	if(b>=c){
		d=c;
		c=b;
		b=d;
	}
	if(a>=b){
		d=b;
		b=a;
		a=d;
	}
	printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2104