akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    string S;
    cin >> S;

    int year = 0;
    for (int i = 0; i < 4; i++) {
        year = year * 10 + (S[i] - '0');
    }

    int month = (S[5] - '0') * 10 + (S[6] - '0');
    int day =  (S[7] - '0') * 10 + (S[8] - '0');

    bool heisei = false;
    if (year < 2019) {
        heisei = true;
    } else if (year == 2019) {
        if (month <= 4) {
            heisei = true;
        }
    }

    if (heisei) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
signed main() {
	string s, t;
	cin >> s >> t;
	if (s == t)puts("Yes");
	else {
		for (int i = 1; i < s.size(); i++) {
			if (s.substr(0, i) == t.substr(s.size() - i, i) && s.substr(i, s.size() - i) == t.substr(0, s.size() - i)) {
				puts("Yes");
				return 0;
			}
		}
		puts("No");
	}
	getchar(); getchar(); return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        REP(i,b){
            cout << a;
        }
    }
    else{
        REP(i,a){
            cout << b;
        }
    }
    cout << endl;
    return 0;
}

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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v,int n,bool visited[nmax]){
  bool all_visited =true;

  for(int i=0;i<n;i++){
    if(visited[i]==false)
      all_visited =false;
  }
  if(all_visited){
    return 1;
  }

  int ret =0;

  for(int i=0;i<n;i++){
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;

    visited[i]= true;
    ret += dfs(i,n,visited);
    visited[i]=false;
  }
  return ret;
}

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

  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }

  bool visited[nmax];
  for(int i=0;i<n;i++){
    visited[i]=false;
  }

  visited[0]=true;
  cout << dfs(0,n,visited) << endl;
  return 0;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    long k,n;
    cin >> n >> k;
    vec<long> h(n);
    for (auto &&e : h)
    {
        cin >> e;
    }
    sort(h.begin(),h.end());
    long ans = 1000000007;
    for (long i = 0; i+k-1 < n; i++)
    {
        ans = min(h.at(i+k-1) - h.at(i),ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    return a*b//gcd(a, b)

n = int(input())
t1 = int(input())
ans = t1
for _ in range(n-1):
    t2 = int(input())
    ans = lcm(ans, t2)
print(ans)


Measured memory_bytes: 9168
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

//二次元平面を探索しよう
template <typename T,typename U>                                                   
pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.first+r.first,l.second+r.second};                                    
} 

vector<pair<int, int>> nei;
void nei_init(){
	nei.push_back(make_pair(-1,0));nei.push_back(make_pair(1,0));nei.push_back(make_pair(0,-1));nei.push_back(make_pair(0,1));
	//4近傍なら以下をコメントアウト
	//nei.push_back(make_pair(-1,-1));nei.push_back(make_pair(1,-1));nei.push_back(make_pair(1,1));nei.push_back(make_pair(-1,1));
}

bool is_safe(pair<int, int> p, int h, int w){
	if(p.first < 0 || p.second < 0) return false;
	else if(p.first >=h || p.second >=w) return false;
	else return true;
}
//

int main() {
	ll ans = 0;
	ll tmp;
	int h, w; cin >> h >> w;
	int cx, cy, dx, dy; cin >> cx >> cy >> dx >> dy;
	cx--; cy--; dx--; dy--;
	vector<string> s(h);
	cin >> s;
	priority_queue<tuple<int, int, int>> q;
	bool ch[2000][2000] = {};
	q.push(make_tuple(0, cx, cy));
	nei_init();
	bool cho = false;
	while(!q.empty()){
		int wp, x, y;
		tie(wp, x, y) = q.top();
		q.pop();
		if(ch[x][y]) continue;
		ch[x][y] = true;
		//out << wp << " " << x << " " << y << endl;
		pair<int, int> here = make_pair(x, y);
		if(x==dx&&y==dy){
			cho = true;
			ans = -wp;
		}
		REP(i, nei.size()){
			if(is_safe(here+nei[i], h, w) && s[x+nei[i].first][y+nei[i].second] == '.'){
				q.push(make_tuple(wp, x+nei[i].first, y + nei[i].second));
			}
		}
		for(int wx = -2; wx <= 2; wx++){
			for(int wy = -2; wy <= 2; wy++){
				if(is_safe(make_pair(x+wx, y+wy), h, w) && (wx!=0||wy!=0) && s[x+wx][y+wy] == '.'){
					q.push(make_tuple(wp-1, x+wx, y+wy));
				}
			}
		}
	}
	if(cho)cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 12164
#include <stdio.h>

int main(void){
    int N,M,X,Y,Z;
    int x[100],y[100];
    int max,min;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    scanf("%d",&x[0]);
    max = x[0];
    for(int i=1;i<N;i++){
        scanf("%d",&x[i]);
        if(x[i] > max) max = x[i];
    }
    scanf("%d",&y[0]);
    min = y[0];
    for(int i=1;i<M;i++){
        scanf("%d",&y[i]);
        if(y[i] < min) min = y[i];
    }
    for(Z=-100;Z<=100;Z++){
        if(Z > X && Z <= Y && Z > max && Z <= min){
            printf("No War\n");
            break;
        }
    }
    if(Z==101){
        printf("War\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    int a[n],b[n],c[n-1];
    int ans = 0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
      cin>>b[i];
      ans += b[i];
    }
    for(int i=0;i<n-1;i++) cin>>c[i];
   // cout<<ans<<endl;
    for(int i=0;i<n-1;i++)
    {
      if(a[i] == a[i+1]-1)
      {
        ans += c[a[i]-1];
      }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
int memo[mxN][2];
int solve(int a, int turn) {
    if(memo[a][turn]!=-1)return memo[a][turn];
    if(turn==0) {
        //takahashi's turn
        if(a==1)return 1;
        if(a==0||a==2)return 0;
        //cout<<solve(a-1, turn^1)<<" "<<solve(a-2)
        return memo[a][turn] = solve(a-1, turn^1)|solve(a-2, turn^1);
    }else {
        //aoki's turn
        if(a==0||a==2)return 1;
        if(a==1)return 0;
        return memo[a][turn] = solve(a-1, turn^1)&solve(a-2, turn^1);
    }
}
int n;
vector<int> adj[mxN];
int dist[mxN];
void dfs(int u, int p=-1) {
    for(int v:adj[u]) {
        if(v^p) {
            dist[v] = dist[u]+1;
            dfs(v, u);
        }
    }
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    memset(memo, -1, sizeof(memo));
    int a, b;
    owo(i, 0, n-1) {
        cin>>a>>b;
        a--; b--;
        adj[a].senpai(b);
        adj[b].senpai(a);
    }
    int first = -1;
    dfs(0);
    int mx = 0;
    owo(i, 0, n) {
        if(dist[i]>mx) {
            mx = dist[i];
            first = i;
        }
    }
    dist[first] = 0;
    dfs(first);
    owo(i, 0, n) {
        if(dist[i]>mx) {
            mx = dist[i];
        }
    }
    //cout<<mx<<"\n";
    cout<<(solve(mx+1, 0) ? "First\n" : "Second\n");
    return 0;
}

Measured memory_bytes: 29320
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a[100010],b=0,c=0;
  cin>>n;
  fr(i,n) cin>>a[i];
  fr(i,n){
    if(a[i]>0) b+=a[i];
    else{
      c+=b/2;
      b=0;
    }
  }
  c+=b/2;
  cout<<c<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static double[] x, y, z;

	public static void main(String[] args) {
		int T = sc.nextInt();
		OUT: for (int i = 0; i < T; ++i) {
			double QR = sc.nextDouble();
			double RP = sc.nextDouble();
			double PQ = sc.nextDouble();
			int N = sc.nextInt();
			x = new double[N];
			y = new double[N];
			z = new double[N];
			for (int j = 0; j < N; ++j) {
				x[j] = sc.nextDouble();
				y[j] = sc.nextDouble();
				z[j] = sc.nextDouble();
			}
			for (int p = 0; p < N; ++p) {
				for (int q = 0; q < N; ++q) {
					if (q == p) continue;
					for (int r = 0; r < N; ++r) {
						if (r == p || r == q) continue;
						double qr = dist(q, r);
						double rp = dist(r, p);
						double pq = dist(p, q);
						if (Math.abs((rp / qr - RP / QR) / (RP / QR)) <= 0.001
								&& Math.abs((pq / qr - PQ / QR) / (PQ / QR)) <= 0.001) {
							System.out.println((p + 1) + " " + (q + 1) + " " + (r + 1));
							continue OUT;
						}
					}
				}
			}
		}
	}

	static double dist(int i, int j) {
		return Math.sqrt(sq(x[i] - x[j]) + sq(y[i] - y[j]) + sq(z[i] - z[j]));
	}

	static double sq(double v) {
		return v * v;
	}

}

Measured memory_bytes: 13000
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        h: usize,
        w: usize,
        board: [chars; h],
    }

    let mut ans = 0;

    let mut dp = vec![vec![0; h + 1]; w + 1];

    for i in 1..w + 1 {
        for j in 1..h + 1 {
            let x = i - 1;
            let y = j - 1;

            let left = if x < 1 {
                -1
            } else {
                dp[i - 1][j]
                    + if board[y][x - 1] != board[y][x] && board[y][x] == '#' {
                        1
                    } else {
                        0
                    }
            };

            let right = if y < 1 {
                -1
            } else {
                dp[i][j - 1]
                    + if board[y - 1][x] != board[y][x] && board[y][x] == '#' {
                        1
                    } else {
                        0
                    }
            };

            if left == -1 && right == -1 {
                dp[i][j] = if board[y][x] == '#' { 1 } else { 0 };
            } else if left == -1 {
                dp[i][j] = right;
            } else if right == -1 {
                dp[i][j] = left;
            } else {
                dp[i][j] = cmp::min(left, right);
            }

            //println!("{},{} {} {}", i, j, dp[i][j], dp[i][j - 1]);
        }
    }

    println!("{:?}", dp[w][h]);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const string YES = "Yes";
const string NO = "No";
Int N;
vector<uint> a;

void solve(){
	map<uint,int> s;
	for(auto t:a)s[t]++;
	if(s.size()==1){
		if(a[0]==0){
			cout<<YES<<endl;
		}else{
			cout<<NO<<endl;
		}
	}else{
		if(N%3!=0){
			cout<<NO<<endl;
		}else{
			int t = N/3;
			if(s.size()==2){
				if(s.begin()->first==0){
					if(s.begin()->second!=t){
						cout<<NO<<endl;
					}else{
						auto it = s.begin();
						it++;
						if(it->second!=t*2){
							cout<<NO<<endl;
						}else{
							cout<<YES<<endl;
						}
					}
				}else{
					cout<<NO<<endl;
				}
			}else if(s.size()==3){
				vector<uint> v;
				bool valid = true;
				for(auto p:s){
					v.push_back(p.first);
					if(p.second!=t)valid = false;
				}
				if(!valid){
					cout<<NO<<endl;
				}else{
					if((v[0]^v[1])==v[2] or
						(v[1]^v[2])==v[0] or 
						(v[2]^v[0])==v[1] ){
						cout<<YES<<endl;
					}else{
						cout<<NO<<endl;
					}
				}
			}else{
				cout<<NO<<endl;
			}
		}
	}
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	a.assign(N,Int());
	for(int i = 0 ; i < N ; i++){
		cin >> a[i];
	}
	solve();
	return 0;
}
//}}}


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

const int MOD = 1e9 + 7;
const int kN = 100000 + 5;
int n, T[kN], A[kN];
int v[kN];

int main()
{
    memset(v, -1, sizeof(v));
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) {
        scanf("%d", T + i);
    }
    for (int i = 1; i <= n; ++ i) {
        scanf("%d", A + i);
    }
    for (int i = 1; i <= n; ++ i) {
        if (T[i] != T[i - 1]) {
            v[i] = T[i];
        }
    }
    for (int i = n; i >= 1; -- i) {
        if (A[i] != A[i + 1]) {
            if (v[i] != -1 && v[i] != A[i]) {
                puts("0"); return 0;
            }
            v[i] = A[i];
        }
    }
    int result = 1;
    for (int i = 1; i <= n; ++ i) {
        if (v[i] > A[i] || v[i] > T[i]) {
            puts("0"); return 0;
        }
        if (v[i] == -1) {
            result = result * 1ll * std::min(A[i], T[i]) % MOD;
        }
    }
    printf("%d\n", result);
}

Measured memory_bytes: 1408
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,3){
    if(s.at(i)=='1')cnt++;
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxt[6] = {0, 0, -1, -1, 1, 1};
const int dyt[6] = {-2, 2, 1, -1, -1, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const int MOD = 1e9 + 7; //998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //rnd(chrono::high_resolution_clock::now().time_since_epoch().count())

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;

int32_t main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll k, a, b;
    cin >> k >> a >> b;
    if (a + 1 >= b)
    {
        cout << (k + 1);
        return 0;
    }
    if (k < a - 1)
    {
        cout << (k + 1);
        return 0;
    }
    b -= a;
    ll ans = a;
    k -= (a - 1);
    ans += (k / 2LL) * b;
    k %= 2;
    ans += k;
    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll N, A, B;
    cin >> N;
    if(N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  V v(n);
  VIN(v);
  I t=0;
  REP(i,n){
    for (I j=i+1;j<n;j++){
      t += v.at(i) * v.at(j);
    }
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  unordered_map<string, ll> mp{};
  REP(i, N) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  REP(i, s.size()) {
    mp[s[i]]--;
    ans += mp[s[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 13352
S_prime = input()
T = input()

# Tを含み条件を満たす文字列全てのリストを作る
S_list = []
for T_first_idx in range(len(S_prime) - len(T) + 1):
    ok_flg = 1
    for i in range(len(T)):
        if S_prime[T_first_idx+i] != "?" and S_prime[T_first_idx+i] != T[i]:
            ok_flg = 0
    if ok_flg == 1:
        S_list.append(S_prime[:T_first_idx] + T + S_prime[T_first_idx+len(T):])
        
if len(S_list) == 0:
    print("UNRESTORABLE")
else:
    print(min(S_list).replace("?", "a"))

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    ll sum = 0;
    int k; cin>>k;
    for(i = 1; i <= k; i++){
        for(j = 1; j <= k; j++){
            for(int m = 1; m <= k; m++){
                sum += __gcd(i,__gcd(j,m));
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BScoring {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int d; cin >> d;
      vector<ll> c(26);
      rep(i, 26) {
        cin >> c[i];
      }
      vector<vector<ll>> s(d, vector<ll>(26));
      rep(i, d) rep(j, 26) {
        cin >> s[i][j];
      }
      ll ret = 0;
      vector<ll> last(26);
      rep(i, d) {
        int t; cin >> t;
        t--;
        ret += s[i][t];
        last[t] = i+1;
        rep(j, 26) {
          ret -= c[j]*(i+1-last[j]);
        }
        cout << ret << '\n';
      }
    }
};

signed main() {
  BScoring solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	NO  = "No"
	YES = "Yes"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var X int
	scanner.Scan()
	X, _ = strconv.Atoi(scanner.Text())
	var Y int
	scanner.Scan()
	Y, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(X, Y))
}
func solve(X int, Y int) string {
	for i := 0; i <= X; i++ {
		if 2*i+4*(X-i) == Y {
			return YES
		}
	}
	return NO
}


Measured memory_bytes: 1760
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){


    double x1, y1, x2, y2, dist;
    cin >> x1 >> y1 >> x2 >> y2;

    dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));

    cout << fixed;
    cout << setprecision(8) << dist << endl;

    return 0;
}



Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
bool IsPrime[55000];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, sizeof(bool) * 55000);
	for(int i = 2; i < 55000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 55000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n)
	{
		int pos = 0;
		while(Prime[pos] < n)
		{
			pos++;
		}
		if(IsPrime[n])
		{
			cout << Prime[pos - 1] << " " << Prime[pos + 1] << endl;
		}
		else
		{
			cout << Prime[pos - 1] << " " << Prime[pos] << endl;
		}
	}
}

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

Measured memory_bytes: 0
N, K = map(int, input().split())
x, y = 0, 0
for i in range(1, N + 1):
    if i % K == 0:
        x += 1
    elif K % 2 == 0 and i % (K//2) == 0:
        y += 1
print(x ** 3 + y ** 3)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll bin(ll a, ll b) {
	//a%=m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a; //mod
        a = a * a; //mod
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll fact(ll x)
{
  ll res=1;
  for(ll i=1;i<=x;i++)
    res=(res*i)%mod;

  return res;
}

ll bcof(ll x,ll y) //x choose y
{
  return fact(x)*bin(fact(x-y)*fact(y)%mod,mod-2)%mod;
}

ll lmod(string n,ll x)
{
	
	ll res=0;
	for(ll i=0;i<n.length();++i)
	{
		res=(res*10+(int)n[i]-'0')%x;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
int main(void){
    int x;
    cin >> x;
    if (x == 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i = 0; i < 5; i++) {
            arr.add(sc.nextInt());
        }
        Collections.sort(arr, (a, b) -> {
            if(a % 10 == 0) 
                return -1;
            else if(b % 10 == 0)
                return 1;
            return b % 10 - a % 10;
        });
        int cnt = 0;
        for(int i = 0; i < arr.size(); i++) {
            
            int a = arr.get(i);
            if(a % 10 == 0 || i == arr.size() - 1)
                cnt += a;
            else
             cnt += ((a / 10) + 1) * 10;
        }
        System.out.println(cnt);
    }
}


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

int main()
{
	ios::sync_with_stdio(false);cout.tie(NULL);
	int a, b, x;
	while(cin >> a >> b >> x)
	{
		if (a > x)
			cout << "NO" << endl;
		else if (a <= x && b > x - a)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc158/b.cpp
 */

// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cstring>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  Point operator + (Point v) { return Point(x + v.x, y + v.y); }
  Point operator - (Point v) { return Point(x - v.x, y - v.y); }
  bool operator == (const Point &v) const {
    return x == v.x && y == v.y;
  }
  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


vector<Int> slice(vector<Int> &vec, int s, int t) {
  return vector<Int>(vec.begin()+s, vec.begin()+t);
}

vector<Int> trim(vector<Int> &vec, int n) {
  auto init = slice(vec, 0, n);
  auto tail = slice(vec, n+2, vec.size());
  init.insert(init.end(), tail.begin(), tail.end());
  return init;
}


// 10 1 1
// b r b r b r b r b r = 5
// 10 3 1
// b b b r b b b r b b = 
Int N, A, B;

void input() {
  cin >> N >> A >> B;
}


void solve() {
  Int c = A + B;
  Int n = N / c;
  Int m = N % c;
  Int ans = (n*A) + min(A, m);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c,k,d;
	d=0;
	scanf("%d %d %d",&a,&b,&c);
	for (k=a; k<=b; k++){
		if (c%k==0){
			d=d+1;
		}
	}
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep (i, n) {
        cin >> s[i];
    }
    sort(all(s));
    rep (i, n) {
        cout << s[i];
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7

#define rep(i,n) for(int i=1;i<=n;i++)
int main(){
   int a;
   cin >> a;
   if(a==25)
   cout << "Christmas" << endl;
   if(a==24)
   cout << "Christmas Eve" << endl;
   if(a==23)
   cout << "Christmas Eve Eve" << endl;
   if(a==22)
   cout << "Christmas Eve Eve Eve" << endl;
    
  }



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n; bool card[4][13]={};
    for (int i=0; i<4; i++) for (int j=0; j<13; j++) card[i][j]=false;
    cin>>n;
    char c;
    int r,t;
    for (int i=0; i<n; i++)
    {
        cin>>c>>r;
        if (c=='S') t=0;
        if (c=='H') t=1;
        if (c=='C') t=2;
        if (c=='D') t=3;
        card[t][r-1]=true;
    }
    for (int i=0; i<4; i++)
    {
        for (int j=0; j<13; j++)
        {
            if (!card[i][j])
            {
                if (i==0) cout<<"S ";
                if (i==1) cout<<"H ";
                if (i==2) cout<<"C ";
                if (i==3) cout<<"D ";
                cout<<j+1<<'\n';
            }
        }
    }
    return 0;
}



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

int n, m, d[500000], t[500000];

int main(){
  cin >> n;
  rep(i, n){
    cin >> d[i];
  }
  cin >> m;
  rep(i, n){
    cin >> t[i];
  }
  sort(d, d + n);
  sort(t, t + m);
  //rep(i, n) cerr << d[i] << endl; cerr << endl; rep(i, m) cerr << t[i] << endl;
  int itr = 0;
  bool flag = true;
  rep(i, m){
    while(true){
      cerr << t[i] <<" "<< d[itr] << endl;
      if(t[i] < d[itr] || itr >= n){
        flag = false;
        break;
      }
      if(t[i] == d[itr]){
        itr++;
        break;
      }
      itr++;
    }
    if(!flag){
      break;
    }
  }
  if(flag){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    string s,t;
    cin >> s >>t;
    ll ans = 0;
    for(ll i = 0; i < s.length();i++){
        if(s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    std::string s,t;
    cin>>s>>t;
    if(!t.empty()){
        t.resize(t.size()-1);
    }

    if(s == t){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

const double PI = acos(-1);

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    double c;
    if(x >= a * a * b / 2) {
        c = (a * a * a) / (2 * a * a * b - 2 * x); 
    } else {
        c = (2 * x) / (a * b * b);
    }
    ans = 90 - atan(c) * 180 / PI; 
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define range(x,l,r) (l<=x && x<r)
#define chmax(a,b) ((a) = max((a),(b)))
using namespace std;

const int dy[] = {0,1,0,-1}, dx[] = {1,0,-1,0};
int dp[50][50][4][1<<12];

inline int visit(int bit){
  int y=0, x=0;
  rep(i,6){
    int d = bit&3; bit>>=2;
    y += dy[d], x += dx[d];
    if(y==0 && x==0)return true;
  }
  return false;
}

int main(){
  int h,w,k;
  string g[50];
  cin >> h >> w >> k;
  rep(i,h)cin >> g[i];

  memset(dp,-1,sizeof(dp));
  dp[0][0][0][0] = isdigit(g[0][0])?(int)(g[0][0]-'0'):0;

  rep(rev,k+1){
    rep(y,h)rep(x,w){
      if(g[y][x] == '#')continue;
      rep(bit,1<<12){
	if(dp[y][x][rev][bit]<0)continue;

	rep(d,4){
	  int ny = y+dy[d], nx = x+dx[d];
	  if(!range(ny,0,h) || !range(nx,0,w))continue;
	  if(g[ny][nx] == '#')continue;

	  int nbit = ((bit<<2)|d) & ((1<<12)-1);
	  int item = isdigit(g[ny][nx])?(int)(g[ny][nx]-'0'):0;
	  if(visit(nbit))item = 0;

	  if(d<2){
	    chmax(dp[ny][nx][rev][nbit], dp[y][x][rev][bit] + item);
	  }else if(rev!=k){
	    chmax(dp[ny][nx][rev+1][nbit], dp[y][x][rev][bit] + item);
	  }
	}
      }
    }
  }

  int res = 0;
  rep(bit,1<<12)chmax(res, dp[h-1][w-1][k][bit]);
  cout << res << endl;
}

Measured memory_bytes: 161224
// * template

#include <bits/stdc++.h>
#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

// * solve

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n, m, k; cin >> n >> m >> k && n;) {
		vector<int> x(n);
		vector<double> forward(n), back(n);
		vector<double> dp(n + 1, 0.0);

		for(int i = 0; i < n; ++i) {
			int l, f, d, ud;
			cin >> x[i] >> l >> f >> d >> ud;
			if(ud == 1) {
				swap(f, d);
				dp[i] = static_cast<double>(l) / d;
			}

			forward[i] = static_cast<double>(l) / f;
			back[i] = static_cast<double>(l) / d;
		}

		vector<int> v(m);
		for(auto &e : v) cin >> e;

		double ans = INT_MIN;
		int prev_v = -1;

		for(int i = 0; i < m; ++i) {
			double t = 0.0;
			int pos = -i;

			for(int j = 0; j < n; ++j) {
				t = max(dp[j], t + static_cast<double>(x[j] - pos) / v[i]) + forward[j];
				dp[j] = t + max(back[j], 1.0 / v[i]);
				pos = x[j];
			}

			t += static_cast<double>(k - pos) / v[i];
			if(t < dp[n] + 1e-8) {
				t = dp[n];
			}
			else {
				prev_v = v[i];
			}

			ans = t;
			dp[n] = t + 1.0 / prev_v;
		}
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1272
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int diff(const string& A, const string& B) {
  int res = 0;
  for (int i = 0; i < A.size(); i++) {
    if (A[i] != B[i]) ++res;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  string S;
  while (cin >> S) {
    int N = S.size();
    string A(N, '0'), B(N, '0');
    for (int i = 0; i < N; i++) {
      A[i] = i % 2 == 0 ? '0' : '1';
      B[i] = i % 2 == 1 ? '0' : '1';
    }
    int res = min(diff(S, A), diff(S, B));
    cout << res << endl;
  }
  return 0;
}


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

int main() {
	int N, X;
	cin >> N >> X;
	int Length = 0;
	int count = 1;
	for (int i = 1; i <= N; i++) {
		int num;
		cin >> num;
		Length += num;
		count++;
		if (Length > X) {
			cout << i  << endl;
			return 0;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    const lint M = 1001000;
    // const lint M = 20;
    vector<vector<lint>> primes(M + 1, vector<lint>(0));
    for (int p = 2; p <= M; p++) {
        if (primes[p].size() != 0) continue;
        for (int pk = p; pk <= M; pk += p) {
            primes[pk].push_back(p);
        }
    }

    vector<lint> min_factor(M, 1);
    for (int p = 2; p <= M; p++) {
        if (min_factor[p] != 1) continue;
        for (int pk = p; pk <= M; pk += p) {
            if (min_factor[pk] == 1) min_factor[pk] = p;
        }
    }
    // dump(min_factor);

    lint G      = 0;
    rep(i, N) G = __gcd(G, A[i]);
    if (G != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    set<lint> used;
    for (int i = 0; i < N; i++) {
        // for (auto p : primes[A[i]]) {
        //     if (used.count(p) == 1) {
        //         cout << "setwise coprime" << endl;
        //         return 0;
        //     } else {
        //         used.insert(p);
        //     }
        // }

        // set<lint> primess{};
        // int a = A[i];
        // if (a == 1) continue;
        // while (a != 1) {
        //     primess.insert(a / min_factor[a]);
        //     a /= min_factor[a];
        // }
        for (auto p : primes[A[i]]) {
            if (used.count(p) == 1) {
                cout << "setwise coprime" << endl;
                return 0;
            } else {
                used.insert(p);
            }
        }
    }

    cout << "pairwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 88984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

bool p(ll x){
	if(x <= 1)
		return false;
	
	for(ll i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	
	return true;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll x;
	cin >> x;
	while(!p(x))
		x++;
	
	cout << x << endl;

	return 0;
}


Measured memory_bytes: 256