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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N;
void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>S;
	N=S.size();
	FOR(i,N) {
		if(i%2==0) {
			if(S[i]=='L') return _P("No\n");
		}
		if(i%2==1) {
			if(S[i]=='R') return _P("No\n");
		}
	}
	_P("Yes\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ps := make(map[int]int)
	for i := 1; i <= n; i++ {
		tmp := primeFactorize(i)
		for k, v := range tmp {
			ps[k] += v
		}
	}

	nums := make([][2]int, 0)
	for k, v := range ps {
		nums = append(nums, [2]int{k, v})
	}

	dp := [100][100]int{}
	dp[0][1] = 1
	for i := 0; i < len(nums); i++ {
		for j := 0; j <= 75; j++ {
			p := nums[i]
			for k := 0; k <= p[1]; k++ {
				dp[i+1][min(99, j*(k+1))] += dp[i][j]
			}
		}
	}

	fmt.Println(dp[len(nums)][75])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func primeFactorize(n int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			res[i]++
			n /= i
		}
	}
	if n != 1 {
		res[n]++
	}
	return res
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(Math.abs(x - a) > Math.abs(x - b)) {
			System.out.println("B");
		} else {
			System.out.println("A");
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Max_Flow{
    struct edge{
        int to; T cap; int rev;
        edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector<vector<edge>> es;
    vector<bool> used;
    const T INF_T;

    Max_Flow(int n) : INF_T(numeric_limits<T>::max()){
        es.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, T cap, bool directed = true){
        es[from].eb(to, cap, sz(es[to]));
        es[to].eb(from, directed? 0 : cap, sz(es[from])-1);
    }

    T dfs(int now, int t, T flow){
        if(now == t) return flow;
        used[now] = true;
        for(auto &e: es[now]){
            if(!used[e.to] && e.cap > 0){
                T f = dfs(e.to, t, min(flow, e.cap));
                if(f > 0){
                    e.cap -= f;
                    es[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t){
        T flow = 0;
        for(;;){
            fill(all(used), false);
            T f = dfs(s, t, INF_T);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(){
    int H, W;
    cin >> H >> W;
    int N = H*W;
    string S[H];
    rep(i, H) cin >> S[i];
    Max_Flow<int> G(3*N+2);
    int s = 3*N, t = 3*N+1;
    int sum = 0;
    rep(i, H){
        rep(j, W){
            if(S[i][j] == '.') continue;
            int p = W*i+j;
            G.add_edge(s, p, 1), G.add_edge(p, t, 1);
            int ni = i+1, nj = j+1;
            if(ni < H && S[ni][j] == '#'){
                int np = W*ni+j;
                sum--;
                G.add_edge(s, N+p, 1);
                G.add_edge(N+p, p, inf), G.add_edge(N+p, np, inf);
            }
            if(nj < W && S[i][nj] == '#'){
                int np = W*i+nj;
                sum--;
                G.add_edge(2*N+p, t, 1);
                G.add_edge(p, 2*N+p, inf), G.add_edge(np, 2*N+p, inf);
            }
        }
    }
    cout << sum+G.max_flow(s, t) << endl;
}


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

namespace AtCoderGrandContest041
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
			var total = inputs[0];
			var personA = inputs[1];
			var personB = inputs[2];

			var isBigA = personA >= personB;
			var sub = isBigA ? personA - personB : personB - personA;
			if (sub % 2 == 0)
			{
				Console.WriteLine(sub / 2);
			}
			else
			{
				var maxSub = Math.Max(total - personA, total - personB);
				var minSub = Math.Max(personA - 1, personB - 1);

				var isTop = Math.Min(maxSub, minSub) == maxSub;
				if (isTop)
				{
					if (isBigA)
					{
						var tmp = total - personA + 1;
						var result = (total - (personB + tmp)) / 2;
						Console.WriteLine(tmp + result);
					}
					else
					{
						var tmp = total - personB + 1;
						var result = (total - (personA + tmp)) / 2;
						Console.WriteLine(tmp + result);
					}
				}
				else
				{
					if (isBigA)
					{
						var tmp = personB - 1 + 1;
						var result = (personA - tmp - 1) / 2;
						Console.WriteLine(tmp + result);
					}
					else
					{
						var tmp = personA - 1 + 1;
						var result = (personB - tmp - 1) / 2;
						Console.WriteLine(tmp + result);
					}
				}
			}
		}
	}
}


Measured memory_bytes: 11348
#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>;
#define chmax(x,y) x = max(x,y);

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 6-a-b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll              long long int
#define nl              '\n'
using namespace std;

int now(int a, int b, int c) {
	if (a > b) {
		swap(a, b);
	}
	if (a > c) {
		swap(a, c);
	}
	if (b > c) {
		swap(b, c);
	}
	return a != b && b != c && a + b > c;
}


int main(void){

    ll t,b,c,d,k,r,n,m,x,y,mx,mi,f=0,sum=0,ans=0;
        cin>>n;
    ll a[n];

    for(ll i=0; i<n; i++){
        cin>>a[i];
    }
    //sort(a,a+n);
    ll cnt=0;

    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            for(ll k=j+1; k<n; k++){
                if(now(a[i],a[j],a[k]) ) cnt++;
            }
        }
    }
    cout<<cnt;
}



Measured memory_bytes: 3644
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    fast;
    ll k, ans=0;
    cin>>k;
    for(ll a=1;a<=k;a++)
    {
        for(ll b=1;b<=k;b++)
        {
            for(ll c=1;c<=k;c++)
            {
                ans=ans+__gcd(c,__gcd(a,b));
            }
        }
    }
    cout<<ans;
        return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(void)
{
	int H,W;
	int i,j;
	
	//i = 0;
	//j = 0;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("#");
			}
		printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L


const int mod = 998244353;



class UnionFind{
public:
    int uf[200005];
    UnionFind(){
        memset(uf,-1,sizeof uf);
    }
    
    int parent(int i){
        if (uf[i] < 0) return i;
        return uf[i] = parent(uf[i]);
    }
    
    void join(int i, int j){
        int pi = parent(i);
        int pj = parent(j);
        if (pi == pj) return;
        if (size(pi) < size(pj)) swap(pi,pj);
        uf[pi] += uf[pj];
        uf[pj] = pi;
        
    }
    
    int size(int i){
        int pi = parent(i);
        return abs(uf[pi]);
    }
    
    void init(){
        memset(uf,-1,sizeof uf);
    }
};





void solve(){
    
    int n,m;
    cin >> n >> m;
    UnionFind uf;
    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        uf.join(a,b);
    }
    
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if (uf.parent(i)==i){
            ans++;
        }
    }
    
    cout << ans-1;
}




int main() {
    int T;
    
    T = 1;
    //cin >> T;
    
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 4404
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        int max = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            max = Math.max(a[i], max);
        }
        if (n == 1) {
            if (a[0] == k) {
                System.out.println("POSSIBLE");
                return;
            } else {
                System.out.println("IMPOSSIBLE");
                return;
            }
        }

        int [] b = new int[n];
        int c = gcd(a[0], a[1]);
        b[0] = c;
        for (int i = 1 ; i < n ; i++) {
            b[i] = gcd(b[i - 1], a[i]);
        }

        if (k % b[n - 1] == 0 && k <= max) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }

    }

    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
int n;


int main(){
  int num[3];
  cin >> num[0] >> num[1] >> num[2];
  sort(num, num+3);
  cout << 10*num[2]+num[1]+num[0] << endl;
  return 0;
}

Measured memory_bytes: 256
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
ld DP[SIZE2][SIZE2];
bool finished[SIZE2][SIZE2];
ld A[SIZE];
string s, t;
ld solve2(LL x,LL t) {
	if (t == 0) return 1;
	if (x == 0) return 0;
	if (finished[x][t]) return DP[x][t];
	finished[x][t] = true;
	//cout << x<<" " <<t<<" "<<A[x]<<" "<<solve2(x - 1, t - 1)*A[x] <<" " << solve2(x - 1, t - 1)*A[x] + solve2(x - 1, t)*(1 - A[x])<< endl;
	return DP[x][t]=solve2(x-1,t-1)*A[x]+solve2(x-1,t)*(1-A[x]);
}
LL solve() {
	cin >> N ;
	EFOR(i,1, N) {
		cin >> A[i];
	}

	EFOR(i, 1, N) {
		if (i > N - i) {
			cout << solve2(N, i) << endl;
			return 0;
		}
	}
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 95872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        s.at(i) = s.at(i) + n;
        if (s.at(i) > 'Z') {
            s.at(i) = s.at(i) - 26;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 3656
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        System.out.println(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad" : "Good");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef vector<int> vi;

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

#define A 1
#define B 2
#define AB 0

vector<int> Sac, Tac;

inline int abab(int ch){
    switch (ch) {
    case 'A': return 1;
    case 'B': return 2;
    default: return 0;
    }
}

void reduce(string s, vector<int>& ac) {
    int L = s.size();
    ac.assign(L+1, 0);
    rep(i,L){
        ac[i+1] = (ac[i] + abab(s[i])) % 3;
    }
#ifdef DEBUG
    cerr << ac << endl;
#endif
}

bool query(int a, int b, int c, int d) {
    int d1 = (Sac[b] - Sac[a-1] + 3) % 3;
    int d2 = (Tac[d] - Tac[c-1] + 3) % 3;
#ifdef DEBUG
    cerr << vi(Sac.begin()+(a-1), Sac.begin()+b+1) << " " << "+AB"[d1] << endl;
    cerr << vi(Tac.begin()+(c-1), Tac.begin()+d+1) << " " << "+AB"[d2] << endl;
#endif
    return d1 == d2;
}

int main() {
    string S, T; cin >> S >> T;
    reduce(S, Sac);
    reduce(T, Tac);

    int q; cin >> q;
    rep(i, q){
        int a,b,c,d; cin >> a >> b >> c >> d;
        cout << (query(a,b,c,d) ? "YES":"NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
use std::thread;

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

fn is_ok(in_s: &[Vec<char>], h: usize, w: usize) -> bool {
    let h = h as i64;
    let w = w as i64;
    let hs = [h + 1, h - 1, h, h];
    let ws = [w, w, w + 1, w - 1];
    for (&h, &w) in hs.iter().zip(ws.iter()) {
        if 0 <= h
            && h < in_s.len() as i64
            && 0 <= w
            && w < in_s[h as usize].len() as i64
            && in_s[h as usize][w as usize] == '#'
        {
            return true;
        }
    }
    false
}

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let in_h: i64 = input.next().unwrap().parse().unwrap();
    let in_w: i64 = input.next().unwrap().parse().unwrap();
    let mut in_s: Vec<Vec<char>> = vec![];
    for _ in 0..in_h {
        let row = input.next().unwrap().chars().collect();
        in_s.push(row);
    }

    let mut ok = true;
    for h in 0..in_h as usize {
        for w in 0..in_w as usize {
            if in_s[h][w] == '#' {
                ok &= is_ok(&in_s, h, w);
            }
        }
    }
    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  sum+=P[N-1];
  K=N-2;
  if(K&1)flag=1;
  K/=2;
  num=N-1;
  while(K--){
    sum+=P[num-1]*2;
    num--;
  }
  if(flag)sum+=P[num-1];
  Out(sum);
}

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


const double EPS = 1e-10;
bool EQ(double a, double b){return fabs(a-b) < EPS;}

typedef complex<double> Point;
#define X real()
#define Y imag()

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

double dot(Point a, Point b){return real(conj(a) * b);}
double cross(Point a, Point b){return imag(conj(a) * b);}

// 線分の交差判定を使って、線分が交差していると判定し、
// かつ、線分が交点をもつ (重なっていない) 場合に使える
Point getCrossPointSS(Segment s1, Segment s2) {
  Point b = s2.p2 - s2.p1;
  double d1 = abs(cross(b, s1.p1 - s2.p1));
  double d2 = abs(cross(b, s1.p2 - s2.p1));
  double t = d1 / (d1 + d2);
  return s1.p1 + (s1.p2 - s1.p1) * t;
}

int main() {
  int q;
  cin>>q;
  for(int i=0;i<q;++i){
    int a,b,c,d,e,f,g,h;
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
    Line s1(Point(a,b), Point(c,d));
    Line s2(Point(e,f), Point(g,h));
    double x=getCrossPointSS(s1,s2).X;
    double y=getCrossPointSS(s1,s2).Y;
    printf("%.10f %.10f\n", x,y);
  }


  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll H,W;
  cin >> H >> W;
  if (H > W) {
    swap(H,W);
  }
  ll halfH = H / 2;
  ll halfW = W / 2;
  ll ans = 100000000000;
  if (H % 3 == 0 || W % 3 == 0) {
    ans = min(ans,0LL);
  }
  if (H >= 3) {
    ans = min(ans,H);
  }
  for (ll i = 1; i <= H - 1; i++) {
    ll S1 = i * W;
    ll S2 = (H - i) * halfW;
    ll S3 = (H - i) * (W - halfW);
    ll res = max({S1,S2,S3}) - min({S1,S2,S3});
    ans = min(ans,res); 
  }
  for (ll i = 1; i <= W - 1; i++) {
    ll S1 = i * H;
    ll S2 = (W - i) * halfH;
    ll S3 = (W - i) * (H - halfH);
    ll res = max({S1,S2,S3}) - min({S1,S2,S3});
    ans = min(ans,res); 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        struct xy {
            public int x;
            public int y;
        }
        public void Solve(ConsoleInput cin) {
            while(true) {
                var H = cin.ReadInt;
                var W = cin.ReadInt;
                if(W == 0 && H == 0) break;
                var Edge = new string('#', W);
                var Inside = '#' + new string('.', W - 2) + '#';
                Console.WriteLine(Edge);
                for(int i = 1; i < H - 1; i++) {
                    Console.WriteLine(Inside);
                }
                Console.WriteLine(Edge);
                Console.WriteLine("");
            }
        }
    }

    static class ExtendClass {
        public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



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

int main() {
  int n;
  cin >> n;
  int p[21];
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  int count = 0;
  for(int i = 0;i < n - 2;i++){
    if(p[i] > p[i + 1] && p[i + 1] > p[i + 2]){
      count++;
    }
    if(p[i] < p[i + 1] && p[i + 1] < p[i + 2]){
      count++;
    }
    if(p[i] == p[i + 1] && p[i + 1] < p[i + 2]){
      count++;
    }
    if(p[i] > p[i + 1] && p[i + 1] == p[i + 2]){
      count++;
    }
    if(p[i] == p[i + 2] && p[i + 1] < p[i + 2]){
      count++;
    }
  }
  cout << count << endl;
 }


Measured memory_bytes: 256
package main

import ("fmt")

func hoge(a int, b int) int {	
	if (a == 1 && b == 2) || (a == 2 && b == 1){
		return 3
	}else if (a == 1 && b == 3) || (a == 3 && b == 1) {
		return 2
	} else{
		return 1
	}
}

	func main(){
		var a, b int
		fmt.Scan(&a, &b)
		fmt.Println(hoge(a, b))
	}

Measured memory_bytes: 512
h,w=map(int,input().split())
if h*w%3:
  ans=min(h,w)
  for x in range(1,w+1):
    ans=min(ans,max(h*x,h//2*(w-x),(h-h//2)*(w-x))-min(h*x,h//2*(w-x),(h-h//2)*(w-x)))
  h,w=w,h
  for x in range(1,w+1):
    ans=min(ans,max(h*x,h//2*(w-x),(h-h//2)*(w-x))-min(h*x,h//2*(w-x),(h-h//2)*(w-x)))
  print(ans)
else:print(0)

Measured memory_bytes: 40496
a=list(map(int,input().split()))
if a[0]*2 == a[1]:
    print(str(a[0]))
elif a[0]*2 < a[1]:
    a[1]-=a[0]*2
    print(str(a[0]+int(a[1]/4)))
else:
    print(str(int(a[1]/2)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h, m, s;
		h = sc.nextInt();
		m = sc.nextInt();
		s = sc.nextInt();
		while (h != -1 && m != -1 && s != -1) {
			int rest = 120 * 60 - (h * 3600 + m * 60 + s);
			System.out.printf("%02d:%02d:%02d\n", rest / 3600, (rest % 3600) / 60, rest % 60);
			rest *= 3;
			System.out.printf("%02d:%02d:%02d\n", rest / 3600, (rest % 3600) / 60, rest % 60);
			
			h = sc.nextInt();
			m = sc.nextInt();
			s = sc.nextInt();
		}
	}
}

Measured memory_bytes: 26236
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
//const int MAX_INT = (1 << 31) - 1;

char used[1024 * 128];

int main() {

	int n, y;
	cin >> n >> y;
	int maxi = y / 1000;
	int findi = maxi - n;

	for (int i = 0; i <= findi; i++)
		used[i] = 0;
	
	used[0] = 1;
	for (int i = 0; i < findi; i++)
		if (used[i]) {
			used[i + 4] = 1;
			used[i + 9] = 1;
		}
		
	if (!used[findi]) {
		cout << "-1 -1 -1";
		return 0;
	}

	int one = maxi;
	int five = 0;
	int dec = 0;

	while (findi != 0) {
		if (findi - 9 >= 0 && used[findi - 9]) {
			findi -= 9;
			one -= 10;
			dec++;
		}
		else {
			findi -= 4;
			one -= 5;
			five++;
		}
	}

	if (one < 0) {
		cout << "-1 -1 -1";
		return 0;
	}
	cout << dec << " " << five << " " << one << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int make(int n);
int n,F[45];
int main(){

  scanf("%d",&n);
  make(n);
  printf("%d\n",F[n]);
  return 0;
}

int make(int n){
  if(n==0||n==1)
    return F[n]=1;
  if(F[n]!=0)
    return F[n];
  return F[n]=make(n-2)+make(n-1);
}

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

          #define pb push_back
          #define cend(s) return cout << s, 0;
          using namespace std;
          typedef long long ll;
	int fr[3232];
          int main()
          {
            string s;
            int k;
            cin >> k >> s;
            if(s.size() > k)
            {
              for(int i = 0; i < k; i++)
                cout << s[i];
              cout << "...";
            }
            else cend(s);
          }

Measured memory_bytes: 3592
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
#print(field)

L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]

#print(L)
for h in range(H):
  for w in range(W-1,-1,-1):
    if field[h][w] == "#":
      R[h][w] = 0
    elif w == W-1:
      R[h][w] = 1
    else:
      R[h][w] = R[h][w+1] + 1
#print(R)
for h in range(H-1,-1,-1):
  for w in range(W):
    if field[h][w] == "#":
      D[h][w] = 0
    elif h == H-1:
      D[h][w] = 1
    else:
      D[h][w] = D[h+1][w] + 1
#print(D)     
#print(U)
ans = 0
for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      L[h][w] = 0
    elif w == 0:
      L[h][w] = 1
    else:
      L[h][w] = L[h][w-1] + 1
    if field[h][w] == "#":
      U[h][w] = 0
    elif h == 0:
      U[h][w] = 1
    else:
      U[h][w] = U[h-1][w] + 1
    ans = max(ans,L[h][w] + R[h][w] + D[h][w] + U[h][w] - 3)

print(ans)

Measured memory_bytes: 313736
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<ctime>
#include<cstdlib>
#include<queue>
using namespace std;
#define N 806
#define ll long long
#define mp make_pair
ll read()
{
	ll f=1,x=0;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int t,n,x[N],st[N],dep[N],top,size,head[N],S,T,pre[10000020],cnt;
bool isp[10000020];
struct ndoe{
	int next,to,vlu;
}mem[N*N*4];
void add(int u,int v,int vlu)
{
	mem[++size].to=v;mem[size].next=head[u];head[u]=size;mem[size].vlu=vlu;
	mem[++size].to=u;mem[size].next=head[v];head[v]=size;mem[size].vlu=0;
}
void init()
{
	int top=1e7;
	isp[1]=1;
	for(int i=2;i<=top;++i)
	{
		if(!isp[i]) pre[++cnt]=i;
		for(int j=1;j<=cnt&&pre[j]*i<=top;++j)
		{
			isp[pre[j]*i]=1;
			if(i%pre[j]==0) break;
		}
	}
}
queue<int>q;
bool bfs(){
	memset(dep,0,sizeof(dep));
	dep[S]=1;
	q.push(S);
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=head[x];i;i=mem[i].next)
		{
			int v=mem[i].to;
			if(mem[i].vlu&&!dep[v])
			{
				dep[v]=dep[x]+1;
				q.push(v);
			}
		}
	}
	return dep[T];
}
int dfs(int x,int flow)
{
	if(x==T) return flow;
	int now,used=0;
	for(int i=head[x];i;i=mem[i].next)
	{
		int v=mem[i].to;
		if(mem[i].vlu&&dep[v]==dep[x]+1)
		{
			now=dfs(v,min(mem[i].vlu,flow-used));
			used+=now;
			mem[i].vlu-=now;
			mem[i^1].vlu+=now;
			if(used==flow) break;
		}
	}
	if(used!=flow) dep[x]=-1;
	return used;
}
int main()
{
//	freopen("light3.in","r",stdin);
//	freopen("B.out","w",stdout);
	init();
	t=1;
	while(t--)
	{
		top=0;
		size=1;
		memset(head,0,sizeof(head));
		n=read();
		for(int i=1;i<=n;++i) x[i]=read();
		for(int i=1;i<=n;++i)
		{
			st[++top]=x[i]-1;
			int now=x[i],r=i;
			while(x[r]==now&&r<=n) now++,r++;
			i=r-1;
			st[++top]=x[r-1];
		}
	//	for(int i=1;i<=top;++i) cout<<st[i]<<" ";cout<<'\n';
		S=top+1,T=S+1;
		int s1=0,s2=0;
		for(int i=1;i<=top;++i)
		{
			if(st[i]&1) add(S,i,1),s1++;
			else add(i,T,1),s2++;
			for(int j=i+1;j<=top;++j) if(st[j]-st[i]!=2&&!isp[st[j]-st[i]])
			if(st[i]&1) add(i,j,1);
			else add(j,i,1);
		}
		int k=0;
		
		while(bfs()) k+=dfs(S,1e9);
	//	cout<<"k"<<k<<" "<<s1<<" "<<s2<<'\n';
		cout<<k+2*((s1-k)/2+(s2-k)/2)+3*((s1-k)%2)<<'\n';
	}
	return 0;
}
/*
1
1
6
*/


Measured memory_bytes: 14720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll n, a, b, c, d, e;

  cin >> n >> a >> b >> c >> d >> e;

  ll x = min({a, b, c, d, e});

  cout << (n+x-1)/x + 4 << endl;



  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y,i,a,flg;
	scanf("%d %d",&x,&y);
	flg=0;
	for(i=0;i<=x;i++){
		a=i*4+(x-i)*2;
		if(a==y){
			flg=1;
			break;
		}
	}
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n+1);
	rep(i,n+1){
		int k=i;
		for(int j=2;j<=k;++j){
			while(k%j==0){
				a.at(j)++;
				k/=j;
			}
		}
	}
	ll ans=1,mod=1000000007;
	rep(i,n+1){
		ans*=a.at(i)+1;
		ans%=mod;
	}
	cout << ans << endl;
}

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

int main()
{
  string S, T;

  cin >> S >> T;

  int min_num = T.length();

  for (int i = 0; i < S.length() - T.length() + 1; i++)
  {
    int cnt = 0;
    for (int j = 0; j < T.length(); j++)
    {
      if (S.at(i + j) != T.at(j))
      {
        cnt++;
      }
    }
    min_num = min(min_num, cnt);
  }

  cout << min_num << endl;
}


Measured memory_bytes: 3588
a, b, c, d = map(int, input().split())
p = 0


while(c > 0):
    c = c - b
    if c <= 0:
        break
    a = a - d
    if a <= 0:
        p = 1
        break
if p == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1LL)res=res*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}
ll h[105];
ll h_min[205];
ll h_dif[205];
int l[205],r[205];
int w[205];
int siz;
vector<int> G[205];
ll dp1[205],dp2[205];

void build(int lx,int rx){
	l[siz]=lx;
	r[siz]=rx;
	h_min[siz]=h[lx];
	w[siz]=rx-lx;
	for(int i=lx;i<rx;i++){
		h_min[siz]=min(h_min[siz],h[i]);
	}
	h_dif[siz]+=h_min[siz];
	int par=siz;
	int prv=lx;
	for(int i=lx;i<rx;i++){
		if(h[i]==h_min[par]){
			if(i==prv){
				prv++;
			}else{
				siz++;
				G[par].push_back(siz);
				h_dif[siz]-=h_min[par];
				w[par]-=i-prv;
				build(prv,i);
				prv=i+1;
			}
		}
	}
	if(prv!=rx){
		siz++;
		G[par].push_back(siz);
		h_dif[siz]-=h_min[par];
		w[par]-=rx-prv;
		build(prv,rx);
	}
}

void solve(int v){
	if(h_dif[v]==0)w[v]=0;
	dp1[v]=1;
	dp2[v]=1;
	for(int i=0;i<G[v].size();i++){
		solve(G[v][i]);
		dp1[v]*=dp1[G[v][i]];
		dp1[v]%=MOD;
		dp2[v]*=(dp1[G[v][i]]+dp2[G[v][i]])%MOD;
		dp2[v]%=MOD;
	}
	dp2[v]=dp2[v]*mod_pow(2,w[v])%MOD;
	if(h_dif[v]>0)dp2[v]+=dp1[v]*(mod_pow(2,h_dif[v])-2)%MOD;
	dp2[v]%=MOD;
	if(dp2[v]<0)dp2[v]+=MOD;
	dp1[v]*=mod_pow(2,h_dif[v]);
	dp1[v]%=MOD;
}

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
	}
	build(0,n);
	solve(0);
	printf("%lld\n",dp2[0]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);

  int flag[B];
  int ans = 0;
  for(int i = 0;i < B;i++) flag[i] = 0;

  for(int i = 1;;i++){
    if((A*i)%B == C){
      ans = 1;
      break;
    }
    if(flag[(A*i)%B]) break;
    flag[(A*i)%B] = 1;
  }

  if(ans) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  cout << Z << ' ' << X << ' ' << Y << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

#define INF 1e9;
//#define mod 1e9+7

//#define max(x,y) (x>y)?x:y
//#define min(x,y) (x<y)?x:y
#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define mi(n) (int*)malloc(sizeof(int)*n);
#define mc(n) (char*)malloc(sizeof(char)*n);

using namespace std;
int mod=1000000007;

int main(){
    bool judge=true;
   string s,ss;
   getline(cin,s);
   getline(cin,ss);
   
   if(s.length()<ss.length()) cout<<"LESS"<<endl;
   else if(s.length()>ss.length())cout<<"GREATER"<<endl;
   else{
       rep(i,0,s.length()){
           if(s[i]<ss[i]){
               cout<<"LESS"<<endl;
               judge=false;
                break;   
           }
           else if(s[i]>ss[i]){
               cout<<"GREATER"<<endl;
               judge=false;
                break;   
           }
           else continue;
       }
       
       if(judge) cout<<"EQUAL"<<endl;
   }
   
    return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;


int main(void) {
   ll N;
   cin>>N;
   ll Xc = N/1.08;
   bool flag = false;
   ll X = 0;
   rep(i,-10,10) {
      X = Xc+i;
      if ((ll)(X*1.08) == N) {
         flag = true;
         break;
      }
   }
   if (flag) cout<<X<<endl;
   else cout<<":("<<endl;





   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

int seg[400005],lz[400005];

void build(int ver,int tl,int tr)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
    {
        seg[ver]=1e17;
        lz[ver]=1e17;
    }
    else
    {
        int tm=(tl+tr)/2;
        build(2*ver,tl,tm);
        build(2*ver+1,tm+1,tr);
        seg[ver]=1e17;
        lz[ver]=1e17;
    }    
}

void push_lz(int ver)
{
    seg[ver]=min(seg[ver],lz[ver]);
    seg[2*ver]=min(seg[2*ver],lz[ver]);
    seg[2*ver+1]=min(seg[2*ver+1],lz[ver]);
    lz[2*ver]=min(lz[2*ver],lz[ver]);
    lz[2*ver+1]=min(lz[2*ver+1],lz[ver]);
    lz[ver]=1e17;
}


void upd(int ver,int tl,int tr,int l,int r,int val)
{
    if(tl>tr||l>r||tr<l||r<tl)
        return ;
    else if(tl==l&&tr==r)
    {
        seg[ver]=min(seg[ver],val);
        lz[ver]=min(val,lz[ver]);
    }
    else
    {
        int tm=(tl+tr)/2;
        if(lz[ver]!=1e17)
            push_lz(ver);
        upd(2*ver,tl,tm,l,min(tm,r),val);
        upd(2*ver+1,tm+1,tr,max(tm+1,l),r,val);
        seg[ver]=min(seg[2*ver],seg[2*ver+1]);
    }    
}

int get(int ver,int tl,int tr,int l,int r)
{
    if(tl>tr||l>r||tr<l||r<tl)
        return 1e17;
    else if(tl==l&&tr==r)
        return seg[ver];
    else
    {
        int tm=(tl+tr)/2;
        if(lz[ver]!=1e17)
            push_lz(ver);
        seg[ver]=min(seg[2*ver],seg[2*ver+1]);
        return min(get(2*ver,tl,tm,l,min(tm,r)),get(2*ver+1,tm+1,tr,max(tm+1,l),r));
    }    
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    int l,r,c;
    vector<pair<pair<int,int>,int> >pp;
    for(int i=0;i<m;i++)
    {
        cin>>l>>r>>c;
        pp.push_back({{l,r},c});
    }
    sort(pp.begin(),pp.end());
    build(1,1,n);
    upd(1,1,n,1,1,0);
    for(auto i:pp)
    {
        int z=get(1,1,n,i.first.first,n);
        z+=i.second;
        upd(1,1,n,i.first.first+1,i.first.second,z);
        // for(int j=1;j<=n;j++)
        // {
        //     // cout<<get(1,1,n,j,j)<<" ";
        // }
        // cout<<'\n';
    }
    int z=get(1,1,n,n,n);
    if(z<1e17)
        cout<<z;
    else
        cout<<-1;
    
} 
    


Measured memory_bytes: 9660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

ll dp[1<<16];

int main(){
	int n;
	while (cin >> n, n){
		vector<int> v(n), w(n);
		rep(i, n){
			int m;
			cin >> m >> v[i];
			while (m--){
				int s, e;
				cin >> s >> e;
				for (int x = s; x < e; ++x){
					w[i] |= 1 << (x - 6);
				}
			}
		}


		MEMSET(dp, -1);
		dp[0] = 0;
		rep(i, n) rep(j, 1<<16){
			if (dp[j] < 0) continue;
			if (j&w[i]) continue;
			dp[j|w[i]] = max(dp[j|w[i]], dp[j] + v[i]);
		}
		cout << *max_element(dp, dp + (1 << 16)) << endl;
	}

	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll N,K,S;
	cin >> N >> K >> S;
	vector<ll> ans;
	FOR(i,0,K){
		ans.push_back(S);
	}
	FOR(i,K,N){
		if(S==1)S+=5;
		ans.push_back(S-1);
	}
	FOR(i,0,N){
		cout << ans[i] << (i==N-1?'\n':' ');
	}
}


Measured memory_bytes: 2164
#include<stdio.h>
#include<iostream>

int A, B, C, D;

int main(){
    scanf("%d %d %d %d", &A, &B, &C, &D);

    if(A + B < C + D)
        std::cout << "Right";
    else if(A + B > C + D)
        std::cout << "Left";
    else
        std::cout << "Balanced";
    return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int gcd(int x,int y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    else return gcd(y,x%y);
}

int main(){
    int x,y;
    cin>>x>>y;
    cout<<x+y-gcd(x,y)+1<<endl;

}



    


Measured memory_bytes: 3096
arr = [input() for i in range(4)]
count = 0
sum = 0
for fihun in range(int(arr[0]) + 1):
    for hun in range(int(arr[1]) + 1):
        for fi in range(int(arr[2]) + 1):
            sum = fihun * 500 + hun * 100 + fi * 50
            if sum == int(arr[3]):
                count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int nax = 3005;
#define ll long long

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<ll>> dp(nax,vector<ll>(nax,0));
    
    for(auto &it:a)
    {
        cin >> it;
    }

    for(int i=n-1;i>=0;--i)
    {
        for(int j=i;j<n;++j)
        {
            if(i==j)
            dp[i][j]=a[i];
            else
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    
   cout << dp[0][n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 73972