akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=300010;
int a[N];
int main(){
    int n,i,j=1;long long ans=0;
    scanf("%d",&n);
    for(i=1;i<=3*n;i++) scanf("%d",&a[i]);
    sort(a+1,a+3*n+1,greater<int>());
    for(i=2;j<=n;i+=2,j++) ans+=a[i];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int mypow(int a,int b){
	if(b==0) return 1;
	if(b%2) return mypow(a,b-1)*a%mod;
	int z=mypow(a,b/2);
	return z*z%mod;
}
signed main(){
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a,a+5);
	int x;
	cin>>x;
	if(a[4]-a[0]>x) puts(":(");
	else puts("Yay!");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a[200001];
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  if(a[n/2]==a[n/2-1]) cout << 0 << endl;
  else cout << (a[n/2]-a[n/2-1]) << endl;
  return 0; 
}

Measured memory_bytes: 640
import java.util.Scanner;

// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long H = sc.nextInt();//行
		long W = sc.nextInt();//列
		sc.close();

		long a;

		if(H==1) {
			System.out.println(1);
			return;
		}
		if(W==1) {
			System.out.println(1);
			return;
		}

		if (W % 2 == 0) {
			a = W / 2;
			System.out.println(a * H);
		} else {
			a = W / 2 + 1;
			if (H % 2 == 0) {
				long A = H / 2;
				System.out.println(a * A + (a - 1) * A);
			} else {
					long A = H / 2;
					System.out.println((2 * a - 1) * A + a);
			}
		}

	}
}

Measured memory_bytes: 21716
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        t_vec: [isize; n],
        m: usize,
        px_vec:[(usize, isize); m],
    }

    let sum: isize = t_vec.iter().sum();

    for (p, x) in px_vec.into_iter() {
        println!("{}", sum - t_vec[p-1] + x)
    }

    println!("", );
}


Measured memory_bytes: 2128
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, s: "List[int]", c: "List[int]"):

    dict = {}
    ans = "1"
    if N == 1:
        ans = "0"
    for i in range(N-1):
        ans += "0"

    for i in range(len(s)):
        if s[i] == 1 and c[i] == 0 and N != 1:
            print(-1)
            return
        # dup check
        if s[i] in dict.keys():
            if dict[s[i]] != c[i]:
                print(-1)
                return
        else:
            dict[s[i]] = c[i]

        ans = ans[:s[i]-1] + str(c[i]) + ans[s[i]:]
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i, n) cin >> a[i+1];
  vector<int> ans(n+1);
  vector<int> out;
  for (int i = n; i >= 1; i--) {
    int x = 0;
    for (int j = i*2; j <= n; j += i) {
      x ^= ans[j];
    }
    ans[i] = x ^ a[i];
    if (ans[i] != 0) {
      out.push_back(i);
    }
  }
  cout << out.size() << endl;
  rep(i, out.size()) cout << out[i] << '\n';
}

Measured memory_bytes: 3192
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	void submit() {
		int a = nextInt();
		int b = nextInt();
		int ab = nextInt();
		int x = nextInt();
		int y = nextInt();
		
		int ret = Integer.MAX_VALUE;
		for (int c = 0; c <= Math.max(x, y); c++) {
			
			int cost = 2 * c * ab + Math.max(x - c, 0) * a + Math.max(y - c, 0) * b;
			ret = Math.min(ret, cost);
			
		}
		
		out.println(ret);
	}

	void test() {

	}

	void stress() {
		for (int tst = 0;; tst++) {
			if (false) {
				throw new AssertionError();
			}
			System.err.println(tst);
		}
	}

	Main() throws IOException {
		is = System.in;
		out = new PrintWriter(System.out);
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();
	static final int C = 5;

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	private InputStream is;
	PrintWriter out;

	private byte[] buf = new byte[1 << 14];
	private int bufSz = 0, bufPtr = 0;

	private int readByte() {
		if (bufSz == -1)
			throw new RuntimeException("Reading past EOF");
		if (bufPtr >= bufSz) {
			bufPtr = 0;
			try {
				bufSz = is.read(buf);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufSz <= 0)
				return -1;
		}
		return buf[bufPtr++];
	}

	private boolean isTrash(int c) {
		return c < 33 || c > 126;
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isTrash(b))
			;
		return b;
	}

	String nextToken() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	String nextString() {
		int b = readByte();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	char nextChar() {
		return (char) skip();
	}

	int nextInt() {
		int ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}

	long nextLong() {
		long ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
 
#define N 100000
int main() {
    int i,j,k,n;
    cin>>n;
    int arr[N+1][3], dp[N+1][3];;
    for(i=0;i<n;i++)  {
        cin>>arr[i][0] >> arr[i][1] >> arr[i][2];
        for(j=0;j<3;j++) dp[i][j] = 0;
    }
    for(i=0;i<3;i++) {
        dp[0][i] = arr[0][i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<3;j++) {
            for(k=0;k<3;k++) {
                if(j==k) continue;
                dp[i+1][k] = max(dp[i+1][k],dp[i][j] + arr[i+1][k]);
            }
        }
    }
    int mx = dp[n-1][0];
    for(i=1;i<3;i++) {
        mx = max(dp[n-1][i],mx);
    }
    cout << mx << endl;
}

Measured memory_bytes: 2560
x,k,d = map(int,input().split())
x = abs(x)
num = x//d
if k >= num:
    x -= num*d
    cnt = k-num
else:
    x -= k*d
    print(x)
    exit()
#print(x,k,d,cnt)
if abs(x) > abs(x-d):
    x -= d
    cnt -= 1
#print(x,k,d,cnt)
if cnt%2 == 0:
    print(abs(x))
else:
    print(abs(abs(x)-abs(d)))

Measured memory_bytes: 9068
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string s;
	int a=0;
		cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == 'C') {
			for (int j = i;j < s.length();j++) {
				if (s[j] == 'F') {
					a=1;
					goto hoge;
				}
			}
		}
	}
	hoge:
	if (a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


input = sys.stdin.readline
n, q = map(int, input().split())
info = [tuple(map(int, input().split())) for i in range(n-1)]
p = [tuple(map(int, input().split())) for i in range(q)]

tree = [[] for i in range(n)]
for i in range(n-1):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)

memo = {}
for i in range(n):
    memo[i] = 0
for i in range(q):
    memo[p[i][0] - 1] += p[i][1]

dp = [0] * n
visited = [False]*n
q = deque([0])
visited[0] = True
dp[0] = memo[0]

while q:
    pos = q.popleft()
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        dp[next_pos] += dp[pos] + memo[next_pos]
        q.append(next_pos)
print(*dp)


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

using namespace std;

int main()
{
    int n,m,count=0,penalty=0;
    cin>>n>>m;
    int p,p1[m];
    string s1[m],s;
    set <int> ac;
    map <int,int> wa;
    for(int i=0; i<m; i++)
    {
        cin>>p1[i]>>s1[i];
    }
    for(int i=0; i<m; i++){
        p=p1[i];
        s=s1[i];
        if(s=="WA"){
                if(ac.find(p)==ac.end()){
                if(wa.count(p)==0) wa[p]=1;
                else wa[p]++;
                }
            }
        else if(s=="AC")
        {
            if(ac.find(p)==ac.end())
            {
                count++;
                ac.insert(p);
                if(wa.count(p)!=0) penalty+=(wa[p]);
            }
        }
    }
    cout<<count<<" "<<penalty;
    return 0;
}


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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> iP; // firstはsからの最短距離, secondは頂点の番号

const int max_n = 1e6;
const int INF = 1e9;

struct edge {P to; int cost;};
map<P, vector<edge>> g;
map<P, int> d;

int n;

void dijkstra(P s){
	d[s] = 0;

	priority_queue<iP,vector<iP>,greater<iP> > que;
	que.push(iP(0,s));

	while(!que.empty()){
		iP p = que.top();
		que.pop();

		P v = p.second;
		if(d.find(v) != d.end() && d[v] < p.first) continue; //後から最短パスが見つかった場合、先にqueに入っているものはここではじかれる

		for(int i = 0; i < g[v].size(); i++){
			edge e= g[v][i];
			if(d.find(e.to) == d.end() || d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(iP(d[e.to], e.to));
			}
		}
	}
}

void show_g(){
	for(auto x : g){
		for(auto y : x.second){
			cout << x.first.first 
			     << "," << x.first.second
			     << "," << y.to.first
			     << "," << y.to.second
			     << "," << y.cost << endl;
		}
	}
}

void show_d(){
	for(auto x : d){
		cout << x.first.first 
		     << "," << x.first.second
		     << "," << x.second << endl;
	}
}

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

	int m;
	cin >> n >> m;

	rep(i, m){
		int p, q, c;
		cin >> p >> q >> c;

		//同じ色の駅に長さ0の辺を張る
		g[P(p, c)].push_back((edge){P(q, c), 0});
		g[P(q, c)].push_back((edge){P(p, c), 0});

		//色付き駅から無色駅へ長さ0の辺を張る
		g[P(p, c)].push_back((edge){P(p, -1), 0});
		g[P(q, c)].push_back((edge){P(q, -1), 0});

		//無色駅から色付き駅へ長さ1の辺を張る
		g[P(p, -1)].push_back((edge){P(p, c), 1});
		g[P(q, -1)].push_back((edge){P(q, c), 1});
	}

	// show_g();

	dijkstra(P(1,-1));

	// cout << endl;	
	// show_d();

	if(d.find(P(n,-1)) == d.end())	{
		cout << -1 << endl;
	}else{
		cout << d[P(n, -1)] << endl;
	}
}

Measured memory_bytes: 91700
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    int n,end=0;
    cin>>n;
    string s;
    cin>>s;
    vector<int> s1(11,0),s2(101,0),s3(1001,0);
    rep(i,0,n){
        int d=s[i]-'0';
        rep(j,0,100)if(s2[j])s3[j*10+d]=1;
        rep(j,0,10)if(s1[j])s2[j*10+d]=1;
        s1[d]=1;
    }
    rep(i,0,1001)if(s3[i])end++;
    cout<<end<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class  Main {
    static Integer n, arr[];
    static long mod = 998244353;

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;


        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int s=sc.nextInt();
        int w=sc.nextInt();
        if ( w>=s ) System.out.println("unsafe");
        else System.out.println("safe");
    }
}

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

int main(){
  int n,m,b;
  cin >> n;
  map<int,int>tmt;
  for(int i=0;i<n;i++){
    cin >> b;
    tmt[b]++;
  }
  cin >> m;
  map<int,int>hty;
  for(int i=0;i<m;i++){
    cin >> b;
    hty[b]++;
  }
  bool ans=true;
  for(auto x:hty){
    if(tmt[x.first]<x.second)
      ans=false;
  }
  cout << (ans?"YES":"NO") << endl;
  return 0;
}

Measured memory_bytes: 22356
N = input()
K = int(input())

L = len(N)
dp = [[[0]*(K+2) for _ in range(2)] for _ in range(L+1)]
dp[0][0][0] = 1

for i in range(1,L+1):
    a = int(N[i-1])
    for k in range(K+1):
        dp[i][0][k] += dp[i-1][0][k] if a==0 else dp[i-1][0][k-1]
        dp[i][1][k] += dp[i-1][1][k-1]*9 + dp[i-1][1][k]
        if a>0:
            dp[i][1][k] += dp[i-1][0][k-1]*(a-1) + dp[i-1][0][k]

print(dp[L][0][K]+dp[L][1][K])

Measured memory_bytes: 62440
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2040
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? (a=b,1) : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

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

    const auto f = [](i64 n) {
        return (n & 1) ? 3*n + 1 : n/2;
    };

    i64 s;
    cin >> s;

    unordered_set<i64> U;
    U.emplace(s);

    i64 now = s;

    int cnt = 1;

    while(true) {
        i64 k = f(now);
        ++cnt;
        if (U.count(k)) {
            break;
        }

        U.emplace(k);
        now = k;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    FasterIO
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n, = map(int, input().split())
a = list(map(int, input().split()))
a.append(0)
m = []

i = 0
j = a[0]
s = abs(a[0])
for x in range(1, n+1):
    k = a[x]
    s += abs(j-k)
    if i<=j<=k or k<=j<=i:
        m.append(0)
    else:
        ij = abs(i-j)
        jk = abs(j-k)
        if ij<jk:
            m.append(-2*ij)
        else:
            m.append(-2*jk)
    i = j
    j = k
for x in m:
    print(s+x)

Measured memory_bytes: 14048
# https://atcoder.jp/contests/abc133/tasks/abc133_e

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())

    edges = defaultdict(list)
    for _ in range(n - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(b)
        edges[b].append(a)

    # print(edges)
    patterns = [-1] * n
    # dfs
    stack = deque()
    patterns[0] = k

    rest = k - 1
    for neighbor in edges[0]:
        patterns[neighbor] = max(0, rest)
        rest -= 1
        stack.append(neighbor)

    while len(stack) > 0:
        node = stack.pop()

        rest = k - 2
        for neighbor in edges[node]:
            if patterns[neighbor] == -1:
                patterns[neighbor] = max(0, rest)
                rest -= 1
                stack.append(neighbor)

    ans = 1
    for p in patterns:
        ans = ans * p % mod

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    string s;
    cin >> s;
    int n = s.size() - 1;
    ll sum = 0;
    for(int bit = 0; bit < (1<<n) ; bit++){ 
        ll num = s[0] - '0'; 
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){     
                sum += num;
                num = 0;
            }
            num = num * 10 + s[i+1] - '0';
        }
        sum += num;
    }


    cout << sum << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, D, x;
  cin >> N >> D;
  int ans = 0;

  vector<vector<int>> vec(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x;
      vec.at(i).at(j) = x;
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      double dst = 0;
      for (int k = 0; k < D; k++) {
        dst += abs(vec.at(i).at(k) - vec.at(j).at(k))*abs(vec.at(i).at(k) - vec.at(j).at(k));
      }
      double r;
      double f = modf(sqrt(dst), &r);
      if(f == 0) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
char A;
char B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;

	if( A < B )
		cout << "<" << endl;
	else if( A > B )
		cout << ">" << endl;
	else
		cout << "=" << endl;

	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
    int A,B,C;
	cin >> A >> B >> C;
	if(A < B) swap(A,B);
	if(A < C) swap(A,C);
	int ans = (A-B)/2 + (A-C)/2;
	if((A-B)&1){
		if((A-C)&1) ++ans;
		else ans += 2;
	} else if((A-C)&1) ans += 2;
	cout << ans << endl;
	return 0;
}  

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

using namespace std;

const int N = 345;

int n, m;
int a[N][N];
int cnt[N];

int solve(int step = m) {
  int ret = 1 << 30;
  if (step == 0) return ret;
  for (int i = 0; i <= m; i++) cnt[i] = 0;
  int best = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cnt[a[i][j]]++;
      if (a[i][j] > 0 && cnt[a[i][j]] > cnt[best]) best = a[i][j];
      if (a[i][j] > 0) break;
    }
  }
  for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (a[i][j] == best) a[i][j] = 0;
  int cnt_best = cnt[best];
  ret = min(cnt_best, solve(step - 1));
  return ret;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", a[i] + j);
  int ans = solve();
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
int n , m ;
const int nmax = 1005 ;
string a[nmax];
int dist[nmax][nmax]={-1};
void solve(){
    cin >> n >> m ;
    for( int  i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    queue < pair < int , int > > q ;
    for( int i = 0 ; i < n ; i++){
        for( int j = 0 ; j < m ; j++){
                dist[i][j]=inf;
            if(a[i][j]=='#'){
                q.push({i,j});
                dist[i][j]=0;
            }
        }
    }
    int c=0;
    while(!q.empty()){
        c++;
        int row = q.front().ff;
        int col = q.front().ss;
        q.pop();
        for( int i = 0 ; i < 4 ; i++){
            int r = row + dx[i];
            int c = col + dy[i];
            if(r>=0 & r<n && c >=0 && c<m && dist[r][c]>dist[row][col]+1){
                q.push({r,c});
                dist[r][c] = dist[row][col]+1;
            }
        }
    }
    int maxm = -1 ;
    for( int i = 0 ; i< n ; i++){
        for( int j = 0 ; j < m ; j++){
                //cout << dist[i][j] <<  " ";
            maxm = max(maxm,dist[i][j]);
        }
        //cout << "\n";
    }
    cout << maxm ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define sz(x) x.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return (a * b) / gcd(a,b);}

signed main()
{
//	freopen("THREEPRIMES.inp", "r", stdin); freopen("THREEPRIMES.out", "w", stdout);
	fastio();

	int n, k; cin >> n >> k;
	ld a[n + 1];

	vector<int> q;

	int sum = 0, pos = 0;
	int max_sum = 0;

	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < k - 1; i++) q.eb(a[i]), sum += a[i];
	for (int i = k - 1; i < n; i++) {
        q.eb(a[i]);
        sum += a[i];
        if (max_sum < sum) {
            max_sum = sum;
            pos = i - (k - 1);
        }
        sum -= q.front();
        q.erase(q.begin());
	}
//	cout << "max sum at pos " << pos << endl;
	ld ans = 0;
	for (int i = pos; i < pos + k; i++) {
        ans += (a[i] + 1) / 2;
	}
	cout << setprecision(10) << fixed << ans;
}


Measured memory_bytes: 4600
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;
int main() {
    int n;
    cin >> n;

    vector<int> inp(n);
    // int _sum = 0;
    ll _sum = 0;
    rep(i, 0, n) {
        cin >> inp[i];
        _sum += inp[i];
        // if (i > 0) {
        //     sum[i] = sum[i - 1] + inp[i];
        // } else {
        //     sum[i] = inp[i];
        // }
    }
    // vector<int> x(n);
    vector<ll> x(n);
    x[0] = inp[0];
    // int ans = abs(_sum - 2 * x[0]);
    ll ans = abs(_sum - 2 * x[0]);

    rep(i, 1, n - 1) {
        x[i] = x[i - 1] + inp[i];
        // if (abs(_sum - 2 * x[i]) < ans) {
        //     ans = abs(_sum - 2 * x[i]);
        // }
        ans = min(ans, abs(_sum - 2 * x[i]));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    string s;cin>>s;
    int n=s.length();
    stack<char> st;
    int co=1;
    int ans=0;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]){
            co++;
        }else{
            ans+=co-co%2;
            if(co%2){
                if(!st.empty()&&st.top()!=s[i-1]){
                    ans+=2;
                    st.pop();
                }else{
                    st.push(s[i-1]);
                }
            }
            co=1;
        }
    }
    ans+=co-co%2;
    if(co%2){
        if(!st.empty()&&st.top()!=s[n-1]){
            ans+=2;
            st.pop();
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int k, n; cin >> k >> n;
    vector<int> a(n); rep(i,n) cin >> a.at(i);
    int ans = k;
    rep(i, n) {
        int p1,p2; //p1 ClockWise, p2 CouterClockWise

        if(i == 0) p1 = a.at(n-1) - a.at(0);
        else p1 = k - (a.at(i) - a.at(i-1));

        if(i == n-1) p2 = k - (a.at(i) - a.at(i-1));
        else p2 = k - (a.at(i+1) - a.at(i));

        int tmp = min(p1,p2);
        ans = min(ans, tmp);

    }
    cout << ans << endl;
}

Measured memory_bytes: 4060
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
vector<long long int> G;
vector<int> B;
int N;

int solve(int v, long long int t){
  if(v >= B.size() || t == (1LL<<N) - 1LL) return 0;
  int ret = 0;
  if(!(t>>v & 1)){
    long long t_ = t | (1LL<<v);
    t_ |= G[v];
    int v_ = v + 1;
    while(t_>>v_ & 1) ++v_;
    ret = B[v] + solve(v_,t_);
    if(t_ == (t|1LL<<v)) return ret;
  }
  int v_ = v + 1;
  while(t>>v_ & 1) ++v_;
  t |= 1LL<<v;
  ret = max(ret, solve(v_,t));
  return ret;
}

int main(){
  while(cin >> N, N){
    map<string,int> M;
    vector< vector<string> > D(N);
    string a;
    B = vector<int>(N);
    int c;
    for(int i = 0; i < N; ++i){
      cin >> a >> B[i] >> c;
      M[a] = i;
      string d;
      for(int j = 0; j < c; ++j){
        cin >> d;
        D[i].push_back(d);
      }
    }
    G = vector<long long int>(N,0LL);
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < D[i].size(); ++j){
        G[i] |= 1LL<<M[D[i][j]];
      }
    }
    long long int t = 1LL;
    t |= G[0];
    cout << B[0] + solve(1,t) << endl;
  }
  return 0;
}



Measured memory_bytes: 3304
# coding: utf-8

LIMIT = 999999

# 1 から LIMIT までのリスト
# 素数（の候補）を 1 、素数でないもを 0 とする  
# 2 以外の偶数は素数ではない
prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

# 3 から LIMIT の平方根までを走査
for i in range(3, int(LIMIT ** 0.5) + 1):
    # 対象が素数である場合
    if prime[i - 1] == 1:
        # 自身の倍数は素数ではない
        for j in range(i ** 2, LIMIT + 1, i):
            # 素数ではないので 0
            prime[j - 1] = 0

while True:
    try:
        n = int(input())
    except EOFError:
        break
    
    # 1 から n までの素数の個数を合計して出力
    print(sum(prime[:n]))


Measured memory_bytes: 21240
from collections import Counter
s = input()
fist = s.replace('A', '').replace('C', '')

if not fist.islower():
    print('WA')
else:
    seco = s[2:-1]
    cnt = Counter(seco)
    if not cnt['C'] == 1:
        print('WA')
    else:
        if s[0] == 'A':
            print('AC')
        else:
            print('WA')

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n, ans, s[105], a[10];
vector<int> b;
bool v[105], v1[2000005];
int main()
{
	int i, j, k, z;
	cin >> n;
	for (i= 2; i <= n; i++) {
		if (v[i]) continue;
		b.push_back(i);
		for (j = i * 2; j <= n; j += i) v[j] = 1;
		for (j = i; j <= n; j *= i) {
			s[i] += n / j;
		}
	}
	for (i = 0; i < b.size(); i++) {
		for (j = 0; j < b.size(); j++) {
			if (i == j) continue;
			for (k = 0; k < b.size(); k++) {
				if (i == k || j == k) continue;
				a[0] = j;
				a[1] = k;
				sort(a, a + 2);
				z = i * 10000 + a[0] * 100 + a[1];
//				if (s[b[i]] >= 2 && s[b[j]] >= 4 && s[b[k]] >= 4 && !v1[z]) {ans++; v1[z] = 1;}
				if (s[b[i]] >= 2 && s[b[j]] >= 4 && s[b[k]] >= 4 && !v1[z]) {ans++; v1[z] = 1;}
			}
		}
	}
	for (i = 0; i < b.size(); i++) {
		for (j = 0; j < b.size(); j++) {
			if (i == j) continue;
//			a[0] = i;
//			a[1] = j;
//			sort(a, a + 2);
//			z = a[0] * 100 + a[1];
//			if ((s[b[i]] >= 2 && s[b[j]] >= 24 || s[b[i]] >= 4 && s[b[j]] >= 14) && !v2[z]) {ans++; v2[z] = 1;}
			if (s[b[i]] >= 2 && s[b[j]] >= 24) {ans++;}
			if (s[b[i]] >= 4 && s[b[j]] >= 14) {ans++;}
		}
	}
	for (i = 0; i < b.size(); i++) {
		if (s[b[i]] >= 74) ans++;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
ll f()
{
ll l=s.size();

if(l&1)return 0;
l>>=1;
for(int i=0;i<l;i++)if(s[i]!=s[l+i])return 0;
return 1;

}
int main()
{
   
    cin>>s;
    while(!s.empty())
    {s.pop_back();
    if(f()){cout<<s.size()<<endl;return 0;}
    
    }
}

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

using namespace std;

int INF=1e9;

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

    int a,b,c;
    cin>>a>>b>>c;

    int ma=a%2,mb=b%2,mc=c%2,ans=0;

    int MAX=max(a,max(b,c));

    if(ma==mb && mb==mc){

        ans=(3*MAX-a-b-c)/2;

    }
    else if(ma==mb){

        if(MAX!=c){
            ans+=(MAX-c+1)/2;
            MAX=c+2*ans;
        }

        ans+=(2*MAX-a-b)/2;

    }
    else if(mb==mc){

        if(MAX!=a){
            ans+=(MAX-a+1)/2;
            MAX=a+2*ans;
        }

        ans+=(2*MAX-b-c)/2;

    }
    else{

        if(MAX!=b){
            ans+=(MAX-b+1)/2;
            MAX=c+2*ans;
        }

        ans+=(2*MAX-a-c)/2;

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int val,pay,rem;

  for(;;){
    int ans1=0,ans2=0,ans3=0;
    scanf("%d %d", &val, &pay);
    if(val==0&&pay==0) break;

    rem=pay-val;
    for(;;){
      if(rem<1000) break;
      if(rem-1000>=0){
	rem-=1000;
	ans3++;
      }
    }
    for(;;){
      if(rem<500) break;
      if(rem-500>=0){
      rem-=500;
      ans2++;
      }
    }
    for(;;){
      if(rem==0) break;
      if(rem-100>=0){
      rem-=100;
      ans1++;
      }
    }
    printf("%d %d %d\n", ans1, ans2, ans3);
  }

  return 0;
}


Measured memory_bytes: 600
# input
A, B, C = map( int, input().split() )

# calc 
AB = abs( A - B )
AC = abs( A - C )
BC = abs( B - C )

ans = False
if( AB == 0 and AC != 0 ):
    ans = True
elif( AC == 0 and AB != 0 ):    
    ans = True
elif( BC == 0 and AB != 0 ):    
    ans = True

# output      
if(ans):
    print( "Yes" )
else:
    print( "No" )


Measured memory_bytes: 3060
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

char a[107];
int size;

int main () {
    static char c;
	while (~(c = getchar ())) {
		if (c == '0') a[++size] = '0';
		else if (c == '1') a[++size] = '1';
		else if (c == 'B' && size) a[size--] = '\0';
	}
	printf ("%s\n", a + 1);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		String[] s = reader.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(s[i]);
		}
		int sum = 0;

		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i + 1; j < n; j++) {
				if (a[j] < a[minj]) {
					minj = j;
				}

			}
			if (i != minj) {
				int tmp = a[i];
				a[i] = a[minj];
				a[minj] = tmp;
				sum++;
			}
		}

		StringBuilder builder = new StringBuilder();
		for (int k = 0; k < n; k++) {
			if (k > 0)
				builder.append(" ");
			builder.append(a[k]);
		}
		builder.append("\n").append(sum);
		System.out.println(builder);

	}
}

Measured memory_bytes: 17064
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int i, j;
    
    int w = scan.nextInt();
    int h = scan.nextInt();
    int n = scan.nextInt();
    
    int[][] b = new int[n][3];
    
    for(i = 0; i < n; i++){
      for(j = 0; j < 3; j++){
        b[i][j] = scan.nextInt();
      }
    }
    
    int maxx = 0;
    int minx = w;
    int maxy = 0;
    int miny = h;
    int ans;
    
    for(i = 0; i < n; i++){
      if(b[i][2] == 1 && maxx < b[i][0]){
        maxx = b[i][0];
      }
      else if(b[i][2] == 2 && minx > b[i][0]){
        minx = b[i][0];
      }
      else if(b[i][2] == 3 && maxy < b[i][1]){
        maxy = b[i][1];
      }
      else if(b[i][2] == 4 && miny > b[i][1]){
        miny = b[i][1];
      }
    }
    
    if(maxx >= minx || maxy >= miny){
      System.out.println("0");
    }
    else{
      ans = (minx - maxx) * (miny - maxy);
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  vector<long> dp(13);
  
  dp.at(0)=1;
  long mul=1,mod=1000000007;
  
  for(int i=S.size()-1;i>=0;i--){
    vector<long> nextDP(13);
    if(S.at(i)=='?'){
      for(int j=0;j<10;j++){
        for(int k=0;k<13;k++){
          nextDP.at((j*mul+k)%13)+=dp.at(k);
          nextDP.at((j*mul+k)%13)%=mod;
        }
      }
    }
    else{
      int j=S.at(i)-'0';
      for(int k=0;k<13;k++){
          nextDP.at((j*mul+k)%13)+=dp.at(k);
          nextDP.at((j*mul+k)%13)%=mod;
      }
    }
    dp=nextDP;
    mul=mul*10%13;
  }
  cout<<dp.at(5)<<endl;
}

Measured memory_bytes: 512
/**
 * 与えられた文字列の小文字と大文字を入れ替えるプログラムを作成してください。
 */

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);

		char[] iremono = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
				'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
				'w', 'x', 'y', 'z' };
		int[] cou = new int[26];
		int j = 0;


		while (sc.hasNext()) {
			String stralf = sc.nextLine();

			for (int i = 0; i < stralf.length(); i++) {
				char chalf = stralf.charAt(i);
				chalf = Character.toLowerCase(chalf);
				for (j = 0; j < 26; j++) {
					if (iremono[j] == chalf) {
						cou[j]++;
					}
				}
			}
		}
		for (int k = 0; k < 26; k++) {
			System.out.print(iremono[k]);
			System.out.println(" : " + cou[k]);
		}
	}
}

Measured memory_bytes: 18048
#include<stdio.h>
#include<string.h>

int main(){
  long long int a,b,k;
  scanf("%lld%lld%lld",&a,&b,&k);
  
  long long int ans,takahashi=a,aoki=b;
  if(k-a<0){
    takahashi=a-k;
    printf("%lld %lld",takahashi,aoki);
    return 0;
  }else if(k-a-b<0){
    takahashi=0;
    aoki=b-k+a;
    printf("%lld %lld",takahashi,aoki);
    return 0;
  }else{
    printf("0 0");
  }
  

  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

const double EPS = 1e-8;        // 非常に小さな値

// a == b なら true (誤差に寛容)
inline bool Eq(double a, double b) { return fabs(b - a) < EPS; }

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

    ll a, b, c;
    cin >> a >> b >> c;

    ll lval = a * b;
    ll rval = c - a - b;
    if(rval <= 0) {
        printf("No\n");
        return 0;
    }

    rval *= rval;

    if(lval < rval / 4) {
        printf("Yes\n");
        return 0;
    }
    else if(lval == rval / 4) {
        if(rval % 4 == 0) {
            printf("No\n");
            return 0;
        }
        else {
            printf("Yes\n");
            return 0;
        }
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    if(m>2*n){
        ans+=n;
        m-=2*n;
        ans+=m/4;
    }else{
        ans+=m/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> h(n + 2);
    for (int i = 1; i <= n; i++) {
        std::cin >> h[i];
    }
    int ret = 0;
    while (std::any_of(h.begin(), h.end(), [](auto hh) { return hh > 0; })) {
        int l = 0;
        int min = 100000;
        for (int i = 0; i < n + 2; i++) {
            if (!h[i]) {
                if (i - l > 1) {
                    ret += min;
                    for (int j = l + 1; j < i; j++) h[j] -= min;
                }
                l = i;
                min = 100000;
                continue;
            } else {
                min = std::min(min, h[i]);
            }
        }
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
//Try until you reach your goal
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll y;
    cin>>y;
    ll a[y];
    f(i,y){
        cin>>a[i];
    }
    ll ans=0;
    ll k=1;
    for(ll i=0;i<y;i++){
        if(a[i]==k){
            k++;
        }
        else{
            ans++;
        }
    }
    if(ans==y){
        cout<<-1;
    }
    else{
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 5232
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sum := 0.0
	limit := n
	if n > k {
		limit = k
		sum += float64(n - k)
	}
	for i := 1; i <= limit; i++ {
		sum += math.Pow(0.5, math.Ceil(math.Log2(float64(k)/float64(i))))
	}
	fmt.Println((1 / float64(n)) * sum)
}


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

int main(){
	int N;
	cin >> N;
	int heights[N];
	for(int i=0; i<N; ++i){
		cin >> heights[i];
	}
	int dp[N];
	dp[0] = 0;
	dp[1] = abs(heights[1]-heights[0]);
	for(int i=2; i<N; ++i){
		dp[i] = min(dp[i-1]+abs(heights[i]-heights[i-1]),
								dp[i-2]+abs(heights[i]-heights[i-2])); 
	}
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 4380
N, a, b = map(int, input().split())
mod = 10**9+7

def comb(n,a):
    x = 1
    for i in range(n-a+1, n+1):
        x *= i
        x %= mod
    y = 1
    for i in range(1, a+1):
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)


ans = pow(2,N,mod)-1-comb(N,a)-comb(N,b)
print(ans%mod)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int n;
inline void cnt(int x,int &tp){
	while(x){
		tp+=x%10;
		x/=10;
	}
}
int main(){
	scanf("%d",&n);
	int ans=1e9;
	for(int i=1;i<n;++i){
		int a=i,b=n-i,tp=0;
		cnt(a,tp);
		cnt(b,tp);
		ans=min(ans,tp);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 888
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    int N, K;

    cin >> N >> K;
    queue<double> q;
    int p;
    double sum = 0;
    while(q.size() < K - 1) {
        cin >> p;
        double e = (1+p)/2.0;
        sum += e;
        q.push(e);
    }
    double max_ = 0;
    for(size_t i = 0; i < N - K + 1; i++) {
        cin >> p;
        double e = (1+p)/2.0;
        sum += e;
        q.push(e);
        max_ = max(max_, sum);
        sum -= q.front();
        q.pop();
    }
    printf("%.10lf", max_);
}

Measured memory_bytes: 1792
def min(a,b)
  a < b ? a : b
end

N = gets.to_i
H = gets.split.map(&:to_i)
dp = Array.new(N, Float::INFINITY)
dp[0] = 0
N.times do |i|
  1.upto(2) do |j|
    next if i - j < 0
    dp[i] = min(dp[i], dp[i - j] + (H[i] - H[i - j]).abs)
  end
end
puts dp[N - 1]

Measured memory_bytes: 10756