akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashSet;
// d
fn main() {
    input! {
        n: usize,
        k: usize,
        lr: [(usize, usize); k]
    }

    let MOD = 998244353;

    let mut dp = vec![0; n];
    let mut diff_pdp: Vec<Vec<usize>> = vec![vec![]; n];
    let mut diff_mdp: Vec<Vec<usize>> = vec![vec![]; n];
    dp[0] = 1;
    dp[1] = -1;
    for i in 0..n {
        for j in &lr {
            let l = j.0;
            let r = j.1;
            if i + l < n {
                diff_pdp[i + l].push(i);
            }
            if i + r + 1 < n {
                diff_mdp[i + r + 1].push(i);
            }
        }
    }

    for i in 1..n {
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
        for j in &diff_pdp[i] {
            dp[i] += dp[*j];
            dp[i] %= MOD;
        }
        for j in &diff_mdp[i] {
            dp[i] -= dp[*j];
            dp[i] = if dp[i] < 0 { dp[i] + MOD } else { dp[i] };
            dp[i] %= MOD;
        }
    }
    println!("{}", dp[n - 1]);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


Measured memory_bytes: 42904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int a, b, c, k;
bool bl;

signed main() {
	cin >> a >> b >> c >> k;
	for (int i = 0; i <= k; i++)for (int j = 0; j + i <= k; j++)for (int l = 0; i + j + l <= k; l++) {
		int p = a * pow(2, i);
		int q = b * pow(2, j);
		int r = c * pow(2, l);
		if (p < q&&q < r)bl = true;
	}
	if (bl)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 4004
#include <iostream>
using namespace std;
int main(void){
    int r,c,rc,i,j,sumr,sumc[100];
    cin >> r >> c ;
    sumc[c]=0;
    for(i=0;i<r;i++){
        sumr=0;
        for(j=0;j<c;j++){
            if(i==0) sumc[j]=0;
            cin >> rc ;
            cout << rc << " " ;
            sumr+=rc;
            sumc[j]+=rc;
        }
        cout << sumr << endl;
        sumc[c]+=sumr;
    }
    for(i=0;i<=c;i++){
        cout << sumc[i] ;
        if(i==c) cout << endl;
        else cout << " " ;
    }
     
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf(" %d",&n);
    int a[2][n];
    for(int i=0;i<n;i++)
        scanf(" %d",&a[0][i]);
    for(int i=0;i<n;i++)
        scanf(" %d",&a[1][i]);
    for(int i=1;i<n;i++)
    {
        a[0][i]+=a[0][i-1];
        a[1][i]+=a[1][i-1];
    }
    int max=0;
    int ans=a[0][0]+a[1][n-1];
    if(ans>max) max=ans;
    for(int i=1;i<n;i++)
    {
        ans=a[0][i]+a[1][n-1]-a[1][i-1];
        if(ans>max) max=ans;
    }
    printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 128
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-19 18:52:05
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=100010;
int n;
struct arr
{
	int a[N];
	arr(){ memset(a,0,sizeof(a)); }
	int &operator[](int p){ return a[p]; }
};
arr inv(arr a)
{
	arr b;
	fr(i,1,n) b[a[i]]=i;
	return b;
}
arr operator*(arr a,arr b)
{
	arr c;
	fr(i,1,n) c[i]=a[b[i]];
	return c;
}
arr &operator*=(arr &a,arr b){ return a=a*b; }
int k;
arr a,b,c;
arr power(arr a,int b)
{
	arr r;
	fr(i,1,n) r[i]=i;
	for(;b;b>>=1,a*=a) if(b&1) r*=a;
	return r;
}
int main()
{
	n=read(); k=read();
	fr(i,1,n) a[i]=read();
	fr(i,1,n) b[i]=read();
	c=b*inv(a)*inv(b)*a; k--;
	while(k%6)
	{
		arr d=a; a=b; b*=inv(d); k--;
	}
	a=power(c,k/6)*a*power(inv(c),k/6);
	fr(i,1,n) printf("%d%c",a[i],i==n?'\n':' ');
	return 0;
}
/*
a
b
bA
bAB
bABaB
bABaaB
bABabaB
bABabAbaB
*/

Measured memory_bytes: 13696
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
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; }

int main()
{
    int n;
    cin >> n;
    set<int> set;
    rep(i,n){
        int a;
        cin >> a;
        set.insert(a);
    }
    if(set.size()!=n){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

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

int main() {
    unsigned long Q, H, S, D, N;
    cin >> Q >> H >> S >> D;
    cin >> N;

    double L[4] = {Q * 4, H * 2, S, D * 0.5};

    unsigned long min = L[0];
    bool Dflag = false;
    for (int i = 0; i < 4; i++) {
        if (L[i] < min) {
            min = L[i];
            if (i == 3) {
                Dflag = true;
            }
        }
    }

    if (Dflag) {
        unsigned long min2 = L[0];
        for (int i = 0; i < 3; i++) {
            if (L[i] < min2) {
                min2 = L[i];
            }
        }
        if (N % 2) {
            cout << (N - 1) / 2 * D + min2 << endl;
        } else {
            cout << N / 2 * D;
        }
    } else {
        cout << min * N << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc099/tasks/abc099_b

#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	int m;
	cin >> n >> m;
	int f=m-n;
	int l=f*(f+1)/2;
	cout << l-m << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n,m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
pair<int64_t,int> expr(const string &s, int i);

pair<int64_t,int> num(const string &s, int i) {
  int64_t v = 0;
  while(i < s.size() && ('0' <= s[i] && s[i] <= '9')) {
    v *= 10;
    v += s[i] - '0';
    ++i;
  }
  return make_pair(v, i);
}

pair<int64_t,int> factor(const string &s, int i) {
  if (s[i] == '(') {
    auto p = expr(s, i+1);
    ++p.second;
    return p;
  } else {
    return num(s, i);
  }
}
pair<int64_t,int> term(const string &s, int i) {
  int64_t val;
  tie(val, i) = factor(s, i);
  while(i < s.size() && (s[i] == '*' || s[i] == '/')) {
    int64_t val2;
    int j;
    tie(val2, j) = factor(s, i+1);
    if (s[i] == '*') val *= val2;
    else val /= val2;
    i = j;
  }
  return make_pair(val, i);
}

pair<int64_t,int> expr(const string &s, int i) {
  int64_t val;
  tie(val, i) = term(s, i);
  while(s[i] == '+' || s[i] == '-') {
    int64_t val2;
    int j;
    tie(val2, j) = term(s, i+1);
    if (s[i] == '+') val += val2;
    else val -= val2;
    i = j;
  }
  return make_pair(val, i);
}

int main() {
  int n;
  cin>>n;
  REP(ds,n) {
    string s;
    cin>>s;
    cout << expr(s, 0).first << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>

int main(void)

{

  int W,H,x,y,r;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if((r<=x)&&(x<=(W-r))&&(r<=y)&&(y<=(H-r)))

  {

    printf("Yes\n");

  }

  else

  {

    printf("No\n");

  }

  return 0;

}

Measured memory_bytes: 584
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    
    else cout << b << " " << c << " " << a << endl;
}


Measured memory_bytes: 3084
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
import sys
c=[map(float,s[:-1].split(",")) for s in sys.stdin]
x0,y0=c[0]
x1,y1=c[1][0]-x0,c[1][1]-y0
s=0
for ex,ey in c[2:]:
    x2,y2=ex-x0,ey-y0
    s+=abs(x1*y2-x2*y1)
    x1,y1=x2,y2
print s/2

Measured memory_bytes: 4236
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
H = li()

cnt = 0

for i in range(N):
    flag = 1
    for j in range(i):
        if H[i] < H[j]:
            flag = 0
            break
    if flag:
        cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)
template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}
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;
}
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int N = 2e5+9;
ll n, m, k, a[N], b[N], cum[N];


int main() {
#ifndef	ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i)
    	cin >> a[i];
    for(int i = 1; i <= m; ++i) {
    	cin >> b[i];
    	cum[i] += cum[i - 1] + b[i];
    }
    ll tot = 0;
    ll ans = 0;
    for(int i = 0; i <= n; ++i) {
    	tot += a[i];
    	ll x = k - tot;
    	if(x >= 0) {
    		ll lo = 0, hi = m;
    		ll best = 0;
    		while(lo <= hi) {
    			ll mid = (lo + hi) >> 1;
    			if(cum[mid] <= x) {
    				best = mid;
    				lo = mid + 1;
    			} else {
    				hi = mid - 1;
    			}
    		}
    		ans = max(ans, i + best);
    	} else {
    		// negative value
    		break;
    	}
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8292
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    string t;
    cin>>t;
    int ans = 0;
    for(int i=0;i<t.length();i++){
        if(t[i] == '?') t[i] = 'D';
    }
    for(int i=0;i<t.length()-1;i++){
        if(t[i] == 'D') ans++;
        else if(t[i] == 'P' && t[i+1] == 'D') ans++;
    }
    if(t[t.length()-1] == 'D') ans++;
    cout<<t<<endl;
}

Measured memory_bytes: 3712
use num_integer::gcd;
use proconio::{fastout, input};

// set wiseは簡単
// pairwiseをどうするか？

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let set_gcd = a.iter().fold(a[0], |acc, x| gcd(acc, *x));
    let setwise = set_gcd == 1;

    let max = 1_000_000;
    // let max = 1_000;
    let min_factor = Factorize::new(max).min_factor;
    // dbg!(&min_factor);
    let mut cnt = vec![0; max + 1];
    let mut pairwise = true;
    for ai in a.iter().copied() {
        let mut ai = ai;
        while ai != 1 {
            let prime = min_factor[ai];
            let mut _exp = 0;
            while min_factor[ai] == prime {
                _exp += 1;
                ai /= prime;
            }
            cnt[prime] += 1;
            if cnt[prime] >= 2 {
                pairwise = false;
            }
        }
    }

    let ans = if pairwise {
        "pairwise coprime"
    } else if setwise {
        "setwise coprime"
    } else {
        "not coprime"
    };
    println!("{}", ans);
}

struct Factorize {
    min_factor: Vec<usize>,
}

impl Factorize {
    fn new(max: usize) -> Factorize {
        let min_factor = Factorize::prime_min_factor(max);
        Factorize { min_factor }
    }

    fn prime_min_factor(max: usize) -> Vec<usize> {
        let mut min_factor = vec![0usize; max + 1];
        min_factor[0] = 0;
        min_factor[1] = 1;

        for i in 2..=max {
            if min_factor[i] == 0 {
                min_factor[i] = i;
                let mut j = i * 2;
                while j <= max {
                    if min_factor[j] == 0 {
                        min_factor[j] = i;
                    }
                    j += i;
                }
            }
        }

        min_factor
    }

    fn factorize(&mut self, n: usize) -> Vec<(usize, usize)> {
        let mut factors = vec![];
        let mut n = n;
        while n != 1 {
            let prime = self.min_factor[n];
            let mut exp = 0;
            while self.min_factor[n] == prime {
                exp += 1;
                n /= prime;
            }
            factors.push((prime, exp));
        }

        factors
    }
}


Measured memory_bytes: 28212
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  string S;
  cin>>S;
  ll N=S.size();
  ll A[100010];
  rep(i,N){
    A[i]=0;
  }
  
  ll i=0;
  ll ir=0;
  ll count=0; 
  while(i<N){
    ll countR=0;
    ll countL=0;
    while(S[i]=='R'){
      countR++;
      i++;
      ir=i;
    }
    while(S[i]=='L'){
      countL++;
      i++;
    }
    ll countM=countR+countL;
    if(countM%2==0){
      A[ir-1]=countM/2;
      A[ir]=countM/2;
    }
    else if(countR%2==1&&countL%2==0){
      A[ir-1]=countM/2+1;
      A[ir]=countM/2;
    }
    else if(countL%2==1&&countR%2==0){
      A[ir-1]=countM/2;
      A[ir]=countM/2+1;
    }
  }
  rep(i,N){
    cout<<A[i]<<" ";
  }
}
    
    
    

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

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#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

ll n,k,a[55],dp[55][55][105];

ll F(ll l,ll r,ll cnt)
{
  ll maxi=0;
  if(cnt>k){return -INF;}
  if(cnt==k||l>r){return 0;}
  ll curl=a[l],curr=a[r];
  if(dp[l][r][cnt]!=-1){return dp[l][r][cnt];}
  if(curl>=0){maxi=max(maxi,curl+F(l+1,r,cnt+1));}
  else
  {
    maxi=max(maxi,F(l+1,r,cnt+2));
    maxi=max(maxi,curl+F(l+1,r,cnt+1));
  }
  if(curr>=0){maxi=max(maxi,curr+F(l,r-1,cnt+1));}
  else
  {
    maxi=max(maxi,F(l,r-1,cnt+2));
    maxi=max(maxi,curr+F(l,r-1,cnt+1));
  }
  return dp[l][r][cnt]=maxi;
}

int main()
{
  ms(dp,-1);
  cin>>n>>k;
  for(ll i=0;i<n;i++){cin>>a[i];}
  cout<<F(0,n-1,0)<<endl;
}


Measured memory_bytes: 2688
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: u128,
        a: [u128;n],
    }

    let mut sum: u128 = 1;
    let mut check_zero: bool = false;
    let ten: u128 = 10;
    let BASE: u128 = ten.pow(18);

    for element in &a {
        if *element == 0 {
            check_zero = true;
        }
    }

    if check_zero {
        println!("{}", 0)
    } else {
        for element in a {
            sum *= element;
            if sum > BASE {
                println!("{}", -1);
                break;
            }
        }
    }
    if sum <= BASE && !check_zero {
        println!("{}", sum);
    }
}


Measured memory_bytes: 5516
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int main() {
    int n, x;
    bool flag = true;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        if (x % 2 == 0 && x % 3 != 0 && x % 5 != 0) flag = false;
    }
    if (flag) puts("APPROVED");
    else puts("DENIED");
    return 0;
}

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


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<vector<int>> edges(N, vector<int>());

    for(int i=0; i<M; i++){
        edges[a[i]-1].push_back(b[i]-1);
        edges[b[i]-1].push_back(a[i]-1);
    }
    long long ans=0l;
    for(int i=0; i<M; i++){
        auto bana=a[i]-1;
        auto banb=b[i]-1;
        vector<int> visited(N, 0);
        deque<int> q = {0};
        while(!q.empty()){
            auto j = q.front();
            q.pop_front();
            visited[j]++;
            for(auto dist: edges[j]){
                if(!visited[dist] && !(j==bana&&dist==banb) && !(j==banb&&dist==bana)){
                    q.push_back(dist);
                }
            }
        }
        if(!all_of(visited.begin(), visited.end(), [](int j){return j>0;}))ans++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
const int mod = 1e9 +7 , N = 1e5 + 5 ;
typedef long long ll ;
ll dp[N] ;
ll qmi(ll a, ll b)
{
  ll res =1 ;
  while(b)
   {
     if(b & 1) res = res * a % mod ;
     a = a * a % mod ;
     b >>= 1;
   }
   return res ;
}
int main()
{
  ll ans = 0 ;
  int n , k ;
  cin >> n >> k ;
  for(int i = k ;i >= 1;i --)
   {
     dp[i] = qmi(k / i , n) % mod ;
     for(int j = 2 * i ;j <= k ;j += i)
      dp[i] -= dp[j] , dp[i] = (dp[i] % mod + mod) % mod ;
     ans += i * dp[i] % mod , ans %= mod ;
   }
  cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 4344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int area = 0;

		area = (a + b) * h / 2;
		System.out.println(area);
	}

}

Measured memory_bytes: 21844
//
// Created by TakahiroYamaji on 2020/08/14.
//
#include<iostream>
#include<queue>
char field[51][51];
int visited[51][51];
int dis[51][51];
int H, W;
typedef std::pair<int, int> P;
std::queue<P> Q;
int dh[] = {-1, 0, 1, 0};
int dw[] = {0, 1, 0, -1};

void init_dis(int h,int  w){
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            dis[i][j] = 1000000;
        }
    }
}

//void init_que(){
//    Q.push(P(0, 0));
//    dis[0][0] = 1;
//}

void bfs(){
    Q.push(P(0, 0));
    dis[0][0] = 0;

    while(!Q.empty()){
        P p = Q.front();
        Q.pop();
        visited[p.first][p.second] = 1;
        for (int i=0;i<4;i++){
            int next_h = p.first + dh[i];
            int next_w = p.second + dw[i];
            if (0 <= next_h && next_h < H && 0 <= next_w && next_w < W && dis[next_h][next_w] == 1000000){
                if (field[next_h][next_w] == '.'){
                    Q.push(P(next_h, next_w));
                    if (dis[next_h][next_w] > dis[p.first][p.second] + 1){
                        dis[next_h][next_w]  = dis[p.first][p.second] + 1;
                    }
                }

            }
        }
    }
}

void print_dis(){
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            std::cout << dis[i][j] << " ";
        }
        std::cout << std::endl;
    }
}

int main(){
    std::cin >> H >> W;
    int cnt = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            std::cin >> field[i][j];
            if (field[i][j] == '#')cnt++;
        }
    }

    init_dis(H, W);
    //init_que();
    bfs();

    int res = dis[H-1][W-1];
    int ans = H * W - res - cnt - 1;
    if (res == 1000000){
        std::cout << -1 << std::endl;
    }else{
        std::cout << ans << std::endl;
    }
//    std::cout << ans << std::endl;
//    std::cout << res << std::endl;
//    //print_dis();
}



Measured memory_bytes: 3224
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

N,K = LI()
s = [0 for _ in range(N+1)]
for _ in range(K):
    d = NI()
    for a in LI():
        s[a] = 1

print(N-sum(s))

Measured memory_bytes: 69212
#include<bits/stdc++.h>
#define ll long long int
#define mod 998244353
using namespace std;
const ll maxN = 400001;
ll st[4*maxN], lazy[4*maxN];
ll base[400001];
void build(ll ind, ll lef, ll right)
{
    if(lef == right)
    {
        st[ind] = base[lef];
        return;
    }
    ll mid = (lef + right) / 2;
    build(2*ind, lef, mid);
    build(2*ind+1, mid+1, right);
    st[ind] = (st[2*ind]%mod + st[2*ind+1]%mod)%mod;
}
void update(ll ind, ll lef, ll right, ll i, ll j, ll val)
{
    if(lazy[ind] != 0)
    {
          st[ind]=0;
          if(lef!=0)
          {
             ll dx = ((base[right] - base[lef-1]+mod)%mod * lazy[ind]%mod)%mod;
             st[ind] =(st[ind]%mod+ dx%mod)%mod;
             if(lef != right)
             lazy[2*ind] = lazy[ind], lazy[2*ind+1] = lazy[ind];
             lazy[ind]=0;
          }
          else
          {
            ll dx = (base[right]%mod * lazy[ind]%mod)%mod;
            st[ind] =(st[ind]%mod+ dx%mod)%mod;
            if(lef != right)
            lazy[2*ind] = lazy[ind], lazy[2*ind+1] =lazy[ind];
            lazy[ind]=0;
          }
    }

    if(lef > j || right < i) return;

    if(lef >= i && right <= j)
    {
          st[ind]=0;
          if(lef!=0)
          {
             ll dx = ((base[right]%mod - base[lef-1]%mod+mod)%mod * val%mod)%mod;
             st[ind] =(st[ind]%mod+ dx%mod)%mod;
             if(lef != right)
             lazy[2*ind] = val, lazy[2*ind+1] = val;
          }
          else
          {
             ll dx =( base[right]%mod * val%mod)%mod;
             st[ind] =(st[ind]%mod+ dx%mod)%mod;
            if(lef != right)
            lazy[2*ind] = val, lazy[2*ind+1] = val;
          }
        return;
    }

    ll mid = (lef + right) / 2;
    update(2*ind, lef, mid, i, j, val);
    update(2*ind+1, mid+1, right, i, j, val);
    st[ind] = (st[2*ind]%mod + st[2*ind+1]%mod)%mod;
}


int main()
{
    ll n, q, l, r, val,i,digit;

    scanf("%lld%lld",&n,&q);

        base[0]=1;
        for(i=1;i<n;i++)
        base[i]=(base[i-1]%mod*10%mod)%mod;
        build(1, 0, n-1);
        for(i=1;i<n;i++)
            base[i]=(base[i-1]%mod+base[i]%mod)%mod;

    while(q--)
    {
        scanf("%lld%lld%lld",&l,&r,&digit);
        update(1,0,n-1,n-r,n-l,digit);
        printf("%lld\n",st[1]%mod);
    }

return 0;
}













































































Measured memory_bytes: 13560
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int d[111];
	memset(d, 0, sizeof d);
	d[a]++, d[b]++, d[c]++;
	int ans = 0;
	for(int i = 1; i <= 100; i++) ans+=(d[i]!=0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main() {
    int N;
    cin>>N;
    string S;
    cin>>S;
    map<int, int> Rmap;
    map<int, int> Bmap;
    map<int, int> Gmap;
    vector<int> Rarr;
    vector<int> Barr;
    vector<int> Garr;
    for(int i=0;i<N;++i){
        if(S[i]=='R'){
            Rmap[i]++;
            Rarr.push_back(i);
        }
        if(S[i]=='B'){
            Bmap[i]++;
            Barr.push_back(i);
        }
        if(S[i]=='G'){
            Gmap[i]++;
            Garr.push_back(i);
        }
    }
    long ans = Rarr.size() * Barr.size() * Garr.size();
    /**
    for(int i=0;i<Rarr.size();++i){
        cout<<Rarr[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<Barr.size();++i){
        cout<<Barr[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<Garr.size();++i){
        cout<<Garr[i]<<" ";
    }
    cout<<endl;
    **/
    for(int i=0;i<Rarr.size();++i){
        for(int j=0;j<Barr.size();++j){
            if(Rarr[i]<Barr[j]){
                if(Gmap[Barr[j] + (Barr[j] - Rarr[i])] > 0)ans--;
            }
            else{
                if(Gmap[Rarr[i] + (Rarr[i] - Barr[j])] > 0)ans--;
            }
        }
    }
    for(int i=0;i<Rarr.size();++i){
        for(int j=0;j<Garr.size();++j){
            if(Rarr[i]<Garr[j]){
                if(Bmap[Garr[j] + (Garr[j] - Rarr[i])] > 0)ans--;
            }
            else{
                if(Bmap[Rarr[i] + (Rarr[i] - Garr[j])] > 0)ans--;
            }
        }
    }
    for(int i=0;i<Garr.size();++i){
        for(int j=0;j<Barr.size();++j){
            if(Garr[i]<Barr[j]){
                if(Rmap[Barr[j] + (Barr[j] - Garr[i])] > 0)ans--;
            }
            else {
                if(Rmap[Garr[i] + (Garr[i] - Barr[j])] > 0)ans--;
            }
        }
    }
    cout<<ans<<endl;
}


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


int chk_dig(int n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

int main(){
	int a,b; cin >> a >> b;
	int tmp=b;
	a*=pow(10,chk_dig(b));

	for(int i=1;i<=1000;++i){
		if( i * i == a + b ) { cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl;
}

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

typedef long long ll;
using namespace std;

int main() {
    int ans = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i += 2) {
        int c = 0;
        for (int k = 1; k <= i; k++)
            if (i % k == 0)
                c++;
        if (c == 8)
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  vector<string> T={"SUN","MON","TUE","WED","THU","FRI","SAT","1","2","3","4","5","6","7"};
  cin>>S;
  if(S==T.at(0)){cout<<T.at(13)+"\n";}
  else if(S==T.at(1)){cout<<T.at(12)+"\n";}
  else if(S==T.at(2)){cout<<T.at(11)+"\n";}
  else if(S==T.at(3)){cout<<T.at(10)+"\n";}
  else if(S==T.at(4)){cout<<T.at(9)+"\n";}
  else if(S==T.at(5)){cout<<T.at(8)+"\n";}
  else{cout<<T.at(7)+"\n";}
}

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

int N;
int X[3];
vector<long> A[100000];
long ans[2][100001];
void sub(int j) {
  fill(ans[j], ans[j] + (N + 1), -1e17);
  priority_queue<long, vector<long>, greater<long>> que;
  
  long sum = 0;
  for (int i = 0; i < X[j]; ++i) {
    long diff = A[i][j] - A[i][2];
    que.push(diff);
    sum += diff;
  }
  ans[j][X[j]] = sum;
  
  for (int i = X[j]; i < N; ++i) {
    long diff = A[i][j] - A[i][2];
    long th = que.top();
    if (diff > th) {;
      que.pop();
      que.push(diff);
      sum += diff - th;
    }
    ans[j][i + 1] = sum;
  }
}

int main() {
  cin >> X[0] >> X[1] >> X[2];
  N = X[0] + X[1] + X[2];
  for (int i = 0; i < N; ++i) {
    long a, b, c;
    cin >> a >> b >> c;
    A[i] = vector<long>{ a, b, c };
  }
  
  sort(A, A + N, [](auto& a, auto& b) {
    return a[0] - a[1] > b[0] - b[1];
  });
  sub(0);
  
  reverse(A, A + N);
  sub(1);
  
  long mx = -1e18;
  for (int i = 0; i <= N; ++i) {
    mx = max(mx, ans[0][i] + ans[1][N - i]);
  }
  
  long sum = mx;
  for (int i = 0; i < N; ++i) {
    sum += A[i][2];
  }
  cout << sum << endl;
}

Measured memory_bytes: 8440
N = int(input())  # nは入力回数
S = [input() for _ in range(N)]

print("AC x "+str(S.count('AC')))
print("WA x "+str(S.count('WA')))
print("TLE x "+str(S.count('TLE')))
print("RE x "+str(S.count('RE')))



Measured memory_bytes: 16280
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = int(1e+18) + 1

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	l := -INF
	r := INF
	for abs(l-r) > 1 {
		M := (l + r) / 2
		count := 0
		// M未満の組み合わせ数を計算
		for i := 0; i < N; i++ {
			if A[i] < 0 {
				ll := i
				rr := N
				for abs(rr-ll) > 1 {
					mid := (rr + ll) / 2
					if A[i]*A[mid] < M {
						rr = mid
					} else {
						ll = mid
					}
				}
				count += N - rr
			} else {
				ll := i
				rr := N
				for abs(rr-ll) > 1 {
					mid := (rr + ll) / 2
					if A[i]*A[mid] < M {
						ll = mid
					} else {
						rr = mid
					}
				}
				count += ll - i
			}
		}

		// M未満の組み合わせ数がK未満
		if count < K {
			l = M
		} else {
			r = M
		}
	}

	fmt.Fprintln(wtr, l)
}


Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
typedef long long int ll;

int A, B, C;

int main(void){
	cin >> A >> B >> C;
	bool def;
	if(C >= A && C <= B) def = true;
	else def = false;
	cout << (def ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int H,W,x,y,r;

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(((r<=y)&&(y<=H-r))&&((r<=x)&&(x<=W-r)))           
        printf("Yes\n");
    else
        printf("No\n");

    return 0;


}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];
    cout << a[0];
    FOR(j, 1, n) cout << " " << a[j];
    cout << endl;
    FOR(i, 1, n) {
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        cout << a[0];
        FOR(j, 1, n) cout << " " << a[j];
        cout << endl;
    }
    

    return 0;
}


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

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;
}

int main()
{
    string s,t;
    cin >> s >> t;
    bool blag = true;
    for( int i = 0; i < s.size(); ++i )
    {
        if( s[i] != t[i] )
        {
            blag = false;
        }
    }
    if(blag == true)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RULL(X, Y);
  PULL(X + Y / 2);
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
    return 0;
  }
  cout << "Odd" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int i;
    i = n / 111;
    if (n % 111 != 0) ++i;

    cout << i * 111 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main (void)
{
    intmax_t N = 0, D[(int)1e5] = {}, d[(int)1e5] = {};
    intmax_t dmax = 0, ans = 1;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &D[i]);
        d[D[i]]++;
        if (D[i] > dmax) dmax = D[i];
    }

    if (D[0] != 0) {
        puts("0");
        return 0;
    }
    if (d[0] != 1) {
        puts("0");
        return 0;
    }

    for (intmax_t i = 1; i <= dmax; i++) {
        ans *= modpow(d[i - 1], d[i], 998244353);
        ans %= 998244353;
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
 
class Program{
    static void Main(){
         int n = int.Parse(Console.ReadLine());
        string[] inputs = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = int.Parse(inputs[i]);
        }
        bool[] check = new bool[n];
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(!check[i]){
                if(a[a[i] - 1] == i + 1){
                    cnt++;
                    check[a[i] - 1] = true;
                }
                check[i] = true;
            }
        }
        Console.WriteLine(cnt);
    }
}

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

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B;
    cin >> A >> B;

    cout << (A - 1) * (B - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int d = sc.nextInt();
        
        double[][] array = new double[n][2];
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            array[i][0] = sc.nextDouble();
            array[i][1] = sc.nextDouble();
            
            double result = Math.sqrt(Math.pow(array[i][0], 2) + Math.pow(array[i][1], 2));
            if (result <= d) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}

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

long long GCD (long long a, long long b) {
    if (b == 0) {
        return a;
    }
    return GCD(b, a%b);
}

int main() 
{
    long long A, B;
    cin >> A >> B;
    cout << fixed << setprecision(10);
    cout << A*B/GCD(A, B) << endl;
}

Measured memory_bytes: 256