akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        long K = nextLong();
        
        int[] map = new int[N+1];
        
        for(int i = 1; i<=N; i++){
            map[i] = nextInt();
        }

        int[] count = new int[N+1];
        int[] Indexstep = new int[N+1];
        int[] stepIndxe = new int[N+1];
        
        count[1]= 1; // start from 1
        int next = map[1];
        Indexstep[1] = 0;   
        stepIndxe[0] = 1;
        for(int i = 1; i<=N; i++){
            count[next]++;
            if(count[next]>1){
                // here is the loop
                int mod = i - Indexstep[next]; 
                long k = (K-Indexstep[next]) % mod + Indexstep[next]; 
                if(K<=Indexstep[next]){
                    k=K;
                }
                System.out.println(stepIndxe[(int)k]);

                return;
            }
            else {
                Indexstep[next] = i; 
                stepIndxe[i] = next;  
            }
            next= map[next];

        }

 
 
        
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 54252
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=20;
const int M=1<<17;
const int mod=1e9+7;
int n,m,a[N],fac[M],inv[M],w,ans,b[N],dp[N][M],f[N],lef;
inline int lowbit(int x){return x&-x;}
inline int Count(int S){int sum=0;while(S)sum++,S-=lowbit(S);return sum;}
inline void Preprocess(){
	fac[0]=1;for(register int i=1;i<=w;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(register int i=2;i<=w;i++)inv[i]=(-1ll*mod/i*inv[mod%i]%mod+mod)%mod;
	for(register int i=2;i<=w;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
inline int C(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int Minus(int x){x+=x<0? mod:0;return x;}
inline int calc(int S){
	int res=w-1;
	for(register int i=1;i<=n;i++)
		if((S>>(i-1))&1)res-=(1<<(i-1));
	return fac[res];
}
int main(){
	scanf("%d%d",&n,&m);w=(1<<n);
	for(register int i=1;i<=m;i++)scanf("%d",&a[i]);
	Preprocess();ans=fac[w-1];
	sort(a+1,a+m+1,[](int &c,int &d){return c>d;});
	dp[0][0]=1;
	for(register int i=1;i<=m;i++){
		for(register int S=0;S<w-1;S++){
			lef=w-a[i];
			for(register int j=1;j<=n;j++)
				if((S>>(j-1))&1)lef-=(1<<(j-1));
			Add(dp[i][S],dp[i-1][S]);//注意考虑不选的情况！ 
			for(register int j=1;j<=n;j++){
				if((S>>(j-1))&1)continue;
				Add(dp[i][S|(1<<(j-1))],1ll*dp[i-1][S]*C(lef,(1<<(j-1))-1)%mod*fac[1<<(j-1)]%mod);
			}
		}
	}
	for(register int S=1;S<w;S++)Add(f[Count(S)],1ll*dp[m][S]*calc(S)%mod);
	for(register int i=1;i<=n;i++)
		if(i&1)ans=Minus(ans-f[i]);else Add(ans,f[i]);
	ans=1ll*ans*w%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9728
N , M = [int(n) for n in input().split(' ')]

list_AC = [0] * N
list_WAcount = [0] * N
sumAC = 0
sumWA = 0

for i in range(M):
    sp , S = input().split(' ')
    p = int(sp)
    
    if (list_AC[p-1] != 0):
        # 既にAC済みの場合は何もしない
        continue 
    else:
        # 最初に正解したときにそれまでのWA回数を加算
        if S == 'AC':
            sumAC += 1
            list_AC[p-1] = 1
            sumWA += list_WAcount[p-1]
        else:
            list_WAcount[p-1] += 1

print("{} {}".format(sumAC,sumWA))

Measured memory_bytes: 4596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int BUF = 16;


enum Type {
    TRUE = 1,
    UNKNOWN = 0
};


class Edge {
public:
    int dst, type;
    Edge(int dst, int type):
        dst(dst), type(type) {}
};


int n;
vector<Edge> adj[BUF];

void read() {
    for (int i = 0; i < BUF; ++i) adj[i].clear();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int nEdge;
        cin >> nEdge;
        for (int j = 0; j < nEdge; ++j) {
            int dst, type;
            cin >> dst >> type;
            adj[i].push_back(Edge(dst - 1, type));
        }
    }
}


int getBit(int mask, int idx) {
    return mask & (1 << idx);
}


void work() {
    int maxV = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) {
            if (!getBit(mask, i)) continue;
            for (int j = 0; j < adj[i].size(); ++j) {
                Edge &e = adj[i][j];
                if ((getBit(mask, e.dst) > 0) != e.type == TRUE) {
                    goto _fail;
                }
            }
        }
        maxV = max(maxV, __builtin_popcount(mask));
    _fail:;
    }
    cout << maxV << endl;
}


int main() {
    read();
    work();
    return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    set<ll> a;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        a.insert(A[i]);
    }
    if(A.size() == a.size()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main(){
    
    int H,W;
    cin>>H>>W;
    char S[H+2][W+2];
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            if(i!=H+1&&j!=W+1&&i!=0&&j!=0){
                cin>>S[i][j];
            }
            else S[i][j]='.';
        }
    }
    S[H][W+1]='#';
    S[1][0]='W';
    bool check=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i+1][j+1]=='#'){
                if(S[i+2][j+1]==S[i+1][j+2]) check=false;
                if(S[i][j+1]==S[i+1][j]) check=false;
            }
        }
    }
    if(check) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] stepInfo = new int[n];
		for(int i =0;i < n; i++) {
			stepInfo[i] = sc.nextInt();
		}
		int[] minimumCostInfo = new int[n];
		minimumCostInfo[1] = Math.abs(stepInfo[1]-stepInfo[0]);

		for(int i =2; i < n;i++) {
			int costBeforeOne = minimumCostInfo[i-1] + Math.abs(stepInfo[i]-stepInfo[i-1]);
			int costBeforeTwo = minimumCostInfo[i-2] + Math.abs(stepInfo[i]-stepInfo[i-2]);
			if(costBeforeOne> costBeforeTwo) {
				minimumCostInfo[i] = costBeforeTwo;
			}else {
				minimumCostInfo[i] = costBeforeOne;
			}

		}

		System.out.println(minimumCostInfo[n-1]);

	}
}

Measured memory_bytes: 59540
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>



using namespace std;


int main() {
	long long  a, b, c;
	cin >> a >> b >> c;
	
	//if(a > b && a > c) ma = a;
//	else if(b > a && b > c) ma = b;
//		 else if(c > a && c > b) ma = c;
	long long  ma = max(a,max(b,c));
	long long  k;
	cin >> k;
	long long  s = 1, base = 2;
	while(k) {
		if(k&1) {
			s *= base;
		}
		base *= base;
		k >>= 1;
	}
	s *= ma;
	if(ma == a) s += b + c;
	else if(ma == b) s += a + c;
		 else if(ma == c) s += a + b;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	ll arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	ll sum = 0;
	for (int i = 1; i < n; ++i){
		if(arr[i] < arr[i - 1]){
			sum += arr[i - 1] - arr[i];
			arr[i] = arr[i - 1];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   string s,t;
   cin >> s >> t;
   bool ans = false;

   rep(i,0,s.size()){
      if(s == t){
         ans = true;
         break;
      }
      // 入れ替え処理
      // sの最後の文字 + 0から最後の文字-1の位置まで
      s = s.back() + s.substr(0, s.size() - 1);
   }

   if(ans){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }

   return 0;
}


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


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int input[100000][2] = {};
	int memo = 0;

	for (int i = 0; i < 100000; ++i) {
		CI input[i][0];
		CI input[i][1];
		if (input[i][0] == 0) {
			memo = i;
			break;
		}
	}

	for (int i = 0; i < memo; ++i) {
		for (int k = 0; k < input[i][0]; ++k) {
			if (k == 0 || k == input[i][0] - 1) {
				for (int j = 0; j < input[i][1]; ++j) {
					CO "#";
				}
			}
			else {
				CO "#";
				for (int j = 0; j < input[i][1] - 2; ++j) {
					CO ".";
				}
				CO "#";
			}
			
			CO "\n";
		}
		CO "\n";
	}
}

Measured memory_bytes: 1908
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<unordered_map<ll, ll>> cards(M);
    for (ll i = 0; i < N; i++) {
        ll X;
        cin >> X;
        cards[X % M][X]++;
    }
    ll ans = 0;
    for (ll m = 1; 2 * m < M; m++) {
        ll total[2] = {};
        ll odd_cnt[2] = {};
        for (const auto& kv : cards[m]) {
            total[0] += kv.second;
            odd_cnt[0] += kv.second % 2;
        }
        for (const auto& kv : cards[M-m]) {
            total[1] += kv.second;
            odd_cnt[1] += kv.second % 2;
        }
        if (total[0] < total[1]) {
            swap(total[0], total[1]);
            swap(odd_cnt[0], odd_cnt[1]);
        }
        ans += total[1];
        total[0] -= total[1];
        if (odd_cnt[0] >= total[1]) {
            odd_cnt[0] -= total[1];
        } else {
            odd_cnt[0] = (total[1] - odd_cnt[0]) % 2;
        }
        ans += (total[0] - odd_cnt[0]) / 2;
    }
    // zero case
    {
        ll total = 0;
        for (const auto& kv : cards[0]) {
            total += kv.second;
        }
        ans += total / 2;
    }
    // M/2 case
    if (M % 2 == 0) {
        ll total = 0;
        for (const auto& kv : cards[M / 2]) {
            total += kv.second;
        }
        ans += total / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12032
n = int(input())
numbers = [int(x) for x in input().rstrip("\n").split(" ")]

from collections import defaultdict
odd = defaultdict(int)
even = defaultdict(int)
for i in range(0,n,2):
  odd[numbers[i]] += 1
  even[numbers[i+1]] += 1

odd_items = list(reversed(sorted([(count, odd_number) for (odd_number, count) in odd.items()])))

even_items = list(reversed(sorted([(count, even_number) for (even_number, count) in even.items()])))

if odd_items[0][1] != even_items[0][1]:
  print(n - odd_items[0][0] - even_items[0][0])
else:
  if len(odd_items) == 1 and len(even_items) == 1:
    print(n // 2)
  else:
    if len(odd_items) == 1 and len(even_items) == 2:
      print(n - odd_items[0][0] - even_items[1][0])
    elif len(odd_items) == 2 and len(even_items) == 1:
      print(n - odd_items[1][0] - even_items[0][0])
    else:
      second_best1 = n - odd_items[0][0] - even_items[1][0]
      second_best2 = n - odd_items[1][0] - even_items[0][0]
      print(min(second_best1,second_best2))


Measured memory_bytes: 21404
[<EntryPoint>]
let main argv =
    let abcd = stdin.ReadLine().Split() |> Array.map int
    let left = abcd.[0] + abcd.[1]
    let right = abcd.[2] + abcd.[3]
    if left > right then "Left" else if left = right then "Balanced" else "Right"
    |> stdout.WriteLine
    0


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

// int main() {
//   ll n;
//   cin >> n;
//   ll ans = n * (n-1) % modint;

//   rep(i,n-2){
//     ans = (ans * 8) % modint;
//   }
//   cout << ans << endl;
// }

int main(){
  int n;
  cin >> n;
  int j;
  ll ans = 0;
  for(int i = 1;i < n;i++){
    j = 1;
    while(true){
      if(i * j < n)ans++;
      else break;
      j++;
    }
  }
  cout << ans << endl;
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll A;
    string B;
    cin >> A >> B;
    int s = B.size();
    ll B100 = (B[3]-'0')+10*(B[2]-'0')+100*(B[0]-'0');
    ll ans = A*B100/100;
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <functional>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    vector<vector<char>> S(N,vector<char>(N));
    vector<vector<int>> v(N);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++){
        cin >> S[i][j];
        if(S[i][j]=='1'){
            v[i].push_back(j);
            v[j].push_back(i);
        }
    }
    vector<int> vis(N,0);
    function<bool(int,int)> is_nibu = [&](int cur,int col){
        vis[cur] = col;
        bool ok = true;
        for(auto x:v[cur]){
            if(vis[x]==0) ok &= is_nibu(x,-col);
            else if(vis[x]==col) return false;
        }
        return ok;
    };
    if(!is_nibu(0,1)){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) vis[j] = -1;
        queue<P> Q;
        Q.push({i,1});
        vis[i] = 1;
        while(!Q.empty()){
            P p = Q.front(); Q.pop();
            for(auto x:v[p.first]){
                if(vis[x]==-1){
                    vis[x] = p.second+1;
                    Q.push({x,p.second+1});
                    ans = max(ans,p.second+1);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long int


vector<int> v;

int main(){
    int n;
    cin >> n;
    int a;
    cin >> a;
    v.push_back(a);
    int k = 0;
    for(int i = 1; i < n; ++i){
        int x;
        cin >> x;
        if(v[k] >= x){
            v.push_back(x);
            k++;
        }
    }

    cout << v.size() << endl;
 }

Measured memory_bytes: 1400
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s,w=MI()
    if w>=s:print("unsafe")
    else:print("safe")

main()

Measured memory_bytes: 9196
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll a[5];
    ll arg = 0;
    ll onesMin = 9;
    REP(i, 5) {
        cin >> a[i];
        ll onesPlace = a[i] % 10;
        if (onesPlace == 0 || onesMin <= onesPlace) continue;
        onesMin = onesPlace;
        arg = i;
    }
    ll ans = 0;
    REP(i, 5) {
        if (i == arg) continue;
        ans += ((ceil)((double)a[i] / (double)10) * 10);
    }
    ans += a[arg];
    print(ans);
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        if(a1 + a2 + a3 >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }

    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

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

}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 1015
#define INF 100000000005.0L
#define MOD 1000000007

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

struct edge{int to,cost;};

int V;
int N;
vector<edge> G[SIZE];
ll d[SIZE];

ll x[SIZE],y[SIZE],r[SIZE];

ll cost(int a,int b){
  return max(0.0L,sqrt(pow(x[a]-x[b],2.0)+pow(y[a]-y[b],2.0))-r[a]-r[b]);
}

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+N+3,INF);
  d[s] = 0.0L;
  que.push(P(0.0L,s));

  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(d[v] < p.first)continue;
    rep(i,1,N+2){
      if(i == v)continue;
      if(d[i] > d[v] + cost(v,i)){
        d[i] = d[v] + cost(v,i);
        que.push(P(d[i],i));
      }
    }
    /*
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
    */
  }
}


int main(){
  ll xs,ys,xt,yt;
  cin >> xs >> ys >> xt >> yt >> N;
  x[0]=xs;y[0]=ys;x[N+1]=xt;y[N+1]=yt;
  rep(i,1,N+1){
    cin >> x[i] >> y[i] >> r[i];
  }
  dijkstra(0);

  //cout << setprecision(20) << cost(2,1) << endl;

  cout << fixed << setprecision(20) << d[N+1] << endl;


  return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d; cin >> n;
    set<int> st;
    rep (i, n) {
        cin >> d; st.insert(d);
    }
    cout << st.size() << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,k;
    cin>>n>>k;
    vi p(n);
    rep(i,n) cin>>p[i];
    sort(all(p));
    lli ans=0;
    rep(i,k){
        ans+=p[i];
    }
    out(ans);
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

int main(){
    int N, sum_h=0;
    cin >> N;
    vector<int> h(N);
    for(int i=0; i<N; i++){
        cin >> h[i];
        sum_h += h[i];
    }

    vector<int> now(N);
    int ans = 0;
    for(int i=0; i<sum_h; i++){
        int g = 0, n = 0;
        for(int j=0; j<N; j++){
            if(h[j] != now[j]){
                if(n == 0){
                    g += 1;
                    n = 1;
                }
                now[j] += 1;
            }
            else n = 0;
        }
        ans += g;
        if(g == 0) break;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int N, M, K, ans = 0;
	int board[6][6] = { 0, };
	cin >> N >> M >> K;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++) {
			char c;
			cin >> c;
			if (c == '#')board[i][j] = 1;
		}

	for (int bitsY = 0; bitsY < (1 << N); bitsY++) {
		for (int bitsX = 0; bitsX < (1 << M); bitsX++) {
			int cnt = 0;
			for (int i = 0; i < N; i++) {
				if (bitsY&(1 << i))continue;
				for (int j = 0; j < M; j++) {
					if (bitsX&(1 << j))continue;
					if (board[i][j] == 1)cnt++;
				}
			}
			if (cnt == K)ans++;
		}
	}

	cout << ans;
}

Measured memory_bytes: 3628
#include <iostream>

#include<stdio.h>
using namespace std;

int main()
{
	int a,b,t;
	int c;
	while(scanf("%d%d%d",&a,&b,&t)!=EOF)
	{
	c=(t+0.5)/a;
	c=c*b;
	printf("%d\n",c);
	}

	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
struct objects{
    int weight,value;
};
ll solve(){
   int n,w;
   cin>>n>>w;
   objects object[n];
   int totalvalue=0;
   for(int i=0;i<n;i++){
       cin>>object[i].weight>>object[i].value;
       totalvalue+=object[i].value;
   }
   ll dp[n+1][totalvalue+1];
    //dp[i][j] denotes the least weight to get a value of
   // j from the first i objects
   dp[0][0]=0;//It takes 0 weight here
   int ans=0;
   for(int i=1;i<=totalvalue;i++){
       dp[0][i]=1e18;
      // Just set it arbitrarily large
       //because it's not possible
   }
   for(int i=0;i<n;i++){
       for(int j=0;j<=totalvalue;j++){
           if(j>=object[i].value){
                dp[i+1][j]=min(dp[i][j],dp[i][j-object[i].value]+object[i].weight);
                //Either don't choose this object(dp[i][j]) or choose this object
                //The value without it would be j-object[i].value
                //the minimum weight would be the minimum weight needed to
                //get a value of j- object[i].value and add the weight of this object.
           }
           else{
               //If I choose this object the value will go over j
               dp[i+1][j]=dp[i][j];
           }
           if(dp[i+1][j]<=w){//Is it possible to get value of j in less than w weight
               ans=max(ans,j);//Find maximum such j
           }
       }
   }
   return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<solve();
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int K;
    cin >> K;

    if(K % 2 == 0) cout << -1 << endl;
    else {
        int t = 7;
        if(t % K == 0) {
            cout << 1 << endl;
            return 0;
        }
        for(int i = 2; i <= K; ++i) {
            t = t * 10 + 7;
            t %= K;
            if(t == 0) {
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3652
#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;
	cout << 3 * N*N << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int MOD = 1000000007;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);

int main() {
	
	//B
	int n;
	cin >> n;
	int k;
	cin >> k;
	int i = 0;
	while (n > 0) {
		n = (int)(n / k);
		i++;
	}
	cout << i << endl;
	return 0;
	//C
	/*int n;
	cin >> n;
	int x[100];
	int i;
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	int sum, j, summin = 100000000;
	for (i = 0; i <= 100; i++) {
		sum = 0;
		for (j = 0; j < n; j++) {
			sum = sum + (x[j] - i) * (x[j] - i);
		}
		if (sum < summin)summin = sum;
	}
	cout << summin << endl;
	return 0;
	*/
	//D
	/*
	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a >> b;
	if (n == 2) {
		cout << 0 << endl;
		return 0;
	}
	long long int sum = 1;
	int i;
	long long int x = 2, m = n;
	//2^nを計算
	while (m > 0) {
		if (m % 2 == 1) {
			sum = (sum * x) % MOD;
		}
		m = (int)(m / 2);
		x = (x * x) % MOD;
	}

	//cout << 1 << endl;
	
	long long int sum1 = 1;
	for (i = 1; i <= a; i++) {
		sum1 = (sum1 * (n + 1 - i)) % MOD;
	}
	for (i = 1; i <= a; i++) {
		sum1 = (sum1 * modinv(i, MOD)) % MOD;
	}
	sum = (sum - sum1 + MOD) % MOD;
	//cout << 2 << endl;

	sum1 = 1;
	for (i = 1; i <= b; i++) {
		sum1 = (sum1 * (n + 1 - i)) % MOD;
	}
	for (i = 1; i <= b; i++) {
		sum1 = (sum1 * modinv(i, MOD)) % MOD;
	}
	sum = (sum - sum1 + MOD) % MOD;
	sum = (sum + MOD - 1) % MOD;
	cout << sum << endl;
	return 0;
	*/
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}

Measured memory_bytes: 3596
open Printf
open Scanf

let id x = x

let n = scanf "%d" id

let () =
    let r = ref 0 in
    let s = string_of_int n in
    String.iter (fun c -> r := !r + (int_of_char c - int_of_char '0')) s;
    if n mod !r = 0 then
        print_endline "Yes"
    else
        print_endline "No"


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n; cin >> n;

    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    // ll ans = 0;
    // rep(i, n){
    //     reps(j, i, n){
    //         ll tempxor = 0;
    //         ll tempsum = 0;
    //         reps(k, i, j+1){
    //             tempxor ^= a[k];
    //             tempsum += a[k];
    //         }

    //         if(tempxor == tempsum){
    //             ans++;
    //         }
    //     }
    // }

    int l = 0, r = 0;
    bool rmove = true;

    ll tempxor = a[r];
    ll ans = 1;



    while(true){

        // cout << l << " " << r << " " << tempxor << endl;

        if(r == n - 1) break;

        // cout << " " << tempxor << " " << a[r+1]   << endl;

        if( (tempxor & a[r+1]) != 0){
            tempxor -= a[l];
            l++;
            if(r < l){
                r = l ;
                ans++;
                tempxor = a[r];
            }
            // cout << "Ng" << endl;
        }
        else{
            tempxor ^= a[r+1];
            r++;
            ans += r - l + 1;
            // cout << "Ok" << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

bool Check(const std::vector<int> Wi, int k, int P)
{
    int p = 0;
    --k;
    for(int i = 0; i < Wi.size(); ++i){
        if(P - p >= Wi[i]){
            p += Wi[i];
        }else{
            p = Wi[i];
            --k;
        }
    }
    return k >= 0;
}
int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<int> Wi(n);
    for(int i = 0; i < n; ++i){
        std::cin >> Wi[i];
    }

    int MaxValue = *std::max_element(Wi.begin(), Wi.end());
    int MaxBad  = std::floor(std::accumulate(Wi.begin(), Wi.end(), 0) / k - 0.1);
    int MinGood = std::ceil(((double)n / k)) * MaxValue;
    while(MaxBad + 1 != MinGood){
        int P = (MaxBad + MinGood) / 2;
        if(MaxValue <= P && Check(Wi, k, P)){
            MinGood = P;
        }else{
            MaxBad = P;
        }
    }
    std::cout << MinGood << std::endl;
    return 0;
}

Measured memory_bytes: 1796
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////


signed main(){
  int r, d, x;cin>>r>>d>>x;
  rep(i,10){
    x = r*x-d;
    cout << x << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
long long a,b;
long long gcd(long long x,long long y)
{
	if(y == 0)	return x;
	return gcd(y,x%y);
}
int main()
{
	scanf("%lld%lld",&a,&b);
	printf("%lld",a * b / gcd(a, b));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
int S(int n) {
	return n * (n + 1) / 2;
}
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	int ans = 0;

	for (int k = K; k <= N + 1; k++) {
		(ans += (S(N) - S(N - k) - S(k - 1) + 1 + MOD) % MOD) %= MOD;
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
ll dp[4444][2222];

int main(){

	ll n,m,k;cin >> n >> m >> k;
	ll ans = 0;

	dp[0][0] = 1;

	REP(i,(n+m)/(k-1)){
		REP(j,m+1)if(dp[i][j]){
			REP(ii,k)if(j + ii <= m){
				dp[i+1][j+ii] += dp[i][j];
				dp[i+1][j+ii] %= MOD;
			}
			for(int ii = 1;ii < k;ii++){
				if(j + ii > m)continue;
				if(i * (k - 1) + k - j - ii > n)continue;
				if((m - j - ii) % (k - 1) != 0)continue;
				ans += dp[i][j];
				ans %= MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 68352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

int max(int x, int y) {
    if (x > y) return x;
    else return y;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    int a[N];
    rep(i ,N) cin >> a[i];
    int count = 0;
    count += max(0,a[0] - x);
    a[0] -= max(0,a[0] - x);
    count += max(0,a[N-1] - x);
    a[N-1] -= max(0,a[N-1] - x);
    //cout << count << endl;
    rep(i, N-2) {
        count += max(0,((a[i] + a[i+1]) - x ));
        a[i+1] -= max(0,((a[i] + a[i+1]) - x ));
    }
    count += max(0,((a[N-2] + a[N-1]) - x ));
    a[N-1] -= max(0,((a[N-2] + a[N-1]) - x ));
    //rep(i, N) cout << a[i] << " ";
    //cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int a, b, c;

void swap(int &x, int &y) {
    int tmp = x;
    x = y;
    y = tmp; 
} 

int main() {
    cin >> a >> b >> c;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    cout << a * 10 + b + c << endl; 
    
    return 0;
} 


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> count(3,0);
    for(int i=0;i<n;i++){
        ll A;
        cin>>A;
        if(A<=a){count[0]++;}
        else if(A<=b){count[1]++;}
        else{count[2]++;}
    }
    cout<<min(min(count[0],count[1]),count[2])<<endl;;
    
    
    return 0;
}

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

using namespace std;

struct Vector2{
	int x;
	int y;
};

Vector2 sample[1000];

Vector2 star[10000];

Vector2 ans, par;

int main(){
	int m, n;
	while(true){
		cin >> m;
		if(m == 0){
			break;
		}
		for(int i = 0; i < m; i++){
			cin >> sample[i].x >> sample[i].y;
		}
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> star[i].x >> star[i].y;
		}
		ans.x = 0;
		ans.y = 0;
		bool checker;
		for(int i = 0; i < n; i++){
			par.x = sample[0].x - star[i].x;
			par.y = sample[0].y - star[i].y;
			for(int j = 1; j < m; j++){
				checker = false;
				for(int k = 0; k < n; k++){
					if(sample[j].x == star[k].x + par.x && sample[j].y == star[k].y + par.y){
						checker = true;
						break;
					}
				}
				if(!checker){
					break;
				}
				if(j == m - 1){
					ans.x = par.x;
					ans.y = par.y;
				}
			}
		}
		printf("%d %d\n", -ans.x, -ans.y);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
ll k;
ll a[2000];
ll b[2000];

int main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	ll cnt = 0;
	rep(i,n) for (int j = i+1; j < n; j++) {
		if (a[i] > a[j]) cnt++;
	}
	ll ans = cnt * k % MOD;
	rep(i,n) {
		rep(j,n) if (a[j] < a[i]) b[i]++;
		ll tmp = k*(k-1)/2; tmp %= MOD;
		tmp = tmp * b[i] % MOD;
		ans = (ans + tmp) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
A=[int(input()) for i in range(n)]
l=[-A[0],1]#-にして小さい順から並ぶようにする
from bisect import *
for a in A[1:]:
    idx=bisect_left(l,-a+1)
    p=-l[idx]
    if p==-1:
        l[-1]=-a
        l.append(1)
    else:
        l[idx]=-a
print(len(l)-1)

Measured memory_bytes: 11848
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  string s;
  cin >> s;
  if(s == "keyence") {
    cout << "YES" << endl;
    return 0;
  }
  int n = s.size();
  for(int i = 0;i < n;i++) {
    for(int j = i + 1;j < n;j++) {
      string t = s.substr(0,i) + s.substr(j,n - j);
      if(t == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

public class Program
{
    static public void Main()
    {
        var s = new Sol();
        s.Solve1();
        s.Solve2();
        s.Solve3();
    }
}
public class Sol
{
    //ABC 054 C One-stroke Path
    //https://atcoder.jp/contests/abc054/tasks/abc054_c
    //ハミルトンパス
    //参考：https://atcoder.jp/contests/abc054/submissions/16082982
    public void Solve1()
    {
        int[] In = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        n = In[0];
        int m = In[1];

        L = new List<int>[n + 1];
        for(int u = 1; u <= n; u++)
        {
            L[u] = new List<int>();
        }
        for(int j = 0; j < m; j++)
        {
            int[] In2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = In2[0];
            int b = In2[1];
            L[a].Add(b);
            L[b].Add(a);
        }
        var V = new int[n + 1];
        var result = DFS(1, 1, V);
        Console.WriteLine(result.ToString());
    }
    static int n;
    static List<int>[] L;
    static int DFS(int current, int cnt, int[] V)
    {
        int result = 0;
        if (V[current] > 0) return 0;

        V[current] = cnt;
        if (cnt == n) return 1;
        foreach(int i in L[current])
        {
            var VV = V.Clone();
            result += DFS(i, cnt + 1, (int[])VV);
        }
        return result;
    }

    //
    //
    public void Solve2()
    {

    }

    //
    //
    public void Solve3()
    {

    }
}

Measured memory_bytes: 33084
/*à¥à¥*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* â€œStrength is the only thing that matters in this world. Everything else is just a delusion for the weak.â€ â€“ Vegeta */

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



ll A,B,K;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
 cin>>A>>B>>K;

 if(A>=K){
  cout<<A-K<<' '<<B<<'\n';
 }

 else if(A<K){
  K -= A; 
  A= 0;
  if(B>=K){
    cout<<0<<' '<<B-K<<'\n';
  }

  else{
    cout<<0<<' '<<0<<'\n';
  }
 }


}



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

  return 0;
}

Measured memory_bytes: 3616