akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String args []) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char [][] list = new char[H+2][W+2];
        for(int i=0;i<H+2;i++)for(int j=0;j<W+2;j++)list[i][j]='#';
        for(int i=1;i<=H;i++){
            String a = sc.next();
            for(int j=0;j<W;j++) list[i][j+1]=a.charAt(j);
        }
        for(int i=0;i<H+2;i++){
            for(int j=0;j<W+2;j++) System.out.print(list[i][j]);
            System.out.println();
        }
    }
}


Measured memory_bytes: 22464
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	char b;
	cin>>b;
	if(b=='A')
	{
		printf("T")	;	
	}
	if(b=='T')
	{
		printf("A")	;	
	}
	if(b=='C')
	{
		printf("G")	;	
	}
	if(b=='G')
	{
		printf("C")	;	
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int m = n / 2;
	sort(all(a));
	cout << a[m] - a[m - 1] << endl;

	return 0;
}

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

using namespace std;

int count_black(
    const vector<string> &color, int mask_h, int mask_w, int h, int w)
{
    int ans = 0;
    for (int r = 0; r < h; ++r)
    {

        for (int c = 0; c < w; ++c)
        {
            if (((mask_h >> r) & 1) or (mask_w >> c) & 1)
                continue;
            if (color[r][c] == '#')
                ans++;
        }
    }
    return ans;
}

int main(void)
{
    int            h, w, k, ans = 0;
    vector<string> c;

    cin >> h >> w >> k;
    c.resize(h);
    for_each(c.begin(), c.end(), [](string &row) { cin >> row; });

    for (int mask_h = 0; mask_h < (1 << h); ++mask_h)
    {
        for (int mask_w = 0; mask_w < (1 << w); ++mask_w)
        {
            if (auto cur = count_black(c, mask_h, mask_w, h, w); cur == k)
                ans++;
        }
    }

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


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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans="No";
  
  if(L%2==0){
    int cnt=0;
    for(int i=0; i<L; i+=2){
      if(S.at(i)=='h' && S.at(i+1)=='i') cnt++;
    }
    if(cnt==L/2) ans="Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int[] countor = new int[26];

        try {String Str;
            while((Str = reader.readLine()) != null){
                String str = Str.toLowerCase();
                int n = str.length();
                for(int i = 0; i < n; i++){
                    char c = str.charAt(i);
                    int x = c - 'a';
                    if(x < 0 || 25 < x) continue;
                    countor[x]++;
                }
            }

            char a = 'a';

            for(int i = 0; i < 26; i++){
                char al = a;
                System.out.println(al + " : " + countor[i]);
                a++;
            }
        }catch (IOException e){
            System.out.println(e);
        }

    }
}



Measured memory_bytes: 24348
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] nt = line.split(" ");
        int n = Integer.parseInt(nt[0]);
        int t = Integer.parseInt(nt[1]);
        
        String rel = "TLE";
        for (int i = 0; i < n; i++) {
            String keiro = sc.nextLine();
            String[] k = keiro.split(" ");
            if (Integer.parseInt(k[1]) <= t) {
                if (rel.equals("TLE")) {
                    rel = String.valueOf(k[0]);
                } else if (Integer.parseInt(rel) > Integer.parseInt(k[0])) {
                    rel = String.valueOf(k[0]);
                }
            }    
        }
        System.out.println(rel);
        sc.close();
    }
}


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  // たこ焼きを何回焼く必要があるか
  int times = (n + x - 1) / x;
  int ans = times * t;
  cout << ans << endl;

  return 0;
}


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

int main() {
	string abc = "abcdefghijklmnopqrstuvwxyz.?! ";
	string b;
	while (cin >> b) {
		if (b.size() % 2 != 0) {
			cout << "NA" << endl;
		} else {
			string a = "";
			bool hantei = true;
			for (int i = 0; i < b.size(); i++) {
				int p = b[i] - '0';
				int q = b[i+1] - '0';
				if (p <= 0 || p > 6 || q <= 0 || q > 5) {
					hantei = false;
					break;
				}
				a += abc[5*(p-1)+q-1];
				i++;
			}
			if (hantei) {
				cout << a << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <ostream>
#include <cmath>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i] << (i + 1 == v.size() ? "" : ", ");
  }
  os << "]";
  return os;
}

int main() {
  int N, t, x, y, pt = 0, px, py;
  bool ans = true;

  px = py = 0;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> t >> x >> y;
    if ((abs(x - px) + abs(y - py)) % 2 == (t - pt) % 2 && (abs(x - px) + abs(y - py)) <= t - pt) {
      pt = t;
      px = x;
      py = y;
    }
    else {
      ans = false;
    }
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  cin >> N;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

int calc_max_prifit(deque<int> nums, int n) {
  int min_val = nums[0];
  int res = nums[1] - nums[0];

  for (int i = 1; i < n; i++) {
    // 最小値を保持
    if (nums[i] < min_val) {
      min_val = nums[i];
      continue;
    }

    // 最小値との差が最も大きいものを保持
    if (nums[i] - min_val > res) {
      res = nums[i] - min_val;
    }
  }

  return res;
}

int main() {
  int n;
  deque<int> nums;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    nums.push_back(tmp);
  }

  cout << calc_max_prifit(nums, n) << endl;

  return 0;
}


Measured memory_bytes: 4360
import sys
import fractions

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
gcda = a[0]
ans = 0
for i in range(1, n):
    gcda = gcda * a[i] // fractions.gcd(gcda, a[i])
for j in a:
  ans += gcda//j
ans %= (10**9)+7
print(ans)


Measured memory_bytes: 6204
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
	{
		COUT("Possible");
	}
	else
	{
		COUT("Impossible");
	}
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = []
A_portion = []
B = []
judge = 0

if(N < M):
  print('No')
else:
 for i in range(N):
   a = input() + '?'*(M)
   A.append(list(a))
 for i in range(M):
   list_dummy = list('?'*(len(a)))
   A.append(list_dummy)
  
 for i in range(M):
   b = input()
   B.append(list(b))

 for i in range(N):
  for j in range(N):
   for k in range(M):
    A_portion.append(A[j+k][i:i+M])
   #print(j+k,i,i+M-1)
   #print(A_portion)
   if(A_portion == B):
     judge = 1
   A_portion = []
    
 if(judge == 1):
   print('Yes')
 else:
   print('No')

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int
main(void)
{
	char line[256];

	if (fgets(line, sizeof line, stdin)) {
		int len = strlen(line);
		for (int i = 0; i < len; i++) {
			if (islower(line[i])) {
				line[i] = toupper(line[i]);
			}
		}
		
		printf("%s", line);
	}

	return 0;
}

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

int main() {
  vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  map<string, int> res;
  for (int i = 0; i < 7; i++) {
    res[day[i]] = 7 - i;
  }
  string s;
  cin >> s;
  cout << res[s] << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
prob = []
for i in range(N):
    line = input()
    inp = list(map(int, line.split(" ")))
    prob.append(inp)

ans = 0
for i in range(N):
    if ((ans+prob[N-i-1][0]) % prob[N-i-1][1]==0):
        continue
    if (ans + prob[N-i-1][0]) > prob[N-i-1][1]:
        ans += prob[N-i-1][1] - (ans+prob[N-i-1][0]) % prob[N-i-1][1]
    else:
        ans += prob[N-i-1][1] - (ans + prob[N-i-1][0])

print (ans)

Measured memory_bytes: 27380
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n+2);
    a[0]=0;
    vi pre(n+1),suf(n+2);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre[i]=pre[i-1]+abs(a[i]-a[i-1]);
    }
    for(int i=n;i>=1;i--)
        suf[i]=suf[i+1]+abs(a[i+1]-a[i]);
    for(int i=1;i<=n;i++)
        print(pre[i-1]+suf[i+1]+abs(a[i+1]-a[i-1]));
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	long long x, k, d;
	std::cin >> x >> k >> d;
	
	if (x < 0) x = -x;
	
	long long dis = x / d;
	if (dis >= k) {
		x -= k * d;
		std::cout << x << '\n';
	} else {
		x -= dis * d;
		k -= dis;
		if (k & 1) {
			std::cout << std::abs(x - d) << '\n';
		} else {
			std::cout << x << '\n';
		}
	}
	
	return 0;
}

Measured memory_bytes: 3648
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()

  println(abc057c(n))
}

private fun abc057c(n: Long): Int {
  val sqrt = Math.sqrt(n.toDouble()).toInt()

  val pairList = mutableListOf<Pair<Long, Long>>()
  for (i in 1..sqrt) {
    if (n % i == 0L) {
      val pair = Pair(i.toLong(), n / i)
      pairList.add(pair)
    }
  }

  val digitList = mutableListOf<Int>()
  for (pi in pairList) {
    val f = pi.first
    val s = pi.second
    val d = Math.max(f.toString().length, s.toString().length)
    digitList.add(d)
  }
  val ans = digitList.min()!!

  return ans
}


Measured memory_bytes: 31264
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    vector<ll> x(3);
    cin >> n >> x[0] >> x[1] >> x[2];
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];
    ll ans = INF;
    rep(i, 0, pow(4, n))
    {
        ll tmp = i;
        vector<vector<ll>> v(4);
        ll cta = 0;
        rep(j, 0, n)
        {
            auto x = (i >> (2 * j)) % 4;
            v[x].push_back(l[j]);
        }
        if (v[0].empty() || v[1].empty() || v[2].empty())
            continue;
        ll sa = abs(accumulate(all(v[0]), 0) - x[0]) + (v[0].size() - 1) * 10;
        ll sb = abs(accumulate(all(v[1]), 0) - x[1]) + (v[1].size() - 1) * 10;
        ll sc = abs(accumulate(all(v[2]), 0) - x[2]) + (v[2].size() - 1) * 10;
        ans = min(ans, sa + sb + sc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M >> K;
	while (N) {
		ans = 0;
		for (int i = 1; i < K; i++) {
			for (int j = 1; j < K; j++) {
				if (i*(100 + N) / 100 + j*(100 + N) / 100 > K)break;
				if (i*(100 + N) / 100 + j*(100 + N) / 100 == K) {
					ans = max(ans, i*(100 + M) / 100 + j*(100 + M) / 100);
				}
			}
		}
		cout << ans << endl;
		cin >> N >> M >> K;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    string s; cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    const int s = 51;
    int n = h * s;
    int t = s * (h - 1) + (w - 1);

    char c[52][s] = {};
    char *c0 = c[1];
    int r = 0;
    for (int i = 0; i < h; i++) {
        cin >> c[i + 1];
        for (int j = 0; j < w; j++) {
            r += c[i + 1][j] == '#';
        }
    }

    deque<int> q;
    q.push_back(0);

    vector<int> v(n, -1);
    v[0] = 0;

    while (!q.empty()) {
        int k = q.front(); q.pop_front();
        for (int d : { -1, 1, -s, s }) {
            if (c0[k + d] == '.' && v[k + d] < 0) {
                v[k + d] = v[k] + 1;
                if (k + d == t) goto exit;
                q.push_back(k + d);
            }
        }
    }
exit:

    if (v[t] < 0) {
        cout << -1 << endl;
        quick_exit(0);
    }
    cout << h * w - (v[t] + 1) - r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    for(int i=1; i<10; i++)
    {
        for(int j=1; j<10; j++)
        {
            cout<<i<<'x'<<j<<'='<<i*j<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
     
priority_queue<ll> a;
int main() {
  ll n,m;
    cin>>n>>m;
    for(ll i=0;i<n;i++){
      ll x;
      cin>>x;
    a.push(x);
    }
    for(ll i=0;i<m;i++){
      ll now=a.top();
      a.pop();
      now/=2;
      a.push(now);
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
      ll now=a.top();
      a.pop();
      ans+=now;
    }
    cout <<ans;
    // your code goes here
    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>

#include <algorithm>

using namespace std;

#define NMAX 200000
#define MOD 1000000007

typedef long long i64;

static int n, a[NMAX + 10];
static i64 f[NMAX + 10], g[NMAX + 10];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    n = unique(a + 1, a + n + 1) - a - 1;
    f[1] = g[a[1]] = 1;
    for (int i = 2; i <= n; i++) {
        f[i] = (f[i - 1] + g[a[i]]) % MOD;
        g[a[i]] = (g[a[i]] + f[i - 1]) % MOD;
    }
    printf("%lld\n", f[n]);

    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{

  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;

void insert(int);
void delete(NodePointer);
void deleteFirst(void);
void deleteLast(void);
NodePointer findkey(int);
 
NodePointer nil;

int main(){

  int i,in,n;
  char s[20];
  NodePointer x;

  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;

  scanf("%d",&n);

  i=0;
  while(i!=n){

    memset(s,'\0',20);
    scanf("%s",s);
    i++;
      if(strcmp(s,"insert")==0){
	scanf("%d",&in);
	insert(in);
      }
      else if(strcmp(s,"delete")==0){
	scanf("%d",&in);
	x=findkey(in);
	if(x==nil) continue;
	else delete(x);
      }
      else if(strcmp(s,"deleteFirst")==0) {
	deleteFirst();
      }
      else if(strcmp(s,"deleteLast")==0){
	  deleteLast();
	}
  }
	
	
  for(x=nil->next;x->next!=nil;x=x->next) printf("%d ",x->key);
  
 printf("%d\n",x->key);


  return 0;
}

void insert(int x){

  NodePointer new;

  new=malloc(sizeof(struct node));

  new->key=x;
  new->next=nil->next;
  nil->next->prev=new;
  nil->next=new;
  new->prev=nil;

}

void delete(NodePointer delnode){

  delnode->prev->next=delnode->next;
  delnode->next->prev=delnode->prev;
  free(delnode);

}

NodePointer findkey(int x){

  NodePointer tmp;

  tmp=malloc(sizeof(struct node));

  tmp=nil->next;
  while(tmp!=nil && tmp->key!=x){
    tmp=tmp->next;
  }

  return tmp;
}

void deleteFirst(void){
  NodePointer delnode;
  delnode=nil->next;

  if(delnode->next==nil){
    nil->next=nil;
    nil->prev=nil;
    free(delnode);
  }
  else{
    nil->next=delnode->next;
    delnode->next->prev=delnode->prev;
    free(delnode);
  }
  

}

void deleteLast(void){

  NodePointer delnode;

  delnode=nil->prev;
  delnode->prev->next=nil;
  nil->prev=delnode->prev;

  free(delnode);
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H = -1, W = -1;
    cin >> H >> W;

    while (H != 0 && W != 0) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (0 < j && j < W-1 && i != 0 && i != H - 1) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


Measured memory_bytes: 3060
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::collections::{ HashSet, VecDeque};

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let s = scan.chars();
    let mut ret = 0;
    for l in 1..n/2+1 {
        let mut k1 = 0;
        let mut t1 = 1;
        let mut k2 = 0;
        let mut t2 = 1;
        for i in 0..l {
            k1 = (k1 * B1 % M1 + s[i] as i64) % M1;
            t1 = t1 * B1 % M1;
            k2 = (k2 * B2 % M2 + s[i] as i64) % M2;
            t2 = t2 * B2 % M2;
        }
        let mut hset = HashSet::new();
        let mut que = VecDeque::new();
        que.push_back((k1, k2));
        for i in l..n {
            k1 = (((k1 * B1 % M1 + s[i] as i64) % M1 - (s[i - l] as i64 * t1 % M1)) + M1) % M1;
            k2 = (((k2 * B2 % M2 + s[i] as i64) % M2 - (s[i - l] as i64 * t2 % M2)) + M2) % M2;
            que.push_back((k1, k2));
            if que.len() > l {
                let pre = que.pop_front().unwrap();
                hset.insert(pre);
            }
            if hset.contains(&(k1, k2)) {
                ret = l;
            }
        }
    }

    println!("{}", ret);
}

#[allow(dead_code)]
const B1: i64 = 1007;
const B2: i64 = 2009;

#[allow(dead_code)]
const M1: i64 = 1_000_000_007;
const M2: i64 = 1_000_000_009;

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

int main() {
  vector<vector<int>> data(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }

  bool flag = true;

  for (int i = 0; i < 2; i++) {
      if (data.at(0).at(i+1) - data.at(0).at(i) == data.at(1).at(i+1) - data.at(1).at(i) && data.at(1).at(i+1) - data.at(1).at(i) == data.at(2).at(i+1) - data.at(2).at(i)) {
      } else { flag = false; }
  }
  for (int i = 0; i < 2; i++) {
      if (data.at(i+1).at(0) - data.at(i).at(0) == data.at(i+1).at(1) - data.at(i).at(1) && data.at(i+1).at(1) - data.at(i).at(1) == data.at(i+1).at(2) - data.at(i).at(2)) {
      } else { flag = false; }
  }

  
  if (flag){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //ABC 162_a
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n){
		if(n%10==7){
		cout<<"Yes";
		return 0;
		}
		n/=10;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;


int main()
{
    ll n;
    cin >> n;
    ll sol = 0;
    for (int i = 1; i <= n; ++i)
        if (i % 3 && i % 5)
            sol += i;
    cout << sol;
}


Measured memory_bytes: 3636
'use strict'

const pf = (n, res) => {
  for (let i = 2; i <= n; i++) {
    while(n % i === 0) {
      n /= i;
      if (!(i in res)) res[i] = 0
      res[i]++
    }
  }
  return res
}

function main(input) {
  input = Number(input.trim())
  const mod = 1e9 + 7
  let obj = {}
  let ans = 1

  for (let i = 1; i <= input; i++) {
    obj = pf(i, obj)
  }

  Object.keys(obj).forEach(n => {
    ans = ans * (obj[n] + 1) % mod
  })
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

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

  if (x >= 30)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

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

int main()
{
    long long int n , a , b , c , total =0;;
    cin >> n;

    for(a=1;a<=n; a++)
    {
        for(b=1; b<=n; b++)
        {
            for(c=1; c<=n; c++)
                total += gcd(a, gcd(b, c))+ gcd(gcd(a, b), c)+ gcd(gcd(a, c), b);
        }
    }

    cout << total/3;
    return 0;
}


Measured memory_bytes: 3188
N = int(input())
s = ""
while True:
    a = N//26
    b = N%26
    if b == 0:
        b += 26
        a -= 1
    if a == 0:
        s += chr(b+96)
        break
    s += chr(b+96)
    N = a
rslt = s[::-1]
print(rslt)

Measured memory_bytes: 61864
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n, m;
	cin >> n >> m;
	vvi g(n);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		u--; v--;
		
		g[u].push_back(v);
	}
	vi cur;
	int s, t;
	cin >> s >> t;
	s--; t--;
	cur.push_back(s);
	vector<vector<bool> > visited(3, vector<bool>(n, false));
	int res = 0;
	visited[0][s] = true;
	while (!cur.empty())
	{
		for (int i = 0; i < 3; i++)
		{
			vi next;
			for (int j = 0; j < sz(cur); j++)
			{
				int u = cur[j];
				for (int k = 0; k < sz(g[u]); k++)
				{
					int v = g[u][k];
					if (!visited[(i + 1) % 3][v])
					{
						visited[(i + 1) % 3][v] = true;
						next.push_back(v);
					}
				}
			}
			cur = next;
		}
		res++;
		for (int i = 0; i < sz(cur); i++)
			if (cur[i] == t)
			{
				cout << res << endl;
				return 0;
			}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    string s, t;
    cin >> s >> t;
    int k = s.size();
    s += s;
    int n = s.size();
    int m = t.size();
    int Next[n][26];
    rep(i, 26) Next[n-1][i] = k;
    rFor(i, n, 1)rep(j, 26){
        if(s[i] - 'a' == j) Next[i-1][j] = i % k;
        else Next[i-1][j] = Next[i][j];
    }
    lint ans = 0;
    int cur = k - 1;
    rep(i, m){
        int ncur = Next[cur][t[i] - 'a'];
        if(ncur == k){
            printf("-1\n");
            return 0;
        }
        if(ncur <= cur) ncur += k;
        ans += (lint)ncur - (lint)cur;
        cur = ncur % k;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 21120
#https://atcoder.jp/contests/abc113/tasks/abc113_c


n,m=map(int,input().split())
PY=[list(map(int,input().split()))+[0] for i in range(m)]

sortPY=sorted(PY,key=lambda x: x[1])

city={}

for i in range(m):
	p=sortPY[i][0]
	if p in city:
		city[p]+=1
	else:
		city[p]=1
	sortPY[i][2]=city[p]


for i in range(m):
	print(str(PY[i][0]).zfill(6)+str(PY[i][2]).zfill(6))








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

int main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int time = a+b+c+d; 
   int hun = time/60;
   int byou = time%60;
   cout<<hun<<endl;
   cout<<byou<<endl;
   return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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()
int n;
vector<p> w;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a>>b;
        w.push_back(make_pair(b,a));
    }
    sort(ALL(w));
    ll t=0;
    for(int i=0;i<n;i++){
        t+=w[i].second;
        if(t>w[i].first){
            no;
            return 0;
        }
    }
    yes;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;

int Count(int n) {
	int c = 2;
	for (int i = 3; i < n; i += 2) {
		if (n%i == 0)c++;
	}
	return c;
}

int main() {
	int N,C;
	cin >> N;
	C = 0;
	for (int i = 1; i <= N; i += 2) {
		if (Count(i) == 8)C++;
	}
	cout << C << endl;
}

Measured memory_bytes: 256
use std::i64;

macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, _) = scan!(usize, i64);
    let mut num = n;
    let mut v = scan!(usize;;);
    v.sort();
    v.reverse();
    let matches = vec![2usize, 5, 5, 4, 5, 6, 3, 7, 6];
    let mut dp = vec![i64::MIN; n + 1];

    dp[0] = 0;
    for i in 1..dp.len() {
        dp[i] = v
            .iter()
            .map(|&m| {
                if i >= matches[m - 1] {
                    dp[(i - matches[m - 1]) as usize] + 1
                } else {
                    i64::MIN
                }
            })
            .max()
            .unwrap()
    }

    let mut ans = String::new();
    while num != 0 {
        for &m in v.iter() {
            if num >= matches[m - 1] && dp[(num - matches[m - 1]) as usize] == dp[num] - 1 {
                ans.push_str(&m.to_string());
                num -= matches[m - 1];
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def selection_sort(A,N):
    cnt = 0
    for i in range(N):
        minj = i
        for j in range(i+1,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i],A[minj] = A[minj],A[i]
            cnt += 1
    return A, cnt

N = int(input())
A = list(map(int, input().split()))

A,cnt = selection_sort(A,N)
print(*A)
print(cnt)


Measured memory_bytes: 5604
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int A, B;
  while (cin >> A >> B) {
    bool res = false;
    for (int C = 1; C <= 3; C++) {
      int p = A * B * C;
      if (p % 2 == 1) {
        res = true;
        break;
      }
    }
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

int n, i, l, r;
int a[maxN];
ll ans;

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    
    l = r = n + 1;
    for (i = n; i >= 1; i--) {
        if (i < l) {
            ans += 1LL * a[i];
            l = i - a[i];
            r = i;

            if (l < 1) {
                printf("-1");
                return 0;
            }
        } else {
            if (a[i] == i - l) continue;
            if (a[i] < i - l) {
                printf("-1");
                return 0;
            }

            l = i - a[i];
            r = i;
            if (l >= 1) {
                ans += 1LL * a[i];
            } else {
                printf("-1");
                return 0;
            }
        }
    }

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int tot = 0;
    for (int i = 0; i < N; i++) {
      int x = scanner.nextInt();
      tot += Math.min(x, Math.abs(K - x)) * 2;
    }
    System.out.println(tot);
  }
}


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

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

using namespace std;
const long long INF = 1LL << 61;
const int MOD = 2019;

int main() {
	int n; cin >> n;
	vector<int> p(n);
	rep(i, n)cin >> p[i];
	int ans = 0;
	for (int i = 1; i < n - 1; ++i) {
		int max = *max_element(p.begin() + i - 1, p.begin() + i + 2);
		int min = *min_element(p.begin() + i - 1, p.begin() + i + 2);
		//cout << max << " " << min << endl;
		if (p[i] != max && p[i] != min)++ans;
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long maxIdx = n - 1;
        long maxVal = k - a[n - 1] + a[0];
        for (int i = 0; i < n - 1; i++) {
            long val = a[i + 1] - a[i];
            if (val > maxVal) {
                maxIdx = i;
                maxVal = val;
            }
        }
        System.out.println(k - maxVal);
    }

}


Measured memory_bytes: 79896
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    string s;cin>>s;
    string t = "hi";
    int n = s.size();
    rep(i,n){
        if(s.substr(i,2) != t){cout<<"No"<<endl;return 0;}
      //cout<<s.substr(i,2)<<endl;
        i++;
    }
    cout<<"Yes"<<endl;
}



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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;

int MOD = 1000000007;

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

    if(n == 1){
        cout << "Hello World" << endl;
        return 0;
    }else{
        int a,b;

        cin >> a >>b;
        cout << a+b;
    }

    // REP(i,n) cin >> a[i]; 
    // REP(i,n) cin >> b[i]; 

    int ans = 0;

    // cout << ans << endl;
    
    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define WRONG -1
#define N 20001

typedef struct{
  int index;
  int area;
}A;


int stack1[N],top1=0,top2=0,count=0;
A stack2[N];

void push1(int x){ stack1[top1++]=x; }
void push2(int g,int area){
  stack2[top2].index=g;
  stack2[top2].area=area;
  top2++;
}
int pop(){ 
  top1--;
  if(top1<0){
    top1++;   
 return WRONG;
  } 
  else 
    return stack1[top1];
}
/*int getarea(){
  int sumarea=0;
  for(int i=0;i<top2;i++){
    sumarea+=stack2[i].area;
    count++;
  }
  return sumarea;
}*/
int main(){
  char s[N];
  int g,i,j,length,area=0,area2,sumarea=0,count=0;
  
  scanf("%s",s);
  length=strlen(s);
  
  for(i=0;i<length;i++){

    if(s[i]=='\\'){
      push1(i);
    }
    else if(s[i]=='/'){
      if((g=pop())==WRONG)continue;
      area=i-g;
      for(j=top2-1;j>=0&&top2>=0;j--){
	if(g<stack2[j].index){
	  area+=stack2[j].area;
	  top2--;
	}
      }
	  push2(g,area);    
      
    }
  }
    
    for( i=0;i<top2;i++){
      sumarea+=stack2[i].area;
      count++;
    }

  

  printf("%d\n%d",sumarea,count);

  for(i=0;i<top2;i++){
    printf(" %d",stack2[i].area);
 }
  printf("\n");
 
    return 0;
  }
  



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); };

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

int Q;

signed main()
{
	cin >> Q;

	int x = 0, mn = 0, S = 0;

	priority_queue<int> small;
	priority_queue<int, vi, greater<int>> big;

	int sz = 0;
	
	rep(_, Q) {
		int t; cin >> t;

		if (t == 1) {
			int a, b; cin >> a >> b;

			S += b;

			if (small.empty()) {
				small.push(a);
				x = a;
			} else {
				if (big.empty()) {
					mn += abs(a - small.top());
				} else {
					if (sz % 2 == 0) {
						unless (small.top() <= a and a <= big.top()) {
							mn += min(abs(a - small.top()), abs(a - big.top()));
						}
					} else {
						mn += abs(a - small.top());
					}
				}

				if (small.top() >= a) {
					small.push(a);
				} else {
					big.push(a);
				}

				if (small.size() >= big.size() + 2) {
					big.push(small.top()); small.pop();
				}

				if (big.size() >= small.size() + 1) {
					small.push(big.top()); big.pop();
				}

				x = small.top();
			}

			sz++;
		} else {
			printf("%lld %lld\n", x, mn + S);
		}
	}
}


Measured memory_bytes: 3828
d = {
    "1": ".,!? ",
    "2": "abc",
    "3": "def",
    "4": "ghi",
    "5": "jkl",
    "6": "mno",
    "7": "pqrs",
    "8": "tuv",
    "9": "wxyz",
    "0": None
}

def solve(input):
    ret = ""
    state = "0"
    cnt = 0
    for c in input:
        if state != c and state is not "0":
            ret += d[state][(cnt-1) % len(d[state])]
            cnt = 0
        elif c is "0":
            cnt = 0
        else:
            cnt += 1
        state = c
    return ret

N = int(raw_input())
for _ in range(N):
    input = raw_input()
    print solve(input)


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  rep(i, in()){
    int c, a, n;
    int maxi = 0;
    c = in();
    a = in();
    n = in();
    rep(can, 1001){
      if (c < can || a < can || n < can) break;
      int nc, na;
      nc = c - can;
      na = a - can;
      rep(cca, 1001){
        if (nc < cca + cca || na < cca) break;
        int nnc = nc - (cca + cca);
        maxi = max(can + cca + nnc / 3, maxi);
      }
    }
    printf("%d\n", maxi);
  }
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=a;i<=b;i++){
        if(i/10000 == (i%10) && ((i%10000)/1000) == ((i%100)/10)){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Author: Kewth

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Type "!!sh" in Vim.

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
   __  __                  __   __
  |  |/  |.-----.--.--.--.|  |_|  |--.
  |     < |  -__|  |  |  ||   _|     |
  |__|\__||_____|________||____|__|__|

 */

#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

static struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

ll __tmp1, __tmp2;
ll exgcd(ll a, ll b, ll &x = __tmp1, ll &y = __tmp2) {
	if(!b) {
		x = 1;
		y = 0;
		return a;
	}
	ll x0, y0;
	ll res = exgcd(b, a % b, x0, y0);
	x = y0;
	y = x0 - a / b * y0;
	return res;
}

ll inv(ll x, ll Mod) {
	ll res;
	if (exgcd(x, Mod, res) != 1)
		return -1;
	return ((res % Mod) + Mod) % Mod;
}

ll ans = 1000000000000000000;
void solve (ll x, ll y) {
	ll iv = inv(x, y);
	if (iv == -1) return;
	ll z = iv * x - 1;
	if (z < 1) z += x * y;
	ans = std::min(ans, z);
}

int main () {
	ll n = read;
	n <<= 1;
	for (ll x = 1; x * x <= n; x ++)
		if (n % x == 0) {
			solve(x, n / x);
			solve(n / x, x);
		}
	printf("%lld\n", ans);
}


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


public class Main {
	public static void main(String[] args) throws IOException{

		boolean[] S = new boolean[14];
		boolean[] H = new boolean[14];
		boolean[] C = new boolean[14];
		boolean[] D = new boolean[14];

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		int num = Integer.parseInt(input);
		int n=0;

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


			String[] rank = br.readLine().split(" ");

			n=Integer.parseInt(rank[1]);

			switch(rank[0]){
			case "S":
				S[n]=true;
				break;
			case "H":
				H[n]=true;
				break;
			case "C":
				C[n]=true;
				break;
			case "D":
				D[n]=true;
				break;
			}


		}

		for(int i=1;i<14;i++){
			if(S[i]==false){
				System.out.println("S "+i);
			}
		}
		for(int i=1;i<14;i++){
			if(H[i]==false){
				System.out.println("H "+i);
			}
		}
		for(int i=1;i<14;i++){
			if(C[i]==false){
				System.out.println("C "+i);
			}
		}
		for(int i=1;i<14;i++){
			if(D[i]==false){
				System.out.println("D "+i);
			}
		}
	}

}

Measured memory_bytes: 24268