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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int n;
    cin >> n;

    if (n==1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


Measured memory_bytes: 892
A, B, M = [int(n) for n in input().split()]
a  = [int(n) for n in input().split()]
b = [int(n) for n in input().split()]
ma = sorted(a)[0]
mb = sorted(b)[0]
ans = ma + mb
for m in range(M):
    x, y, c = [int(n) for n in input().split()]
    dv = a[x-1] + b[y-1] - c
    ans = min(ans , dv)
print(ans)
        

Measured memory_bytes: 18488
N = gets.strip.to_i
restaurants = []
nums = {}
N.times do |n|
  s, p = gets.strip.split(' ')
  id = s + (201 - p.to_i).to_s
  restaurants.push id
  nums[id] = n+1
end
restaurants.sort!
restaurants.each do |id|
  puts nums[id]
end


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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod1 998244353
#define mod2 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define FILL(name,val) memset(name , val , sizeof(name))
#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const ll inf = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;

int H , W;
string mat[2020];
int U[2020][2020] , D[2020][2020] , L[2020][2020] , R[2020][2020];

void solve(){
    cin >> H >> W;
    repo(i , 1 , H+1){
        cin >> mat[i];
        mat[i] = " " + mat[i];
    }
    int ans = 0 ;
    repo(i ,1 , H+1){
        repo(j , 1 , W+1){
            if(mat[i][j] == '.'){
                L[i][j] = L[i][j-1] + 1;
            }
            if(mat[i][W-j+1] == '.'){
                R[i][W-j+1] = R[i][W-j+2] + 1;
            }
        }
    }
    repo(i , 1 , W+1){
        repo(j , 1 , H+1){
            if(mat[j][i] == '.'){
                U[j][i] = U[j-1][i] + 1;
            }
            if(mat[H-j+1][i] == '.'){
                D[H-j+1][i] = D[H-j+2][i] + 1;
            }
        }
    }
    repo(i , 1, H+1){
        repo(j, 1 , W+1){
            if(mat[i][j] == '.'){
                ans = max(ans , 1 + U[i-1][j] + D[i+1][j] + R[i][j+1] + L[i][j-1]);
            }
        }
    }
    cout << ans << endl;
    return;
}



int main(){
    FIO;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 67840
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "algorithm"
#include "functional"
#include "set"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int Cal_Cost(vector<long long int>&place, vector<long long int>&cost,int node, bool in_right, bool out_right) {
	if (in_right&&out_right) {
		long long int box = cost[node];
		box -= place[node] * 2;
		if (box <= 0)return place[node] * 2;
		return place[node] * 2 + (box / (K * 2) + !!(box % (K * 2)))*K * 2;
	}
	if (!in_right && !out_right) {
		long long int box = cost[node];
		box -= (K - place[node]) * 2;
		if (box <= 0)return (K - place[node]) * 2;
		return (K - place[node]) * 2 + (box / (K * 2) + !!(box % (K * 2)))*K * 2;
	}
	long long int box = cost[node];
	box -= 2 * K;
	if (box <= 0)return K * 2;
	return K * 2 + (box / (K * 2) + !!(box % (K * 2)))*K * 2;
}

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

	cin >> N >> K;
	vector<long long int>place(N + 1);
	for (int i = 1; i <= N; i++)cin >> place[i];
	vector<long long int>cost(N + 1);
	for (int i = 1; i <= N; i++)cin >> cost[i];
	long long int ans = Cal_Cost(place, cost, N, false, false);
	ans += place[N] * 2;
	for (int i = 1; i < N; i++)ans += Cal_Cost(place, cost, i, true, false);
	vector<int>lft(N + 1);
	vector<int>rht(N + 1);
	int two = 0;
	int add_num = 0;
	int c = 0;
	for (int i = 1; i < N; i++) {
		if (Cal_Cost(place, cost, i, true, false) > Cal_Cost(place, cost, i, true, true))rht[i] = 1;
		if (Cal_Cost(place, cost, i, true, false) > Cal_Cost(place, cost, i, false, false))lft[i] = 1;
		if (rht[i] && !lft[i]) {
			c++;
		}
		if (!rht[i] && lft[i]) {
			if (c > 0) {
				c--;
				add_num++;
			}
			else {
				if (two > 0) {
					two--;
					c++;
				}
			}
		}
		if (rht[i] && lft[i]) {
			if (c > 0) {
				c--;
				two++;
				add_num++;
			}
			else {
				c++;
			}
		}
	}
	cout << ans - K * 2 * add_num << endl;
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
 
using namespace std;
 
int h,v,k;
int row[10],column[10];
char matrix[10][10];
 
int main(){
 
    cin>>h>>v>>k;
    for(int i=0;i<h;i++)
        cin >> matrix[i];
    int uk=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<v;j++){
            if(matrix[i][j]=='#'){
                row[i]++;
                column[j]++;
            }
        }
    }
    int rj=0;
    for(int row_mask=0;row_mask<(1<<h);row_mask++){
        for(int column_mask=0;column_mask<(1<<v);column_mask++){
            int zbr=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<v;j++){
                    if(matrix[i][j]=='#' && (row_mask&(1<<i))==0 && (column_mask&(1<<j))==0)
                        zbr++;
                }
            }
            if(zbr==k)
                rj++;
        }
    }
    cout <<rj<<endl;
 
}
 

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 110;

LL n;

int main()
{
	cin >> n;
	if (n & 1LL)
	{
		puts("0");
		return 0;
	}
	
	LL cnt2 = 0, cnt5 = 0;
	for (LL i = 2; i <= n; i *= 2LL) cnt2 += n / i;
	for (LL i = 5; i <= n; i *= 5LL) cnt5 += n / i / 2LL;
	
	cout << min(cnt2, cnt5) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;
using Graph = vector<vector<int> >;

Graph G;
vector<bool> seen;

int dfs(int v, int &res){
  seen[v] = true;
  bool end = true;
  rep(i, seen.size()) if(!seen[i]) end = false;

  if(end){
    ++res;
    seen[v] = false;
    return 0;
  }

  for(auto nv : G[v]){
    if(seen[nv]) continue;
    dfs(nv, res);
  }

  seen[v] = false;
}

int main(){
  int n, m; cin >> n >> m;
  G.assign(n, vector<int>());
  rep(i, m){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.assign(n, false);
  int res = 0;
  dfs(0, res);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
public class
Main
{
  public void
  run (
    final java.util.Scanner sc,
    final java.io.PrintStream out
    )
  {
    final java.util.List<Integer> u = new java.util.LinkedList<Integer> ( );
    final java.util.List<Pair> v = new java.util.LinkedList<Pair> ( );
    boolean[ ] b;
    int m, n;
    java.util.ListIterator<Integer> it;
    java.util.ListIterator<Pair> pt;
    int i;

    m = sc.nextInt ( );
    n = sc.nextInt ( );
    b = new boolean[ m + 1 ];
    for ( i = 1; i <= m; ++i )
      u.add ( i );
    for ( i = 0; i < n; ++i )
    {
      int x, y;

      y = sc.nextInt ( );
      x = sc.nextInt ( );
      v.add ( new Pair ( x, y ) );
    }

    while ( !u.isEmpty ( ) )
    {
      java.util.Arrays.fill ( b, true );

      for ( pt = v.listIterator ( ); pt.hasNext ( ); )
        b[ pt.next ( ).a ] = false;

      for ( it = u.listIterator ( ); it.hasNext ( ); )
      {
        final int e = it.next ( );

        if ( b[ e ] )
        {
          out.println ( e );
          it.remove ( );
        }
      }

      for ( pt = v.listIterator ( ); pt.hasNext ( ); )
      {
        final Pair e = pt.next ( );

        if ( b[ e.b ] )
          pt.remove ( );
      }
    }
  }

  public static void
  main (
    final String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ), System.out );
  }

  private class
  Pair
  {
    public int a;
    public int b;

    public
    Pair (
      int a,
      int b
      )
    {
      this.a = a;
      this.b = b;
    }
  }
}

Measured memory_bytes: 18780
n = gets.to_i
h = gets.split.map(&:to_i)

ans, tmp = [0, 0]
(1...n).each do |i|
  if h[i] > h[i - 1]
    ans = ans > tmp ? ans : tmp
    tmp = 0
  else
    tmp += 1
  end
end

puts ans > tmp ? ans : tmp

Measured memory_bytes: 8580
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <cmath>
#include <climits>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{
    ll n = av.size();
    vector<ll> p(n), av2(n), bv2(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](ll a, ll b) { return av[a] < av[b]; });
    for (ll i = 0; i < n; i++)
    {
        av2[i] = av[p[i]];
        bv2[i] = bv[p[i]];
    }
    av = av2;
    bv = bv2;
}

int main()
{
    ll N,M; cin >> N >> M;
    vector<ll> A(N), B(N);
    REP(i,N){
        cin >> A[i] >> B[i];

    }

    sort2vectors(A, B);
    ll ans=0;
    ll res=0;

    /*REP(i,N){
        cout << A[i] << " " << B[i] << endl;
    }*/

    //res 現状買った本数
    //M 現状残っている本数

    REP(i, N)
    {
        if(M<=0){
            break;
        }else if(B[i]>M){
            ans += A[i] * M;
            break;
        }else{
            res += B[i];
            ans += A[i] * B[i];
            M -= B[i];
        }
        //cout << "M= " << M << " res= " << res << " ans= " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4096
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int high = 0;
  int result = 0;
  F0R(i, N) {
    int h;
    cin >> h;
    if (h >= high) {
      high = h;
      result++;
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 3644
from fractions import gcd

A, B, C, D = map(int,input().split())

cd_lcm = C * D//gcd(C, D)

def cnt_mod0(st, ed, x):
    c = 0
    if st % x !=0: st = x * (st // x + 1)
    if st > ed:return 0
    c = (ed-st) // x + 1
    return c

cnt = B- A + 1 - (cnt_mod0(A, B, C) + cnt_mod0(A, B, D) - cnt_mod0(A, B, cd_lcm))
print(cnt)

Measured memory_bytes: 5048
#include <string.h>
#include <stdio.h>
#define swap(type, a, b) {type tmp = a; a = b; b = tmp;}
#define rep(i, n) for (i = 0; i < n; i++)
#define repi(k, o) for (k; k < o; k++)

int main(void) {
    char string[201] = {'\0'};
    int m, n, i, j, k, len;

    while (1) {
        scanf("%s", string);
        if (string[0] == 45) break;
        len = strlen(string);
        scanf("%d", &m);

        rep(i, m) {
            scanf("%d", &n);
            rep(j, n) {
                k = 1;
                repi(k, len) {
                    swap(char, string[k], string[k-1]);
                }
            }
        }
        printf("%s\n", string);
    }
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;
typedef long long ll;
double eps = 0.000000001;

struct st
{
	int p, q;
	double time;
};
struct compare
{
	bool operator()(st x, st y)
	{
		return x.time > y.time;
	}
};
double pow(double x)
{
	return x * x;
}
double D(double a, double b, double c)
{
	return b * b - 4 * a * c;
}
double minans(double a, double b, double c)
{
	if (abs(a) > eps)
		return -(b + sqrt(D(a, b, c))) / (2 * a);
	else
		return -c / b;
}
double maxans(double a, double b, double c)
{
	if (abs(a) > eps)
		return (-b + sqrt(D(a, b, c))) / (2 * a);
	else
		return -1;
}
int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)
			break;

		double p[3][200], v[3][200], r[200], vr[200];
		double ans[200];
		bool exist[200];
		priority_queue<st, vector<st>, compare> q;
		for (int i = 0; i < n; i++)
		{
			exist[i] = true;
			cin >> p[0][i] >> p[1][i] >> p[2][i] >> v[0][i] >> v[1][i] >> v[2][i] >> r[i] >> vr[i];
		}
		for (int i = 0; i < n; i++)
		{
			q.push({ i, i, r[i] / vr[i] });
			for (int j = i + 1; j < n; j++)
			{
				double a = -pow(vr[i] + vr[j]), b = (r[i] + r[j]) * (vr[i] + vr[j]), c = -pow(r[i] + r[j]);
				for (int k = 0; k < 3; k++)
				{
					a += pow(v[k][i] - v[k][j]);
					b += (p[k][i] - p[k][j]) * (v[k][i] - v[k][j]);
					c += pow(p[k][i] - p[k][j]);
				}
				b *= 2;
				if (D(a, b, c) > eps)
				{
					if (minans(a, b, c) > eps)
						q.push({ i, j, minans(a, b, c) });
					else if (maxans(a, b, c) > eps)
						q.push({ i, j, maxans(a, b, c) });
				}
			}
		}
		while (q.size())
		{
			st p = q.top();
			q.pop();
			if (exist[p.p] && exist[p.q])
			{
				exist[p.p] = false;
				exist[p.q] = false;
				ans[p.p] = p.time;
				ans[p.q] = p.time;
			}
		}
		for (int i = 0; i < n; i++)
		{
			printf("%.12f\n", ans[i]);
		}
	}

	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;

	if (a >= 13){
		cout << b << endl;
	}else if(a >= 6 && a <= 12){
		cout << b / 2 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
count_0 = 0
count_1 = 0

l = len(s)

# start with 0
for i in range(l):
    # print(" i : ", i)
    if i % 2 == 0:
        if s[i] == "1":
            count_0 += 1
    else:
        # print("odd")
        # print(s[i])
        if s[i] == "0":
            count_0 += 1
            # print(count_0)

# start with 1
for i in range(l):
    if i % 2 == 0:
        if s[i] == "0":
            count_1 += 1
    else:
        if s[i] == "1":
            count_1 += 1



# print(count_0)
# print(count_1)
print(min(count_0, count_1))



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int A;
  cin >> S;
  if(S == "SUN")A = 7;
  if(S == "SAT")A = 1;
  if(S == "MON")A = 6;
  if(S == "TUE")A = 5;
  if(S == "WED")A = 4;
  if(S == "THU")A = 3;
  if(S == "FRI")A = 2;
  
  cout << A << endl;
}


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

using namespace std;

int main() {
    int q;
    scanf("%d", &q);
    int l[q], r[q];
    for(int i = 0; i < q; i++) {
        scanf("%d %d", l + i, r + i);
    }

    bitset<100000> is_prime;
    is_prime.set();
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 0; i < 100000; i++) {
        if(!is_prime[i]) continue;
        for(int j = i*2; j < 100000; j += i) {
            is_prime[j] = false;
        }
    }

    int sum[100000];
    sum[0] = 0;
    // 2K-1
    for(int i = 1; (2*i - 1) <= 100000; i++) {
        int val = 2*i - 1;
        if(is_prime[val] && is_prime[(val+1)/2]) sum[i] = sum[i-1]+1;
        else sum[i] = sum[i-1];
    }

    for(int i = 0; i < q; i++) {
        int left = (l[i] + 1) / 2;
        int right = (r[i] + 1) / 2;
        printf("%d\n", sum[right] - sum[left-1]);
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  if(N%K==0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 


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

int main() {
  int x; cin>>x;
  do {
    if (prime(x)) {
      cout << x << endl;
      return 0;
    }
  } while (x++);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  
  int match[10] = {10000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  string number[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
  vector<string> dp(n+100, "+");
  dp[0] = "";

  for (int i = 0; i < n; i++) {
    for (auto itr : a) {
      if (dp[i] == "+") continue;
      int num = match[itr];
      string temp = dp[i] + number[itr];
      if (dp[i + num] == "") dp[i + num] = temp;
      else if (dp[i + num].size() < temp.size()) {
        dp[i + num] = temp;
      } else if (dp[i + num].size() == temp.size()) {
        dp[i + num] = max(dp[i + num], temp);
      }
    }
  }
  cout << dp[n] << endl;
}


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

// 8:34AM 
int main()
{
	int H, W;
	std::string s;

	std::cin >> H;
	std::cin >> W;
	std::vector<std::vector<char>> res;

	res.assign(H + 2, std::vector<char>());

	res[0].assign(W + 2, '#');
	res[H+1].assign(W + 2, '#');
	
	for (int i = 1; i <= H; ++i)
	{		
		res[i].assign(W + 2, '#');
		std::cin >> s;	
		for (int j = 1; j <= W; ++j)
			res[i][j] = s[j-1];
	}

	for (int i = 0; i < H+2; ++i)
	{
		for (int j = 0; j < W+2; ++j)
			std::cout << res[i][j];
		std::cout << std::endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

set <pair <int, int> > s;

int a[N];

int main () {
	boost;
	int n, k;
	cin >> n >> k;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> a[i];
		s.insert ({-a[i], i});
	}
	while (k--) {
		pair <int, int> p = *s.begin();
		s.erase (s.begin());
		s.insert ({p.first / 2, p.second});
	}
	long long ans = 0;
	for (auto p : s)
		ans -= p.first;
	cout << ans;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("READ.txt", "r", stdin)
#define Write          freopen("OUTPUT.txt", "w", stdout)
#define INF            1000000007

vector<int>adj[200005];
int visited[200005]={0};
int ans=0,Max=0;;

void Dfs(int i)
{
	if(visited[i]==1) return;
	visited[i]=1;
	ans++;
	Max=max(ans,Max);
	for(int j=0;j<adj[i].size();j++)
	{
		Dfs(adj[i][j]);
	}
}

void solve()
{
    int n,m;
    cin>>n;
    cin>>m;
    for(int i=1;i<=m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	adj[a].push_back(b);
    	adj[b].push_back(a);
    }
    //ms(visited,-1);
    for(int i=1;i<=n;i++)
    {
    	if(visited[i]==0)
    	{
    		ans=0;
    		Dfs(i);
    	}
    }
    cout<<Max<<endl;
}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    Read;
    Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}

Measured memory_bytes: 21524
a, b, c, d, e = map(int, input().split())

hour = e // 60
min = e % 60

a += hour
b += min

if b >= 60:
    a += b // 60
    b %= 60

ans = 0
if b > d:
    c -= 1
    ans += 60 - (b - d)
else:
    ans += (d - b)

if c >= a:
    ans += 60 * (c - a)
else:
    print(0)
    exit()

print(ans)

Measured memory_bytes: 9204
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1
print(ans)

Measured memory_bytes: 96352
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char* argv[])
{

	int X, Y; cin >> X >> Y;
	if (X <= 8 && Y <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;

}

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

using namespace std;

#define ll long long

int main()
{
	int n;
	cin >> n;

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

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		while (arr[i] % 2 == 0)
		{
			ans++;
			arr[i] /= 2;
		}
	}

	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> v1;
typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;

ll n;
ll a[100000];
unordered_map<ll,ll> m;
unordered_map<ll,ll> o;
ll l,r;

int main(){
    cin >> n;
    for(ll i = 0;i < n;i++) cin >> a[i];
    for(ll i = 0;i < n;i++){
        m[a[i]]++;
    }
    for(ll i = 1;i < n;i++){
        if(o.find(a[i]) != o.end()){
            l = a[0];
            r = a[i];
            m[l]--;
            m[r]--;
            for(ll i = 2;i < n;i++){
                l = l^r;
                swap(l,r);
                if(m[r] > 0){
                    m[r]--;
                }else{
                    cout << "No" << endl;
                    return 0;
                }
            }
            if(l^r == a[0]){
                cout << "Yes" << endl;
                return 0;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            o[a[i]^a[0]] = a[i];
        }
    }

    cout << "No" << endl;

}


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

int main(){
  int N,M;
  cin>>N>>M;
  int A[100];
  int B[50];
  for(int i =0;i<2*M;i++){
    cin>>A[i];
  }
  for(int i = 1;i < N+1;i++){
    int sum = 0;
  for(int j = 0;j <2*M;j++){
    if(A[j] == i){
      sum++;
    }
  }
    B[i] = sum;
  }
  for(int i = 1; i<N + 1;i++){
    cout<<B[i]<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = Integer.parseInt(scan.next()); 
        int m = Integer.parseInt(scan.next());

        int[][] matrix = new int[n][m];
        int[] vector = new int[m];
        int[] dot = new int[n];

        for (int i=0; i<n; i++){
            for (int j=0; j<m; j++){
                matrix[i][j] = Integer.parseInt(scan.next());
            }
        }

        for (int i=0; i<m; i++)
            vector[i] = Integer.parseInt(scan.next());

        for (int i=0; i<n; i++){
            for (int j=0; j<m; j++){
                dot[i] += matrix[i][j] * vector[j];
            }
        }

        for (int ele: dot){
            System.out.println(ele);
        }
    }
}

Measured memory_bytes: 38580
X,N = map(int,input().split())
p = list(map(int,input().split()))
ans1 = X
ans2 = X

if X not in p:
    print(X)
    exit()

for i in range(len(p)):
    ans1 -= 1
    ans2 += 1
    if ans1 not in p:
        print(ans1)
        exit()
    if ans2 not in p:
        print(ans2)
        exit()
print(X)


Measured memory_bytes: 9192
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{

    class Program
    {

        static bool Isou(double s, double t, double u, double v, double x1, double y1, double x2, double y2)
        {
            if(s - u == 0)
            {
                if((x1 < s && x2 < s) || (x1 > s && x2 > s))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }


            double k = (t - v) / (s - u);
           

            double b = t - k * s;

            double n = k * x1 + b;
            double m = k * x2 + b;
           

            if ((n < y1 && m < y2) || (n > y1 && m > y2))
            {
                return true;
            }
            else
            {
                return false;
            }

        }

        static void Main(string[] args)
        {

            while (true)
            {

                string str1 = Console.ReadLine();

                if (string.IsNullOrEmpty(str1))
                {
                    break;
                }

                string[] str = str1.Split(',');

                double x1 = double.Parse(str[0]);
                double y1 = double.Parse(str[1]);

                double x2 = double.Parse(str[2]);
                double y2 = double.Parse(str[3]);

                double x3 = double.Parse(str[4]);
                double y3 = double.Parse(str[5]);

                double x4 = double.Parse(str[6]);
                double y4 = double.Parse(str[7]);               
              

                if (Isou(x1, y1, x3, y3, x2, y2, x4, y4))
                {
                    Console.WriteLine("NO");                   
                }
                else if (Isou(x2, y2, x4, y4, x1, y1, x3, y3))
                {
                    Console.WriteLine("NO");                  
                }            
                else
                {
                    Console.WriteLine("YES");
                }

            }


        }
    }
}



Measured memory_bytes: 13848
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
	vector<int> v;
	int m, nmin, nmax, gap = -1, gapnum;
	for (;;) {
		cin >> m >> nmin >> nmax;
		if (m == 0 && nmin == 0 && nmax == 0) break;
		v.resize(m);
		for (int i = 0; i < m; i++) cin >> v[i];

		for (int i = nmin-1; i < nmax; i++) {
			if (gap == -1) {
				gap = v[i] - v[i + 1];
				gapnum = i+1;
			}
			else {
				if (gap <= v[i] - v[i + 1]) {
					gap = v[i] - v[i + 1];
					gapnum = i+1;
				}
			}
		}
		cout << gapnum << endl;
		gap = -1;
	}
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int num=0;
	for(int i=0;i<a.length();i++)
	   {
	   	if(a[i]==b[i])num++;
	   }
	cout<<num;
	return 0;
	   
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll n,d;
    cin>>n>>d;
    int ans=0;
    rep(i,1,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>

using namespace std;
using uint = unsigned int;

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

  uint N, K;
  cin >> N >> K;
  
  string buf;
  cin.ignore();
  getline(cin, buf);

  cout << ceil((double)(N - 1) / (double)(K - 1)) << endl;

	return 0;
}

Measured memory_bytes: 1172
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int K,X;
	scanf("%d", &K);
	scanf("%d", &X);
	int A;
	A = X - K;
	for (int i = 1; i < 2 * K; i++) {
		A = A + 1;
		printf("%d ",A);
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import product


"""
def solve(string):
    n = int(string)
    t = [[0] * 10 for _ in range(10)]
    for i in range(n + 1):
        i = str(i)
        t[int(i[0])][int(i[-1])] += 1
    # print(t)
    # return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))
"""


def solve(string):
    l = len(string)
    n = int(string)
    c = [0] + [10**i for i in range(6)]
    t = sum(c[:l - 1])
    t = [[t] * 10 for _ in range(10)]
    if l > 1:
        for i in range(10):
            t[i][i] += 1
    for i in range(10 ** (l - 1), n + 1):
        i = str(i)
        t[int(i[0])][int(i[-1])] += 1
    return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))

if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

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

    int x, y;

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;


}

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

using namespace std;
     
const int MAX_N = 100001;
     
int N, Q;
long long int ans;
int par[MAX_N]; 
bool marked[MAX_N];

void init() {
  for (int i = 0; i <= N; i++) {
    par[i] = i;
  }
}

int search(int x) {
  if (marked[x]) return x;
  else return search(par[x]);
}
  
int main()
{
  marked[1] = true;
  while(1){
    int num;
    scanf("%d %d", &N, &Q);
    if(N == 0 && Q == 0) break;
    init();
    ans = 0;
    for(int i = 2; i <= N; i++){
      scanf("%d", &num);
      par[i] = num;
      marked[i] = false;
    }
    char ope;
    for(int i = 0; i < Q; i++){
      scanf(" %c", &ope);
      scanf("%d", &num);
      if (ope == 'M') {
        marked[num] = true;
      }
    
      else if(ope == 'Q'){
        ans += search(num);
      }
    } 
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1676
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int res10000 = -1;
        int res5000  = -1;
        int res1000  = -1;

        for (int a=0; a<=N; a++) {
            boolean breakFlag = false;
            for (int b=0; b<=N-a; b++) {
                int c = N - a - b;
                int total = a * 10000 + b * 5000 + c * 1000;
                if (total == Y) {
                    res10000 = a;
                    res5000  = b;
                    res1000  = c;
                    breakFlag = true;
                    break;
                }
            }
            if (breakFlag) break;
        }

        System.out.println(res10000 + " " + res5000 + " " + res1000);
    }
}


Measured memory_bytes: 21844
ans = 0
a = []
for _ in range(5):
    x = int(input())
    if x%10 == 0:
        ans += x
    else:
        ans += (x//10)*10
        a.append(x%10)

ans += (len(a)-1)*10
if a != []:
    ans += min(a)
else:
    ans += 10

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <numeric>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
typedef long long ll;

vector<int> line_to_array(istream& is, const int cnt, const char sep);
vector<string> split(const string &str, const char sep);
string trim(const string& str, const char* trimCharacterList  = " \t\v\r\n");
bool chk_rcsv(int j, int k, char** t, bool** chk_t, string str, int pos);

int a,b;

int main(){
    //ifstream cin("inputAB54_A.txt");
    cin >> a >> b;
    if(a == 1){
        a = 14;
    }
    if(b == 1){
        b = 14;
    }
    string str;
    if(a==b){
        str = "Draw";
    }else if(a>b){
        str = "Alice";
    }else{
        str = "Bob";
    }

    cout << str << endl;
    return 0;
}

vector<int> line_to_array(istream& is, const int cnt, const char sep){
    vector<int> v;
    string str;
    getline(is, str);
    vector<string> words = split(str, sep);
    for (int i=0; i < cnt; i++) {
        v.push_back( atoi(words[i].c_str()) );
    }
    return v;
}

vector<string> split(const string &str, const char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ){
        v.push_back(buffer);
    }
    return v;
}

string trim(const string& str, const char* trimCharacterList)
{
    string result;
    string::size_type left = str.find_first_not_of(trimCharacterList);
    
    if (left != string::npos)
    {
        string::size_type right = str.find_last_not_of(trimCharacterList);
        result = str.substr(left, right - left + 1);
    }
    return result;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, L; cin >> N >> L;
    ll idx = -1, abs_min = LINF, sum = 0;
    REP(i, N){
        ll now = L+i; sum += now;
        if(abs(now) < abs_min){
            abs_min = abs(now);
            idx = i;
        }
    }
    cout << sum - (L+idx) << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	
	int n; cin >> n;
	bool ok = false;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    ll ans = 1;
    vector <int> count(1000005);
    count[0] = 3;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        ans = ans * count[a] % MOD;
        count[a]--;
        count[a + 1]++;
    }

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

Measured memory_bytes: 4728
import java.util.*;

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

		    int N = sc.nextInt();
		    long A[] = new long [N+1];
		    long B[] = new long [N];
		    long sum = 0;
		    
		    for(int i = 0; i<=N; i++) {
		    	A[i] = sc.nextLong();
		    }
		    
		    for(int i = 0; i<N; i++) {
		    	B[i] = sc.nextLong();
		    }
		    
		    for(int i=N-1;i>=0;i--) {
				sum+=Math.min(A[i+1], B[i]);
				B[i]=Math.max(0, B[i]-A[i+1]);
				sum+=Math.min(A[i], B[i]);
				A[i]=Math.max(0, A[i]-B[i]);
			}
		    
		    System.out.println(sum);
		    
	  }
}


Measured memory_bytes: 61996
#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
vector<bool> volt;
map<long long, int> ma;
int n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        long long sza;
        cin>>sza;
        v.push_back(sza);
        volt.push_back(false);
        ma[sza]++;
    }
    int ans=0;
    sort(v.begin(), v.end());
    for(int i=n-1; i>=0; i--)
    {
        if(ma[v[i]]<=0) continue;
        ma[v[i]]--;
        long long h=1;
        while(h<=v[i]) h*=2;
        if(ma[h-v[i]]>0)
        {
            ans++;
            ma[h-v[i]]--;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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


int main()
{
  int n; cin >> n;
  vector<pair<int, int>> x;
  vector<pair<int, int>> y;
  rep(i, n)
  {
    int X, Y;
    cin >> X >> Y;
    x.emplace_back(X, i);
    y.emplace_back(Y, i);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  vector<vector<pair<int, int>>> g(n);
  rep(i, n-1)
  {
    g[x[i].second].emplace_back(x[i+1].first - x[i].first, x[i+1].second);
    g[x[i+1].second].emplace_back(x[i+1].first - x[i].first, x[i].second);
    g[y[i].second].emplace_back(y[i+1].first - y[i].first, y[i+1].second);
    g[y[i+1].second].emplace_back(y[i+1].first - y[i].first, y[i].second);
  }
  int ans = 0;
  vector<int> check(n, false);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.emplace(0, 0);
  while (!q.empty())
  {
    auto P = q.top();
    q.pop();
    int p = P.second;
    if (check[p])
      continue;
    check[p] = true;
    ans += P.first;
    for (auto i : g[p])
      if (!check[i.second])
        q.push(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	cin >> n;
	int j;
	long long int ansmin = 1000000, ansmax = -1000000, anssum = 0;
	for (int i = 0; i < n; i++) {
		cin >> j;
		anssum += j;
		if (j < ansmin) {
			ansmin = j;
		}
		if (j > ansmax) {
			ansmax = j;
		}
	}
	cout << ansmin << " " << ansmax << " " << anssum << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<string> v;
map<string, ll> cnt;
const ll INF = 1e12;

int main()
{
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i)
    {
        string st;
        cin >> st;
        sort(st.begin(), st.end());
        cnt[st]++;
    }

    ll result = 0;
    for (auto p : cnt)
    {
        result += p.second * (p.second - 1) / 2;
    }

    cout << result << endl;
}

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

const int N = 512;
const int INF = 2e9;
const int mod = 1e9+7;

int n, m, k;
int c[N], s[N], f[N];
vector<int> ans;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n-1; ++i) {
    scanf("%d%d%d", c+i, s+i, f+i);
  }
  for (int i = 0; i < n; ++i) {
    int ct = 0;
    for (int j = i; j < n-1; ++j) {
      if (ct < s[j]) ct = s[j];
      while (ct%f[j]) ++ct;
      ct += c[j];
    }
    ans.push_back(ct);
  }
  for (const auto &e: ans) {
    printf("%d\n", e);
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,v,w;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    k=0;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    sort(v.B,v.E);
    k=0;
    for(i=1;i<n;i++)
    {
     k+=(v[i]-v[i-1]);
    }
    cout<<k<<endl;



    return 0;

}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	int A, B;
	string s, ans = "No";
	cin >> A >> B >> s;
	FOR(i, 0, s.length()) {
		if (i < A) {
			if (s[i] >= '0'&&s[i] <= '9') {
				continue;
			}
			else {
				break;
			}
		}
		else if (i == A) {
			if (s[i] != '-')
				break;
		}
		else {
			if (s[i] >= '0'&&s[i] <= '9') {
				//continue;
			}
			else {
				break;
			}
		}
		if (i == s.length() - 1)
			ans = "Yes";
	}
	O(ans);

	return 0;
}

Measured memory_bytes: 256