akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    if(n<3200){
      System.out.println("red");
    }else{
      System.out.println(s);
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() 
{
    int w, a, b;
    cin >> w >> a >> b;

    if ((a <= b && a + w >= b) || (a <= b + w && a + w >= b + w)) {
        cout << 0 << endl;
    }   

    else if (a + w < b) {
        cout << b - a - w << endl;;
    }   
    else {
        cout << a - b - w << endl;
    }   
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

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

    if(A+B >= X && X >= A)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 256
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll n,k;
	cin>>n>>k;
	n=n%k;
	cout<<min(n,k-n);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::string s, t; std::cin >> n >> s >> t;
	std::string result;
	for (auto i = 0; i < n; ++i) {
		result.push_back(s[i]);
		result.push_back(t[i]);
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 888
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn f(mut n: u64, seq: &[u64]) -> u64 {
    for &x in seq {
        n = n / x * x;
    }
    n
}

fn main() {
    let k = get!(usize);
    let aa = util::gets::<u64>();

    let mut l = 0;
    let mut r = 1 << 60;

    while l != r {
        let mid = (l + r + 1) / 2;
        if f(mid, &aa) >= 2 {
            r = mid - 1;
        } else {
            l = mid;
        }
    }

    let a1 = l + 1;

    if f(a1, &aa) != 2 {
        println!("{}", -1);
        return;
    }

    let mut l = 0;
    let mut r = 1 << 60;
    while l != r {
        let mid = (l + r + 1) / 2;
        if f(mid, &aa) > 2 {
            r = mid - 1;
        } else {
            l = mid;
        }
    }

    let a2 = l;

    println!("{} {}", a1, a2);
}


Measured memory_bytes: 8444
import copy

h,w,k=map(int,input().split())
a=[]
for _ in range(h):
  b=list(input())
  a.append(b)

ans=0
for i in range(2**h):
  for j in range(2**w):
    c=copy.deepcopy(a)
    for x in range(h):
      if ((i>>x)&1):
        for u in range(w):
          c[x][u]='R'
          
    for y in range(w):
      if ((j>>y)&1):
        for t in range(h):
          c[t][y]='R'
    ch=0
    for z in c:
      ch+=z.count('#')
    if ch==k:
      ans+=1
      
print(ans)

Measured memory_bytes: 9360
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> n(5);
    for(int i=0;i<5;i++)
    cin>>n[i];
    vector<int> diff(5,0);
    for(int i=0;i<5;i++){
        while((n[i]+diff[i])%10!=0){
            diff[i]++;
        }
    }
    int max_diff=max(max(diff[0],diff[1]),max(diff[2],max(diff[3],diff[4])));
    int ans=0;
    for(int i=0;i<5;i++){
        ans+=n[i];
        ans+=diff[i];
    }
    cout<<ans-max_diff<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define REP(i,a,b) for(int i=a;i<(b);++i)
using namespace std;
typedef long long ll;


ll a[100000],b[100000];
int main()
{
  ll n;
  cin >> n;
  REP(i,0,n){
    cin >> a[i] >> b[i];
  }
  ll cnt=0;
  REP(i,0,n){
    if((a[n-1-i]+cnt)%b[n-1-i] != 0){
      cnt += (b[n-1-i] - (a[n-1-i]+cnt)%b[n-1-i]);
    }
      
  }
  cout << cnt<<endl;
}


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

long long l[100];

int main() {
  int n;
  cin>>n;
  l[0]=2;
  l[1]=1;
  for(int i=2;i<=n;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n]<<endl;
}

Measured memory_bytes: 256
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n,a,b;
cin>>n>>a>>b;
if(a==b) cout<<1;
else if(a>b || n == 1) {
    cout<<0;
} else cout<<(n-2)*b-(n-2)*a+1;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,l,x;
signed main(){
	cin >> n >> x;
	int cur = 0;
	int bounce = 1;
	for(int i = 1 ; i <= n ; i ++){
		cin >> l;
		cur += l;
		if(cur > x) break;
		bounce ++;
	}
	cout << bounce;
}


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

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

using namespace std;
using lint=long long;

int MOD;
class mint{
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

int main(){
	int n;
	string s; cin>>n>>MOD>>s;

	if(MOD==2 || MOD==5){
		lint ans=0;
		rep(i,n) if((s[i]-'0')%MOD==0) ans+=i+1;
		printf("%lld\n",ans);
		return 0;
	}

	vector<int> cnt(MOD);
	mint x=0,ten=1;
	for(int i=n-1;i>=0;i--){
		x+=ten*(s[i]-'0');
		cnt[x.to_int()]++;
		ten*=10;
	}

	lint ans=0;
	x=0; ten=1;
	for(int i=n-1;i>=0;i--){
		ans+=cnt[x.to_int()];
		x+=ten*(s[i]-'0');
		cnt[x.to_int()]--;
		ten*=10;
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 640
int main()
{
    int a,b,c;
    char e='1',f='2',g='3';
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

if (a==b && b==c && a==c)
{
    printf("%c",e);
}
else if(a==b || b==c || a==c)
{
    printf("%c",f);
}
else
{
    printf("%c",g);
}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e9)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
int dp[100001];
int n,m,res=MINI;
int a[100001][3];
vector <int> g[100001];
int solve (int i){
	if(SZ(g[i])==0)return 0;
	if(dp[i]!=-1)return dp[i];
	dp[i]=0;
	for(auto x : g[i]){
		dp[i]=max(dp[i],1+solve(x));
	}
	return dp[i];
}

int main(){FIN;
	cin >> n >> m;
	fore(i,1,m+1){
		cin >> a[i][1] >> a[i][2];
		g[a[i][1]].pb(a[i][2]);
	}
	memset(dp,-1,sizeof(dp));
	fore(i,1,n+1){
		res = max(res,solve(i));
	}
	cout << res;
}

Measured memory_bytes: 8704
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

/*
    Special functions:
        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

int main(){
    quicken();

    int n, k; cin >> n;
    string str; cin >> str >> k;
    repeat(n)
        if(str[i]!=str[k-1]) str[i]='*';

    cout << str;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M, L, K, A, H;
    while (cin>>N>>M>>L>>K>>A>>H, N|M|L|K|A|H) {
        vector<int> refrigerator(L);
        for(auto &r: refrigerator)
            cin >> r;
        refrigerator.push_back(A); refrigerator.push_back(H);
        
        vector<vector<int>> d(N, vector<int>(N, INF));
        for(int i=0; i<N; i++)
            d[i][i] = 0;
        
        for(int i=0; i<K; i++){
            int x, y, t;
            cin >> x >> y >> t;
            d[x][y] = d[y][x] = t;
        }
        
        for(int k=0; k<N; k++)
            for(int i=0; i<N; i++)
                for(int j=0; j<N; j++)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        
        vector<vector<int>> d2(L+2, vector<int>(L+2, INF));
        for(int i=0; i<L+2; i++)
            d2[i][i] = 0;
        
        for(int i=0; i<L+2; i++)
            for(int j=0; j<L+2; j++)
                if(d[refrigerator[i]][refrigerator[j]] <= M)
                    d2[i][j] = d2[j][i] = d[refrigerator[i]][refrigerator[j]];
        
        for(int k=0; k<L+2; k++)
            for(int i=0; i<L+2; i++)
                for(int j=0; j<L+2; j++)
                    d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
        
        if(d2[L][L+1] != INF){
            cout << d2[L][L+1]*2-min(M, d2[L][L+1]) << endl;
        }else{
            cout << "Help!" << endl;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 1312
#include <stdio.h>

int main(void) {
	unsigned int x;
	unsigned int a = 0;
	unsigned int b = 0;

	scanf("%d", &x);

	a = x / 500;
	a *= 1000;

	b= x % 500;
	b /= 5;
	b *= 5;
	printf("%d\n", a+b);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
As = []
for i in range(N):
  A = int(input())
  As.append(A)
A2s = sorted(As)

for i in range(N):
  A = As[i]
  if A == A2s[N-1]:
    print(A2s[N-2])
  else:
    print(A2s[N-1])


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

#define int long long

int giveans(string s ){
	if(s.size() == 0) return 0 ;
	int x = s[0]-'0' ;
	return giveans(s.substr(1)) + x;  
	
}

int32_t main() {
	string s ;
	cin >> s ;
	int k = giveans(s) ;
	if(k == 1) cout << 10 ;
	else cout << k ;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
  int n,m;
  std::cin>>n;
  int X[n];
  for(int i=0;i < n;i++){
    std::cin>>X[i];
  }
  std::cin>>m;
  int A[m];
  for(int i=0;i < m;i++){
    std::cin>>A[i];
  }
  
  for(int i=0;i<m;i++){ 
    int cc = X[A[i]-1] + 1;
    int aa = 0;
    if(cc > 2019){}
    else{
    for(int j =0;j<n;j++){
      if(cc==X[j]) aa += 1; 
    }
    if(aa == 0){
      X[A[i]-1] += 1;
    }
    }

  }
    for(int i=0;i<n;i++){
    std::cout<<X[i]<<"\n";
    }
}



Measured memory_bytes: 3112
#include<iostream>
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,counter=0;
    cin>>n>>k;
    while(n>0){
        n=n/k;
        counter++;
    }
    cout<<counter<<endl;
    return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 1e5+5;
int dp[N];
vector<int>adj[N];
bool vis[N];
int dfs(int i){
    if(dp[i]!=-1){
        return dp[i];
    }
    int s = 0;
    for(auto x:adj[i]){
        s = max(1+dfs(x),s);
    }
    return dp[i] = s;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(vis,0,sizeof(vis));
    memset(dp,-1,sizeof(dp));
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(dfs(i),ans);
    }
    cout<<ans<<endl;
    
    return 0;
    
}



Measured memory_bytes: 8704
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

int N,M;
int A[SIZE],B[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
	}
	sort(A,A+N);


	scanf("%d",&M);

	for(int i = 0; i < M; i++){

		scanf("%d",&B[i]);
	}
	sort(B,B+M);

	vector<int> C;

	set_union(A,A+N,B,B+M,inserter(C,end(C)));

	for(int i = 0; i < C.size(); i++){

		printf("%d\n",C[i]);
	}

	return 0;
}



Measured memory_bytes: 6440
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	unsigned LLI a, b, c;
	cin >> a >> b >> c;
	if (c < a + b) {
		cout << "No";
		return 0;
	}
	if (4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

int main() {

    int a,b;

    for(int i=0;i<4;i++){

        cin>>a>>b;
        
        switch(a){
        case  1:
            cout<<6000*b<<endl;
            break;
            
        case 2:
            cout<<4000*b<<endl;
            break;
            
        case 3:
            cout<<3000*b<<endl;
            break;
            
        case 4:
            cout<<2000*b<<endl;
            break;
            
        default:
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

bool isok(string str){
  int n = str.size();
  rep(i,n){
    if(str[i]!=str[n-1-i])return false;
  }
  return true;
}

int main(){
  string str;
  in(str);
  int n = str.size();
  if(isok(str) and isok(str.substr(0,(n-1)/2)) and isok(str.substr((n+2)/2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e18
typedef long long ll;
using namespace std;
ll func(ll n,ll b)
{
	ll ret=0;
	while(n)
	{
		ret=ret+n%b;
		n=n/b;
	}
	return ret;
}
int main()
{
    ll n,s;
    cin>>n>>s;
    ll i;
    	if(n==s)
	{
		cout<< n+1<<endl;
		return 0;
	}
	if(n<s)
	{
		cout<<"-1"<<endl;
		return 0;
	}
    ll ans=1000000000000000000;
    for(i=2;i<=1000000;i++)
    {
    	ll k=func(n,i);
    	if(k==s)
    	{
    		cout<< i<<endl;
    		return 0;
		}
	}
	for(i=1;i*i<=(n-s);i++)
	{
		if((n-s)%i) continue;
		ll b1=i+1;
		ll b2=((n-s)/i)+1;
		if(b1>=2)
		if(func(n,b1)==s)
		ans=min(ans,b1);
		if(b2>=2)
		if(func(n,b2)==s)
		ans=min(ans,b2);
	}
	if(ans==1000000000000000000)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ans;
	
	 return 0;		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ll long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod1 998244353
#define INT_MAX1 900000000

int f1(int x)
{
    if(x==0)
        return 1;
    int ret = 1;
    while(x>=1)
    {
        ret *= x;
        x--;
    }

    return ret;
}

int rk(vi curr)
{
    if(curr.size()==0)
        return 0;
 
    int x = curr[0];
    int xx = 0;
    for(int i=1; i<curr.size(); i++)
        if(curr[i]<x)
            xx++;
    vi cc1;
    rep(i,1,curr.size()-1)
        cc1.pb(curr[i]);


    return f1(curr.size()-1)*xx + rk(cc1); 
}

void solve()
{
    int n;
    cin >> n;
    vi a(n), b(n);

    inp(a, n);
    inp(b, n);


    cout << abs(rk(a)-rk(b));

}

signed main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int p[] = new int[n];
		int test[] = new int[3];
		test[0] =0;
		test[1] =0;
		test[2] =0;

		for ( int i = 0 ; i < n ; i++ ) {
			p[i] = sc1.nextInt();
			if ( p[i] <= a) {
				test[0]++;
			}
			else if ( p[i] > a && p[i]<= b) {
				test[1]++;
			}
			else {
				test[2]++;
			}
		}

		Arrays.sort(test);

		System.out.println(test[0]);

		sc1.close();

	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>

using namespace std;

const long long divs = 1000000007;

int main() {
    long long n, k;
    cin >> n >> k;
    long long answer = 0;

    for (long long i = k; i <= n + 1; i++) {
        long long min = i * (i - 1) / 2;
        long long max = (2 * n - i + 1) * i / 2;
        answer = (answer + max - min + 1) % divs;
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  int n, s;
  ll o;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  for(int i = 0; i < n; i++) {
    if(!i) {
      if(s1.at(i) == s2.at(i)) {
        o = 3;
        s = 1;
      } else {
        o = 6;
        s = 0;
        i++;
      }
    } else {
      if(s1.at(i) == s2.at(i)) {
        if(s)
          o *= 2;
        else
          s = 1;
      } else {
        if(s) {
          o *= 2;
          s = 0;
        } else
          o *= 3;
        i++;
      }
    }
    o %= MOD;
  }
  cout << o << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int a[100010], num[100010], ans[100010];

int main() {
	int N;
	cin >> N;
	for(int i=1; i<=N; ++i){
		cin >> a[i];
		++num[a[i]];
	}
	if(N==2){
		cout << -1 << endl;
		return 0;
	}
	vector<set<int>> race(N);
	for(int i=1; i<=N; ++i) race[num[i]].insert(i);
	set<int> st;
	for(int i=1; i<=N; ++i) st.insert(i);
	int proh=0;
	for(int i=1; i+3<=N; ++i){
		if(!race[N-i].empty()){
			ans[i]=*race[N-i].begin();
		}else{
			auto itr=st.begin();
			if(*itr==proh) ++itr;
			ans[i]=*itr;
		}
		st.erase(ans[i]);
		race[num[ans[i]]].erase(ans[i]);
		proh=a[ans[i]];
		if(race[num[a[ans[i]]]].erase(a[ans[i]])==1){
			--num[a[ans[i]]];
			race[num[a[ans[i]]]].insert(a[ans[i]]);
		}
	}
	int cand[3], t[3];
	for(int i=0; i<3; ++i){
		cand[i]=*st.begin();
		st.erase(cand[i]);
	}
	if(proh!=cand[0] && a[cand[0]]!=cand[1] && a[cand[1]]!=cand[2]){
		t[0]=0, t[1]=1, t[2]=2;
	}else if(proh!=cand[0] && a[cand[0]]!=cand[2] && a[cand[2]]!=cand[1]){
		t[0]=0, t[1]=2, t[2]=1;
	}else if(proh!=cand[1] && a[cand[1]]!=cand[0] && a[cand[0]]!=cand[2]){
		t[0]=1, t[1]=0, t[2]=2;
	}else if(proh!=cand[1] && a[cand[1]]!=cand[2] && a[cand[2]]!=cand[0]){
		t[0]=1, t[1]=2, t[2]=0;
	}else if(a[cand[2]]!=cand[0]){
		t[0]=2, t[1]=0, t[2]=1;
	}else{
		t[0]=2, t[1]=1, t[2]=0;
	}
	for(int i=0; i<3; ++i) ans[N-2+i]=cand[t[i]];
	cout << ans[1];
	for(int i=2; i<=N; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 16128
A,B,M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = []
for _ in range(M):
    xyc.append(list(map(int, input().split())))

result = min(a) + min(b)
for i in range(M):
    x,y,c = xyc[i]
    cost = a[x-1] + b[y-1] - c
    result = min(result, cost)
print(result)

Measured memory_bytes: 38568
l = input()
a,b,c = map(int, l.split())
z=0
if a == b:
    if c%a == 0:
        print(1)
    else:
        print(0)
else:
    for i in range(a, b+1, 1):
        if c%i == 0:
            z = z + 1
    print(z)



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string str;
    std::cin >> str;

    unsigned long t = 10000000;
    for (unsigned long i = 0; i < str.size() - 1; i++) {
        if (str[i] == str[i+1]) continue;
        t = std::min(t, std::max(i + 1, str.size() - i - 1));
    }

    std::cout << ((t == 10000000) ? str.size() : t) << std::endl;

    return 0;
}

Measured memory_bytes: 512
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  if (k == 1) cout << 0 << '\n';
  else cout << n - k << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
	double a, b, d;
	cin >> a >> b >> d;
	double s = a * b * sin(d *= M_PI / 180) / 2;
	cout << fixed << setprecision(10) << s << endl;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(d));
	cout << fixed << setprecision(10) << a + b + c << endl;
	cout << fixed << setprecision(10) << b * sin(d) << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H - h) * (W - w));
	}
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector <int> v(n);
    for (auto &x: v) cin >> x;
    int ans = 1;
    set <int> s;
    int leftSortedLength[n];
    leftSortedLength[0] = 1;
    for (int i = 1; i < n; i++) {
        leftSortedLength[i] = v[i] > v[i - 1] ? leftSortedLength[i - 1] + 1 : 1;
    }
    for (int i = 0; i < k; i++) s.insert(v[i]);
    bool found = leftSortedLength[k - 1] == k;
    for (int i = k; i < n; i++) {
        s.insert(v[i]);
        int mn = *s.begin(), mx = *s.rbegin();
        s.erase(v[i - k]);
        if (v[i - k] == mn && v[i] == mx) continue;
        if (leftSortedLength[i] != k)
            ans++;
        else if (!found)
            ans++, found = true;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <assert.h>
using namespace std;

int main(){
    int N, K, i;
    cin >> N >> K;
    assert(1 <= N);
    assert(1 <= K);
    vector<int> h(N);

    for(i = 0; i < N; i++){
        cin >> h.at(i);
    }

    int cnt = 0;
    for(i = 0; i < N; i ++){
        if(h.at(i) >= K){
            cnt++;
        }
    }

    cout << cnt;
    
    return 0;
}



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

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k){
        cout << s << endl;
    }else{
        s.erase(k);
        cout << s+"..." << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
	
	ll N,A,B;
	cin >> N >> A >>B;
	
	print(min(N*A, B));
	
 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 sum = A +  B;
        int hiku = A - B;
        int seki = A * B;

        System.out.println(Math.max(seki,Math.max(sum,hiku)));
    }
}


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

fn func(n: u64) -> u64 {
    if n % 2 == 0 {
        n / 2
    } else {
        3 * n + 1
    }
}

fn main() {
    let mut s = read::<u64>();
    let mut a = std::collections::BTreeSet::new();
    a.insert(s);
    let mut ans = 1;
    loop {
        s = func(s);
        ans += 1;
        if a.contains(&s) {
            println!("{}", ans);
            return;
        }
        a.insert(s);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define ff first
#define ss second
#define tt third
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{


   $$ a,b;
   cin>>a>>b;
   b*=2;
   if (b<a)
   {
   	/* code */cout<<(a-b)<<endl;
   }
   else
   	cout<<"0\n";








return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:Vec<u32> = (0..3).map(|_| read()).collect();

    println!("{}", min(a[0]+a[1], min(a[1]+a[2],a[0]+a[2])));

}


Measured memory_bytes: 4352
import sys

n=int(input())
P=[]
for i in range(n):
    x,y,h=map(int,input().split())
    P.append([h,x,y])
P=list(reversed(sorted(P)))

for x in range(101):
    for y in range(101):
        flag=0
        H=P[0][0]+abs(P[0][1]-x)+abs(P[0][2]-y)
        for p in P:
            ph=p[0]
            px=p[1]
            py=p[2]
            if ph==0:
                if H-abs(px-x)-abs(py-y)>0:
                    flag=1
                    break
            else:
                if H-abs(px-x)-abs(py-y)!=ph:
                    flag=1
                    break
        if flag==1:
            continue
        else:
            print(x,y,H)
            sys.exit()

Measured memory_bytes: 3064
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main() {
    ll X;
    cin >> X;
    ll a,b;
    b = 0;
    for(ll i = 0; i*i*i*i*i <= X; i++) {
        a = i;
    }
    //cout << a << b << endl;
    if(a*a*a*a*a == X) {
        cout << a << " " << b << endl;
        return 0;
    }
    b = -1;
    while(1) {
        if(a <= 0) break;
        while(1) {
            ll B = b*b*b*b*b;
            if(-B == X-a*a*a*a*a) {
                cout << a << " " << b << endl;
                return 0;
            }
            if(-B+a*a*a*a*a > X) break;
            else b--;
        }
        a--;
        //b = 0;
    }
    for(ll i = 0; i*i*i*i*i <= X; i++) {
        a = i;
    }
    a++;
    b = 0;
    while(1) {
        while(1) {
            ll B = b*b*b*b*b;
            ll A = a*a*a*a*a;
            if(X == A-B) {
                cout << a << " " << b << endl;
                return 0;
            } 
            if(X > A-B) break;
            b++;
        }
        a++;
        //b = 0;
    }
}


Measured memory_bytes: 3560
#16D8101012J 伊藤惇　dj Python3

def Insertion_Sort():
    N=int(input())
    A=list(map(int,input().split()))
    for i in range(0,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j=j-1
        A[j+1]=v
        
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")
        


if __name__ == "__main__":
    Insertion_Sort()

    



Measured memory_bytes: 5984
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int X[N];
  int A[N];
  for(int i=0;i<N;i++){
    cin>>X[i];
    A[i]=X[i];
  }
  sort(X,X+N);
  for(int i=0;i<N;i++){
    if(A[i]<X[N/2]){
      cout<<X[N/2]<<endl;
    }else cout<<X[N/2-1]<<endl;
  }
  return 0;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int n,p1,a,b,vis[9];
int factorial(int x) {
    int ret=1;
    for (int i=1; i<=x; i++) ret*=i;
    return ret;
}
int main() {
    cin>>n;
    for (int i=n; i>=1; i--) {
        cin>>p1;
        int cnt=0;
        vis[p1]=1;
        for (int j=1; j<=p1; j++) {
            if (!vis[j]) cnt++;
        }
        a+=(cnt*factorial(i-1));
    }
    memset(vis,0,sizeof(vis));
    for (int i=n; i>=1; i--) {
        cin>>p1;
        vis[p1]=1;
        int cnt=0;
        for (int j=1; j<=p1; j++) {
            if (!vis[j]) cnt++;
        }
        b+=(cnt*factorial(i-1));
    }
    cout<<abs(a-b)<<'\n';
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string S;
    cin >> S;
    int y = 0, m = 0, d = 0;
    for (int i = 0; i < 4; i++) {
        y = y * 10 + (S[i] - '0');
    }
    for (int i = 5; i < 7; i++) {
        m = m * 10 + (S[i] - '0');
    }
    bool heisei = true;
    if (y < 2019) {
        heisei = true;
    } else if (y > 2019) {
        heisei = false;
    } else {
        if (m <= 4) {
            heisei = true;
        } else {
            heisei = false;
        }
    }
    if (heisei) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/problems/1127


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]

    def root(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[y] = x
        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)


def distance(x1, y1, z1, x2, y2, z2):
    dxx = (x1 - x2) ** 2
    dyy = (y1 - y2) ** 2
    dzz = (z1 - z2) ** 2
    return (dxx + dyy + dzz) ** (1/2)


def solve(n, rows):
    # (start, end, corridors_length)
    edges = []
    for i in range(len(rows)):
        for j in range(i + 1, len(rows)):
            x1, y1, z1, r1 = rows[i]
            x2, y2, z2, r2 = rows[j]
            d = distance(x1, y1, z1, x2, y2, z2)
            # print(i, j, d)
            if d > r1 + r2:
                edges.append((i, j, d-r1-r2))
            else:
                edges.append((i, j, 0))

    edges.sort(key=lambda x: x[2])
    # print(edges)

    result = 0
    uf = UnionFind(n)
    for edge in edges:
        s, t, d = edge
        unioned = uf.union(s, t)
        if unioned:
            result += d

    print('{:.3f}'.format(result))


if __name__ == "__main__":
    while(True):
        n = int(input())
        if n == 0:
            break
        rows = [list(map(float, input().split())) for _ in range(n)]
        solve(n, rows)



Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]=='?') s[i]='D';
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
};

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

enum { OUT, ON, IN };
int containPG(const P& p, const G& g) {
    int n = g.size();
    bool in = false;
    rep(i, n) {
        P a = here(g, i) - p, b = next(g, i) - p;
        if (a.imag() > b.imag()) swap(a, b);
        if (a.imag() <= 0 && 0 < b.imag() && cross(a, b) > 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

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

    int n;
    cin >> n;
    G g;
    while (n--) {
        double x, y;
        cin >> x >> y;
        g.emplace_back(x, y);
    }

    int q;
    cin >> q;
    while (q--) {
        double x, y;
        cin >> x >> y;
        cout << containPG(P(x, y), g) << endl;
    }
}

Measured memory_bytes: 3304
#include <stdio.h>
#include <stdlib.h>

int *arr, *arr2, num;

int verify()
{
	int i, j, sum;

	for (i = 1; i <= num; i++)
	{
		sum = 0;

		for (j = i; j <= num; j += i)
			sum += arr2[j];

		if (sum % 2 != arr[i])
			return -1;
	}

	return 1;
}

int main()
{
	int i, j, sum, goal = 0, ok = 0;

	scanf("%d", &num);

	arr = (int*)malloc(sizeof(int) * (num + 1));
	arr2 = (int*)calloc(num + 1, sizeof(int));

	arr[0] = 0;

	for (i = 1; i <= num; i++)
		scanf("%d", &arr[i]);

	for (i = num; i >= 1; i--)
	{
		sum = 0;

		if (i * 2 <= num)
		{
			for (j = i; j <= num; j += i)
				sum += arr2[j];

			if (sum % 2 == (arr[i] % 2))
				arr2[i] = 0;
			else
				arr2[i] = 1;
		}
		else
			arr2[i] = arr[i];

		if (arr2[i] == 1)
			goal++;
	}

	ok = verify();

	if (ok == -1)
		printf("-1\n");
	else
	{
		printf("%d\n", goal);

		for (i = 1; i <= num; i++)
		{
			if (arr2[i] == 1)
				printf("%d\n", i);
		}
	}

	return 0;
}

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

int main() {

    priority_queue<int> que;

    int N, M;
    cin >> N >> M;
//    vector<int> numbers(N, 0);
    long int a;
    for(int i=0;i<N;i++){
        cin >> a;
        que.push(a);
    }
    for(int i=0;i<M;i++){
        a = que.top();
        que.pop();
        que.push(a/2);
//        cout << a << "," << a/2 << ",";
    }
    long int sum_a = 0;
    for(int i=0;i<N;i++){
        sum_a += que.top();
        que.pop();
    }
    cout << sum_a;
}


Measured memory_bytes: 892
using System;
public class Hello{
    public static void Main(){
        int[] x = Array.ConvertAll<string,int>(Console.ReadLine().Split(' '),int.Parse);
        int area = x[0]*x[1];
        int periphery = (x[0]+x[1]) * 2;
        Console.WriteLine("{0} {1}",area,periphery );
    }
}




Measured memory_bytes: 15928