akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>

#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define vector std::vector
#define max(a, b) std::max(a, b)
#define min(a, b) std::min(a, b)
#define swap(a, b) std::swap(a, b)
#define sort(...) std::sort(__VA_ARGS__)
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)
#define abs(x) ((x) < 0 ? -(x) : (x))

#if __cplusplus >= 201103L
using ll = long long;
using ull = unsigned long long;
#else
typedef long long ll;
typedef unsigned long long ull;
#endif

#define _GIO 1

#if _GIO
struct _gio
{
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

	char rcha;
	bool rneg;
#if _GG
#else
	char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

	_gio()
	{
		rcha = ' ';
#if _GG
#else
		r1 = r2 = ruf, w1 = wuf;
#endif
	}

	~_gio()
	{
#if _GG
#else
		fwrite(wuf, 1, w1 - wuf, stdout);
#endif
	}

	inline void flush()
	{
#ifdef _GG
#else
		fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
	}

	inline int readc()
	{
#if _GG
		return getchar();
#else
		return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
					? -1
					: *r1++);
#endif
	}

	template <typename T, typename... Args>
	void read(T &x, Args &... args)
	{
		read(x), read(args...);
	}

	inline void read() {}

	inline void read(char *s)
	{
		while (blank(rcha))
			rcha = readc();
		while (!blank(rcha) && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	inline void readl(char *s)
	{
		while (blank(rcha))
			rcha = readc();
		while (rcha != '\n' && rcha > 0)
			*s++ = rcha, rcha = readc();
		*s = '\0';
	}

	template <typename T>
	inline void read(T &x)
	{
		x = rcha = rneg = 0;
		while (!isdigit(rcha) && rcha != '-')
			rcha = readc();
		rcha == '-' && (rneg = true, rcha = readc());
		while (isdigit(rcha))
			x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
		rneg && (x = -x);
	}

	inline void writec(const char &c)
	{
#if _GG
		putchar(c);
#else
		(w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
		*w1++ = c;
#endif
	}

	template <typename T, typename... Args>
	void write(const T &x, const Args &... args)
	{
		write(x), write(args...);
	}

	template <typename T, typename... Args>
	void writel(const T &x, const Args &... args)
	{
		write(x), write(args...);
		writec('\n');
	}

	inline void write() {}

	inline void write(const char &c) { writec(c); }

	template <typename T>
	void write(T x)
	{
		if (x < 0)
		{
			writec('-');
			write(-ll(x));
			return;
		}
		if (x > 9)
			write(x / 10);
		writec(x % 10 ^ 48);
	}

	inline void write(const char *s)
	{
		while (*s)
			writec(*s++);
	}
#undef BFSZ
} io;
#endif

int main()
{
	ll n, k, t;
	io.read(n, k);
	t = n % k;
	io.writel(min(abs(k - t), t));
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut ls: Vec<usize> = vec![0; n];
    let mut rs: Vec<usize> = vec![0; n];
    for i in 0..n {
        if i + v[i] < n {
            ls[i + v[i]] += 1;
        }
        if i >= v[i] {
            rs[i - v[i]] += 1;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        ans += ls[i] * rs[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6720
n = gets.strip.to_i
 
min = gets.strip.to_i
profit = -1000000000
 
(n-1).times do
  x = gets.strip.to_i
  pr = x - min
  if profit < pr
    profit = pr
  end
  if x < min
    min = x
  end
end
 
puts profit

Measured memory_bytes: 8764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        return a > p.a;
    }
    int a, i;
};

int main() {
    int n;
    scanf("%d", &n);

    P p[2000];
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);

        p[i] = { a, i };
    }
    sort(p, p + n);

    ll dp[2001];
    dp[0] = 0;
    for (int k = 0; k < n; k++) {
        dp[k + 1] = dp[k] + (ll)p[k].a * (p[k].i - k);
        for (int i = k - 1, j = 0; i >= 0; i--, j++) {
            dp[i + 1] = max(dp[i] + (ll)p[k].a * (p[k].i - i), dp[i + 1] + (ll)p[k].a * (n - 1 - j - p[k].i));
        }
        dp[0] += (ll)p[k].a * (n - 1 - k - p[k].i);
    }

    printf("%lld\n", *max_element(dp, dp + n + 1));

    return 0;
}

Measured memory_bytes: 3872
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, M;

//x^nをmodのもとで計算する
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow((x*x) % mod, n/2, mod);
  if (n & 1) res = (res*x) % mod;
  return res;
}

ll my_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = pow(x*x, n/2);
  if (n & 1) res *= x;
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);

  cin >> N >> M;

  cout << my_pow(2, M) * 100 * (N + 18*M) << endl;
}


Measured memory_bytes: 384
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline 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>inline 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));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>m)
    {
        vector<pair<LL,LL> > a;
        rep(i,n)
        {
            cin>>x>>y;
            a.pb({x,y});
        }
        s=c=0;
        c=INT_MAX;
        bool f=1;
        rep(i,n)
        {
            if(a[i].second>m) continue;
            s=a[i].first;
            if(s<c)
            {
                c=s,f=0;
            }
        }
        if(f) cout<<"TLE"<<en;
        else
        cout<<c<<en;
    }
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
//#include"matrix.h"
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define REP(i,x,y) for(ll (i)=(x);(i)<(y);(i)++)
#define RREP(i,x,y) for(ll (i)=(x);(i)>=(y);(i)--)
#define sqr(x) ((x)*(x))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define fst first
#define snd second
#define itm1 fst
#define itm2 snd.fst
#define itm3 snd.snd
#define sz(v) ((ll)v.size())
#define oo 200000000000
//#define EPS 1e-9

//#define pi acos(-1)
#define MOD 1000000007
#define MAXN 999409605
#define cot 20
//#define N 300005
//#define min -9042414321442
#define INF 1065435634
#define N1 90
//typedef long double ld;
typedef  long long ll;
//typedef short int ll;
//typedef ll ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef pair<ll,ii> tri;
typedef vector<ll> vi;

#define N 243555   
#define M 31
//#define cap 1000000000
#define bas 31

inline ll ma(ll a, ll b){ return ((a-b>0)? a:b);}
inline ll mi(ll a, ll b){return ((a-b>0)? b:a);}
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

inline ll go(ll &a){
  ll ans=0;
  while(a) ans+=a%10, a/=10;
  return ans;
}
int main(){
  fastio;
  ll n; cin>>n;
  ll ans=MAXN;
  REP(i,1,n){
    ll a=i, b=n-i;
    ans=mi(ans, go(a)+go(b));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll n,k,p[2000],i,cost;
int main ()
{
    cin>>n>>k;
    for (i=1;i<=n;++i) cin>>p[i];
    sort(p+1,p+n+1);
    for (i=1;i<=k;++i) cost+=p[i];
    cout<<cost;
}



Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
    int N,i,len,A,ans;
    int *count;
    bool flag=false;
    cin >> N;
    len = N/2 + N%2;
    count = new int[len];
    for(i=0;i<len;i++) count[i] = 0;
    for(i=0;i<N;i++){
        cin >> A;
        if(A%2 == N%2 || A/2 >= len){
            flag = true;
            break;
        }
        count[A/2]++;
    }
    ans = 1;
    if(N%2 == 1 && count[0] != 1) flag = true;
    for(i=N%2;i<len&&(!flag);i++){
        if(count[i] != 2) flag = true;
        else ans = (ans*2)%1000000007;
    }
    if(flag) cout << 0 << endl;
    else cout << ans << endl;
    delete[] count;
    return 0;
}

Measured memory_bytes: 384
use std::io::Write;
use std::ops::{Add, Mul, Sub};

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let _n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let d: Vec<isize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let mut counts = vec![0; 13];
    counts[0] += 1;
    for x in d {
        counts[x as usize] += 1;
    }

    let mut a = vec![];
    let mut b = vec![];
    for i in 0..13 {
        if counts[i] == 1 {
            a.push(i as isize);
        } else if counts[i] == 2 {
            b.push(i as isize);
        } else if counts[i] >= 3 {
            // answer
            println!("0");
            return;
        }
    }

    let mut v = vec![];
    for x in b {
        v.push(x);
        v.push(24 - x);
    }

    let mut max = 0;
    let l = a.len();
    for bits in 0..(1 << l) {
        let mut v = v.clone();
        for (i, x) in a.iter().enumerate() {
            if is_plus(bits, i) {
                v.push(*x);
            } else {
                v.push(24 - *x);
            }
        }

        let tmp = calc_min(&v);
        if max < tmp {
            // debugln!("{}, {:?}", tmp, v);
            max = tmp;
        }
    }

    println!("{}", max);
}

fn calc_min(v: &Vec<isize>) -> isize {
    let mut min = std::isize::MAX;
    for i in 0..v.len() {
        for j in (i + 1)..v.len() {
            let tmp = calc_diff(v[i], v[j]);
            if tmp < min {
                min = tmp;
            }
        }
    }

    min
}

fn calc_diff(a: isize, b: isize) -> isize {
    std::cmp::min((a - b).abs(), (24 - (a - b).abs()))
}

fn is_plus(bits: isize, index: usize) -> bool {
    (bits & (1 << index)) > 0
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<map>

using namespace std;

map<char,int> a;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > 12) cout << b << endl;
  else if(a <= 12 & a > 5) cout << b/2 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
Q = int(input())
ans = []
s = sum(A)
for _ in range(Q):
    b, c = map(int, input().split())
    n = cnt[b]
    if b in cnt:
        cnt[c] += cnt[b]
        del cnt[b]
    s += (c-b)*n
    print(s)

Measured memory_bytes: 21400
#include<stdio.h>
#include<math.h>
int main(){
	int n,i;
	int ten[1000];
	double hei,a,bun,gou=0;
	
	while(1){
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(i=0;i<n;i++){
		scanf("%d",&ten[i]);
		gou += ten[i];
	}
	hei = gou/n;
	for(i=0;i<n;i++){
		a += pow(ten[i] - hei,2.0);
	}
	bun = sqrt(a/n);
	printf("%.8f\n",bun);
	gou=0;
	a=0;
	}
}

Measured memory_bytes: 1068
symbol = list(input().split())
stack = []

while len(symbol) > 0:
    x = symbol.pop(0)
    if x.isdigit():
        stack.append(int(x))
    else:
        a,b = stack.pop(),stack.pop()
        if x == "+":
            stack.append(b + a)
        elif x == "-":
            stack.append(b - a)
        elif x == "*":
            stack.append(b * a)

print(stack.pop())



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
int main(){
    int n;cin>>n;
    ll ans=0;
    vi v(n);
    rep(i,n){
        int a;cin>>a;
        v[n-a]=i;
    }
    S s;
    rep(i,2){s.insert(-1);s.insert(n);}
    rep(i,n){
        auto it=s.lower_bound(v[i]);
        it++;
        vi x(4);
        rep(j,4){
            x[3-j]=*it;
            it--;
        }
        ans+=(n-i)*((x[1]-x[0])*(x[2]-v[i])+(v[i]-x[1])*(x[3]-x[2]));
      s.insert(v[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int n;
  int sm;
  while(cin>>n&&n){
    n=1000-n;
    sm=0;
    while(n>=500){
      n-=500;
      sm++;
    }
    while(n>=100){
      n-=100;
      sm++;
    }
    while(n>=50){
      n-=50;
      sm++;
    }
    while(n>=10){
      n-=10;
      sm++;
    }
    while(n>=5){
      n-=5;
      sm++;
    }
    while(n){
      n--;
      sm++;
    }
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<pair<int,int>>> xy(N,vector<pair<int,int>>(N-1));
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    for (int j = 0; j < A.at(i); j++){
      int x, y;
      cin >> x >> y;
      xy.at(i).at(j) = make_pair(x, y);
    }
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);
    bool ok = true;
    for (int i = 0; i < N; i++){
      if(s.test(i)){
        bool unkind = false;
        for (int j = 0; j < A.at(i); j++){
          if (s.test(xy.at(i).at(j).first-1)){
            if(xy.at(i).at(j).second == 0){
              unkind = true;
              break;
            }
          } else {
            if(xy.at(i).at(j).second == 1){
              unkind = true;
              break;
            }
          }
        }
        if (unkind){
          ok = false;
          break;
        }
      }
    }
    if(ok) {
      int num = s.count();
      ans = max(ans, num);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var K = Number(lines[0].split(" ")[1]);

    var ans = 0;
    var num = Array(1000000).fill(0)

    for (var i = 1; i <= N; i++) { num[i % K]++ }
    for (var a = 0; a < K; a++) {
        var b = (K - a) % K
        var c = (K - a) % K
        if ((b + c) % K === 0) { ans += num[a] * num[b] * num[c]; }
    }
    console.log(ans)
}); 

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

int main()
{
    char ch;

    while(1)
    {
        scanf("%c", &ch);

        if(ch == '\n') break;

        if('a' <= ch && ch <= 'z')  ch = ch - 32;
        else if ('A' <= ch && ch <= 'Z') ch = ch + 32;

        cout << ch;
        
    }
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 3244
#include <iostream>
using namespace std;
int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2 + y1 - y2;
  int y3 = x2 - x1 + y2;
  int x4 = x1 - y2 + y1;
  int y4 = y1 + x2 - x1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
map<ll, string> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
	mp[400] = "8";
	mp[600] = "7";
	mp[800] = "6";
	mp[1000] = "5";
	mp[1200] = "4";
	mp[1400] = "3";
	mp[1600] = "2";
	mp[1800] = "1";
    cin >> N;
    for(auto x: mp) {
    	if(N >= x.ff && N <= x.ff + 199) {
    		cout << x.ss << "\n";
    		quit;
    	}
    }
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3660
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (h, w) = {
        let hw:Vec<_> = st.trim().split(" ").map(|x| x.parse::<usize>().unwrap()).collect();
        (hw[0], hw[1])
    };
    let mut c:Vec<Vec<i64>> = Vec::with_capacity(10);
    for i in 0..10 {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        let c_i = st.trim().split(" ").map(|x| x.parse::<i64>().unwrap()).collect();
        c.push(c_i);
    };
    for k in 0..10 {
        for i in 0..10{
            for j in 0..10 {
                if c[i][j] > c[i][k]+c[k][j] {
                    c[i][j] = c[i][k]+c[k][j];
                };
            };
        };
    };
    let mut result:i64 = 0;
    for i in 0..h {
        let mut st = String::new();
        stdin().read_line(&mut st).unwrap();
        let a:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i64>().unwrap()).collect();
        for j in 0..w {
            if a[j] >= 0 {
                result += c[a[j] as usize][1];
            };
        };
    };
    println!("{}", result);
}

Measured memory_bytes: 4352
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():
    a, b = in_nn()
    print(max(a + b, a - b, a * b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

// red - blue
bool dp[81][81][12801];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    vector<vector<int>> b(h, vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> b[i][j];
        }
    }
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            for(int diff = 0; diff < 12801; diff++) {
                if(dp[i][j][diff]) {
                    if(i + 1 < h) {
                        int hoge = abs(a[i + 1][j] - b[i + 1][j]);
                        dp[i + 1][j][diff + hoge] = true;
                        dp[i + 1][j][abs(diff - hoge)] = true;
                    }
                    if(j + 1 < w) {
                        int hoge = abs(a[i][j + 1] - b[i][j + 1]);
                        dp[i][j + 1][diff + hoge] = true;
                        dp[i][j + 1][abs(diff - hoge)] = true;
                    }
                }
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < 12801; i++) {
        if(dp[h - 1][w - 1][i]) {
            chmin(ans, i);
        }
    }
    cout << ans << endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n;
    cin >> n;

    i64 ans = 0;
    for (i64 i = 1; i <= n; i++) ans += i * (n - i + 1);
    for (i64 i = 0; i < n - 1; i++) {
        i64 u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include <iomanip>      // std::setprecision
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

lli gcd(lli a, lli b) { 
   if (b == 0) return a; 
   return gcd(b, a % b);  
} 
lli n;
vector<double > a;
vector<vector<double> >dp;

double f(lli idx,lli req){
  if(req == 0){return 1;}
  if(idx == n){return 0;}
  //take this or not..
  if(dp[idx][req] != -1){return dp[idx][req];}
  dp[idx][req] = a[idx] * f(idx+1 , req-1) + (1.00 - a[idx])* f(idx+1 , req);
  return dp[idx][req];
}


void solve(){
cin>>n;
a.resize(n);
dp.resize(n+1, vector<double>(n+1 , -1));
fo(i,n){
  cin>>a[i];
}
double fans = f(0,n/2 +1);
cout<<std::setprecision(10)<<fans<<Endl;

}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;

}

Measured memory_bytes: 70912
import collections
N = int(input())
a = list(map(int,input().split()))

a = collections.Counter(a)
a_list = list(a.items())
a_list = sorted(a_list,key = lambda a_list:a_list[0])

if len(a_list) == 1:
	if a_list[0][0] == 0:
		print("Yes")
	else:
		print("No")
elif len(a_list) == 2:
	if ((a_list[0][0] == 0) and (a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(2*N/3))):
		print("Yes")
	else:
		print("No")
elif len(a_list) == 3:
	if ((a_list[0][1] == int(N/3)) and \
		(a_list[1][1] == int(N/3)) and \
		(a_list[2][1] == int(N/3)) and \
		(a_list[0][0]^a_list[1][0]^a_list[2][0] == 0)):
		print("Yes")
	else:
		print("No")
else:
	print("No")

Measured memory_bytes: 16164
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

i64 bs[51], ps[51];

i64 get_size(int k, i64 x) {
    if (x == 0) return 0;
    if (x >= bs[k]) {
        return ps[k];
    }
    if (x > bs[k] / 2) {
        return (ps[k] / 2 + 1) + get_size(k - 1, x - (bs[k] / 2 + 1));
    }
    return get_size(k - 1, x - 1);
}

int main() {
    int n;
    cin >> n;
    bs[0] = 1, ps[0] = 1;
    for (int i = 1; i <= 50; i++) {
        bs[i] = bs[i - 1] * 2 + 3;
        ps[i] = ps[i - 1] * 2 + 1;
    }

    i64 x;
    cin >> x;
    cout << get_size(n, x) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while (n != 0) {
			char[] step = sc.next().toCharArray();
			char on = ' ';
			boolean flag = true;
			for (int i = 0; i < step.length; i++) {
				if (step[i] == on) {
					flag = false;
					break;
				}
				on = step[i];
			}
			System.out.println(flag ? "Yes" : "No");
			n--;
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR(i,k,n) for(ll i=(k);(k)<(n)?i<(n):i>(n);(k)<(n)?i+=1:i-=1)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define sz(a) ll((a).size())
#define all(o) (o).begin(), (o).end()
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define TR(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
template<class T> T** arr2D(int n,int m,T init){
    T** mat=new T*[n];
    FOR(i,0,n){
        mat[i]=new T[m];
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
    return mat;
}
template<class T> void initialise(T** mat,T init,int n,int m){
    FOR(i,0,n){
        FOR(j,0,m){
            mat[i][j]=init;
        }
    }
}
template<class T> void destroy(T** mat,int n,int m){
    FOR(i,0,n){
        delete[] mat[i];
    }delete[] mat;
}
const int MOD = 1000000007;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }

/////////////////////////////////////////////////////////////////////
ll ways[2][100100];
ll prefix_sum[2][100100];
void solve(){
    int N,K;
    cin>>N>>K;
    vector<int> arr(N);
    FOR(i,0,N)cin>>arr[i];
    ways[0][0]=1;
    prefix_sum[0][0]=1;
    FOR(k,0,K+1) prefix_sum[0][k]=1;
    int t=1;
    FOR(i,0,N){
        FOR(k,0,K+1){
            if(k==0){
                ways[t][k]=1;
                prefix_sum[t][k]=1;
            }else{
                ways[t][k]=prefix_sum[t^1][k];
                if(k-arr[i]>0){
                    ways[t][k]-=(prefix_sum[t^1][k-arr[i]-1]);
                }
                ways[t][k]=(ways[t][k]%MOD+MOD)%MOD;
                prefix_sum[t][k]=prefix_sum[t][k-1]+ways[t][k];
                prefix_sum[t][k]=prefix_sum[t][k]%MOD;
            }
        }
        t^=1;
    }
    cout<<ways[t^1][K]<<'\n';
}
int main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    solve();
    return 0;
}


Measured memory_bytes: 6664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll dp[4][3010][3010];

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

	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<ll>> val(r, vector<ll>(c));
	rep(i, k) {
		int x, y, v;
		cin >> x >> y >> v;
		x--; y--;
		val[x][y] = v;
	}
	rep(i, r) {
		rep(j, c) {
			rep(d, 4) {
				chmax(dp[d][i + 1][j + 1], dp[d][i + 1][j]);
				chmax(dp[0][i + 1][j + 1], dp[d][i][j + 1]);
			}
			if (val[i][j]) {
				rep(d, 4) {
					chmax(dp[1][i + 1][j + 1], dp[d][i][j + 1] + val[i][j]);
					if (d) chmax(dp[d][i + 1][j + 1], dp[d - 1][i + 1][j] + val[i][j]);
				}
			}
		}
	}
	ll ans = 0;
	rep(d, 4) chmax(ans, dp[d][r][c]);
	cout << ans << '\n';
}

Measured memory_bytes: 355832
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    //String blank = sc.nextLine();
    String t = sc.nextLine();
    char sary[] = new char[s.length()];
    char tary[] = new char[t.length()];

    for(int i = 0; i < s.length(); i++){
      sary[i] = s.charAt(i);
    }
    for(int i = 0; i < t.length(); i++){
      tary[i] = t.charAt(i);
    }

    Arrays.sort(sary);
    Arrays.sort(tary);
    //Collections.reverseOrder()はプリミティブ型は使えないっぽいので...
    //s = Arrays.toString(sary);//いわゆるStringにならない...
    String sorted_s = "";
    for(int i = 0; i < s.length(); i++){
      sorted_s += String.valueOf(sary[i]);
    }

    String sorted_t = "";//=nulだと"null"にtary[i]がくっついてしまう
    for(int i = t.length()-1; i >= 0; i--){
      sorted_t += String.valueOf(tary[i]);
    }


    if(sorted_s.compareTo(sorted_t) < 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
 
int main()
{
	int N, a, b, c;

    cin >> N;

    a = N / 100;
    b = (N / 10) % 10;
    c = N % 10;  

 
    if(a == 7 || b == 7 || c == 7)
        cout << "Yes";
    else
        cout << "No";
 
	return 0;
}

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

int main()
{
  int N;
  int A[100];
  int count=1;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }

  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      if(A[i]<A[j]){
        int tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
      }
    }
  }

  for(int i=0;i<N-1;i++){
    if(A[i] != A[i+1]){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // This will work only for g++ compiler.
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forab(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define __builtin_popcount(x) ones(x)
#define __builtin_popcountl(x) onesl(x)
#define __builtin_popcountll(x) onesll(x)// to be used with algorithms that processes a container Eg: find(all(c
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define InputOuput freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll linf = 1e18L +5;
const int inf = 1e9 +5 ;

int main(){
   // InputOuput;
    Fast;
    string a,b ; cin >> a >> b ;
    int n = a.size(), m = b.size();

    if(n<m){
        swap(a,b);
        swap(n,m);
    }


    vvi dp(m+1, vi(n+1, 0));

    for1(i,m){
        //vector<int> np(n+1,0);
        for1(j,n){
            if(a[j-1] == b[i-1]) {
                dp[i][j] = dp[i-1][j-1]+1;
                //ans.pb(a[j-1]);
            }
            else{

                dp[i][j] = max(dp[i][j-1], dp[i-1][j]) ;

            }
        }

    }
    //cout << dp[m][n]<<'\n';
    int si = dp[m][n];
    int i =m , j = n ;
    string ans( si,' ');
    si--;
    while(i> 0 && j>0){
        if(a[j-1] == b[i-1]){
            ans[si] = a[j-1];
            j--;
            i--;
            si--;
        }
        else if (dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }
    cout << ans <<'\n';
    return 0;

}

Measured memory_bytes: 38484
n = gets.to_i

1.upto(3500) do |i|
  1.upto(3500) do |j|
    a = n * i * j
    b = 4 * i * j - n * i - n * j

    if b > 0 && a % b == 0
      puts [i, j, a / b].join(' ')
      exit
    end
  end
end

Measured memory_bytes: 14088
#pragma GCC optimize ("O3", "unroll-loops")
#pragma GCC target ("avx")
#include <stdio.h>
#include <algorithm>

constexpr unsigned int N = 2e6;
char buffer[N];
char *ptr = buffer;
constexpr unsigned int S = 3e5 + 5e4;
char *left = buffer + S, *right;

int main(void){
    fread(buffer + S, sizeof(char), N - S, stdin);
  
    unsigned int valid = 0, invalid = S;
    while(invalid - valid > 1){
      unsigned int mid = (valid + invalid) >> 1;
      if(*(left + mid) >= 'a' and *(left + mid - 1) >= 'a') valid = mid;
      else invalid = mid;
    }
    right = left + invalid; ptr = right;
    unsigned int q = 0;
    while(*(++ptr) >= '0') q = 10 * q + *ptr - '0';
    bool flag = false;
    while(q--){
        if(*(++ptr) == '1') flag = not flag;
        else{
            if((*(ptr += 2) == '1') ^ flag) *(--left) = *(ptr += 2);
            else *(right++) = *(ptr += 2); 
        }
        ptr++;
    }
    if(flag) std::reverse(left, right);
    fwrite(left, sizeof(char), right - left, stdout);
    
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A;
  int k=0,i=0,j=0,v=0,a,c=0,size;

  scanf("%d",&size);//size of array
  A = (int *)malloc(size * sizeof(int)); // memory

  for(c=0;c<size;c++){
  scanf("%d",&a);
    A[c]=a;
    }

  for(k=0;k<c-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d",A[k]);
  printf("\n");
  

  for(i=1;i<=c-1;i++){
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  for(k=0;k<c-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d",A[k]);
  // if(i<c-1)
    printf("\n");
  }
  free(A);
  return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
using namespace std;
#define llong long long
int main()
{
   int N;
   cin >> N;
   vector<double> x(N);
   vector<string> u(N);
   double sum = 0; 
   for(int i = 0; i < N; i++)
   {
      cin >> x[i] >> u[i];
      if(u[i] == "BTC")
      {
         sum += 380000*x[i];
      }
      else
      {
         sum += x[i];
      }
   }
   cout << fixed << setprecision(5) << sum << endl;
   return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

int n , a[N] , pos[N] , ans[N];
vector<int> v , adj[N];
set< pair<int,int> > st[N];

void dfs(int node , int par)
{
    int up = lower_bound(v.begin() , v.end() , a[node])-v.begin();
    if (up==v.size()) v.push_back(a[node]);
    else v[up] = a[node];
    st[up].insert({a[node] , node});
    pos[node] = up;
    ans[node] = v.size();

    for(auto ch : adj[node])
    {
        if (ch != par) dfs(ch,node);
    }

    int p = pos[node];
    st[p].erase({a[node] , node});
    if (st[p].size()==0) v.pop_back();
    else v[p] = (*st[p].begin()).f;
}

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

    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];

    for(int i=1; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y) , adj[y].push_back(x);
    }

    dfs(1,1);

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

    return 0;
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int n;
    cin >> n;
    vector<int> arr(n+5, 0);
    arr[0] = 3;

    int ans = 1;
    rep(i,n){
        int a; cin >> a;
        ans = (ans * arr[a]) % MOD;
        arr[a + 1]++;
        arr[a]--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3940
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;



int main() {	
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    char s[3];
    cin >> s;
    int ans = 0, tmp = 1;
    for(int i = 0; i < 3; ++i) {
        if(s[i] == 'R')
            if(s[i - 1] == 'R')
                tmp++, ans = max(ans, tmp);
            else ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, w;
  cin >> n >> w;
  vector<ll> dp(w+1, -1); // dp[j] .. maximum value with j.
  dp[0] = 0;
  rep(i, n) {
    ll nw, nv;
    cin >> nw >> nv;
    for (ll j = w; j >= 0; --j) {
      if (j-nw >= 0 && dp[j-nw] >= 0) {
        chmax(dp[j], dp[j-nw] + nv);
      }
    }
  }
  ll ans = 0;
  rep(i, w+1) {
    chmax(ans, dp[i]);
  }
  cout << ans << endl;
}


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

int a, b, c, d;

int main(){
	cin >> a >> b >> c >> d;
	if(a+b > c+d) cout << "Left";
	else if(a+b == c+d) cout << "Balanced";
	else if(a+b < c+d) cout << "Right";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();

        double angle = (h * 30 + m * 0.5) - (m * 6);
        if (angle > 180) {
            angle = 360 - angle;
        }
        double ans = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(angle)));
        System.out.println(ans);
    }
}

Measured memory_bytes: 35952
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int N;
    string S;
    cin >> N >> S;
    int i = 0, cnt = 0;
    while (i < N) {
        string T = S.substr(i, 2);
        if (T == "OX" || T == "XO") {
            ++cnt;
            i += 2;
        } else {
            ++i;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3304