akhauriyash/Code-Regression huggingface dataset:
/*input
3 2
0 0 0
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 2;

int a[N], s[N + 4];

unordered_set<int> ss;

bool checkSingle(int n) {
  return (ss.size() == 1) && (ss.find(n) == ss.begin());
}

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ss.insert(a[i]);
  }

  int single = checkSingle(n);
  while (!single && k) {
    ss.clear();

    for (int i = 0; i <= n + 1; ++i) {
      s[i] = 0;
    }
    for (int i = 1; i <= n; ++i) {
      s[max(0, i - a[i])]++;
      s[min(N, i + a[i]) + 1]--;
    }
    for (int i = 1; i <= n; ++i) {
      s[i] += s[i - 1];
      a[i] = s[i];
      ss.insert(a[i]);
    }

    single = checkSingle(n);
    k--;
  }

  for (int i = 1; i <= n; ++i) {
    cout << a[i] << ' ';
  }

  return 0;
}

Measured memory_bytes: 10904
// #include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
int solve(){
    int c=0, n;
    while(c<5){
      cin >> n;
      if(n==0) return c+1;
      ++c;
    }
    return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // int t;
  // cin >> t;
  // for (int i = 1; i <= t; ++i) {
  //   cout << solve(i) << "\n";
  // }
  cout << solve() << "\n";

  return 0;
} 

Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		
		int p[][] = new int[n*(n-1)/2][4];
		int x[] = new int[n];
		int y[] = new int[n];
		
		for(int i=0; i < n*(n-1)/2; i++){
			for(int k=0; k < 4; k++){
				p[i][k] = s.nextInt();
			}
		}
		
		for(int i=0; i < n*(n-1)/2; i++){
			if(p[i][2]  > p[i][3])		x[p[i][0] - 1] += 3;
			else if(p[i][2]  == p[i][3]){
				x[p[i][0] - 1] += 1;
				x[p[i][1] - 1] += 1;
			}
			else if(p[i][2] < p[i][3])	x[p[i][1] - 1] += 3;
		}
		
		for(int i=0; i<n; i++){
			y[i] = 1;
			for(int k=0; k<n; k++){
				if(x[i] < x[k])		y[i]++;
			}
		}
		
		for(int i=0; i < n; i++){
			System.out.println(y[i]);
		}
		
	}

}

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

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<i64> sum(N + 1);
  vector<i64> dp(2019, 0);
  i64 ans = 0;
  {
    i64 ten = 1;
    dp[0] = 1;
    for(i64 i = N; i --> 0;) {
      i64 num = s[i] - '0';
      sum[i] = (sum[i + 1] + ten * num) % 2019;
      ans += dp[sum[i]];
      dp[sum[i]]++;
      ten *= 10;
      ten %= 2019;
    }
  }
  cout << ans << endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  n += 2;
  vi a(n);
  a[0] = 0;
  rrep(i, n) std::cin >> a[i];
  a[n-1] = 0;
  ll sum = 0;
  srep(i, 1, n) {
    sum += abs(a[i-1] - a[i]);
  }
  srep(i, 1, n-1) {
    ll ans = sum;
    ans -= abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]);
    ans += abs(a[i-1] - a[i+1]);
    std::cout << ans << "\n";
  }
}


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

template<typename T,bool Mono>
struct ConvexHullTrick{
    typedef function<bool(T,T)> C;
    #define F first
    #define S second
    using Line=pair<T,T>;
    C cmp;
    deque<Line> Lines;
    ConvexHullTrick(C cmp=[](T l,T r){return l>=r;})
        :cmp(cmp){}
    bool check(Line l1,Line l2,Line l3){
        if (l1<l3) swap(l1,l3);
        return (l3.S-l2.S)*(l2.F-l1.F)>=(l2.S-l1.S)*(l3.F-l2.F);
    }
    void add(T a,T b){
        Line line(a,b);
        while(Lines.size()>=2&&check(*(Lines.end()-2)
        ,Lines.back(),line)) Lines.pop_back();
        Lines.emplace_back(line);
    }
    T f(const int &i,const T &x){
        return Lines[i].F*x+Lines[i].S;
    }
    T f(const Line &line,const T &x){
        return line.F*x+line.S;
    }
    T query(T x){
        if (Mono){
            while(Lines.size()>=2
            &&cmp(f(0,x),f(1,x))) Lines.pop_front();
            return f(0,x);
        } else {
            int lb=-1,ub=Lines.size()-1;
            while(ub-lb>1){
                int mid=(lb+ub)>>1;
                (cmp(f(mid,x),f(mid+1,x))?lb:ub)=mid;
            }
            return f(ub,x);
        }
    }
    #undef F
    #undef S
};

// https://atcoder.jp/contests/colopl2018-final-open/tasks/colopl2018_final_c

void colopl2018_final_c(){
    int N; cin >> N;
    vector<long long> a(N);
    for (int i=0;i<N;++i) cin >> a[i];
    ConvexHullTrick<long long,true> CHT;
    for (long long i=0;i<N;++i) CHT.add(-2*i,a[i]+i*i);
    for (long long i=0;i<N;++i) cout << CHT.query(i)+i*i << '\n';
}

// https://atcoder.jp/contests/dp/tasks/dp_z

void dp_z(){
    int N; long long C; cin >> N >> C;
    vector<long long> h(N);
    for (int i=0;i<N;++i) cin >> h[i];
    ConvexHullTrick<long long,true> CHT;
    vector<long long> dp(N,0);
    for (int i=0;i<N;++i){
        if (i) dp[i]=CHT.query(h[i])+h[i]*h[i]+C;
        CHT.add(-2*h[i],h[i]*h[i]+dp[i]);
    }
    cout << dp[N-1] << '\n';
}

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

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

#define ll long long

char a[10][10],b[10][10];
int h,w,k;

void copyMatrix(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			b[i][j]=a[i][j];
	}
}

void color(int i,int j){
	for(int x=0;x<h;x++){
		if(i&(1<<x)){
			for(int y=0;y<w;y++)
				b[x][y]='$';
		}
	}
	for(int x=0;x<w;x++){
		if(j&(1<<x)){
			for(int y=0;y<h;y++)
				b[y][x]='$';
		}
	}
}

bool check(){
	int total=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(b[i][j]=='#')
				total++;
		}
	}
	if(total==k)
		return true;
	else
		return false;
}

int main() {
//#ifndef ONLINE_JUGDE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	int total=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			copyMatrix();
			color(i,j);
			if(check())
				total++;
		}
	}
	cout<<total;
	
    return 0;
}

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


int main(){
    int x, i, a, b, c;
    cin >> a >> b >> c;
    
    for (int x = a ; x <= b ; x++){
        
        if ( (c % x) == 0 ) i++;
        
        
    }
    
    cout << i <<endl;
    
    return 0;
    
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();

/* you get what you work for not what you wish for */
    inp(n);
    vector <pll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i].ff;
        a[i].ss = i+1;
    }
    sort(all(a));
    for(int i=0; i<n; i++){
        cout << a[i].ss << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
import math

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())
divisors_list = make_divisors(n)
ans = []
n_sqrt = math.sqrt(n)
if n_sqrt == int(n_sqrt):
    for i in range(len(divisors_list) // 2 + 1):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
else:
    for i in range(len(divisors_list) // 2):
        move = divisors_list[i] + divisors_list[-1 - i] - 2
        ans.append(move)
print(min(ans))


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


int main(void){
    int n;
    string ox;
    cin>>n>>ox;
    vector<int> ss(n);
    
    for(auto a0:{-1,1})for(auto a1:{-1,1}){
        ss[0]=a0;ss[1]=a1;
        
        for(int i=2;i<=n+1;i++){
            bool c1=ss[(i-1)%n]==1, c2=ox[(i-1)%n]=='x';
            ss[i%n]=ss[(i-2)%n] * (c1 xor c2 ? 1 : -1);
        }
    
        if(ss[0]==a0 and ss[1]==a1){
            for(int i=0;i<n;i++){
                cout<<(ss[i]==1?'S':'W');
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main()
{
	ull a[41];
	a[0] =2;
	for(int i=1;i<=41;i++){
		a[i]=a[i-1]*2+2;
	}int x;cin>>x;cout<<a[x]<<endl;
}

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

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==1)
    {
        if(y==2)
            printf("3\n");
        else
              printf("2\n");
    }
    else if(x==2)
    {
        if(y==1)
            printf("3\n");
        else
              printf("1\n");
    }
    else
    {
        if(y==1)
            printf("2\n");
        else
              printf("1\n");
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();
    let n = read::<usize>();
    let bigger = max(h, w);
    println!("{}", (n + bigger - 1) / bigger);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

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

    int total=0;
    int res=0;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            total=4*j+7*i;
            if(total==N){
                ++res;
                break;
            }
        }
    }

    if(res>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
gets
arr = gets.chomp.split(" ").map(&:to_i)
mul = 1
ngo = 10 ** 18
if arr.find{|a| a==0} != nil then
	puts 0
	exit
end

arr.each do |a|
	mul *= a
	if mul > ngo then
		puts -1
		exit
	end
end
puts mul

Measured memory_bytes: 23436
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template <typename T>
std::vector<T> dijkstra(const Graph<T> &g, int s) {
    int sz = (int)(g.size());
    std::vector<T> dist(sz, std::numeric_limits<T>::max());
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>, std::greater<std::pair<T, int>>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while(!pq.empty()) {
        int now = pq.top().second; pq.pop();
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to, cost = g[now][i].cost;
            if(dist[next] > dist[now] + cost) {
                dist[next] = dist[now] + cost;
                pq.push({cost, next});
            }
        }
    }
    return dist;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double eps = 1e-10;
const int MOD = 1000000007;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n, m, s; cin >> n >> m >> s;
    Graph<ll> g(n);
    for(int i=0;i<m;++i) {
      int u, v, c; cin >> u >> v >> c;
      g[u].push_back(Edge<ll>(u, v, c));
    }
    vector<ll> dist = dijkstra(g, s);
    for(int i=0;i<n;++i) {
      if(dist[i] == LLONG_MAX) cout << "INF" << endl;
      else cout << dist[i] << endl;
    }
}



Measured memory_bytes: 25584
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	long long a, b, c,k,bc,ac,ab;
	cin >> a >> b >> c>>k;
	if (k % 2 == 1) cout << b - a << endl;
	else cout << a - b << endl;
	int y;
	cin >> y;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();
        sc.close();

        double maxConc = -1;
        int wtr = 0;
        int sgr = 0;
        for (int i = 0; i * A * 100 <= F; ++i) {
            int wA = i * A * 100;
            if (wA > F) {
                break;
            }
            for (int j = 0; j * B * 100 <= F; ++j) {
                int wB = j * B * 100;
                if (wA + wB > F || wA + wB == 0) {
                    break;
                }
                for (int k = 0; wA + wB + (C * k) <= F; ++k) {
                    int sC = C * k;
                    if (sC * 100 > E * (wA + wB)) {
                        break;
                    }
                    for (int l = 0; wA + wB + sC + (D * l) <= F; ++l) {
                        int sD = D * l;
                        if ((sC + sD) * 100 > E * (wA + wB)) {
                            break;
                        }
                        double conc = 1000000 * (sC + sD) / (wA + wB + sC + sD);
                        if (maxConc < conc) {
                            maxConc = conc;
                            wtr = wA + wB;
                            sgr = sC + sD;
                        }
                    }
                }
            }
        }
        System.out.println(wtr + sgr + " " + sgr);
    }
}

Measured memory_bytes: 23380
/*
 * VJUDGE E - Flipping Signs
 * author: roy4801
 * (C++)
 */
#include <bits/stdc++.h>

using namespace std;

#define PROB "E"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define N 100000
int n, neg;
LL tmp, arr[N+5];
int main()
{
	#ifdef DBG
	freopen("./testdata/" PROB TESTC ".in", "r", stdin);
	freopen("./testdata/" PROB ".out", "w", stdout);
	#endif
	while(cin >> n)
	{
		for(int i = 0; i < n && cin >> tmp; i++)
		{
			if(tmp < 0)
			{
				neg++;
				tmp = -tmp;
			}
			arr[i] = tmp;
		}

		sort(arr, arr+n);
		if(neg & 1) // odd
			arr[0] = -arr[0];
		printf("%lld\n", accumulate(arr, arr+n, (LL)0));
	}

	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            Stack<int> stk = new Stack<int>();

            for (int i = 0; i < input.Length; i++)
            {
                int a, b;

                switch (input[i])
                {
                    case "+":
                        a = stk.Pop();
                        b = stk.Pop();
                        stk.Push(a + b);
                        break;
                    case "-":
                        a = stk.Pop();
                        b = stk.Pop();
                        stk.Push(b - a);
                        break;
                    case "*":
                        a = stk.Pop();
                        b = stk.Pop();
                        stk.Push(a * b);
                        break;
                    default:
                        stk.Push(int.Parse(input[i]));
                        break;
                }
            }

            Console.WriteLine(stk.Pop());
        }
    }
}

Measured memory_bytes: 10104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    int sum = 0;
    vector<int> t(n);
    rep(i, n) {
        cin >> t[i];
        sum += t[i];
    }
    int m; cin >> m;
    vector<int> p(m), x(m);
    rep(i, m) {
        cin >> p[i] >> x[i];
        p[i]--;
    }
    rep(i, m) {
        cout << sum - t[p[i]] + x[i] << endl;
    }
}


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

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

   string s, ans;  int n;
   while (cin >> n >> s)
   {
      int b = 0; ans.clear();
      for (const auto&c : s)
      {
         ans += c;
         if ('(' == c)
         {
            b++;
         }
         else {
            if (b)
            {
               --b;
            }
            else
            {
               ans = '(' + ans;
            }
         }
      }
      while(b--)
      {
         ans += ')';
      }
      cout << ans << '\n';
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ld h[100005];
int main(){
    ios_base::sync_with_stdio(false);
    ll n;
    ld a,t;
    cin >> n >> t >> a;
    ll id = 0;
    ld mini = 1000000000;
    for(long i = 1; i <= n; i++){
        cin >> h[i];
        ld av = t-h[i]*(long double)(0.006);
        ld raz = abs(a - av);
        if(raz < mini){
            mini = raz;
            id = i;
        }
    }
    cout << id << 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;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<P> A(N);
    rep(i,N) {
        int a; cin >> a;
        A[i] = P(a,i);
    }
    sort(A.begin(),A.end());

    set<int> st = {-1,N};
    ll ans = 0;
    rep(i,N) {
        int j = A[i].second,a = A[i].first;
        int left = *(--st.lower_bound(j));
        int right = *st.lower_bound(j);
        ans += (ll)a*(right - j)*(j - left);
        st.insert(j);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string s;
	char k;
	int i=0;
	cin >> s;
	int m = (int)(s.length());
	int cnt = 0;
	for (i = 0; i < m/2; i++) {
		if (s[i] != s[m - i-1]) {
			cnt++;
		}
	}
	printf("%d", cnt);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll s=0;
	if(k<=a)
	{
		s=s+k;
		k=0;
	}
	if(k>a)
	{
		s=s+(a);
		k=k-a;
	}
	if(k<=b)
	{
		s=s+0;
		k=0;
	}
	if(k>b)
	{
		k=k-b;
	}
	if(k<=c)
	{
		s=s-k;
		k=0;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int c[26];
	for(int i=0;i<26;i++) c[i]=50;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int d[26];
		for(int j=0;j<26;j++) d[j]=0;
		for(int j=0;j<s.size();j++){
			d[s[j]-'a']++;
		}
		for(int j=0;j<26;j++){
			c[j]=min(c[j],d[j]);
		}
	}
	for(int i=0;i<26;i++){
		for(int j=0;j<c[i];j++){
			cout<<(char)('a'+i);
		}
	}
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

    vector<ll> x(n*3+1);
    ll sum1 = 0, sum2 = 0;

    vector<ll> xsum(n);

    priority_queue<ll,vector<int>,greater<>> pque1;
    priority_queue<ll> pque2;

    for(int i = 0; i < n * 3; i++) {
      cin >> x[i];
      if (i < n) {
        sum1 += x[i];
        pque1.push(x[i]);
      } else if (2 * n <= i) {
        sum2 += x[i];
        pque2.push(x[i]);
      }
    }

    REP(k, n) {
      xsum[k] = sum1;      
      sum1 += x[n + k];
      pque1.push(x[n + k]);
      sum1 -= pque1.top();
      pque1.pop();
    }

    ll ans = sum1 - sum2;;
    REP(k, n) {
      sum2 += x[2*n - k - 1];
      pque2.push(x[2*n - k - 1]);
      sum2 -= pque2.top();
      pque2.pop();
      chmax(ans, xsum[n - k - 1] - sum2);
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 4856
#include<cstdio>
int main(){
    int n;
    int a[3], a_cnt[3], cnt=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int a_tmp;
        scanf("%d",&a_tmp);
        int j=0;
        for(;j<cnt;j++){
            if(a[j]==a_tmp){
                a_cnt[j]++;
                break;
            }
        }
        if(j==cnt){
            if(cnt==3){
                printf("No\n");
                return 0;
            }else{
                a[j]=a_tmp;
                a_cnt[j]=1;
                cnt++;
            }
        }
    }
    if(cnt==1){
        if(a[0]==0)printf("Yes\n");
        else printf("No\n");
    }else if(cnt==2){
        if((a_cnt[1]*2==a_cnt[0]&&a[1]==0)||(a_cnt[0]*2==a_cnt[1]&&a[0]==0))printf("Yes\n");
        else printf("No\n");
    }else {
        if(a_cnt[0]==a_cnt[1]&&a_cnt[1]==a_cnt[2]&&(a[0]^a[1]^a[2])==0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N;
LL a[3000],dp[3000][3000];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N;
	for(int i=0; i<N; i++) cin >> a[i];

	for(int l=N-1; l>=0; l--){
		for(int r=0; r<N; r++){
			if(l > r) dp[l][r] = 0;
			else{
				if((l+N-r+1)%2 == 0) dp[l][r] = max(a[l]+dp[l+1][r], a[r]+dp[l][r-1]);
				else dp[l][r] = min(-a[l]+dp[l+1][r], -a[r]+dp[l][r-1]);
			}
		}
	}
	cout << dp[0][N-1] << endl;

	return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;
using Tu = std::tuple<int,int,int>;

int N, Q;
int S, T, X;
int D;
std::vector<Tu> v;
int di[200100];
std::multiset<int> se;

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

    std::cin >> N >> Q;

    for(int i=0;i<N;++i){
        std::cin >> S >> T >> X;

        v.emplace_back(S - X, 1, X);
        v.emplace_back(T - X, 2, X);
    }

    for(int i=0;i<Q;++i){
        std::cin >> D;

        v.emplace_back(D, 3, i);
    }

    std::sort(v.begin(), v.end());

    memset(di, -1, sizeof(di));

    int s = v.size();

    for(int i=0;i<s;++i){
        int a, b, c;
        std::tie(a, b, c) = v[i];

        if(b == 1){
            se.emplace(c);
        }else if(b == 2){
            se.erase(se.find(c));
        }else{
            unless(se.empty()){
                di[c] = *se.begin();
            }
        }
    }

    for(int i=0;i<Q;++i){
        std::cout << di[i] << std::endl;
    }
}


Measured memory_bytes: 20328
n,k=map(int, input().split())
h=list(map(int, input().split()))
dp=[0]*n
for i in range(1,n):
    dp[i]=min([dpj+abs(h[i]-hj) for dpj,hj in zip(dp[max(0,i-k):i],h[max(0,i-k):i])])
print(dp[-1])

Measured memory_bytes: 52576
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll c = b-1;
    while(c>n) c = n;
    cout << a*c/b << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int h,w;
  char m[105][105];
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>m[i][j];
  rep(i,h){
    bool ok=true;
    rep(j,w){
      if(m[i][j]=='#')ok=false;
    }
    if(ok)rep(j,w)m[i][j]='-';
  }

  rep(i,w){
    bool ok=true;
    rep(j,h){
      if(m[j][i]=='#')ok=false;
    }
    if(ok)rep(j,h)m[j][i]='-';
  }

  
  rep(i,h){
    bool is_output=false;
    rep(j,w){
      if(m[i][j]!='-'){
	cout<<m[i][j];
	is_output=true;
      }
    }
    if(is_output)cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,D ;
  cin>>A>>B>>C>>D ;
  if ((A+B)>(C+D) ){
  cout << "Left"<< endl;
    }
  if ((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
  }
  if ((A+B)<(C+D)){
  cout<<"Right"<< endl;
  }
}

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

int d, n;

int Tims(int x)
{
	int res = 0;
	while (x % 100 == 0) {
		res++; x /= 100;
	}
	return res;
}

int main()
{
	scanf("%d %d", &d, &n);
	for (int i = 1; ; i++)
		if (Tims(i) == d) {
			if (--n == 0) { printf("%d\n", i); return 0; }
		}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    map<int,int>mp;
    int n,i,x;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>x;
        mp[x]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12972
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var (
		a, b   int
		result string
	)
	fmt.Scan(&a, &b)

	if a > b {
		for i := 0; i < a; i++ {
			result += strconv.Itoa(b)
		}
	} else {
		for i := 0; i < b; i++ {
			result += strconv.Itoa(a)
		}
	}
	fmt.Println(result)
}


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

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

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

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, M, wa, K, W,L, ans, k[5],A,B,C,n[2];
string s, t[100];
bool a, b, c;
int main() {
	cin >> N>>M>>K;
	if (K >= N&&K <= N + M) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}




Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int k;

vector<int> a;

void input() {
  cin >> n >> k;
  
  a = vector<int>(n);
  for (auto&& i : a)
    cin >> i;
}

void solve1() {
  sort(a.rbegin(), a.rend());
  
  long long ans = 0;
  
  for (int i = k; i < n; ++i)
    ans += a[i];
  
  cout << ans;
}

int main() {
  preambule();
  input();
  solve1();
}

Measured memory_bytes: 1024
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, m, _x, _y] = stdin.split('\n')[0].split(' ').map(Number)
const x = stdin.split('\n')[1].split(' ').map(Number)
const y = stdin.split('\n')[2].split(' ').map(Number)

const xMax = Math.max(...x)
const yMin = Math.min(...y)

const ans = _ => {
  for(let i = _x + 1; i <= _y; i++){
    if(xMax < i && yMin >= i){
      return 'No War'
    }
  }
  return 'War'  
}

console.log(ans())

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int W,H;
int D[12][12];
char stage[25][25];
vector < Pii > c;
int len;
void bfs(int index){
    int s[25][25];
    memset(s,-1,sizeof(s));
    queue < Pii > Q;
    Q.push(c[index]);
    s[c[index].fr][c[index].sc] = 0;
    while(!Q.empty()){
        Pii p = Q.front();Q.pop();
        rep(i,4){
            int ny = p.fr + dy[i];
            int nx = p.sc + dx[i];
            if(s[ny][nx] != -1 || stage[ny][nx] == 'x')continue;
            if(ny < 0 || ny > H-1 || nx < 0 || nx > W-1)continue;
            s[ny][nx] = s[p.fr][p.sc] + 1;
            Q.push(Pii(ny,nx));
        }
    }
    rep(i,len){
        if(i == index)continue;
        D[index][i] = s[c[i].fr][c[i].sc];
    }
    return ;
}
int memo[1<<12];
int getMin(int bit,int prev){
    if((1<<len)-1 == bit){
        return 0;
    }
    int ret = INF;
    rep(i,len){
        if(!(1&bit>>i)){
            if(D[prev][i] == -1)continue;
            ret = min(ret,D[prev][i]+getMin(bit|1<<i,i));
        }
    }
    return ret;
}
int main(){
    while(scanf("%d%d",&W,&H),(W|H)){
        int index = 0;
        int s;
        c.clear();
        rep(i,H){
            scanf("%s",&stage[i]);
            rep(j,W){
                if(stage[i][j] == 'o'){
                    s = index;
                    stage[i][j] = '.';
                    c.PB(Pii(i,j));
                    index++;
                }
                if(stage[i][j] == '*'){
                    c.PB(Pii(i,j));
                    index++;
                }
            }
        }
        len = index;
        memset(D,0,sizeof(D));
        rep(i,len){
            bfs(i);
        }
        memset(memo,-1,sizeof(memo));
        int ans = getMin(1<<s,s);
        if(ans == INF)ans = -1;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1232
from collections import deque
n, d, a = [int(v) for v in input().split()]

X = []
for i in range(n):
    xh = [int(v) for v in input().split()]
    X.append(xh)

X.sort()


q = deque()

bomb = 0
d2 = d * 2
attack = 0
for xh in X:
    x, h = xh

    while len(q) > 0 and q[0][0] < x:
        x1, h1 = q.popleft()
        attack -= h1

    if h > attack:
        diff = h - attack
        bomb1 = diff // a
        if diff % a != 0:
            bomb1 += 1
        bomb += bomb1

        attack1 = bomb1 * a
        q.append((x+d2, attack1))
        attack += attack1

print(bomb)

Measured memory_bytes: 54004
import math

N , K = map(int, input().split())
flag = "F"
if N !=0:
    while 1:
        lenN = int (math.log10(N) + 1)
        lenK = int (math.log10(K) + 1)
        N = abs(N-K*(10**abs(lenN-lenK-1)))
        lenN = int (math.log10(N) + 1)
        if abs(lenN-lenK)<2:
            break



        
while 1:
    
    
    a = N
    N = abs(N - K)
    

    if a<=K and N <= K:
        if a < N:
            result = a
            flag="T"
        else:
            result = N
            flag="T"
    if flag == "T":
        break
print(result)

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  string s; cin >> s ;
  using ps = pair<string,string>;
  auto calc = [&](string ss){
    int n = ss.size();
    map<ps,ll> mp; 
    rep(mask,1<<n){
      string ss1 = "";
      string ss2 = "";
      rep(i,n){
        if((mask>>i)&1) ss1 += ss[i];
        else ss2 += ss[i];
      }
      mp[ps(ss1,ss2)]++;
    }
    return mp;
  };
  string s1,s2;
  s1 = s.substr(0,N);
  s2 = s.substr(N,N);
  reverse(ALL(s2));
  auto mp1 = calc(s1);
  auto mp2 = calc(s2);
  ll ans = 0;
  for(auto p:mp1){
    ans += p.second * mp2[p.first];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 108288
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

int main(void)
{
    double l;
    cin >> l;

    printf("%.7f\n", (l/3) * (l/3) * (l/3));
}


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

int main()
{
    vector<int> a(10);
    for (int i = 0; i < 10; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 0; i < 3; i++)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3220
#include<stdio.h>
int main()
{
  int left,right,mid,C=0,i,n,q,S[100000],T[50000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
      left=0;
      right=n;
  
      while(right>left)
	{
	  mid=(right+left)/2;
	  if(S[mid]==T[i])
	    {
	      C++;
	      break;
	    }
	  else if(T[i]<S[mid])
	    {
	      right=mid;
	    }
	  else left=mid+1;
	}
    }
     
  printf("%d\n",C);
	 
  return 0;
}



Measured memory_bytes: 2308
n, m = map(int, input().split())
h = list(map(int, input().split()))

flag = [True] * n
for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        flag[a-1] = False
        flag[b-1] = False
    elif h[a-1] > h[b-1]:
        flag[b-1] = False
    elif h[b-1] > h[a-1]:
        flag[a-1] = False


cnt = 0
for i in flag:
    if i:
        cnt += 1
print(cnt)

Measured memory_bytes: 84732
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

bool isNumber(char a) {
    return(a >= '0' && a <= '9');
}

int calc(string a) {
    int sum = 0;
    int keta = 0;
    for(int r = (int)a.size() - 1; r >= 0; r--) {
        if(isNumber(a[r])) {
            sum += (a[r] - '0') * pow(10, keta);
            keta++;
        } else keta = 0;
    }
    return(sum);
}

int main(void) {
    string input;
    int sum = 0;
    while(cin >> input) {
        sum += calc(input);
    }
    
    cout << sum << endl;
    return(0);
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    A = []
    B = [''] * m
    for i in range(m):
        p, y = map(int, input().split())
        A.append((p, y, i))
    A.sort()
    count = 0
    i, x = 1, 1
    for a in A:
        if a[0] == i:
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        else:
            i, x = a[0], 1
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        x += 1
    print('\n'.join(B))


if __name__ == '__main__':
    main()

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

int main() {
	while (1)
	{
		int a, b, c;
		char op;

		cin >> a >> op >> b;

		if (op == '?')
			break;

		switch (op) {
		case '+':
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a*b;
			break;
		case '/':
			c = a / b;
		}

		cout << c<<endl;
	}
}

Measured memory_bytes: 3072
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
ld a,b,x,S;
int main(void){
    cin>>a>>b>>x;
    S=a*a*b;
    if(S/2>=x){
        cout<<setprecision(10)<<atan((a*b*b)/(2*x))*180/M_PI<<endl;;
    }
    else{
        x=S-x;
        cout<<setprecision(10)<<atan((2*x)/(a*a*a))*180/M_PI<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

double T, X;

void _main() {
  cin >> T >> X;
  cout << (T / X) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
using pi = pair<lint, lint>;
const int MAXN = 100005;
const int mod = 998244353;
const int MAXC = 1005;

lint n;

set<lint> fn;

void Do(lint k){
	if(k == 0) return;
	if(n / k == n % k) fn.insert(k);
}

int main(){
	cin >> n;
	for(int i=1; 1ll*i*i<=n; i++){
		if(n % i == 0){
			Do(i - 1);
			Do(n / i - 1);
		}
	}
	lint ret = 0;
	for(auto &i : fn) ret += i;
	cout << ret << endl;
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int K;
    int x;
    string S,ans;
    cin >> K >> S;
    x = S.size();
    if(K >= x){
        ans = S;
    }else{
        ans = S.replace(K,x-K,"...");
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
  string s;
  cin >> s;
  bool ok1(false),ok2(false);
  for(int i=0;i<s.length();i++){
    if(!ok1){
      if(s[i] == 'C'){
        ok1 = true;
      }
    }
    else if(ok1 && !ok2){
      if(s[i] == 'F'){
        ok2 = true;
      }
    }
    else
      break;
  }
  if(ok1 && ok2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main(){
     int n,k;
     cin>>n>>k;
     int h[n];
     for(int i=0;i<n;i++){
          cin>>h[i];
     }
     
     vector<int> dp(n, INT_MAX);
     dp[0]=0;
      for(int i=0;i<n;i++){
         for(int j=1;j<=k;j++){
              if(j<n){
                   dp[i+j]=min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
              }
         }
     }
     
     cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string s; cin>>s;
	string t=s.substr(0,s.size()/2);
	if (t+t==s) cout<<"Yes";
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
N, A, B = map(int, input().split())
s = 0
for i in range(1, N+1):
    n = i
    m = 0
    while n > 9:
        m += n % 10
        n = n // 10
    m += n
    if A <= m <= B:
        s += i
print(s)

Measured memory_bytes: 2940
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[1000];
	int n, k, sum = 0;
	cin >> n >> k;
	for (int i = 0;i < n;i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0;i < k;i++)
	{
		sum += a[i];
	}
	cout << sum;
	return 0;
}


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

int main() {
   ll i,j,k;
    ll n;
    cin >>n ;
    if(n%2!=0)
    {
cout <<  n/2<< endl;
    }else
    {
        cout << n/2-1 << endl;
    }
  
}


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

int main()
{
	char inputS[99];
	long inputLength;
	int isPalindrome = 1;

	scanf("%s", inputS);
	inputLength = strlen(inputS);

	// Check for words with odd number of letters and 
	if (inputLength % 2 > 0)
	{
		for (int i = 0; i < inputLength / 2; i++)
		{
			// If there is difference between right and left side. If there is difference then prints 'No' and terminates function
			if (inputS[i] != inputS[inputLength / 2 + i + 1])
			{
				isPalindrome = 0;
				break;
			}
		}
	}
	else if (inputLength % 2 == 0)
	{
		// Code for words with even number of letters
		for (int i = 0; i < inputLength / 2; i++)
		{
			if (inputS[i] != inputS[inputLength / 2 + i])
			{
				isPalindrome = 0;
				break;
			}
		}
	}

	if (isPalindrome)
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");

	}

	return 0;
}

Measured memory_bytes: 128