akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<cmath>
using namespace std;

#define PI 3.1415926535898

//?????§?¨?????????¨??????
typedef complex<double> P;


//?¨±?????????
#define EPS (1e-10)
//X Y??§?¨?
#define X real()
#define Y imag()

class Triangle {
    private:
    //????§???¢???3????????§?¨?
    P a,b,c;
    //????§???¢???????????????
    double edgeA, edgeB, edgeC;
    //????§???¢????§??????§??????
    double angleA, angleB, angleC;
    //??????????????????3???????§????????±???????
    double LawOfCosines(double a, double b, double c) {
        return acos((b*b+c*c-a*a)/(2.0*b*c));
    }
    //2??????double??????????????????
    bool equal(double a,double b) {
        return (abs(a-b)<EPS)?true:false;
    }

    public:
    //?????????????????????
    Triangle(P p1, P p2, P p3) {
        a=p1;
        b=p2;
        c=p3;
        edgeB=abs(c-a);
        edgeA=abs(b-c);
        edgeC=abs(a-b);
        angleA=LawOfCosines(edgeA, edgeB, edgeC);
        angleB=LawOfCosines(edgeB, edgeC, edgeA);
        angleC=LawOfCosines(edgeC, edgeA, edgeB);
    }

    double circumscribedCircleRadius() {//?????\????????????
        return (edgeA/sin(angleA)/2.0);
    }

    double circumscribedCircleX() {//?????\????????????X??§?¨?
        double A=sin(2.0*angleA);
        double B=sin(2.0*angleB);
        double C=sin(2.0*angleC);
        return ((a.X * A + b.X * B + c.X * C)/(A+B+C));
    }

    double circumscribedCircleY() {//?????\????????????Y??§?¨?
        double A=sin(2.0*angleA);
        double B=sin(2.0*angleB);
        double C=sin(2.0*angleC);
        return ((a.Y * A + b.Y * B + c.Y * C)/(A+B+C));
    }
};


int main(){
    int mod=1000000007;
    int n;
    double x1,y1,x2,y2,x3,y3;
    double r,xp,yp;
    scanf("%d",&n);
    for (int i=0;i<n;i++) {
        scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
        P a(x1,y1);
        P b(x2,y2);
        P c(x3,y3);
        Triangle Tr(a,b,c);
        xp=Tr.circumscribedCircleX();
        yp=Tr.circumscribedCircleY();
        r =Tr.circumscribedCircleRadius();

        //printf("%.10f %.10f %.10f\n",xp,yp,r);
        printf("%.3f %.3f %.3f\n",xp,yp,r);
    }

    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf(" %d", list[i]);
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int LeftIndex(const vector<int> &list, int index){
    if (list.size() - 1 < index * 2) return 0;
    return index * 2;
}
int RightIndex(const vector<int>&list, int index){
    if (list.size() - 1 < index * 2 + 1) return 0;
    return index * 2 + 1;
}

void MaxHeapfy(vector<int>& list, int index){
    int left = LeftIndex(list, index);
    int right = RightIndex(list, index);
    int largestIndex = index;
    if (list[largestIndex] < list[left]){
        largestIndex = left;
    }
    if (list[largestIndex] < list[right]){
        largestIndex = right;
    }
    if (largestIndex != index) {
        std::swap(list[index], list[largestIndex]);
        MaxHeapfy(list, largestIndex);
    }
}
void BuildMaxHeap(vector<int>& list){
    for (int i = list.size() / 2; 0 < i; i--){
        MaxHeapfy(list, i);
    }
}

void solve() {
    // CompleteBinaryTree
    int n;
    scanf("%d", &n);
    vector<int> tree(n+1);
    tree[0] = std::numeric_limits<int>::min();
    for(int i = 1; i <= n; i++){
        int v;
        scanf("%d", &v);
        tree[i] = v;
    }
    BuildMaxHeap(tree);
    for (int i = 1; i < tree.size(); i++){
        printf(" %d", tree[i]);
    }
    printf("\n");
}


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


Measured memory_bytes: 4604
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <ctime>
#include <iomanip>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >>s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  ll q, h, s, d, n;cin>>q>>h>>s>>d>>n;
  ll e=min(4*q, min(2*h, s));
  if(2*e<d)cout<<n*e<<endl;
  else cout<<(n/2)*d+(n%2)*e<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include "combo.h"
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=1e5+10;
int X,Y,A,B,C,ret;
int a[maxn],b[maxn],c[maxn];
vector<int> R;
main()
{
    //freopen("160E.inp","r",stdin);
   // freopen("160E.out","w",stdout);
    cin>>X>>Y>>A>>B>>C;
    forinc(i,1,A) cin>>a[i];
    forinc(i,1,B) cin>>b[i];
    forinc(i,1,C) cin>>c[i];
    sort(a+1,a+A+1);
    sort(b+1,b+B+1);
    fordec(i,A,A-X+1) R.push_back(a[i]);
    fordec(i,B,B-Y+1) R.push_back(b[i]);
    forinc(i,1,C) R.push_back(c[i]);
    sort(R.rbegin(),R.rend());
    for(int i=0;i<X+Y;++i) ret+=R[i];
    cout<<ret;
}


Measured memory_bytes: 8688
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int t;
	cin >> t;
	rep(_,t) {
		int n;
		cin >> n;
		vector<long long> a(n);
		rep(i, n)cin >> a[i];
		string s;
		cin >> s;
		vector<long long> bits;

		int ans = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (s[i] == '0') {
				bits.push_back(a[i]);
				for (int j = 60; j >= 0; j--) {
					int k = -1;
					rep(kk, bits.size()) {
						if ((bits[kk] & ~((1LL<<j)-1)) == (1LL<<j)) {
							k = kk;
							break;
						}
					}
					if (k == -1)continue;
					rep(kk, bits.size()) {
						if (k == kk)continue;
						if (bits[kk] >> j & 1) {
							bits[kk] ^= bits[k];
						}
					}
				}
				sort(all(bits));
				while (bits.front() == 0)bits.erase(bits.begin());
				reverse(all(bits));
			}
			else {
				long long x = a[i];
				for (int j = 60; j >= 0; j--) {
					if ((x >> j & 1) == 0)continue;
					for (auto y : bits) {
						if ((y & ~((1LL << j) - 1)) == (1LL << j)) {
							x ^= y;
							break;
						}
					}
				}
				if (x) {
					ans = 1;
					break;
				}
			}
		}

		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 3660
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    A = []

    while(True):
        m, f, r = [int(x) for x in input().split()]
        if (m == -1) and (f == -1) and (r == -1):
            break
        else:
            A.append([m,f,r])
    
    for i in A:
        seiseki = i[0]+i[1]
        if i[0]==-1 or i[1]==-1:
            print("F")
        elif seiseki >= 80:
            print("A")
        elif seiseki >= 65:
            print("B")
        elif seiseki >= 50:
            print("C")
        elif seiseki >= 30 and i[2] >= 50:
            print("C")
        elif seiseki >= 30:
            print("D")
        else:
            print("F")

if __name__ == '__main__':
    main()


Measured memory_bytes: 5744
// Problem : C - Walking Takahashi
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll x,k,d;
	cin>>x>>k>>d;
	ll dist=abs(x);
	ll j=dist/d;
	ll ans=0;
	if(j>=k)
	{
		ans=abs(dist-k*d);
	}
	else
	{
		if((k-j)%2)
		ans=abs(dist-(j+1)*d);
		else
		ans=abs(dist-j*d);
	}
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.Scanner;

class Process {
    String name;
    int time;
    int finishTime;

    Process(String name, int time, int finishTime) {
        this.name = name;
        this.time = time;
        this.finishTime = finishTime;
    }
}

class Main {

    int size;
    int quantum;

    public void go() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.quantum = sc.nextInt();
        ArrayList<Process> list = new ArrayList<Process>();
        ArrayList<Process> finishList = new ArrayList<Process>();
        for (int i = 0; i < this.size; i++) {
            list.add(new Process(sc.next(), sc.nextInt(), 0));
        }

        int time = 0;
        while (!list.isEmpty()) {
            Process currentProcess = list.get(0);
            // finish
            if (currentProcess.time <= this.quantum) {
                currentProcess.finishTime = time + currentProcess.time;
                finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));
                time += currentProcess.time;
            } else {
                currentProcess.time -= this.quantum;
                list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));
                time += this.quantum;
            }
            list.remove(0);
        }
        for (Process process : finishList) {
            System.out.println(process.name + " " + process.finishTime);
        }
    }

    public static void main(String[] args) {
        Main cui = new Main();
        cui.go();
    }
}


Measured memory_bytes: 77356
/*
 * aoj/alds1_14_a/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

#define ull unsigned long long

/*
 * 1. 短い方の長さまでのハッシュを取る.
 * 2. 比較する.
 */
const ull b = 100000007;
void solve() {
  string t, s;
  ull tl, sl;
  cin >> t >> s;
  tl = t.size();
  sl = s.size();

  ull th = 0, sh = 0; // オーバーフローを利用した2^64 mod計算
  loop(i,0,sl) th = th * b + t[i];
  loop(i,0,sl) sh = sh * b + s[i];

  ull b_sl = 1;
  loop(i,0,sl) b_sl *= b;

  vector<int> ans;
  for (int i=0; i+sl<=tl; i++) {
    if (th == sh) ans.push_back(i);
    if (i+sl<tl) th = th * b + t[i+sl] - t[i] * b_sl;
  }

  for(auto&&a: ans) cout << a << endl;
}



Measured memory_bytes: 3220
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

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



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

	cin >> N;
	vector<int>v(N + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	vector<int>p(N + 1);
	vector<int>ans;
	for (int i = N; i >= 1; i--) {
		int num = 0;
		for (int j = i; j <= N; j += i) {
			//cout << i << " " << j << endl;
			num += p[j];
		}
		//cout << i << " " << num << endl;
		num &= 1;
		//cout <<i<<" "<< num << endl;
		if (v[i] != num) {
			//cout << "i " << i << endl;
			p[i]++;
			ans.push_back(i);
		}
	}
	//for (auto i : p)cout << i << endl;
	cout << ans.size() << endl;
	for (auto i : ans)cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	rep(i, n){
		char c;
		cin >> c;
		if(c == 'Y'){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
typedef unsigned long long uint64;
using namespace std;
int main(){
 string s;
 cin >> s;
 if (s[s.length()-1]=='3'){
     cout << "bon" << endl;
 }else if(s[s.length()-1]=='0'||s[s.length()-1]=='1'||s[s.length()-1]=='6'||s[s.length()-1]=='8'){
     cout << "pon" << endl;
 }else{
     cout << "hon" << endl;
 }
return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
 
bool cmp(int a,int b){
	return a>b;	
}

int a[66];

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n,cmp);
	int ans=0;
	for(int i=0;i<k;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

struct Graph {
  int n;
  int time;
  vector<vector<int>> g;
  vector<int> num, low, group, backPath;
  vector<vector<int>> scc;
  stack<int, deque<int>> S;
  vector<bool> inS;

  Graph(int n)
      : n(n), g(n), num(n, -1), low(n, -1), inS(n, false),
        group(n, 0), backPath(n) {}

  void addEdge(int u, int v) {
    g[u].push_back(v);
  }
  void dfs(int u) {
    num[u] = low[u] = time++;
    S.push(u);
    inS[u] = true;
    for (auto&& v : g[u]) {
      if (num[v] == -1) {
        dfs(v);
        low[u] = min(low[u], low[v]);
      } else if (inS[v]) {
        low[u] = min(low[u], num[v]);
      }
    }
    if (low[u] == num[u]) {
      scc.push_back({});
      while (true) {
        int v = S.top(); S.pop();
        inS[v] = false;
        scc.back().push_back(v);

        group[v] = scc.size() - 1;
        if (u == v) break;
      }
      for (int i = 0, m = scc.back().size(); i < m; ++i) {
        backPath[scc.back()[i]] = scc.back()[(i + 1) % m];
      }
    }
  }
  void stronglyConnectedComponents() {
    for (int i = 0; i < n; ++i) {
      if (num[i] == -1) dfs(i);
    }
  }
};

const int INF = 1e9;

int n, r;

int solve(Graph& g, vector<vector<int>>& adj) {
  int m = adj.size();
  int res = 0;

  for (int i = 0; i < m; ++i) {
    if (i == r) continue;
    int minVal = INF, minId = 0;
    for (int j = 0; j < m; ++j) {
      if (minVal > adj[j][i]) {
        minVal = adj[j][i];
        minId = j;
      }
    }
    res += minVal;
    g.addEdge(minId, i);
  }
  g.stronglyConnectedComponents();
  if (g.scc.size() == m) return res;

  int sz = g.scc.size();
  vector<vector<int>> mat(sz, vector<int>(sz, INF));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i == j || adj[i][j] == INF) continue;
      int u = g.group[i];
      int v = g.group[j];
      if (u == v) continue;

      mat[u][v] = min(mat[u][v],
          adj[i][j] - (j != g.backPath[j]) * adj[g.backPath[j]][j]);
    }
  }

  res = 0;
  for (int i = 0; i < sz; ++i) {
    if (g.scc[i].size() == 1) continue;
    for (int j = 0, k = g.scc[i].size(); j < k; ++j) {
      res += adj[g.scc[i][(j + 1) % k]][g.scc[i][j]];
    }
  }

  r = g.group[r];
  g.scc.shrink_to_fit();
  g = Graph(sz);
  return res + solve(g, mat);
}

int main() {
  int m; cin >> n >> m >> r;
  vector<vector<int>> adj(n, vector<int>(n, INF));
  while (m--) {
    int s, t, w; cin >> s >> t >> w;
    adj[s][t] = w;
  }
  Graph g(n);
  cout << solve(g, adj) << endl;
  return 0;
}



Measured memory_bytes: 3552
//ITP1_7_A
    //????????????  1??????45???

    using System;
    using System.Collections.Generic;

    class ITP1_7_A
    {
        static void Main(string[] args)
        {
            int count = 0;
            string[] result = new string[50];

            while(true) 
            {
                int[] st = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
                {
                    return int.Parse(value);
                });

                result[count] = judge(st[0], st[1], st[2]);

                if (result[count++] == "E")
                    break;
            }

                for (int i = 0; i < count - 1; i++)
                    Console.WriteLine(result[i]);

        }

        private static string judge(int m, int f, int r)
        {
            int sum = m + f;

            if (m == -1 && f == -1 && r == -1)
                return "E";
             
            if (sum >=80)
                return "A";
            if (sum < 80 && sum >= 65)
                return "B";
            if ((sum < 65 && sum >= 50) || r >= 50)
                return "C";
            if ( (sum < 50 && sum >= 30) && (m != -1 && f != -1) )
                return "D";
            else
                return "F";

        }
    }

Measured memory_bytes: 8868
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)


int n, q;
string s;

void solve() {
  vector<int> t(100001);
  for (int i = 1; i < (int)s.size(); i++) {
    t[i] = t[i - 1];
    if (s[i - 1] == 'A' && s[i] == 'C') {
      t[i]++;
    }
  }
  // REP(i, 10) {
  //   cout << t[i] << " ";
  // }
  // cout << endl;
  REP(i, q) {
    int l, r;
    cin >> l >> r;
    // cout << t[r - 1] << " " << t[l- 1g] << endl;
    cout << t[r - 1] - t[l - 1] << endl;
  }
}

int main() {
  cin >> n >> q >> s;
  solve();
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    string s;
    cin >> s;
    int i=0;
    int j=s.size()-1;
    int cnt=0;
    while(i<j){
        if(s[i]!=s[j])cnt++;
        i++;
        j--;
    }
    cout << cnt << endl;
   
}

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


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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	for(int i=0;i<n;i++)
	{
		string a;
		cin>>a;
		if(a=="AC")
		{
			ac++;
		}
	  else if(a=="WA")
		{
			wa++;
		}
		else if(a=="TLE")
		{
			tle++;
		}
		else if(a=="RE")
		{
			re++;
		}
	}
	cout<<"AC "<<"x "<<ac<<endl;
	cout<<"WA "<<"x "<<wa<<endl;
	cout<<"TLE "<<"x "<<tle<<endl;
	cout<<"RE "<<"x "<<re<<endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int mod = 998244353;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
void qmo(int &x){x += (x >> 31) & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % mod) if(b & 1) res = (LL) res * a % mod;
	return res;
}
template<typename T>
inline bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
const int N = 200003;
int n, ans[20][20], b[N], c[N]; LL a[N], res; double x;
int main(){
	read(n);
	for(Rint i = 1;i <= n;++ i){
		scanf("%lf", &x); a[i] = x * 1e9 + 0.5;
		while(!(a[i] & 1)){++ b[i]; a[i] >>= 1;}
		while(!(a[i] % 5)){++ c[i]; a[i] /= 5;}
		chmin(b[i], 18); chmin(c[i], 18);
	}
	for(Rint i = 1;i <= n;++ i){
		res += ans[18 - b[i]][18 - c[i]];
		for(Rint j = 0;j <= b[i];++ j)
			for(Rint k = 0;k <= c[i];++ k) ++ ans[j][k];
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 6836
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int h,w;
    cin >> h >> w;
    string ans[h*w+1];
    int coin[h+1][w+1];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> coin[i][j];
        }
    }
    int count=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(coin[i][j]%2!=0&&j+1!=w){
                coin[i][j]--;
                coin[i][j+1]++;
                ans[count]=to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+2);
                count++;
            }
            if(j+1==w&&i!=0){
                if(coin[i-1][j]%2!=0){
                    coin[i][j]++;
                    coin[i-1][j]--;
                    ans[count]=to_string(i)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+1);
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    for(int i=0; i<count; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
//template end

int a[500010]={};

int main(){
    string s; cin>>s; int n=s.size()+1;
    rep(i,0,n-1)if(s[i]=='<')chmax(a[i+1],a[i]+1);
    rrep(i,n-2,-1)if(s[i]=='>')chmax(a[i],a[i+1]+1);
    ll sum=0; rep(i,0,n)sum+=a[i];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 2820
using System;
using System.Linq;

namespace _2015
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int sum = 0;
                int[] sums1 = new int[x[0] + 1];
                for (int i = 1; i <= x[0]; i++)
                {
                    sum += int.Parse(Console.ReadLine());
                    sums1[i] = sum;
                }
                int[] a = new int[2000000];
                for (int i = 0; i <= x[0]; i++)
                {
                    for (int j = i + 1; j <= x[0]; j++) a[sums1[j] - sums1[i]]++;
                }
                sum = 0;
                int[] sums2 = new int[x[1] + 1];
                for (int i = 1; i <= x[1]; i++)
                {
                    sum += int.Parse(Console.ReadLine());
                    sums2[i] = sum;
                }
                int[] b = new int[2000000];
                for (int i = 0; i <= x[1]; i++)
                {
                    for (int j = i + 1; j <= x[1]; j++) b[sums2[j] - sums2[i]]++;
                }
                long ret = 0;
                for (int i = 1; i < 2000000; i++) ret += a[i] * b[i];
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 41400
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
vector<ll>g[10010];
bool visited[10010];
int main(void){
    map<int,int>m;
    int n;
    cin>>n;
    int free = 0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a>=3200)free++;
        else m[a/400]++;
    }
    int ans = 0;
    for(int i=0;i<8;i++){
        if(m[i])ans++;
    }
    if(free){
        if(ans == 0)cout<<1<<" "<<free<<endl;
        else cout<<ans<<" "<<ans+free<<endl;
    }
    else cout<<ans<<" "<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = A; i <= B; i++) {
		if (i <= A + K - 1 || B - K + 1 <= i) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,arr[100010];

int main()
{
	int i,j,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		sum += arr[i];
	}
	int ans=0;
	if(sum % 10 != 0)
	{
		printf("%d\n",sum);
	}
	else
	{
		for(i=0;i<n;i++)
		{
			if( (sum-arr[i]) % 10 != 0)
			{
				ans = max(ans,sum-arr[i]);
			}
		}
		printf("%d\n",ans);
	}
	
}

Measured memory_bytes: 3776
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    System.out.println((A <= C &&  C <= B) ? "Yes" : "No");
  }
}


Measured memory_bytes: 25172
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n, m = MI()
lr = [LI() for _ in range(m)]
max_l = lr[0][0]
min_r = lr[0][1]
for l, r in lr:
    max_l = max(max_l, l)
    min_r = min(min_r, r)

print(min_r - max_l + 1 if max_l <= min_r else 0)




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

int main(){
	int n,x;
	cin >> n >> x;
	int sum = 0;
	int mo = 100000000;
	rep(i,n){
		int m;
		cin >> m;
		sum += m;
		mo = min(mo,m);
	}
	int ans = n + (x-sum)/mo;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

struct Q {
    string Relation, Name1, Name2;
    Q(const string& Relation, const string& Name1, const string& Name2) 
        : Relation(Relation), Name1(Name1), Name2(Name2) {}
};
ostream& operator<<(ostream& os, const Q& q) {
    os << "(" << q.Relation << ", " << q.Name1 << ", " << q.Name2 << ")";
    return os;
}

int N, M;
vector<int> Parent;
vector<Q> Queries;
map<string, int> Id;
vector<int> Prev;

int CountPrefixSpaces(const string& s) {
    int i;
    for (i = 0; i < s.size() && s[i] == ' '; i++) ;
    return i;
}

bool input() {
    string l;
    getline(cin, l);
    istringstream is; is.str(l);
    is >> N >> M;
    is.clear();
    if (N == 0 && M == 0) return false;
    Parent.resize(N, -1);
    Queries.clear();
    Id.clear();
    Prev.resize(N, -1);
    for (int i = 0; i < N; i++) {
        getline(cin, l);
        is.str(l);
        string Name;
        is >> Name;
        is.clear();
        Id[Name] = i;
        int C = CountPrefixSpaces(l);
        Prev[C] = i;
        if (C != 0) {
            Parent[i] = Prev[C - 1];
        }
    }
    for (int i = 0; i < M; i++) {
        getline(cin, l);
        is.str(l);
        string Name1, Relation, Name2;
        string _;
        is >> Name1;
        for (int k = 0; k < 2; k++) is >> _;
        is >> Relation;
        is >> _;
        is >> Name2;
        Name2 = Name2.substr(0, Name2.size() - 1);
        is.clear();
        Queries.push_back(Q(Relation, Name1, Name2));
    }
    return true;
}

void solve() {
    for (int i = 0; i < M; i++) {
        string& Relation = Queries[i].Relation,
                Name1 = Queries[i].Name1,
                Name2 = Queries[i].Name2;
        int x = Id[Name1], y = Id[Name2];
        if (Relation == "child") {
            cout << (y == Parent[x] ? "True" : "False") << endl;
        } else if (Relation == "parent") {
            cout << (x == Parent[y] ? "True" : "False") << endl;
        } else if (Relation == "sibling") {
            cout << (Parent[x] == Parent[y] ? "True" : "False") << endl;
        } else if (Relation == "descendant") {
            while (x >= 0) {
                if (y == x) {
                    cout << "True" << endl;
                    goto fin1;
                }
                x = Parent[x];
            }
            cout << "False" << endl;
            fin1:;
        } else if (Relation == "ancestor") {
            while (y >= 0) {
                if (y == x) {
                    cout << "True" << endl;
                    goto fin2;
                }
                y = Parent[y];
            }
            cout << "False" << endl;
            fin2:;
        } else {
            assert(0);
        }
    }
    cout << endl;
}

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

Measured memory_bytes: 1528
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

K,X = inpl()
print(' '.join(map(str,list(range(X-K+1,X+K)))))


Measured memory_bytes: 4208
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=10**9+7
n=int(input())
a=lmp()
s=sum(a)%mod
ans=0
for i in range(n):
    s-=a[i]
    s%=mod
    ans+=a[i]*s
    ans%=mod
print(ans)


Measured memory_bytes: 97060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<SegmentTree<int>> seg(26, SegmentTree<int>(n, [](int a, int b){return a + b;}, 0));
    for(int i = 0; i < n; ++i){
        int foo = s[i] - 'a';
        seg[foo].update(i, 1);
    }
    for(int i = 0; i < q; ++i){
        int query;
        cin >> query;
        if(query == 1){
            int a;
            char c;
            cin >> a >> c;
            --a;
            int foo = s[a] - 'a';
            int bar = c - 'a';
            seg[foo].update(a, 0);
            seg[bar].update(a, 1);
            s[a] = c;
        }
        else{
            int a, b;
            cin >> a >> b;
            --a;
            int ans = 0;
            for(int j = 0; j < 26; ++j){
                if(seg[j].query(a, b) > 0)  ++ans;
            }
            cout << ans << "\n";
        }
    }
}

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

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

  int ans = 0;
  for(int i = 1; i <= N; ++i){
    if(i & 1){
      int n = 0;
      for(int j = 1; j <= i; ++j){
        if(i % j == 0) ++n;
      }
      if(n == 8) ++ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def bubble_sort(A, N):
  sw = 0
  flag = True
  while flag:
    flag = False
    i = 0
    for j in range(N-1,i,-1):
      if A[j] < A[j-1]:
        A[j],A[j-1] = A[j-1],A[j]
        flag = True
        sw += 1
    i+= 1
  print(*A)
  print(sw)

N = int(input())
A = list(map(int, input().split()))
bubble_sort(A,N)


Measured memory_bytes: 5604
n,q=gets.chomp.split(" ").map{|s| s.to_i}
a=[]
ans=Array.new(n+1,0)
for i in 0..n-2
  a[i]=gets.chomp.split(" ").map{|s| s.to_i}
end
a.sort!
for j in 0..q-1
  p,x=gets.chomp.split(" ").map{|s| s.to_i}
  ans[p]+=x
end
for i in 0..n-2
  ans[a[i][1]]+=ans[a[i][0]]
end

for i in 1..n
  print "#{ans[i]} "
end

Measured memory_bytes: 21852
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, A, B;

int main(){
  cin >> N >> A >> B;

  cout << min(A * N, B) << 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;
using ll = long long;

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  sort(a.rbegin(), a.rend());
  int t = n-1;
  ll ans = 0;
  rep(i,n){
    int lim = 2;
    if(i==0) lim = 1;
    rep(j,lim){
      if(t>0){
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans << endl;
  return 0; 
}

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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int n = sc.nextInt();
      Set<String> set = new HashSet<>();
      String prev = null;
      boolean isValid = true;
      for (int i = 0; i < n; i++) {
        String s = sc.next();
        if (!isValid) {
          continue;
        }
        if ((prev != null && !s.startsWith(prev.substring(prev.length() - 1, prev.length())))
            || !set.add(s)) {
          isValid = false;
        }
        prev = s;
      }
      System.out.println(isValid ? "Yes" : "No");
    }
  }
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    string S; cin >> S;
    int ans;
    if(S=="RRR") ans = 3;
    else if(S=="SRR" || S=="RRS") ans = 2;
    else if(S=="SSS") ans = 0;
    else ans = 1;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    int S[n], P[n], cnt = 0;
    memset(P, 0, sizeof(P));
    for(int i = 0 ; i < n ; i++){
      cin >> S[i];
    }
    
    while(1){
      for(int i = 0 ; i < n ; i++){
	for(int j = 0 ; j < n ; j++){
	  if(S[i] == S[j]) P[i]++;
	}
      }
      
      if(memcmp(P, S, sizeof(S)) == 0) break;

      memcpy(S, P, sizeof(P));
      memset(P, 0, sizeof(P));

      cnt++;
    }
    
    cout << cnt << endl;
    for(int i = 0 ; i < n ; i++){
      if(i == n-1) cout << P[i] << endl;
      else cout << P[i] << ' ';
    }
  }
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, d;
  cin >> n >> d;
  vii x(n, vi(d));
  rep(i,n) rep(j,d) cin >> x[i][j];
  int ans = 0;
  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      int dist = 0;
      rep(k,d) {
        dist += pow(abs(x[i][k]-x[j][k]), 2);
      } 
      bool ok = false;
      for(int k = 1; k*k <= dist; k++) {
        if(k*k == dist) ok = true;
      }
      ans += ok;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256