akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void mmax(T &m, const T q) { if (m < q) m = q; }
template<typename T> void mmin(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

const string YES = "YES";
const string NO = "NO";

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

    cout << (((N + 1) >= K * 2) ? YES : NO) << endl;
    return 0;
}


Measured memory_bytes: 256
num=int(input())
line=input().split(" ")
a=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
k=0
for i in range(num):
	if int(line[i])<400:
		a=1
	elif int(line[i])>=400 and int(line[i])<800:
		b=1
	elif int(line[i])>=800 and int(line[i])<1200:
		c=1
	elif int(line[i])>=1200 and int(line[i])<1600:
		d=1
	elif int(line[i])>=1600 and int(line[i])<2000:
		e=1
	elif int(line[i])>=2000 and int(line[i])<2400:
		f=1
	elif int(line[i])>=2400 and int(line[i])<2800:
		g=1
	elif int(line[i])>=2800 and int(line[i])<3200:
		h=1
	elif int(line[i])>=3200:
		k+=1
if a+b+c+d+e+f+g+h==0:
	print(1, k)
else:
	print(a+b+c+d+e+f+g+h, a+b+c+d+e+f+g+h+k)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc083/tasks/abc083_b

#include <iostream>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

void divnum(int n, int *arr) {
    for (int i = 0; i < 5; i++) {
        arr[i] = n % 10;
        n = n / 10;
    }
}
int main() {
    int n, a, b, arr[5], tmp, sum = 0;
    cin >> n >> a >> b;

    for (int i = 0; i <= n; i++) {
        divnum(i, arr);
        tmp = arr[0] + arr[1] + arr[2] + arr[3] + arr[4];
        if (tmp >= a && tmp <= b)
            sum += i;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi dif(n);
  VIN(dif)
  SORT(dif);
  OUT(dif[n/2]-dif[n/2-1]);
}

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

int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double c = M_PI/6;
  long double d = M_PI/30;
  long double s;
  s = (a*a+b*b-2*a*b*cos(m*d*11.0/12.0-h*c));
  cout<<setprecision(20)<<sqrtl((long double)s)<<endl;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long A, B, C, D; cin >> A >> B >> C >> D; 
  long long E = (C*D)/__gcd(C, D); 
  long long fi = (A+C-1)/C;
  long long se = (B/C);
  long long res = B-A+1 - (se - fi + 1);
  fi = (A+D-1)/D;
  se = (B/D);
  res -= (se - fi + 1);
  fi = (A+E-1)/E;
  se = (B/E);
  res += (se - fi + 1);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#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 long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> 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;
}
int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  int a[n][m];
  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
  }
  int ans = 100000000;
  int all = 1 << n;
  for (int mask = 0; mask < all; mask++)
  {
    vector<int> vec(m);
    int cost = 0;
    for (int i = 0; i < n; i++)
    {
      if ((mask >> i) & 1)
      {
        cost += c[i];
        for (int j = 0; j < m; j++)
        {
          vec[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++)
    {
      if (vec[j] < x)
      {
        ok = false;
      }
    }
    if (ok)
    {
      ans = min(ans, cost);
    }
  }
  if (ans == 100000000)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 107;
char s[N];
int main()
{
    int k;
    scanf("%s%d", s+1, &k);
    for(int i = 1; s[i] != '\0'; i++)
    {
        if(s[i]=='1')
        {
            k--;
        }
        if(k==0||s[i]!='1')
        {
            printf("%c\n", s[i]);
            break;
        }
    }
    return 0;
}


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

using namespace std;

int N,M,K,L,R,H,W;

const long long int MOD=1000000007;
const float EPS=1e-8;

float dis(float a,float c,float b,float d){
	return sqrt((a-b)*(a-b)+(c-d)*(c-d));
}

float dp[1<<20][20];

int main(){

	int N;
	float sx,sy,gx,gy;
	while(cin>>N>>sx>>sy>>gx>>gy,N){
		vector<float>y(N);
		vector<float>x(N);
		vector<float>devil(N);
		bool f = true;
		for(int i=0;i<N;i++){
			cin>>x[i]>>y[i];
			devil[i]=dis(gx,gy,x[i],y[i]);
			if (devil[i] < dis(sx,sy,x[i],y[i])) {
				f = false;
			}
		}
		if (!f) {
			cout << "NO\n";
			continue;
		}
		vector<vector<float>>dist(N,vector<float>(N));
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				dist[i][j]=dis(x[i],y[i],x[j],y[j]);
			}
		}
		for(int i=0;i<1<<N;i++){
			for(int j=0;j<N;j++){
				dp[i][j]=MOD;
			}
		}
		for(int i=0;i<N;i++){
			if(devil[i]-EPS>dis(sx,sy,x[i],y[i])){
				dp[1<<i][i]=dis(sx,sy,x[i],y[i]);
			}
		}
		for(int i=1;i<1<<N;i++){
			for(int j=0;j<N;j++){
				if(!((i>>j)&1))continue;
				if(dp[i][j]>=1000000)continue;
				bool hoge = false;
				for(int k=0;k<N;k++){
					if((i>>k)&1)continue;
					if(dp[i][j]+dist[j][k] > devil[k] + EPS)hoge = true;
				}

				if(hoge)continue;
				for(int k=0;k<N;k++){
					if((i>>k)&1)continue;
					float nx=dp[i][j]+dist[j][k];
					if(nx<devil[k]-EPS){
						dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],nx);
					}
				}
			}
		}

		float ans=MOD;
		for(int i=0;i<N;i++){
			ans=min(ans,dp[(1<<N)-1][i]);
		}
		if(ans>=10000000){
			cout<<"NO\n";
		}
		else{
			cout<<"YES\n";
		}
	}

	return 0;
}



Measured memory_bytes: 85184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n];
    
    int ans = 1000000000;
    rep(i, n) cin >> x[i];
    repd(i, 1, 101)
    {
        int d = 0;
        rep(j, n)
        {
            d += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, d);
    }

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

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

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int sum = 0;
      
      int offset=0,next=0;
      char regex = ' ';
      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regex,offset)) == -1)
          next = line.length();
        sum += Integer.parseInt(line.substring(offset, next));
        offset = ++next;
      }

      System.out.println(sum-n);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 25044
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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: usize,
        s: chars
    }
    let mut r: u64 = 0;
    let mut b: u64 = 0;
    let mut g: u64 = 0;
    for i in 0..n {
        match s[i] {
            'R' => r += 1,
            'B' => b += 1,
            'G' => g += 1,
            _   => panic!()
        };
    }

    let mut sub = 0;
    for i in 0..n {
        for j in i..n {
            let k = 2 * j - i;
            if k >= n || s[i] == s[j] || s[i] == s[k] || s[j] == s[k] {
                continue;
            }
            sub += 1;
        }
    }
    println!("{}", r * b * g - sub);
}


Measured memory_bytes: 2172
import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val n = br.readInt()
    val a1 = br.readLong()
    val a2 = br.readLong()
    var x = 0L
    repeat(n - 2) {
        x = x xor br.readLong()
    }

    val b = a1 + a2 - x
    if (b and 1 != 0L) {
        print(-1)
    } else {
        var a1After = b shr 1
        if (a1After > a1) {
            print(-1)
        } else {
            var good = true
            for (bit in 39 downTo 0) {
                val num = 1L shl bit
                if (num and x != 0L) {
                    if(num and a1After != 0L){
                        good = false
                    }
                    if (num + a1After <= a1) {
                        a1After += num
                    }
                }
            }
            if (!good || a1After == 0L) {
                print(-1)
            } else {
                print(a1 - a1After)
            }
        }
    }
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

private fun BufferedReader.readLong(): Long {
    var ret = read().toLong()
    while (ret <= SPACE_INT) {
        ret = read().toLong()
    }
    val neg = ret == '-'.toLong()
    if (neg) {
        ret = read().toLong()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }
    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 34284
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

uint64_t solve(uint64_t n, uint64_t x)
{
    if(x > n) return solve(x, n);
    if(x == 0) return 0;
    uint64_t c = n / x;
    uint64_t modu = solve(x, n % x);
    return 2 * c * x + modu;
}

uint64_t gcd(uint64_t n, uint64_t m)
{
    if(m > n) return gcd(m, n);
    if(m == 0) return n;
    return gcd(m, n % m);
}

int main()
{
    ios::sync_with_stdio(false);
    uint64_t n, x;
    cin >> n >> x;
    cout << n + solve(x,n-x) - gcd(x, n-x) << '\n';
}



Measured memory_bytes: 256
import java.util.Scanner;

//Revenge of Champernowne Constant
public class Main{

	long DIGIT_LIMIT = 1000000000000000000L;
	long MAX_NUMBER = 59477124183006535L;
	long[] endK;
	long[] ten;
	
	void init(){
		endK = new long[20];
		endK[0] = 0;
		long num = 9;
		for(int k=1;k<=17;k++,num*=10){
			endK[k] = endK[k-1]+k*num;
		}
		endK[18] = DIGIT_LIMIT;
		endK[0] = -1;
		ten = new long[20];
		ten[0] = 0;
		ten[1] = 10;
		for(int k=2;k<=17;k++)ten[k]=ten[k-1]*10;
	}
	
	long findNumber(long x){
		if(x<=0||MAX_NUMBER<x)return DIGIT_LIMIT;
		if(x<10)return x;
		int k = (x+"").length()-1;
		return endK[k]+1+(k+1)*(x-ten[k]);
	}
	
	long findString(String target){
		boolean allzero = true;
		for(char ch:target.toCharArray())allzero&=ch=='0';
		if(allzero)return findNumber(Long.parseLong("1"+target))+1;
		int len = target.length();
		if(len==1){
			return findNumber(Long.parseLong(target));
		}
		long res = DIGIT_LIMIT;
		int lenMax = Math.min(17, len);
		for(int h=0;h<lenMax;h++)for(int k=1;k<=lenMax;k++)res = Math.min(res, findStringSub(target, h, k));
		return res;
	}
	
	long findStringSub(String target, int h, int k){
		if(target.charAt(h)=='0')return DIGIT_LIMIT;
		String sub = target.substring(0, h);
		String s = "";
		for(int i=h;i<h+k;i++){
			if(i<target.length())s+=target.charAt(i);
			else {
				int L = h+k-i;
				String r = (Long.parseLong(sub.substring(sub.length()-L))+1)+"";
				while(r.length()-L<0)r="0"+r;
				s+=r.substring(r.length()-L); break;
			}
		}
		long base = Long.parseLong(s);
		if(MAX_NUMBER<base)return DIGIT_LIMIT;
		String match = base+"";
		int pos = h, addLen = 0;
		long b = base-1;
		while(pos>0){
			if(b<=0)return DIGIT_LIMIT;
			String add = b-- +"";
			pos-=add.length();
			addLen+=add.length();
			match = add+match;
		}
		b = base+1;
		pos = h+k;
		while(pos < target.length()){
//			if(MAX_NUMBER<b)return DIGIT_LIMIT;
			String add = b++ +"";
			pos+=add.length();
			match+=add;
		}
		for(int i=0;i<target.length();i++)if(target.charAt(i)!=match.charAt(addLen-h+i))return DIGIT_LIMIT;
//		long res = findNumber(base);
//		while(h--!=0)res--;
		return findNumber(base)-h;
	}
	
	void run(){
		init();
		Scanner sc = new Scanner(System.in);
		for(;;){
			String s = sc.next();
			if("#".equals(s))break;
			System.out.println(findString(s));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
 
// Union find
struct uf {
  vi d;
  uf(){}
  uf(int mx):d(mx,-1){}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y]; d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
  int operator[](int x) { return root(x);}
  int operator()(int x) { return size(x);}
};

 
 
 
int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  uf t(n);
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    t.unite(a,b);
  }
  int ans = 1;
  rep(i,n) maxs(ans,t(i));
  cout<<ans<<endl;
  return 0;
}
 

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

int main(){
  int n; cin>>n;
  vector<int> x(n), y(n), h(n);
  for(int i=0; i<n; ++i)cin>>x[i]>>y[i]>>h[i];

  int piv=0;
  for(int k=0; k<n; ++k)if(h[k]!=0){piv=k; break;}
  
  int ansx, ansy, ansh;
  for(int i=0; i<=100; ++i){
    for(int j=0; j<=100; ++j){
      int z=h[piv]+abs(i-x[piv])+abs(j-y[piv]);
      bool flag=true;
      for(int k=0; k<n; ++k){
        int hh=z-abs(i-x[k])-abs(j-y[k]);
        if(h[k]!=max(hh, 0)){flag=false; break;}
      }
      if(flag){ansx=i; ansy=j; ansh=z;}
    }
  }

  cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std; typedef long long ll;
int main ()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
    
	int a;
	cin >> a;
	
	cout << a + a*a + a*a*a << "\n";
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif
	int a,b;
	cin>>a>>b;
	cout<<max(a-b,max(a+b,a*b));

	
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N;
    int[] A;
    void Solve()
    {
        N = cin.Nextint;
        A = cin.Scanint;
        Array.Sort(A);
        if (A[N - 1] - A[0] >= 2)
        {
            WriteLine("No");
            return;
        }
        //int need = A[0];
        if (A[0] == A[N - 1] && A[0] == 1)
        {
            WriteLine("Yes");
            return;
        }

        Array.Reverse(A);
        int cnt = 0;
        int dnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] == A[0]) cnt++;
            else dnt++;
        }

        if (dnt == 0)
        {
            if (cnt == A[0] + 1 || cnt >= A[0] * 2)
            {
                WriteLine("Yes");
                return;
            }
            else
            {
                WriteLine("No");
                return;
            }
        }



        if (cnt >= 2)
        {
            if (dnt == A[0] - 1)
            {
                WriteLine("Yes");
                return;
            }
            if (dnt == 1 && cnt >= (A[0] - 1) * 2)
            {
                WriteLine("Yes");
                return;
            }
            if (dnt < A[0] - 1 && cnt >= (A[0] - dnt) * 2)
            {
                WriteLine("Yes");
                return;
            }

            else
            {
                WriteLine("No");
                return;
            }
        }




        if (cnt == 1)
        {
            WriteLine("No");
        }


    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 18908
_ = int(input())
A = list(map(int, input().split()))

APPROVED = True

for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            APPROVED = False
            break

if APPROVED:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

long long n;

int main()
{
	scanf("%lld",&n);
	if(n%2==1)
	{
		printf("0\n");
		return 0;
	}
	long long res=0;
	while(n)
	{
		res+=n/10;
		n/=5;
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

char s[123], t[123];
int n;

int main(void)
{
	scanf("%d %s %s", &n, s, t);
	for (int m = 0; m <= n; ++m)
	{
		int match = n - m;
		bool flag = true;
		for (int i = 0; i < match; ++i)
		{
			if (t[i] != s[i + m])
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			return 0 * printf("%d\n", n + m);
		}
	}
	return -1;
}


Measured memory_bytes: 256
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i-1], t[i] = t[i], t[i-1]
		if ''.join(t).count('AGC') >= 1:
			return False
	return True

def dfs(cur, last3):
	if last3 in memo[cur]:
		return memo[cur][last3]
	if cur == N:
		return 1
	ret = 0
	for c in 'ACGT':
		if ok(last3 + c):
			ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
	memo[cur][last3] = ret
	return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 3872
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
map<long long,int> id;
int size[100005];
long long w[100005];
vector<pair<int,int> >e;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long D;
		scanf("%lld",&D);
		id[D]=i;
	}
	for(int i=1;i<=n;i++)size[i]=1,w[i]=0;
	for(int j=1;j<n;j++){
		long long d=id.rbegin()->first;
		int x=id.rbegin()->second;
		id.erase(d);
		d-=n-2*size[x];
		if(!id.count(d)||size[x]*2>n){puts("-1"); return 0;}
		e.push_back(make_pair(id[d],x));
		size[id[d]]+=size[x];
		w[id[d]]+=w[x]+size[x];
	}
	if(size[id.begin()->second]!=n||w[id.begin()->second]!=id.begin()->first){puts("-1"); return 0;}
	for(int i=0;i<e.size();i++)printf("%d %d\n",e[i].first,e[i].second);
	return 0;
}

Measured memory_bytes: 9848
import sys
from collections import defaultdict

n , q = map(int, sys.stdin.readline().split())

lazy = [0]*(n+1)

graph = defaultdict(lambda:list([]))
for i in range(n-1):
	x, y = map(int, sys.stdin.readline().split())
	# x, y = arr[i]
	graph[x].append(y)
	graph[y].append(x)

def dfs(src):
	visited ={src, }
	stack = [src]

	while stack:
		v = stack.pop()
		for next_v in graph[v]:
			if not next_v in visited:
				visited.add(next_v)
				lazy[next_v] += lazy[v]
				stack.append(next_v)

# queries = [(1, 1), (2, 2)]
for i in range(q):
	idx, val = map(int, sys.stdin.readline().split())
	# idx, val = queries[i]
	lazy[idx] += val
dfs(1)
print(*lazy[1:])

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    int n,m;cin >>n >>m;
    vector<pair<ll,ll>> s(n);
    rep(i,n){
        ll a,b;
        cin >>a >>b;
        s[i]=make_pair(a,b);
    }
    sort(all(s));
    ll ans=0;
    for(int i=0;i<n;i++){
        if(m>s[i].second){
                ans+=s[i].first*s[i].second;
                m-=s[i].second;
        }
        else {
                ans+=s[i].first*m;
                m=0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#    60 50
#    34 38

#  0  1   2  3   i
#  0  0  60 110  left 
#  0 60 110 110  right
#  0 34  38  0   speed
inf=1<<60
N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))
csum=0
left=[0]*(N+2)
right=[0]*(N+2)
for i in range(N):
    csum+=T[i]
    left[i+2]=csum
    right[i+1]=csum
right[N+1]=right[N]
speed=[0]+V+[0]

def calc(idx):
    l=inf
    r=inf
    for i in range(0,idx):
        #print(idx,i)
        #print(left)
        #print(right)
        l=min(l,speed[i]+(left[idx]-right[i]))
        r=min(r,speed[i]+(right[idx]-right[i]))
    for i in range(idx+1,N+2):
        l=min(l,speed[i]+(left[i]-left[idx]))
        r=min(r,speed[i]+(left[i]-right[idx]))
    l=min(l,speed[idx])
    r=min(r,speed[idx])
    width=right[idx]-left[idx]
    d=0
    #print(idx,width,l,r,speed[idx])
    if (speed[idx]-l)+(speed[idx]-r)<=width:
        d+=(speed[idx]+l)*(speed[idx]-l)/2
        d+=(speed[idx]+r)*(speed[idx]-r)/2
        d+=(speed[idx])*(width-(speed[idx]-l)-(speed[idx]-r))
    elif l<r:
        d+=(l+r)*(r-l)/2
        d+=(width-(r-l))*(r+r+(width-(r-l))/2)/2
    else:
        d+=(l+r)*(l-r)/2
        d+=(width-(l-r))*(l+l+(width-(l-r))/2)/2
    return d

ans=0
for i in range(1,N+1):
    ans+=calc(i)
print(ans)


Measured memory_bytes: 39536
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)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, K, D = mi()
N = abs(N)

if K * D > N:
    num = N//D
    if not (num-K)%2:
        print(min(abs(N - D * (N//D)), abs(N - D * (N//D) - 2 * D)))
    else:
        print(min(abs(N - D * (N//D) + D), abs(N - D * (N//D) - D)))
else:
    print(N - D * K)


Measured memory_bytes: 9232
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))
#print(L)

A = [[0 for _ in range(2)] for _ in range(N+1)]

for i in range(M) :
  if L[i][1] == "WA" and A[int(L[i][0])][1] != 1:
    A[int(L[i][0])][0] += 1
  else :
    A[int(L[i][0])][1] = 1

#print (A)
ACsum = 0
WAsum = 0
for j in range(N+1) :
  if A[j][1] == 1 :
    ACsum += 1
    WAsum += A[j][0]
  
print(str(ACsum) + " " + str(WAsum))

Measured memory_bytes: 81624
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    char op;
    while(cin>>a>>op>>b)
    {
        if (op=='+')
            cout<<(a+b)<<endl;
        else if(op=='-')
            cout<<(a-b)<<endl;
        else if(op=='*')
            cout<<(a*b)<<endl;
        else if(op=='/')
        cout<<(a/b)<<endl;
        else if(op=='?')
            break;
        else
            continue;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(w,h,c);
    int a=__gcd(w,h);
    out(c*h*w/(a*a));
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int a,b,c,d,i,j,p1,p2,p3,p4;
    long long m=-1e9;
    cin>>a>>b>>c>>d;
    p1=a*c,p2=a*d,p3=b*c,p4=b*d;
    m=max(p1,p2);
    m=max(p3,m);
    m=max(p4,m);
    cout<<m;
    

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int n,max=0,second = 0;
    bool several = false;
    cin>>n;
    vector<int> a(n);

    rep(i,n){
        cin>>a[i];
        if(max == a[i]){
            several = true;
        }
        if(max < a[i]){
            second = max;
            max = a[i];
            several = false;
            // cout<<a[i]<<" "<<second<<" "<<max<<endl;
        }
        else if(second < a[i]) second = a[i];
    }
    rep(i,n){
        if(max == a[i] && several){
            cout<<max<<endl;
        }
        else if(max == a[i] && !several){
            cout<<second<<endl;
        }
        else{
            cout<<max<<endl;
        }
    }
}

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

#define   ipair         pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int mod  =  2019;
const ld  pi   =  acos(-1);
const int Maxn =  1005;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}


int32_t main(){ IOS;
    int n,a,b;  cin>>n;
    for(int i=(int)sqrt(n);i>=1;i--){
        if(n%i == 0){
            a = i;
            b = n/i;
            break;
        }
    }
    cout<<a+b-2<<endl;
}

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

bool kawaisou(int A, int B, int C) {
	set<int> ns = {A, B, C};
	// ns.insert(A);
	// ns.insert(B);
	// ns.insert(C);
	if (ns.size() == 2) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (kawaisou(A, B, C)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(all(p));
    int A = 0;
    bool f = 0;
    repe(i, p){
        A += i.second;
        if(A > i.first){
            f = 1;
            break;
        }
    }
    cout << (f ? "No" : "Yes" ) << endl;


}

Measured memory_bytes: 1920
def inpl(): return [int(i) for i in input().split()]
import sys
N, L = inpl()
a = inpl()
b = []
for i in range(N-1):
    b.append(a[i]+a[i+1])
bmax = max(b)
if bmax < L:
    print('Impossible')
    sys.exit()

print('Possible')
ans = b.index(bmax)

Ans = list(range(0,ans)) + list(range(N-2,ans,-1))+[ans]
for i in range(N-1):
    print(Ans[i]+1)
    

Measured memory_bytes: 16436
import java.util.Scanner;

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

		int row = stdIn.nextInt();
		int[] numbers = new int[row];

		for (int i = 0; i < row; i++) {
			numbers[i] = stdIn.nextInt();
		}

		insertionSort(numbers, row);

	}

	static void insertionSort(int[] numbers, int row) {
		int j;
		int tmp;

		for (int i = 1; i < row; i++) {
			for (int k = 0; k < row - 1; k++) {
				System.out.print(numbers[k] + " ");
			}
			System.out.println(numbers[row - 1]);
			tmp = numbers[i];
			j = i - 1;
			while (j >= 0 && numbers[j] > tmp) {
				numbers[j + 1] = numbers[j];
				j--;
			}
			numbers[j + 1] = tmp;
		}
		for (int k = 0; k < row - 1; k++) {
			System.out.print(numbers[k] + " ");
		}
		System.out.println(numbers[row - 1]);
	}
}

Measured memory_bytes: 35396
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>

typedef long long ll;

using namespace std;

int main(void){
    int n;
    scanf("%d", &n);
    int arr[n];

    for(int i =0 ;i < n; i++){
        scanf("%d", &arr[i]);
    }

    int memo[n];
    for(int i = 0; i < n; i++){
        memo[i] = 0;
    }
    memo[0] = 0;
    memo[1] = abs(arr[1]-arr[0]);
    for(int i = 2;i < n; i++)
    {   
        //  memo[i-1] + llabs(arr[i]-arr[i-1]);
        

        memo[i] = min(memo[i-1] + abs(arr[i]-arr[i-1]) , memo[i-2] + abs(arr[i]-arr[i-2]));
    }

    printf("%d",memo[n-1]);

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]){
      --ans;
      i += 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
const int N = 5005;
const long long inf = 1e18;
using namespace std;

typedef pair <int, int> ii;
vector <ii> mv;

int n, ans;
long long dp[N][N], Min[N];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x, y; cin >> x >> y;
        x += y;
        mv.push_back(ii(x, y));
    }
    sort(mv.begin(), mv.end());
    for (int i = 0; i < N; i++) Min[i] = inf;
    Min[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j >= 1; j--){
            if (mv[i-1].first - mv[i-1].second >= Min[j-1]) dp[i][j] = Min[j-1] + mv[i-1].second;
            else dp[i][j] = inf;
            Min[j] = min(Min[j], dp[i][j]);
            if (dp[i][j] != inf) ans = max(ans, j);
        }
    }
    cout << ans;
}


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

using namespace std;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a <= 0 && b >= 0) {
    puts("Zero");
  } else {
    if (a > 0) {
      puts("Positive");
    } else {
      puts((b - a + 1) % 2 == 0 ? "Positive" : "Negative");
    }
  }
  return 0;
}

Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int n;cin >> n;
    rep(i, n){
        int a;cin >> a;
        if(a%2) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>

using namespace std;

main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;

    int ans1=0, ans2=0;
    for(int i=0;i<n;i++){
      int a, b;
      cin >> a >> b;
      if(a>b){
	ans1+=a+b;
      }else if(a<b){
	ans2+=a+b;
      }else{
	ans1+=a;
	ans2+=b;
      }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int cnt[100100];

int main(void){
	int n,m,l,r,i,ans=0;
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> l >> r;
		--l;
		++cnt[l]; --cnt[r];
	}
	for(i=0; i<n; ++i){
		if(cnt[i]==m){
			++ans;
		}
		cnt[i+1] += cnt[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  int d = 0, tmp = N;
  while(tmp) {
    d++;
    tmp /= 10;
  }
  int ans = 0, p = 1;
  for(int i=1; i<d; i+=2){
    ans += 9*p;
    p *= 100;
  }
  if(d%2)
    ans += N-(p-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256