akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
  ll N, L;
  cin >> N >> L;
  ll a = 0;
  for(int i = 1; i <= N; i++) {
    a += L + i - 1;
  }
  ll diff = LLONG_MAX, ans = 0;
  for(int i = 1; i <= N; i++) {
    ll sum = 0;
    for(int j = 1; j <= N; j++) {
      if(i != j) sum += L + j - 1;
    }
    if(abs(a - sum) < diff) {
      diff = abs(a - sum);
      ans = sum;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#define N 100005
using namespace std;

int n, m, l[N * 2], r, d, a[N];
bool v[N];
vector<int> ve[N], vd[N];

void f(int p) {
	int i;
	for (i = 0; i < ve[p].size(); i++) {
		if (!v[ve[p][i]]) v[ve[p][i]] = 1, a[ve[p][i]] = a[p] + vd[p][i], f(ve[p][i]);
		else if (a[p] + vd[p][i] != a[ve[p][i]]) {cout << "No"; exit(0);}
	}
}

int main()
{
	int i;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &l[i], &r, &d);
		ve[l[i]].push_back(r); vd[l[i]].push_back(d);
		ve[r].push_back(l[i]); vd[r].push_back(-d);
	}
	for (i = 0; i < m; i++) if (!v[l[i]]) v[l[i]] = 1, f(l[i]);
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 17280
if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end

s=STDIN.gets.strip
t=STDIN.gets.strip
if s==t
  puts "Yes"
  exit
end

(1..s.size-1).each do |i|
  ss=s[s.size-1]
  ss+=s[0,s.size-1]
  debug ss
  if t==ss
    puts "Yes"
    exit
  end
  s=ss
end
puts "No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define F first
#define S second

int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};

int32_t main(void)
{
    int k; cin>>k;
    queue<int> q;
    flp(i, 1, 10) q.push(i);
    int ans;
    flp(i, 0, k)
    {
        ans=q.front();
        q.pop();
        if(ans%10!=0) q.push(10*ans +(ans%10)-1);
        q.push(ans*10 + (ans%10));
        if(ans%10!=9) q.push(10*ans+(ans%10)+1);
    }

    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"--->"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here

class Solve
{
public:
    void solve(){
        ll i,j,k,n,m,T; //basic variables
        ll l,r,d;
        cin>>n;
        ll ans = 0;
        for(i=1;i<=n;i++){
            cin>>d;
            if(d%2 && i%2) ans++;
        }
        cout<<ans<<NL;

    }
};

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    Solve A;
    ll T=1;
    // cin>>T;

    while(T--){
        A.solve();
    } 
    


    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3636
class Repaint
  def initialize(h, w, g)
    @height = h
    @width = w
    @grid = g
  end

  def find_sharp_4(r, c)
    # 上のセル
    return true if 1 <= r && @grid[r-1][c] == "#"

    # 下のセル
    return true if r < @height-1 && @grid[r+1][c] == "#"

    # 左のセル
    return true if 1 <= c && @grid[r][c-1] == "#"

    # 右のセル
    return true if c < @width-1 && @grid[r][c+1] == "#"

    # ここまで来た＝4近傍どこにも # がなかった
    # puts "r:c = (#{r}, #{c})"
    false
  end

  def judge_all
    0.upto(@height-1) do |r|
      0.upto(@width-1) do |c|
        return false if @grid[r][c] == "#" && !find_sharp_4(r, c)
      end
    end

    # ここまで来た＝全部OKだった
    true
  end

end

h, w = gets.split.map(&:to_i)
# puts "HW: #{h}, #{w}"

grid = []
while (row = gets&.chomp&.chars)
  # puts row
  grid << row
end
# pp grid

rp = Repaint.new(h, w, grid)
puts rp.judge_all ? "Yes" : "No"


Measured memory_bytes: 1916
#include <stdio.h>

int main()
{
    int K, T;
    int l;
    int i, j, tmp;
    int a[100];
    int sum = 0;
    int min = 0;
    
    scanf("%d%d", &K, &T);
    for (l = 0; l < T; l++)
    scanf("%d", &a[l]);

    for (i = 0; i < T; i++)
    {for ( j = i+1; j < T; j++)
    {if (a[i] < a[j])
    { tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }
    }
    }
    sum = K - a[0];
    
    if (T>=3)
        {if ( a[0] <= sum + 1)
            min = 0;
            else min = a[0] - sum -1;}
    
    if (T == 2)
    {if (a[0] == a[1])
        min = 0;
        else min = a[0] - a[1] - 1;}
    
    if (T == 1)
        min = K - 1;
    printf("%d\n", min);
   
    return 0;
        
}


Measured memory_bytes: 128
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{

    public class Program
    {
        const long MOD = 1000000007;
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            string S = cin.ReadLine;
            List<int> rList = new List<int>();
            List<int> gList = new List<int>();
            List<int> bList = new List<int>();
            var R = 0L; var G = 0L; var B = 0L;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R') R++;
                if (S[i] == 'G') G++;
                if (S[i] == 'B') B++;
            }
            var ans = R * G * B;
            for (int i = 0; i < N; i++)
            {
                for (int j = 1; i + 2 * j < N; j++)
                {
                    if (S[i] != S[i + j] && S[i + j] != S[i + 2 * j] && S[i] != S[i + 2 * j])
                    {
                        ans--;
                    }
                }
            }
            WriteLine(ans);
        }


        static long Gcd(long p, long q)
        {
            if (p % q == 0) return q;
            return Gcd(q, p % q);
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }

    }
}

Measured memory_bytes: 27912
import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)+1):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
      loss = 0
  
print(min(ll))

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

int main () {
    int n, count = 0; cin >>n;
    string s; cin >> s;
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 123456789;
struct edge { int to, cap, rev; };
int H, W; string s[109]; bool vis[209]; vector<edge> g[209];
void add_edge(int  v1, int v2, int cost) {
	g[v1].push_back(edge{ v2, cost, (int)g[v2].size() });
	g[v2].push_back(edge{ v1, cost, (int)g[v1].size() - 1 });
}
int find_increase(int pos, int target, int cur_cap) {
	if (pos == target) return cur_cap;
	vis[pos] = true;
	for (edge &e : g[pos]) {
		if (!vis[e.to] && e.cap > 0) {
			int res = find_increase(e.to, target, min(cur_cap, e.cap));
			if (res > 0) {
				e.cap -= res;
				g[e.to][e.rev].cap += res;
				return res;
			}
		}
	}
	return 0;
}
int max_flow(int src, int dst) {
	int ret = 0;
	while (true) {
		fill(vis, vis + H + W + 2, false);
		int res = find_increase(src, dst, inf);
		ret += res;
		if (res == 0) break;
	}
	return ret;
}
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] != '.') {
				add_edge(i, j + H, s[i][j] == 'o' ? 1 : inf);
				if (s[i][j] == 'S') {
					add_edge(H + W, i, inf);
					add_edge(H + W, j + H, inf);
				}
				if (s[i][j] == 'T') {
					add_edge(H + W + 1, i, inf);
					add_edge(H + W + 1, j + H, inf);
				}
			}
		}
	}
	int ret = max_flow(H + W, H + W + 1);
	cout << (ret >= inf ? -1 : ret) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){

	int k[20]={0},i=0,traina=0,trainb=0,sum=0,dec=0,stoped;
	double t=0,x=0;					//x=trainaÌÚ®£AtÍÔ
	
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&k[0],&k[1],&k[2],&k[3],&k[4],&k[5],&k[6],&k[7],&k[8],&k[9],&traina,&trainb) != EOF){
	
		//scanf("%d %d",&traina,&trainb);	//ñÔ¬x
		dec=0;
		sum=0;
		stoped=0;
		
		for(i=0;i<10;i++){				//SÌÌ·³
			sum=k[i]+sum;
		}
		
		dec=traina+trainb;		//l1=v1t;l2=v2t;l=l1+l2;l/(v1+v2)=t;l=v1t+v2t lÍÚ®£AtÍÔÂ©é¶©ñ
	
		t=(double)sum/dec;	//·êá¤Ô
		x=(double)traina*t;	//·êá¢Êu
		
		//printf("sum=%d dec=%d x=%f t=%f\n",sum,dec,x,t);														
		
		
		for(i=0;i<10;i++){														
			if(stoped>=x){
				break;
			}
			stoped=k[i]+stoped;
		}
			
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
/*
 * 2100.cpp
 *
 *  Created on: 2012/07/08
 *      Author: shimomire
 */

#include <iostream>
#include<algorithm>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <map>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REP0(i,n)   REP(i,0,n)
#define REPr(i,b,n) for(int i=n-1;i>=b;i--)
#define REPr0(i,n)   REPr(i,0,n)

#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define ALL(o) (o).begin(),(o).end()
typedef complex<double> P;
bool operator <(const P& a, const P& b) {
	return abs(a) < abs(b);
}

int datanum,n;

int main(){
	cin >> datanum;

	REP0(datac,datanum){
		cin >>n;
		int data[n];
		int sub[n];
		REP0(i,n){
			cin >>data[i];
		}

		REP0(i,n-1){
			sub[i]=data[i+1]-data[i];
		}
		sort(sub,sub+n-1);
		cout<<max(sub[n-2],0)<<" "<<max(-sub[0],0)<<endl;
	}
}

Measured memory_bytes: 1180
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	scanf(" %d", &n);
	rep(i,n) {
		vector<int> l(3);
		rep(j,3) {
			scanf(" %d", &l[j]);
		}
		int maxl = max<int>(l[0], max<int>(l[1], l[2]));
		for(int k = 0; k < 3; k++) {
			if(l[k] == maxl) {
				l[k] = 0;
				break;
			}
		}
		int s = 0;
		rep(k, 3) {
			s += l[k] * l[k];
		}
		puts(maxl * maxl == s ? "YES" : "NO");
	}
	return 0;
}

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

#define ll long long

int main() {
  ll a,b,c,d,s,x;
  cin >> s;
  a=(ll)sqrt(s-1)+1;
  x=a*a-s;
  b=x%a;
  c=1;
  d=a-x/a;
  if(s==1000000000000000000){
    a=1000000000;
    b=1000000000;
    c=0;
    d=1000000000;
  }
  cout << 0 << ' '  << 0 << ' '  << a << ' '  << b << ' '  << c << ' '  << d << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

using namespace std;

// ユークリッドの互除法
// 最大公約数を求める
int CalcGCD(int a, int b)
{
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return CalcGCD(a % b, b);
}

int main() {

	int M, N;
	cin >> N >> M;

	vector<int> vResult(M, 0);
	for (int i = 0; i < N; i++)
	{
		int K;
		cin >> K;
		vector<int> vNum(K, 0);
		for (int j = 0; j < K; j++)
		{
			int tmp = 0;
			cin >> tmp;
			++vResult[tmp-1];
		}
	}

	int result = 0;
	for (int i = 0; i < vResult.size(); i++)
	{
		if (vResult[i] == N)
		{
			++result;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
void ans(ll n){
    cout<<"? "<<n<<endl;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll l=1,r=9;
    rep(i,0,9){
        ans(r+1);
        char t;cin>>t;
        if(t=='N')break;
        l*=10;
        r=l*10-1;
    }
    if(l==1000000000){
        while(l>1){
            ans(l-1);
            char t;cin>>t;
            if(t=='N'){
                cout<<"! "<<l<<endl;
                return 0;
            }
            l/=10;
        }
        cout<<"! "<<1<<endl;
        return 0;
    }
    while(r-l>1){
        ll mid=(l+r)/2;
        ll midd=mid*10+9;
        ans(midd);
        char t;cin>>t;
        if(t=='Y')r=mid;
        else l=mid;
    }
    cout<<"! "<<r<<endl;
}



Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] S = new int [n];
        for (int i = 0; i < n; i++) {
            S[i] = s.nextInt();
        }
        int q = s.nextInt();
        int [] T = new int [q];
        for (int i = 0; i < q; i++) {
            T[i] = s.nextInt();
        }

        int C  = 0;
        for (int i = 0; i < q; i++) {
            boolean found = false;
            for (int j = 0; j < n; j++) {
                if (T[i] == S[j]) {
                    found = true;
                    break;
                }
            }
            if (found) {
                C++;
            }
        }
        System.out.println(C);
    }
}



Measured memory_bytes: 40292
n=int(input())
hoge=list(map(int,input().split()))
hoge.sort(reverse=True)
for i in range(n-1):
  a,b=hoge[-1],hoge[-2]
  hoge.pop(-1)
  hoge.pop(-1)
  hoge.append((a+b)/2)
print(hoge[0])

Measured memory_bytes: 3060
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
SUM = B - A + 1
c = (B // C - (A - 1) // C)
d = (B // D - (A - 1) // D)
cd = (B // lcm(C, D) - (A - 1) // lcm(C, D))
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - (B // lcm(C, D) - (A - 1) // lcm(C, D))))


Measured memory_bytes: 5076
import sys
stdin = sys.stdin
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

s = ns()
cnt = 0
for si, sj in zip(s, reversed(s)):
    if si != sj:
        cnt += 1
print(cnt//2)

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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

struct State{
    int y, x, lr, c;
    State(int y, int x, int lr, int c): y(y), x(x), lr(lr), c(c){}
    bool operator<(const State& right ) const {
        return c > right.c;
    }
};

int main(){
    while(1){
        int W, H;
        cin >> W >> H;
        if(W == 0) break;

        char field[60][30];
        int minDist[60][30][2];
        memset(minDist, -1, sizeof(minDist));
        priority_queue<State> que;

        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin >> field[i][j];
                if(field[i][j] == 'S'){
                    minDist[i][j][0] = 0;
                    minDist[i][j][1] = 0;
                    que.emplace(i, j, 0, 0);
                    que.emplace(i, j, 1, 0);
                }
            }
        }

        int ans = -1;
        while(que.size()){
            State s = que.top(); que.pop();
            if(minDist[s.y][s.x][s.lr] < s.c) continue;
            if(field[s.y][s.x] == 'T'){
                ans = s.c;
                break;
            }
            int mul = s.lr == 0 ? 1 : -1;
            for(int dx=mul;abs(dx)<=3;dx+=mul){
                for(int dy=-3+abs(dx);abs(dy)+abs(dx)<=3;dy++){
                    int ny = s.y + dy, nx = s.x + dx, nlr = (s.lr+1)%2, nc = s.c;;
                    if(ny<0 || H<=ny || nx<0 || W<=nx) continue;
                    if(field[ny][nx] == 'X') continue;
                    if('1' <= field[ny][nx] && field[ny][nx] <= '9'){
                        nc += field[ny][nx] - '0';
                    }
                    if(minDist[ny][nx][nlr] == -1 || minDist[ny][nx][nlr] > nc){
                        minDist[ny][nx][nlr] = nc;
                        que.emplace(ny, nx, nlr, nc);
                    }
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i, N) cin >> V[i];

    ll ans = 0;
    for (int a=0; a<=min(N,K); ++a) {
        for (int b=0; b<=min(N,K)-a; ++b) {
            vector<ll> tmp;
            ll sum = 0;
            rep(i, a) {
                tmp.push_back(V[i]); sum += V[i];
            }
            rep(i, b) {
                tmp.push_back(V[N-1-i]); sum += V[N-1-i];
            }

            sort(tmp.begin(), tmp.end());
            int k = K-(a+b);
            rep(i, min(k, (int)tmp.size())) {
                if (tmp[i] < 0) {
                    sum -= tmp[i];
                }
            }

            ans = max(ans, sum);
        }
    }

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


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

int main() {
	ll h, m, hh, mm, k;
	cin >> h >> m >> hh >> mm >> k;
	int x = (hh - h) * 60 + mm - m;
	if (x < k) cout << 0 << endl;
	else cout << x - k << endl;
}

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

int main(){
	ios::sync_with_stdio(0);
	int n , m;
	string s[100];
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}	
	sort(s , s + n);
	for (int i = 0; i < n; i++){
		cout << s[i];
	}
	cout << "\n";
	return 0;
}


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

using namespace std;
int main(void){
    // Your code here!
    vector<int>d(6);
    for(int i=0;i<6;i++){
        cin>>d[i];
    }
    char ch;
    int N;
    while(cin>>ch){
        if(ch=='N'){
            N=d[0];
            d[0]=d[1];
            d[1]=d[5];
            d[5]=d[4];
            d[4]=N;
        }
        if(ch=='E'){
            N=d[0];
            d[0]=d[3];
            d[3]=d[5];
            d[5]=d[2];
            d[2]=N;
        }
        if(ch=='W'){
            N=d[0];
            d[0]=d[2];
            d[2]=d[5];
            d[5]=d[3];
            d[3]=N;
        }
        if(ch=='S'){
            N=d[0];
            d[0]=d[4];
            d[4]=d[5];
            d[5]=d[1];
            d[1]=N;
        }
    }
    cout<<d[0]<<endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, m;
	cin >> n >> m;
	int x[m];
	REP(i, m) cin >> x[i];
	if (m == 1){
		cout << 0 << endl;
		return 0;
	}
	int d[m-1] = {};

	sort(x, x+m);
	REP(i, m-1){
		d[i] = x[i+1] - x[i];
	}
	
	sort(d, d+(m-1));

	ll ans = 0;

	REP(i, m-n){
		ans += d[i];
	}

	cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
    struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
    int main()
    {
        string A, B, C;
        cin >> A >> B >> C;
        
        string next;
        next.push_back( A[ 0 ] );
        

        while( true )
        {
            if( next == "a" )
            {
                if( A.empty() )
                {
                    cout << "A" << endl;
                    break;
                }
                next = *A.begin();
                A.erase( A.begin() );
            }
            if( next == "b" )
            {
                if( B.empty() )
                {
                    cout << "B" << endl;
                    break;
                }
                next = *B.begin();
                B.erase( B.begin() );
            }
            if( next == "c" )
            {
                if( C.empty() )
                {
                    cout << "C" << endl;
                    break;
                }
                next = *C.begin();
                C.erase( C.begin() );
            }
        }
        return 0;
    }





Measured memory_bytes: 3652
n=int(input())
p=list(map(int,input().split()))

bl=[True]*n
for i in range(n):
    if (i+1)==p[i]:
        bl[i]=False

count=0
for i in range(n-1):
    if bl[i] is False:
        bl[i]=True
        bl[i+1]=True
        count+=1

if bl[n-1] is False:
    count+=1

print(count)

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a;
  vector<int> b;
  int t;
  rep(i,n) {
    rep(j,m) {
      cin >> t;
      a.push_back(t);
    }
  }

  rep(j,m) {
    cin >> t;
    b.push_back(t);
  }

  rep(i,n) {
    int s = 0;
    rep(j,m) {
      s += a[i*m + j] * b[j];
    }
    cout << s << endl;
  }

  return 0;
}



Measured memory_bytes: 3232
# https://atcoder.jp/contests/abc176/tasks
'''
dp[i]...次に行動するプレイヤーが勝つかどうか。石がi個あったときに。

dp[i]=True if (i-a for a \in A で一つでもFalseがあったら) else False
これは配るdpを用いて
dp[i+a] |= 1-dp[i] で書くことができる
'''

N, K = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] * (K + max(A) + 1)
for i in range(K):
    for a in A:
        dp[i + a] |= 1 - dp[i]
print('First' if dp[K] else 'Second')


Measured memory_bytes: 71364
#include <iostream>
#include <queue>
#include <vector>

using namespace std;



typedef long long ll;
ll h,w;
priority_queue< pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> heap;
unsigned long long ans=0;
ll oper[2];
int main()
{
    cin>>w>>h;
    oper[0]=w+1;
    oper[1]=h+1;
    for (int i=0;i<w;i++)
    {
     ll temp;
     cin>>temp;
     heap.push(make_pair(temp,0));
    }
    for (int i=0;i<h;i++)
    {
     ll temp;
     cin>>temp;
     heap.push(make_pair(temp,1));
    }
    while (!heap.empty())
    {
     auto f=heap.top();
     heap.pop();
     ans+=oper[1-f.second]*f.first;
     //cout<<f.first<<' '<<oper[1-f.second]<<' '<<oper[f.second]<<' '<<f.second<<' '<<ans<<endl;
     oper[f.second]--;
    // cout<<f.first<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef struct Node {
  Node *left, *right;
  int data;
} Node;

Node base;

void Node_init() {
  base.right = &base;
  base.left  = &base;
  return;
}

void Node_insert(int x) {
  Node *node = new Node();
  node->data = x;
  node->right = base.right;
  node->left  = &base;
  base.right->left = node;
  base.right = node;
  return;
}

void Node_delete(int x) {
  Node *node = base.right;
  while( node != &base ) {
    if( node->data == x ) {
      node->right->left = node->left;
      node->left->right = node->right;
      delete node;
      return;
    }
    node = node->right;
  }
  return;
}

void Node_deleteFirst(void) {
  Node *node = base.right;
  node->right->left = node->left;
  node->left->right = node->right;
  delete node;
  return;
}

void Node_deleteLast(void) {
  Node *node = base.left;
  node->right->left = node->left;
  node->left->right = node->right;
  delete node;
  return;
}

void Node_print(void) {
  Node *node = base.right;
  while( node != &base ) {
    if( node->right == &base ) {
      printf("%d\n", node->data);
      return;
    }
    else {
      printf("%d ", node->data);
    }
    node = node->right;
  }
  return;
}

int main(void) {

  int N;
  char str[256];
  int x;

  Node_init();
  
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    scanf("%s", str);
    if( strcmp(str,"insert") == 0 ) {
      scanf("%d", &x);
      Node_insert(x);
    }
    else if( strcmp(str, "delete") == 0 ) {
      scanf("%d", &x);
      Node_delete(x);
    }
    else if( strcmp(str, "deleteFirst") == 0 ) {
      Node_deleteFirst();
    }
    else if( strcmp(str, "deleteLast") == 0 ) {
      Node_deleteLast();
    }
    else {
      std::cout << "Error : " << str << std::endl;
      exit(1);
    }
  }

  Node_print();

  return 0;
}

Measured memory_bytes: 32408
n = int(input())
aa = list(map(int, input().split()))

rate = [False] * 9

for a in aa:
    if a < 400:
        rate[0] = 'T'
    elif a < 800:
        rate[1] = 'T'
    elif a < 1200:
        rate[2] = 'T'
    elif a < 1600:
        rate[3] = 'T'
    elif a < 2000:
        rate[4] = 'T'
    elif a < 2400:
        rate[5] = 'T'
    elif a < 2800:
        rate[6] = 'T'
    elif a < 3200:
        rate[7] = 'T'
    else:
        rate[8] += 1

not_free_rate = rate.count('T')
free_rate = rate[8]


if not_free_rate == 0:
    min_num = 1
else:
    min_num = not_free_rate


print(min_num, not_free_rate+free_rate)


Measured memory_bytes: 3064
#include <stdio.h>
#include <limits.h>
#define N 1000000

typedef struct data{
  char c;
  int  v;
}DATA;


DATA L[N],R[N];
int n;
void mergeSort(DATA *, int, int );
void merge(DATA *, int , int , int );
int partition(DATA *, int, int );
void quickSort(DATA *, int ,int );

int main(){

  int i,v;
  DATA Card_A[N],Card_B[N];
  char S[5];
  int stable =1;

  scanf("%d",&n);

  for(i=0; i < n; i++){
    scanf("%s %d", S, &v);
    Card_A[i].c = Card_B[i].c = S[0];
    Card_A[i].v = Card_B[i].v = v;
  }

  mergeSort(Card_A, 0, n);
  quickSort(Card_B, 0, n-1);

  for(i=0;i<n;i++){
    if(Card_A[i].c != Card_B[i].c)stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  
 for(i=0;i<n;i++){
   printf("%c %d\n" ,Card_B[i].c, Card_B[i].v);
  }

  
  
  return 0;
}

void mergeSort( DATA Card_A[], int left, int right){

  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(Card_A,left,mid);
    mergeSort(Card_A,mid,right);
    merge(Card_A, left, mid, right);
  }
  
}

void merge(DATA Card_A[], int left, int mid, int right){
  int n1,n2;
  int i,j,k;

  n1 = mid -left;
  n2 = right -mid;

  for(i=0;i<n1;i++){
    L[i] = Card_A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = Card_A[mid+i];
  }

  L[n1].v = INT_MAX;
  R[n2].v = INT_MAX;

  i=j=0;

  for(k=left; k<right ; k++){
    if(L[i].v <= R[j].v){
      Card_A[k] = L[i];
      i++;
    }else{
      Card_A[k] = R[j];
      j++;
    }
  }  
}

void quickSort(DATA Card_A[], int p, int r){
  int q;
  if(  p < r ){
    q = partition(Card_A,p,r);
    quickSort(Card_A,p,q-1);
    quickSort(Card_A,q+1,r);
  }
}

int partition(DATA Card_A[] , int p ,int r ){
  int i,j;

  DATA t,x;
  x = Card_A[r];
  i = p-1;
  for(j=p; j < r ; j++){
    if(Card_A[j].v <= x.v){
      i++;
      t = Card_A[i];
      Card_A[i] = Card_A[j];
      Card_A[j] = t;

    }
  }
  t = Card_A[i+1];
  Card_A[i+1] = Card_A[r];
  Card_A[r] = t;
  return i+1;
  
}



Measured memory_bytes: 4048
import heapq
inf = float('inf')
def dijkstra(s, n, G):#スタート, 頂点数, グラフ:[[(cost, v)], ...]
    dist = [inf]*n
    edges = []#(sからvまでのコストの候補, v)
    dist[s] = 0
    for e in G[s]:
        heapq.heappush(edges, e)
    while edges:
        cost, v = heapq.heappop(edges)
        if dist[v] != inf:
            continue
        dist[v] = cost
        for c, nv in G[v]:
            if dist[nv] == inf:
                heapq.heappush(edges, (cost + c, nv))
    return dist

n, m, s, t = map(int, input().split())
G1 = [[] for _ in range(n)]
G2 = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    G1[u-1].append((a, v-1))
    G1[v-1].append((a, u-1))
    G2[u-1].append((b, v-1))
    G2[v-1].append((b, u-1))
dist1 = dijkstra(s-1, n, G1)
dist2 = dijkstra(t-1, n, G2)
ans = [0]*n
ans[-1] = dist1[n-1]+dist2[n-1]
for i in range(n-1)[::-1]:
    ans[i] = min(ans[i+1], dist1[i]+dist2[i])
for i in range(n):
    print(10**15-ans[i])


Measured memory_bytes: 129188
n,k,q = (int(i) for i in input().split())  
a = []
for i in range(q):
    a.append(int(input()))

score = [0 for _ in range(n)]

for i in range(len(a)):
    clear_num = a[i]-1
    score[clear_num] += 1


for j in range(n):
    if k + score[j] - q > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8644
<?php

[$N] = fscanf(STDIN, "%d");
$ans = 1;
const MOD = 1000000007;
for($i=0;$i<$N;$i++){
    $ans *= 10;
    $ans %= MOD;
}
$hiku = 1;
$tasu = 1;
for($i=0;$i<$N;$i++){
    $hiku *= 9;
    $tasu *= 8;
    $hiku %= MOD;
    $tasu %= MOD;
}
$ans -= ($hiku + $hiku - $tasu) % MOD;
$ans  = (int)gmp_mod($ans,  MOD);
echo $ans;

Measured memory_bytes: 16396
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:23:50+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-17T21:44:45+09:00
 */

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;

/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 頂点 s をスタートとした探索
    vector<int> dist(N, -1);
    queue<int> que;
    int count = 0;
    for (int v = 0; v < N; ++v) {
        if (dist[v] != -1) continue; // v が探索済みならスルー
        dist[v] = 0, que.push(v);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (auto nv : G[v]) {
                if (dist[nv] == -1) {
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
        }
        ++count;
    }
    if(count!=1){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    rep(i,N){
        if(i==0) continue;
        for(auto x: G[i]){
            if(dist[i]-1 == dist[x]){
                cout << x + 1 << endl;
                break;
            }
        }
    }

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 10320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,c=0;
    string s,t;
    cin>>s>>t;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c<<endl;
}


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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};


int main(){
ll a,b,c,d; cin>>a>>b>>c>>d;
ll A=a*c;
ll B=a*d;
ll C=b*c;
ll D=b*d;
cout<<max(D,max(C,max(A,B)))<<endl;
 
}
  

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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N   = 1e5+5;
const int INF = 0x7fffffff;



int main(){
	int n,t,hold=0;

	cin>>n>>t;
	for(int i=0;i<t;i++){
		int in;
		cin>>in;
		hold+=in;
	}
	if(hold>n)
		cout<<-1<<endl;
	else
		cout<<n-hold<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
from math import atan2, degrees

a, b, x = map(int, input().split())

initial_base_guess = 2 * x / (a * b)
if(initial_base_guess <= a):
	print(degrees(atan2(b, initial_base_guess)))
else:
	y = (2*x)/ (a*a) - b
	print(degrees(atan2(b-y, a))) 

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    unordered_map<char,int> D;
    for(auto c:s){
        D[c]++;
    }
    int res=1;
    for(auto it:D){
        res*=it.second+1;
        res%=mod;
    }
    cout<<(res-1)%mod<<endl;
}

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

using namespace std;
using LL = long long;


/////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////



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

	int N, M, X;
	cin >> N >> M >> X;

	vector<int> c(N);
	vector< vector<int> > A;

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

		vector<int> a(M);
		for(int &x : a)
			cin >> x;

		A.push_back(a);

	}

	LL ans = 1e18;

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

		LL pay = 0;
		vector< LL > sum(M);
		
		for(int j = 0; j < N; ++j) {
			if (i & (1 << j)) {
				pay += c[j];
				for(int k = 0; k < M; ++k) {
					sum[k] += A[j][k];
				}
			}
		}

		bool ok = true;
		
		for(int j = 0; j < M; ++j) {
			if (sum[j] < X) {
				ok = false;
				break;
			}
		}

		if (ok) ans = min(ans, pay);
	}

	if (ans >= 1e18)
		cout << -1 << '\n';
	else cout << ans << '\n';


	return 0;	
}

Measured memory_bytes: 3636
#include<stdio.h>
 
#define A_MIN 1
#define B_MAX 100
 
int main(void)
{
    int a, b;
 
    scanf("%d %d", &a, &b);
 
    if(a < A_MIN || b > B_MAX)
    {
        return -1;
    }
 
    printf("%d %d\n", a*b, 2*(a+b));
 
    return 0;
 
}


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

int n;
int a[100];

void put_array(int* arr, int size){
	for(int i=0; i<size; i++){
		cout << arr[i];
		if(i == size-1) cout << endl;
		else cout << " ";
	}
}

int main(void){
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	
	put_array(a, n);
	for(int i=1; i<n; i++){
		int v = a[i];
		int j = i-1;
		while(j>=0 && a[j]>v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		put_array(a, n);
	}
	
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    long long h[n + 1];

    int good[n + 1];
    int bad[n + 1];
    long long a, b;

    for(long long i = 1; i <= n; i++){
        cin >> h[i];
        good[i] = 0;
        bad[i] = 0;
    }

    for(long long i = 0; i < m; i++){
        cin >> a >> b;
        if(h[a] - h[b] > 0){
            good[a] = 1;
            bad[b] = 1;

        }
        else if(h[a] - h[b] < 0){
            good[b] = 1;
            bad[a] = 1;
        }
        else{
            bad[a] = 1;
            bad[b] = 1;
        }
    }

    long long count = 0;

    for(long long i = 1; i <= n; i++){
        if(good[i] > 0 and bad[i] == 0){
            count++;
        }
        else if(good[i] == 0 and bad[i] == 0){
            count++;
        }
    }

    printf("%lld\n", count);

    return 0;

    
}

Measured memory_bytes: 5312
argN,argM = list(map(int,input().split()))
aryA = list(map(int,input().split()))
aryCB = [] 
for i in range(argM):
  aryBC = list(map(int,input().split()))
  #print(aryBC)
  aryBC.reverse()
  aryCB.append(aryBC[:])
#print(aryCB)
aryCB.sort(reverse=True)
#print(aryCB)

aryD = []
for i in range(len(aryCB)):
  if len(aryD) + aryCB[i][1] < argN:
    aryD += [aryCB[i][0]] * aryCB[i][1]
  elif len(aryD) < argN:
    wk = argN - len(aryD)
    aryD += [aryCB[i][0]] * wk

wkA = aryA[:] + aryD[:]
#print(wkA)
wkA.sort(reverse=True)
print(sum(wkA[:len(aryA)]))




Measured memory_bytes: 28620
from math import ceil
time=[int(input())for i in range(5)]
mod=[i%10 for i in time]
a=124
res=0
for i in range(len(mod)):
    if mod[i] !=0:
        a=min(a,mod[i])
if a==124:
    a=0
for i in range(5):
    if i==mod.index(a):
        res+=time[i]
    else:
        res+=ceil(time[i]/10)*10
print(res)

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

int main() {
    int32_t n;
    cin >> n;

    vector<int32_t> r(n), c(n);
    for (int32_t i = 0; i < n; i++) {
        cin >> r[i] >> c[i];
    }

    vector<int32_t> table(n*n);
    for (int32_t i = 0; i < n; i++) {
        table[i*n+i] = 0;
    }
    for (int32_t i = n-1; i >= 0; i--) {
        for (int32_t j = i+1; j < n; j++) {
            table[i*n+j] = INT32_MAX;
            for (int32_t k = i; k < j; k++) {
                table[i*n+j] = min(table[i*n+j], table[i*n+k] + table[(k+1)*n+j] + r[i] * c[k] * c[j]);
            }
        }
    }

    cout << table[n-1] << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int N, x[100001], y[100001], t[100001];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> t[i] >> x[i] >> y[i];

    vector< pair<int, P> > v(N);
    for(int i=0;i<N;i++)    v[i] = make_pair(t[i], P(x[i], y[i]));

    string ans = "Yes";
    int nt = v[0].first, nx = 0, ny = 0;
    for(int i=0;i<N;i++){
        int d = abs(nx - v[i].second.first) + abs(ny - v[i].second.second);
        if(0 < i)   nt = v[i].first - v[i-1].first;
        if(nt < d){
            ans = "No";
            break;
        }
        if(i == 0 && nt % 2 != d % 2){
            ans = "No";
            break;
        }
        if(0 < i && nt % 2 != d % 2){
            ans = "No";
            break;
        }
        nx = v[i].second.first;
        ny = v[i].second.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
import sys
from operator import itemgetter

read = sys.stdin.read

N, *XL = map(int, read().split())
seq = []

for X, L in zip(*[iter(XL)] * 2):
    seq.append((X - L, X + L))

seq.sort(key=itemgetter(1))
answer = 0
left = -10 ** 10
for i, j in seq:
    if left <= i:
        answer += 1
        left = j

print(answer)

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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> x(N),y(N),h(N);
    rep(i,N) cin >> x[i]>>y[i]>>h[i];
    
    //-----------------------------------
    vector<int> p(N);
    rep(i,N)p[i]=i;
    sort(p.begin(),p.end(),[&](int a,int b){
        return h[a]>h[b];
    });
    int ansh,ansx,ansy;
    rep(cx,101){
        rep(cy,101){
            int defh=h[p[0]] + abs(cx-x[p[0]])+abs(cy-y[p[0]]);
            bool ist=true;
            repd(i,1,N){
                int er=abs(cx-x[p[i]])+abs(cy-y[p[i]]);
                if(h[p[i]]==0 && defh<er)continue;
                if(er+h[p[i]] != defh){
                    ist=false;
                    break;
                }
            }
            if(ist){
                ansh=defh,ansx=cx,ansy=cy;
                goto CL;
            }
        }
        
    }
CL:
    cout<< ansx <<" "<<ansy<<" "<<ansh<<endl;
    return (0);
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var hps = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        for (int i = 1; i < hps.Length; i++)
        {
            while (hps[i - 1] != hps[i])
            {
                if (hps[i - 1] > hps[i])
                {
                    hps[i - 1] += hps[i];
                    hps[i] = hps[i - 1] - hps[i];
                    hps[i - 1] -= hps[i];
                }

                hps[i] %= hps[i - 1];
                if (hps[i] == 0)
                {
                    hps[i] = hps[i - 1];
                }
            }
        }
        Console.WriteLine(hps.Min());
    }
}


Measured memory_bytes: 21728