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, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream& operator<<(ostream &os, unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, 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, 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...); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> p;

int main()
{
    cin >> N;
    p.resize(N);
    cin >> p;
    cout << accumulate(p.begin(), p.end(), 0) - *max_element(p.begin(), p.end()) / 2 << endl;
}


Measured memory_bytes: 256
using System;

namespace A
{
	static class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			var lineSplited = line.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);

			var y = int.Parse(lineSplited[0]);
			var m = int.Parse(lineSplited[1]);
			var d = int.Parse(lineSplited[2]);

			if (y < 2019
				|| (y == 2019 && m < 4)
				|| (m == 4 && d <= 30)) {
				Console.WriteLine("Heisei");
				return;
			}

			Console.WriteLine("TBD");
		}
	}
}

Measured memory_bytes: 11092
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 101;
ll n,m;
vvi mat(N,vi(N,0));
vvi dp(N,vi(N,0));
vvi ch(N,vi(N,0));


int solve()
{
	cin>>n>>m;
	rep(i,0,n) 
	{
		string s;cin>>s;
		rep(j,0,m) mat[i][j]=(s[j]=='.');
	}



	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if(i==0 && j==0) 
			{
				dp[0][0] = (mat[i][j]==0?1:0);
				ch[0][0] = (mat[i][j]==0?1:0);
			}
			else
			{
				ll ans1 =(i-1>=0?dp[i-1][j] + (mat[i][j]==0 && ch[i-1][j]==0?1:0) : inf);
				ll ans2 = (j-1>=0?dp[i][j-1] + (mat[i][j]==0 && ch[i][j-1]==0?1:0) : inf);
				dp[i][j] = min(ans1,ans2);
				ch[i][j] = (mat[i][j]==0?1:0);
			}
		}
	}

	cout<<dp[n-1][m-1]<<"\n";



	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

/*テンプレートのほうがかんたんだったでおじゃる〜〜〜〜〜〜〜んひ〜〜〜〜*/
int main(){
  char s[100];
  int stack[1000];
  int p=0;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        int tmp=stack[p-2]+stack[p-1];
        stack[p-1]=0;
        p-=2;
        stack[p]=tmp;
        p++;
    } else if ( s[0] == '-' ){
        int tmp=stack[p-2]-stack[p-1];
        stack[p-1]=0;
        p-=2;
        stack[p]=tmp;
        p++;
    } else if ( s[0] == '*' ){
        int tmp=stack[p-2]*stack[p-1];
        stack[p-1]=0;
        p-=2;
        stack[p]=tmp;
        p++;
    } else {
        int x = atoi(s);
        stack[p]=x;
        p++;
    }
/*
    for(int i=0;i<p;i++){
        cout<<stack[i]<<" ";
    }cout<<endl;
*/
  }
  cout<<stack[p-1]<<endl;
  return 0;
}

Measured memory_bytes: 1168
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	result, err := calc(os.Stdin)
	if err != nil {
		println(err)
		os.Exit(1)
	}
	fmt.Println(result)
}

func calc(reader io.Reader) (string, error) {
	scanner := bufio.NewScanner(reader)
	var min int64
	var diff int64

	scanner.Scan()
	count, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		return "", fmt.Errorf("error: %v", err)
	}

	var i int64
	for ; i < count; i++ {
		scanner.Scan()
		price, err := strconv.ParseInt(scanner.Text(), 10, 64)
		if err != nil {
			return "", fmt.Errorf("error: %v", err)
		}

		if min == 0 && diff == 0 {
			min = price
			diff = diff - price
			continue
		}

		newDiff := price - min
		if newDiff > diff {
			diff = newDiff
		}
		if price < min {
			min = price
		}
	}
	return strconv.FormatInt(diff, 10), nil
}



Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

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

  string S;
  cin >> S;

  if(S.size() <= N){
    cout << S << endl;
  } 
  else{
    cout << S.substr(0,N) << "...\n";
  }

  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> V[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
// map<lld,lld> M;


int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc2(n,k);
    curr = 1;
    val = k;
    while(val < n) {
        val += (k - 1);
        curr++;
    }
    prL(curr);
    return 0;
}

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

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

    int A;
    set<int> count;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        count.insert(A);
    }
    if (count.size() % 2 == 0)
    {
        cout << count.size() - 1 << endl;
    }
    else
    {
        cout << count.size() << endl;
    }
}


Measured memory_bytes: 4992
use std::io;

fn ceil_div(a: usize, b: usize) -> usize {
    (a + b - 1) / b
}

fn main() {
    let mut buf = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut buf).unwrap();
    let (N, K): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (
            split.next().unwrap().parse().unwrap(),
            split.next().unwrap().parse().unwrap(),
        )
    };
    buf.clear();
    stdin.read_line(&mut buf).unwrap();
    let a: Vec<usize>=buf.split_whitespace().map(|x|x.parse().unwrap()).collect();
    let mut l = 1;
    let mut r = 1_000_000_001;
    while l<r {
        let m = l + (r-l) / 2;
        let requirement: usize = a.iter().map(|&x| ceil_div(x,m) - 1).sum();
        if requirement > K {
            l = m + 1;
        } else {
            r = m;
        }
    }
    println!("{}", l);
}


Measured memory_bytes: 5608
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
using ll = long long;
using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int target;

bool f(int v) { return v < target; }

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

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    segtree<int, op, e> st(A);
    rep(_, Q) {
        int T;
        cin >> T;
        if ((T == 1) || (T == 3)) {
            int X, V;
            cin >> X >> V;
            if (T == 1) {
                st.set(X - 1, V);
            } else if (T == 3) {
                target = V;
                cout << st.max_right<f>(X - 1) + 1 << '\n';
            }
        } else if (T == 2) {
            int L, R;
            cin >> L >> R;
            cout << st.prod(L - 1, R) << '\n';
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 6196
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<ll> psum(n);
	psum[0] = a[0];
	for (int i = 1; i < n; i++)
		psum[i] = psum[i - 1] + a[i];
	ll ans = abs(2 * psum[0] - psum[n - 1]);
	for (int i = 1; i < n - 1; i++) {
		if (ans > abs(2 * psum[i] - psum[n - 1]))
			ans = abs(2 * psum[i] - psum[n - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import sys
from math import ceil
from itertools import permutations
def input(): return sys.stdin.readline().strip()

def main():
    T = [int(input()) for _ in range(5)]
    ans = 10**10
    for way in list(permutations(T, 5)):
        time = 0
        for i in range(4):
            time += ceil(way[i] / 10) * 10
        time += way[-1]
        #if ans > time: print("way={}, time={}".format(way, time))
        ans = min(ans, time)
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;

  for (int i = A; i <= B; i++){

    int ichi = i % 10;
    int man = i / 10000;

    if(ichi != man){
      continue;
    }

    int zyu = (i % 100)/10;
    int sen = (i/1000)%10;

    if(zyu != sen){
      continue;
    }

    count++;

  }

  cout << count << endl;

}


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

int main(){
ll n,num;
cin>>n;
ll a[n],i;
for(i =0; i<n; i++){
cin>>num;
a[num-1]=i+1;
}

    for(i=0;i<n;i++)cout<<a[i]<<" ";
}

Measured memory_bytes: 1536
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    cnt = 0
    for i in range(A + 1):
        for j in range(B + 1):
            for k in range(C + 1):
                if i * 500 + j * 100 + k * 50 == X:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){



}

void solve(){
    
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2];
    
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_Lucky7_162
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            string n = Console.ReadLine();

            string result;

            string s = "7";

            if (n.Contains(s))
            {
                result = "Yes";
            }
            else
            {
                result = "No";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25660
// by DenyTianly
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define iScf(n) scanf("%d", &n)
#define dug() printf("ok!\n")
#define iNxtL() puts("")
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define nrep(i, val, n) for(int i = val; i < n; i++)
#define ipq priority_queue
typedef long long LL;
typedef unsigned long long ULL;

const int inf = 1 << 26;
const LL INF = 1LL << 60;

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

// Don't hack me, please ~
// #define _Isopen_File_
// #define _Is_Close_STD_

int main(){

#ifdef _Isopen_File_
	freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
#endif

#ifdef _Is_Close_STD_
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif

	int n;
	scanf("%d", &n);
	int ans = n*800;
	ans -= n/15*200;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, i;
	int array[100];
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &array[i]);
	}
	
	for(i = 0; i < n; i++) {
		if(i) {
			printf(" ");
		}
		
		printf("%d", array[n - i - 1]);
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
# AOJ 1054: Distorted Love
# Python3 2018.7.7 bal4u

while True:
	n = int(input())
	if n == 0: break
	input()   # w, h
	pag, dic = [], {}
	for i in range(n):
		nm, k = input().split()
		dic[nm] = i
		btn = []
		for j in range(int(k)):
			x1, y1, x2, y2, bnm = input().split()
			btn.append((int(x1), int(y1), int(x2), int(y2), bnm))
		pag.append((nm, btn))
	buf = [0]*2000
	now, sz = 0, 1
	m = int(input())
	for i in range(m):
		a = input().split()
		if a[0] == "back":
			if now > 0: now -= 1
		elif a[0] == "forward":
			if now < sz-1: now += 1
		elif a[0] == "show": print(pag[buf[now]][0])
		else:		# click
			x, y = int(a[1]), int(a[2])
			btn = pag[buf[now]][1]
			for x1, y1, x2, y2, nm in btn:
				if x1 <= x and x <= x2 and y1 <= y and y <= y2:
					now += 1
					buf[now] = dic[nm]
					sz = now+1
					break



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

int main() {
  int n, k, q, i, a;
  cin >> n >> k >> q;
  vector<int> p(n, 0);
  for (i = 0; i < q; i++) {
    cin >> a; p[a-1]++;
  }
  for (i = 0; i < n; i++) {
    if (p[i] > q-k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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


struct UnionFind{
	vector<int> rnk,par,num;
	UnionFind(int N) : rnk(N),par(N),num(N){
		init();
	}
	void init(){
		for(int i = 0;i < rnk.size();i++){
			rnk[i] = 0;
			par[i] = i;
			num[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]){
			par[x] = y;
			num[y] += num[x];
		}
		else{
			par[y] = x;
			num[x] += num[y];
			if(rnk[x] == rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return (find(x) == find(y));
	}
	int size(int x){
		return num[find(x)];
	}
};

signed main(){
  int N, M; cin >> N >> M;
  vector<int> A(M), B(M);
  UnionFind tree(N);
  for(int i  = 0; i < M; i++){
    cin >> A[i] >> B[i];
    --A[i]; --B[i];
  }
  vector<int> an(M);
  int ans = N*(N - 1)/2;
  for(int i = M - 1; i >= 0; i--){
		an[i] = ans;
		if(!tree.same(A[i],B[i])){
          ans -= tree.size(A[i]) * tree.size(B[i]);
        }
		tree.unite(A[i],B[i]);
	}
	for(int i = 0; i < M; i++) cout << an[i] << endl;
}

Measured memory_bytes: 6016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int sum = 0;
		map<int,int>a;
		for(int i=0;i<n;++i)
		{
			int m;
			scanf("%d",&m);
			a[m]++;
		}
		map<int,int>::iterator b;
		for(b = a.begin();b!=a.end();++b)
		{
			if(b->second & 1)
				sum++;
		}
		printf("%d\n",sum);
	}
}

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

int main() {
	int n;
	cin>>n;
	if(n==0)
	cout<<0;
	else
	{
	int a[n+1];
	int dp[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	dp[1]=0;
	dp[2]= abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
	    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n];
	}
	return 0;
}

Measured memory_bytes: 1024
program prob2
    implicit none
    character(len=200005)::S,T
    integer::i, l, ans
    read(*,*) S, T
    l = len_trim(S)
    ans = 0
    do i = 1, l
        if(S(i:i) .ne. T(i:i))then
            ans = ans + 1
        end if
    end do

    write(*,*) ans
    stop
end program

Measured memory_bytes: 3496
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
		public static void main(String[] args) {
			int a=scan.nextInt();
			int b=scan.nextInt();
			int c=a+b;
			int d=a-b;
			int e=a*b;
			int max=max(c,d);
			max=max(max,e);
			System.out.println(max);
		}
}

Measured memory_bytes: 21972
character(1000) :: s,t
integer :: sLen,tLen,i,j,mx=0,tempMx
read*,s
read*,t
sLen = len_trim( s )
tLen = len_trim( t )

do i = 0,sLen-tLen
  tempMx = 0
  do j = 1,tLen
    if( s(j+i:j+i)==t(j:j) ) tempMx = tempMx + 1
  end do
  mx = max( tempMx,mx )
end do
print*,tLen-mx
end


Measured memory_bytes: 2860
n = int(input())
a = list(map(int,input().split()))
ans = int(1e18)
for i in range(101):
    cnt = 0
    for j in range(n):
        cnt += (a[j]-i)**2
    ans = min(ans,cnt)
    cnt = 0
    for j in range(n):
        cnt += (a[j]+i) **2
    ans = min(ans,cnt)
print(ans)


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

int main(void){
	int n;

	while(cin>>n,n){
		int ans = 0;
		while(n != 1){
			if(n % 2 == 0){
				n /= 2;
			}
			else{
				n = n * 3 + 1;
			}
			ans++;
		}

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.math.BigDecimal;
import java.util.*;

public class Main {

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


        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        int m = scanner.nextInt();
        BigDecimal hourY =new BigDecimal(a * Math.sin(Math.toRadians((double)((60 * h) + m) * 0.5)));
        BigDecimal hourX = new BigDecimal(a * Math.cos(Math.toRadians((double)((60 * h) + m) * 0.5)));
        BigDecimal minuteY = new BigDecimal(b * Math.sin(Math.toRadians(6 * m)));
        BigDecimal minuteX = new BigDecimal(b * Math.cos(Math.toRadians(6 * m)));
        BigDecimal x = hourX.subtract(minuteX);
        BigDecimal y = hourY.subtract(minuteY);
        BigDecimal xx = x.multiply(x);
        BigDecimal yy = y.multiply(y);
        BigDecimal preResult = xx.add(yy);
        System.out.println(Math.sqrt(preResult.doubleValue()));



    }
}


Measured memory_bytes: 36088
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define INF 2000000000
#define typec int//type of cost
const int pN=500,eN=10000;
struct Edge{
	int u,v,next;
	typec w;
};
Edge edge[eN];
int en,head[pN],cur[pN],ps[pN],dep[pN];
void insert(int u,int v){
	edge[en].u=u;
	edge[en].v=v;
	edge[en].w=1;
	edge[en].next=head[u];
	head[u]=en++;
	edge[en].u=v;
	edge[en].v=u;
	edge[en].w=1;//æåä¸º0ï¼æ åä¸ºc
	edge[en].next=head[v];
	head[v]=en++;
}
typec max_flow(int n,int s,int t){
	typec tr,res=0;
	int i,j,k,f,r,top;
	while(1){
		memset(dep,-1,n*sizeof(int));
		for(f=dep[ps[0]=s]=0,r=1;f!=r;)
			for(i=ps[f++],j=head[i];j!=-1;j=edge[j].next){
				if(edge[j].w&&-1==dep[k=edge[j].v]){
					dep[k]=dep[i]+1;
					ps[r++]=k;
					if(k==t){
						f=r;
						break;
					}
				}
			}
			if(-1==dep[t])break;
			memcpy(cur,head,n*sizeof(int));
			for(i=s,top=0;;){
				if(i==t){
					for(k=0,tr=INF;k<top;++k)
						if(edge[ps[k]].w<tr)
							tr=edge[ps[f=k]].w;
						for(k=0;k<top;++k)
							edge[ps[k]].w-=tr,edge[ps[k]^1].w+=tr;
						res+=tr;
						i=edge[ps[top=f]].u;
				}
				for(j=cur[i];cur[i]!=-1;j=cur[i]=edge[cur[i]].next)
					if(edge[j].w&&dep[i]+1==dep[edge[j].v])break;
					if(cur[i]!=-1){
						ps[top++]=cur[i];
						i=edge[cur[i]].v;
					}else{
						if(0==top)break;
						dep[i]=-1;
						i=edge[ps[--top]].u;
					}
			}
	}
	return res;
}
int N,M,S,E;
void get_data(){
	int i;
	scanf("%d%d",&N,&M);
	memset(head,-1,sizeof(head));en=0;
	int u,v;
	for(i=0;i<M;i++){
		scanf("%d%d",&u,&v);
		u--;v--;
		insert(u,v);
	}
	scanf("%d%d",&S,&E);
	S--;E--;
}
void run(){
	int flow=max_flow(N,S,E);
	int cnt=0,i,res[1000];
	for(i=0;i<en;i+=2){
		if(edge[i].w==2)res[cnt++]=i/2+1;
	}
	printf("%d\n%d\n",flow,cnt);
	for(i=0;i<cnt;i++)printf("%d\n",res[i]);
}
int main(){
	get_data();
	run();
	return 0;
}

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

using namespace std;

int cnt, freq[30];
string s;
int main()
{
	cin >> s;
	for(int i = 0 ; i < s.size(); ++i)
	{
		++freq[s[i] - 'A'];
		if(freq[s[i] - 'A'] == 2)	++cnt;
	}
	if(cnt == 2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
double x[100],y[100],t,u,a,b,s;
n,i,j,k,c;
main(m){
	for(;scanf("%d",&n),i=j=n;printf("%d\n",m)){
		for(m=1;i--;scanf("%lf,%lf",x+i,y+i));
		for(i=n;--i;)
			for(j=i-1;j--;)
				if((u=acos(hypot(x[j]-x[i],y[j]-y[i])/2))<9)
					for(s=1,t=atan2(y[j]-y[i],x[j]-x[i]);c=0,s+3;s-=2)
						for(a=x[i]+cos(t+s*u),b=y[i]+sin(t+s*u),k=n;k--;)
							hypot(a-x[k],b-y[k])<1.1&&++c>m?m=c:0;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<size_t> A(M), B(M);
  for (size_t i = 0; i < M; ++i) {
    scanf("%zu %zu", &A[i], &B[i]);
    --A[i];
    --B[i];
  }

  union_find uf(N);
  std::vector<intmax_t> res(M);

  intmax_t cur = 0;
  for (size_t i = M; i-- > 1;) {
    size_t a = A[i];
    size_t b = B[i];
    if (uf.connected(a, b)) {
      fprintf(stderr, "%zu: ---\n", i);
      res[i-1] = cur;
      continue;
    }

    intmax_t u = uf.size(a);
    intmax_t v = uf.size(b);
    uf.unite(a, b);
    intmax_t w = uf.size(a);

    cur -= u*(u-1)/2 + v*(v-1)/2;
    cur += w*(w-1)/2;
    fprintf(stderr, "%zu: %jd %jd => %jd\n", i, u, v, w);
    res[i-1] = cur;
  }

  for (auto x: res)
    printf("%jd\n", N*(N-1)/2-x);
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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 long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
    ci(n>>m);
  vll A(m);
  FOR(i,0,m){
    ci(A[i])
  }
  SORT(A);
  ll ans=A[m-1]-A[0];
  rFOR(i,m-1,0){
    A[i]-=A[i-1];
  }
  A[0]=0;
  SORT(A);
  
  if(n>=m){
    ans=0;
  }
  else{
  FOR(i,0,n-1){
    ans-=A[m-1-i];
  }
  }
  co(ans)
}

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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
    int z;
    if(b==0){
        z=1;
        z%=c;
        return z;
    }
    if(b==1){
        z=a;
        z%=c;
        return z;
    }
    else{
        return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
    }
}
ll mod=1000000007;
ll vec[100010], kaijo[100010], c[100010];
ll comb(int x, int y) {
	return kaijo[x] * mpower(kaijo[x - y], mod - 2, mod) % mod * mpower(kaijo[y], mod - 2, mod) % mod;
}
 
int main(){
  int n,k;
  cin>>n>>k;
  if(k==1){
    cout<<0<<endl;
    return 0;
  }
  
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  kaijo[0]=1;
  for(int i=1;i<n;i++){
    kaijo[i] = kaijo[i-1]*i % mod;
  }
  for(int i=k-2;i<=n;i++) {
		c[i]=comb(i,k-2);
		c[i]+=c[i-1];
		c[i]%=mod;
  }
  sort(vec,vec+n);
  ll maxx=0,minx=0;
  for(int i=0;i<n;i++){
    if(n-i-1>=k-1){
      minx+=vec[i]*c[n-2-i]%mod;
      minx%=mod;
    }
    if(i>=k-1){
      maxx+=vec[i]*c[i-1]%mod;
      maxx%=mod;
    }
  }
  ll ans=maxx-minx+mod;
  if(ans>=mod){
    ans-=mod;
  }
  if(ans>=mod){
    ans-=mod;
  }
  if(ans>=mod){
    ans-=mod;
  }
  cout<<ans<<endl;
}

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

class Student
{
public:
    int i;
    int order;
};

void Main() {
    int n;
    std::cin >> n;
    int order[n + 1];
    int tmp;
    for (int i = 1; i <= n; i++) {
        std::cin >> tmp;
        order[tmp] = i;
    }

    for (int i = 1; i <= n; i++) {
        if (i == 1) {
            std::cout << order[i];
        } else {
            std::cout << " " << order[i];
        }
    }
    std::cout << std::endl;
}

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;


int main() {
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = 0;
    for(ll i = L; i <= R; i++){
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
}

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

void solve() 
{
    int n;cin>>n;int sum=n/500*1000;
    sum+=n%500/5*5;
    cout<<sum<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> L(n);
    rep(i, n) cin >> L.at(i);
    int ans = INF;
    for(int i = 0; i < (1 << (2 * n)); i++){
        int tmp = i;
        vector<vector<int>> bmb(4);
        rep(j, n){
            bmb.at(tmp % 4).push_back(L.at(j));
            tmp /= 4;
        }
        if(bmb.at(0).size() == 0 || bmb.at(1).size() == 0 || bmb.at(2).size() == 0) continue;
        
        int a_bmb = 0, b_bmb = 0, c_bmb = 0;

        rep(j, bmb.at(0).size()){
            a_bmb += bmb.at(0).at(j);
        }
        rep(j, bmb.at(1).size()){
            b_bmb += bmb.at(1).at(j);
        }
        rep(j, bmb.at(2).size()){
            c_bmb += bmb.at(2).at(j);
        }

        int mp = abs(a_bmb - a) + abs(b_bmb - b) + abs(c_bmb - c);
        rep(j, 3){
            mp += 10 * (bmb.at(j).size() - 1);
        }

        ans = min(ans, mp);
    }

    cout << ans << endl;    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

string S,T; cin >> S >> T;

if(S==T.substr(0,S.size())){
cout << "Yes" << endl;
}

else{
  cout << "No" << endl;

}
return 0;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  int n;
  string s;
  cin>>n;
  string A,B;
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  cin>>s;
  A=s.substr(0, n/2);
  B=s.substr(n/2,n/2);
  if(A==B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
from math import ceil
 
N, H = map(int, input().split())
a, b = [], []
 
for _ in range(N):
    a_i, b_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)
 
max_a = max(a)
b = sorted(b, reverse=True)
ans = float('inf')
th_po = 0
 
for i in range(N):
    th_po += b[i]
    
    if H >= th_po:
        ans_cand = i + 1 + ceil((H - th_po) / max_a)
    else:
        ans_cand = i + 1
    
    ans = min([ans, ans_cand])
 
print(ans)


Measured memory_bytes: 12160
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int dp[1<<9][100001];
int v[1<<18], w[1<<18];
int solve(int V, int l){
    if(V < 1 << 9){
        return dp[V][l];
    }
    return max(solve((V - 1) / 2, l), l - w[V] >= 0 ? solve((V - 1) / 2, l - w[V]) + v[V] : 0);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n)cin >> v[i] >> w[i];
    rep(j,100001){
        if(j>=w[0])dp[0][j] = v[0];
    }
    rep(i,min(n, 1<<9) - 1){
        rep(j,100001){
            dp[i + 1][j] = max(dp[i/2][j], j - w[i + 1] >= 0 ? dp[i/2][j-w[i + 1]]+v[i + 1] : 0);
        }
    }
    int q;
    cin >> q;
    while(q--){
        int V, L;
        cin >> V >> L;
        cout << solve(V - 1, L) << "\n";
    }
}


Measured memory_bytes: 205652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a)
	{
		a=a-k;
	}
	else if(k<=(a+b)) 
	{
		b=b-(k-a);
		a=0;
	}
	else
	{
		a=0;b=0;
	}
	cout<<a<<" "<<b<<"\n";
return 0;
}

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

using namespace std;

int main()
{
	int n, m, key = 0, j = 0;
	scanf("%d", &n);
	
	vector<int> v;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	vector<int>::iterator it;
	
	for(int i = 0; i <= v.size()-1; i++)
	{
		key = v[i];
		
		for(j = i - 1; j >= 0 && v[j] > key; j--)
			v[j+1] = v[j];
		
		v[j+1] = key;
		
		for(it = v.begin(); it != v.end()-1; it++)
				printf("%d ", *it);
		printf("%d\n", *it);
		
	}
	
	return 0;
}


Measured memory_bytes: 3260
N,K = map(int,input().split())
S = input()

#N = 10 ** 5
#K = 3
#S = "01" * ((10 ** 5) // 2 )

lis = []

nowchar = -1
num = 0

for i in range(N):

        if nowchar == S[i]:

            num += 1

        elif nowchar != -1:

            lis.append([nowchar,num])

            nowchar = S[i]
            num = 1

        else:

            nowchar = S[i]
            num = 1

lis.append([nowchar,num])


nlis = []
lisst = 0
lisla = -1
zeronum = 0
summ = 0
ans = 0


while True:

    if zeronum <= K:

        ans = max(ans,summ)

        if lisla == len(lis)-1:
            break

        new = lis[lisla+1]
        lisla += 1
        #nlis.append(new)

        if new[0] == "0":
            zeronum += 1

        summ += new[1]

    else:

        old = lis[lisst]
        lisst += 1

        if old[0] == "0":
            zeronum -= 1

        summ -= old[1]

print (ans)
        


Measured memory_bytes: 59760
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] lines = br.readLine().split(" ");
    int n = Integer.parseInt(lines[0]);
    int[] abc = new int[4];
    abc[1] = Integer.parseInt(lines[1]);  //A
    abc[2] = Integer.parseInt(lines[2]);  //B
    abc[3] = Integer.parseInt(lines[3]);  //C
    String mark = "_ABC";
    char[] history = new char[n];
    int[] commands = new int[n];
    for (int i = 0; i < n; i++) {
      String command = br.readLine();
      if ("AB".equals(command)) {
        commands[i] = 12;
      } else if ("AC".equals(command)) {
        commands[i] = 13;
      } else if ("BC".equals(command)) {
        commands[i] = 23;
      }
    }
    br.close();
    for(int i = 0; i < n; i++){
      int command = commands[i];
      int idx_1 = command / 10;
      int idx_2 = command % 10;

      if(abc[idx_1] == 0 && abc[idx_2] == 0){
        System.out.println("No");
        return;
      }
      if(abc[idx_1] == 0){
        abc[idx_1]++;
        abc[idx_2]--;
        history[i] = mark.charAt(idx_1);
      } else if(abc[idx_2] == 0){
        abc[idx_1]--;
        abc[idx_2]++;
        history[i] = mark.charAt(idx_2);
      } else if(abc[idx_1] == 1 && abc[idx_2] == 1){
        if(i + 1 < n && (commands[i + 1] % 10 == idx_1 || commands[i + 1] / 10 == idx_1)){
          abc[idx_1]++;
          abc[idx_2]--;
          history[i] = mark.charAt(idx_1);
        } else {
          abc[idx_1]--;
          abc[idx_2]++;
          history[i] = mark.charAt(idx_2);
        }
      } else {
        if(abc[idx_1] > abc[idx_2]){
          abc[idx_1]--;
          abc[idx_2]++;
          history[i] = mark.charAt(idx_2);
        } else {
          abc[idx_1]++;
          abc[idx_2]--;
          history[i] = mark.charAt(idx_1);
        }
      }
    }

    PrintWriter pw = new PrintWriter(System.out);
    pw.println("Yes");
    for(int i = 0; i < n; i++){
      pw.println(history[i]);
    }
    pw.flush();
  }
}

Measured memory_bytes: 42748
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a;
    x = 1;
    y = 0;
    if(b != 0)
        g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    ll num;
    num = lcm(c, d);
    ll w, x, y, z;
    w = b / c;
    x = (a - 1) / c;
    y = b / d;
    z = (a - 1) / d;
    ll e, f;
    e = b / num;
    f = (a - 1) / num;
    cout << b - a + 1 - w + x - y + z + e - f << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int main(void){
  long long int mod = 1000000007,n,b,sum=0,ans=0;
  scanf("%lld",&n);
  long long int a[n];
  rep(i,0,n){
    scanf("%lld",&a[i]);
    sum += a[i];
    sum = sum%mod;
  }
  rep(i,0,n-1){
    sum -= a[i];
    if(sum<0) sum+=mod;
    ans += a[i]*sum%mod;
    ans = ans%mod;
  }
  printf("%lld",ans);
  return 0;
}

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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

ll p,q,r,n,m,ans;
char b;
string s,t;

int main(){
  ios::sync_with_stdio(false);
  cin>>p>>q;
  int x=q;
  for(int i=1;i<p;i++){
    q*=(x-1);
  }
  dump(q);
}

Measured memory_bytes: 256
n=int(input())
A=[int(input()) for i in range(n)]
b=list(set(A))
if A.count(max(A))>1:
    ans=max(b)
    for i in range(n):
        print(ans)
    exit()

mi,maxi=b[-2:]
for a in A:
    if a==maxi:
        print(mi)
    else:
        print(maxi)

Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.second != b.second)
    {
        return a.second < b.second;
    }
    else
    {
        return a.first > b.first;
    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int> > v;
    for(int i = 0;i < n;i++)
    {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end(),comp);
    long long int sum = 0;
    priority_queue<pair<int,int> > pq;
    int j = 0;
    for(int i = 1;i <= m;i++)
    {
        while(j < n && v[j].second <= i)
        {
            pq.push(v[j]);
            j++;
        }
        if(!pq.empty())
        {
            sum += pq.top().first;
            pq.pop();
        }
    }
    cout << sum;
    
    return 0;
}

Measured memory_bytes: 2548
n = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)
m = gets.chomp.to_i
arr = Array.new
sum = t.inject(:+)
m.times do 
	arr = gets.chomp.split(" ").map(&:to_i)
	puts sum - t[arr[0] - 1] + arr[1]
end



Measured memory_bytes: 1788
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,a[200010];
long long ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]>=i)
		{
			puts("-1");
			return 0;
		}
	}
	int lst=1;
	for (int k=2;k<=n+1;k++)
	{
		if (a[k])
		{
			continue;
		}
		for (int i=k-1;i>=lst;i--)
		{
			if (a[i]>i-lst)
			{
				puts("-1");
				return 0;
			}
			int j=i;
			ans+=1LL*a[i];
			while (j>=lst && a[i]-a[j]==i-j)
			{
				j--;
			}
			if (a[i]-a[j]>i-j)
			{
				puts("-1");
				return 0;
			}
			i=j+1;
		}
		lst=k;
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024