akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin >> N;
	vector<int> pos(N);
	for (int i = 0; i < N; i++) {
		int cur;
		cin >> cur;
		pos[cur - 1] = i;
	}
	long long ans = 0;
	multiset<long long> used;
	used.insert(-1);
	used.insert(-1);
	used.insert(N);
	used.insert(N);
	for (int i = N - 1; i >= 0; i--) {
		used.insert(pos[i]);
		auto it = used.find(pos[i]);
		it--;
		long long a = *it;
		it--;
		long long b = *it;
		it++;
		it++;
		it++;
		long long x = *it;
		it++;
		long long y = *it;
		ans += (i + 1) * ((a - b) * (x - pos[i]) + (y - x) * (pos[i] - a));
	} 
	cout << ans;
	return 0;
} 

Measured memory_bytes: 5376
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	c := mergeSort(&a, 0, len(a))
	fmt.Println(c)
}


func mergeSort(a *[]int, l, r int) int {
	c := 0
	if l + 1 < r {
		m := (l + r) / 2
		c += mergeSort(a, l, m)
		c += mergeSort(a, m, r)
		c += merge(a, l, m, r)
	}
	return c
}

func merge(a *[]int, l, m, r int) int {
	// 番兵
	ll := append([]int{}, (*a)[l:m]...)
	ll = append(ll, 1 << 30)
	rr := append([]int{}, (*a)[m:r]...)
	rr = append(rr, 1 << 30)

	i, j, c := 0, 0, 0
	for k := l; k < r; k++ {
		if ll[i] <= rr[j] {
			(*a)[k] = ll[i]
			i++
		} else {
			(*a)[k] = rr[j]
			j++
			c += (m - l) - i
		}
	}
	return c
}



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

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



    for (int i = n / 1.08; i * 1.08<= n + 1; i++)
        if ((int)(i * 1.08) == n) {
            cout << i;
            return(0);
        }
    cout << ":(";
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;


int main(){
    // input
    int N, A, B; cin >> N >> A >> B;

    // compute
    int ans;
    int a = A * N;
    int b = B;
    if (a < b){
        ans = a;
    }
    else ans = b;

    // output
    cout << ans << endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[200002], sum = 0;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll result = 1e10;
  ll sunuke = 0;
  rep(i, n - 1) {
    sunuke += a[i];
    ll arai = sum - sunuke;
    result = min(result, abs(sunuke - arai));
  }
  cout << result << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, s;
	cin >> n;
	vector<int> a(n + 1), ans(n + 1, 0), g;
	for (i = 1; i <= n; i++) cin >> a[i];
	for (i = n; i >= 1; i--) {
		s = 0;
		for (j = i + i; j <= n; j += i) s += ans[j];
		if (s % 2 != a[i]) ans[i] = 1;
		else ans[i] = 0;
	}

	for (i = 1; i <= n; i++) {
		if (ans[i] == 1) g.push_back(i);
	}

	cout << g.size() << "\n";
	for (auto p : g) cout << p << " ";
	cout << "\n";

	return 0;
}



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A%3==0||B%3==0||(A+B)%3==0) {
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int sum=0,t;
  for(int i=0;i<2;i++){
    cin>>t;
    sum+=t;
  }
  cout<<6-sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main (void)
{
	int i,j;
	string s;

	cin >> s;
	for (i = 0; i < s.size(); i++){
		for (j = i+1; j < s.size(); j++){
			if(s[i] == s[j]){
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char z;
    long long n,a,b,ans1,ans2;
    char c,d;
    while(cin>>n)
    {
        ans1=0;
        ans2=0;
        while(n--)
        {
           cin>>a>>c>>b;
            if(c=='(')
                ans1+=b;
            else
                ans2+=b;
            if(ans1==ans2)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define BLA 0
#define WHI 1
#define GRA 2
#define INF 2001
#define NIL -1
int cost[100];

int G[100][100],p[100],n,color[100],d[100];


int prim( ){
  int i,vertex,min_cost,count=0;


  for(i=0;i<n;i++){
    d[i] = INF;
    p[i]=NIL;
    color[i]=WHI;
  }
  d[0]=0;
  
 
  while(1){

   
    
    min_cost=INF;
    vertex=NIL;
    
    for(i=0;i<n;i++){
      if(color[i]!=BLA && d[i]< min_cost){
	min_cost=d[i];
	vertex=i;
      }
    }
    if(vertex==-1)break;
    color[vertex]=BLA;

    for(i=0;i<n;i++){
      if(color[i]!=BLA &&G[vertex][i]!=NIL){
       
	if(d[i]>G[vertex][i])
	  {d[i]=G[vertex][i];
	p[i]=vertex;
	color[i]=GRA;
	  } }
    }}


  for(i=0;i<n;i++){
    if(p[i]!=NIL) count+=G[i][p[i]];
  }
  return count;
}


    


int main(){
 
  int i,j;
  scanf("%d",&n);


  for(i=0;i<n;i++){
    for(j=0;j<n;j++){

      scanf("%d",&G[i][j]);
    }
  }

  printf("%d\n",prim());
  


  

  return 0;
}




Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll P[3];
    cin >> P[0] >> P[1] >> P[2];
    sort(P,P+3);
    cout << P[0]+P[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 50
#define NIL -1

struct Node {
	int pare;
	int left;
	int right;
};

struct Node T[MAX];

void preParse(int u)
{
	if (u == NIL) {
		return;
	}
	printf(" %d",u);
	preParse(T[u].left);
	preParse(T[u].right);
}

void inParse(int u)
{
	if (u == NIL) {
		return;
	}
	inParse(T[u].left);
	printf(" %d",u);
	inParse(T[u].right);
}

void postParse(int u)
{
	if (u == NIL) {
		return;
	}
	postParse(T[u].left);
	postParse(T[u].right);
	printf(" %d",u);
}

int main() {
	int i, n, p, l, r, root;
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		T[i].pare = NIL;
	}
	for (i = 0; i < n; i++) {
		scanf("%d %d %d",&p, &l, &r );
		T[p].left = l;
		T[p].right = r;
		
		if (l != NIL) {
			T[l].pare = p;
		}
		if (r != NIL) {
			T[r].pare = p;
		}
	} 
	
	for (i = 0; i < n; i++) {
		if (T[i].pare == NIL) {
			root = i;
		}
	}
	
	printf("Preorder\n");
	preParse(root);
	putchar('\n');
	
	printf("Inorder\n");
	inParse(root);
	putchar('\n');
	
	printf("Postorder\n");
	postParse(root);
	putchar('\n');
    
    return 0;
}


Measured memory_bytes: 1968
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

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

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

	vector<vector<int>>v(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> v[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		int a = v[0][i] - v[0][i + 1];
		if (a != v[1][i] - v[1][i + 1] || a != v[2][i] - v[2][i + 1]) {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 0; i < 2; i++) {
		int a = v[i][0] - v[i + 1][0];
		if (a != v[i][1] - v[i + 1][1] || a != v[i][2] - v[i + 1][2]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    map<string, int> co;
    rep(i, N) {
        string a;
        cin >> a;
        co[a]++;
    }
    int max = -1;
    for(auto a : co) {
        chmax(max, a.second);
    }
    for(auto a : co) {
        if(a.second == max) {
            cout << a.first << endl;
        }
    }
}

Measured memory_bytes: 19212
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
  x, y = s[i][0], s[i][1]
  mnht = float("inf")
  res = 0
  for j in range(M):
    cx, cy = c[j][0], c[j][1]
    if abs(cx - x) + abs(cy - y) < mnht:
      mnht = abs(cx - x) + abs(cy - y)
      res = j + 1
  print(res)

Measured memory_bytes: 39408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int W;
	while (cin >> W, W != -1) {

		int cost = 0;
		if (W > 30) {
			cost += (W - 30) * 160;
			W = 30;
		}
		if (W > 20) {
			cost += (W - 20) * 140;
			W = 20;
		}
		if (W > 10) {
			cost += (W - 10) * 125;
			W = 10;
		}
		cout << 4280 - (cost + 1150) << endl;
	}
	return	0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int[] p = new int[n];
            int max = 0;

            for (int i = 0; i < n; i++)
            {
                p[i] = cin.ReadInt;
                if (max < p[i])
                {
                    max = p[i];
                }
            }

            int result = p.Sum() - max / 2;

            Console.WriteLine(result);
        }

        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: 13396
#include <bits/stdc++.h>
using namespace std;
int n,Ans[1000][1000],cnt[1000];

int main() {
	cin>>n;
	int k=0;
	for(int i=1;i*(i-1)/2<=n;i++)
		if(i*(i-1)/2==n) k=i;
	if(!k) return puts("No"),0;
	printf("Yes\n%d\n",k);
	for(int i=1,id=1;i<=k;i++)
		for(int j=i+1;j<=k;j++) {
			Ans[i][++cnt[i]]=id;
			Ans[j][++cnt[j]]=id;
			id++;
		}
	for(int i=1;i<=k;i++) {
		printf("%d ",k-1);
		for(int j=1;j<k;j++)
			printf("%d ",Ans[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int kmp[500001]={0};
void getKMP(char* str, int len)
{
    int i = 1;
    int j = 0;

    while(str[i]!='\0')
    {
        if(str[i] == str[j]){
            j++;
            kmp[i] = j;
            i++;
        }else if(j==0)
        {
            i++;
        }else{
            j = kmp[j-1];
        }
    }
}

//Union Find
int uf[500001];
int ufSize[500001];
void UFinit(int n)
{
    for(int i=0;i<n;i++)
    {
        uf[i] = i;
        ufSize[i] = 1;
    }
}

int UFroot(int i)
{
    if(uf[i]==i) return i;
    uf[i] = UFroot(uf[i]);
    return uf[i];
}

// 元々根が同じならfalse 違うなら統合してtrue
bool UFunite(int i,int j)
{
    int ri = UFroot(i);
    int rj = UFroot(j);

    if(ri == rj) return false;
    ufSize[ri] += ufSize[rj];
    uf[rj] = ri;
    return true;
}

char s[500001];
char t[500001];
bool match[500001];
size_t sl,tl;

int main(void)
{
    scanf("%s",s);
    scanf("%s",t);
    sl = strlen(s);
    tl = strlen(t);
    getKMP(t,tl);
    // for(int i=0;i<tl;i++) printf("%d\n",kmp[i]);
    {
        int i = 0;
        int j = 0;
        while(i<sl+tl)
        {
            if(s[i%sl]==t[j])
            {
                i++;
                j++;
                if(j==tl)
                {
                    match[i-tl] = true;
                    j = kmp[tl-1];
                }
            }else
            {
                if(j==0){
                    i++;
                    j = 0;
                }else
                {
                    j = kmp[j-1];
                }
                
                
            }
        //    printf("%d %d\n",i,j);
        }
    }

//    for(int i=0;i<sl;i++) printf("%d\n",match[i]);
    UFinit(sl);
    for(int i=0;i<sl;i++)
    {
        if(match[i])
        {
            if(!UFunite(i,(i+tl)%sl))
            {
                printf("-1\n");
                return 0;
            }
        }
    }
    int max;
    max = 0;
    for(int i=0;i<sl;i++) max = ufSize[i] > max ? ufSize[i] : max;
    printf("%d\n", max-1);
    
    return 0;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    cin >> n;
    double ans = 0.0;    
    // x * 1.08 = n 
    ans = (n*100.0) / 108.0;
    //cout << ans << " " << ceil(ans) << endl;
    //cout << floor(ceil(ans)*1.08) << " " << floor(n*1.00) << endl;
    if (floor(ceil(ans)*1.08) != floor(n*1.00)) {
        cout << ":(" << endl;
        return 0;
    }

    cout << ceil(ans) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

ans = n
for k in range(0,n+1):
    count = 0
    for i in range(0,7):
        num6 = k//(6**i)%6
        count += num6

    for i in range(0,6):
        num9 = (n-k)//(9**i)%9
        count += num9

    if count < ans: 
        ans = count

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int curr = 1;
  int ans = 0;
  vector<int> snk;
  for (int i = 0; i < n; i++) {
    if (curr == a[i]) {
      curr++;
      snk.emplace_back(a[i] - 1);
    } else {
      ans++;
    }
  }

  for (int i = 0; i < snk.size(); i++) {
    if (snk[i] != i) {
      ans = -1;
      break;
    }
  }

  if(snk.size() == 0) {
    ans = -1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#define NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );
		int L;cin >> L;
		int A,B,C,D;cin >> A >> B >> C >> D;

		cout << L-max((A+(C-1))/C,(B+(D-1))/D)<<endl;
	}
};
 int main(){
ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    set<int> st;
    REP(i, n) {
        cin >> p[i];
        st.insert(p[i]);
    }

    int ans = 1000;
    for(int i = 0; i < 102; i++) {
        if(st.count(i)) continue;
        if(abs(ans - x) > abs(i - x)) {
            ans = i;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3608
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

void main()
{
    auto N = readln.chomp.to!int;
    uint[] ss;
    foreach (_; 0..N) {
        uint s;
        foreach (i, f; readln.split) if (f == "1") s |= (1<<i);
        ss ~= s;
    }
    long[][] ps;
    foreach (_; 0..N) ps ~= readln.split.to!(long[]);

    long r = long.min;
    foreach (uint j; 1..(1<<10)) {
        long rr;
        foreach (i; 0..N) rr += ps[i][popcnt(j & ss[i])];
        r = max(r, rr);
    }
    writeln(r);
}

Measured memory_bytes: 380
import Data.IntMap hiding (map, empty, insert, member)
import Data.IntSet hiding (map, fromList)
import Data.List hiding (insert)
import Data.Maybe

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let [n, k] = map read $ words l1 :: [Integer]
      a = fromList $ zip [1..] $ map read $ words l2 :: IntMap Int
      (lroute, loop_start) = g a empty [] 1
      loop_count = fromIntegral $ length lroute
      k' = if k > loop_count then (k - loop_start) `mod` (loop_count - loop_start) else k
      start = if k > loop_count then lroute !! (fromInteger loop_start) else 1
  -- print (loop_start, loop_count, k', start)
  print $ f a k' start

f as 0 x = x
f as 1 x = as ! x
f as k x = f as (k - 1) (as ! x)

g as visited route x = if x `member` visited then (reverse route, fromIntegral $ fromJust $ elemIndex x $ reverse route) else g as (insert x visited) (x:route) next
  where
    next = as ! x

Measured memory_bytes: 176864
# -*- coding: utf-8 -*-
import sys
from sys import stdin

strN = stdin.readline().rstrip()
N = int(strN)
strLen = len(strN)

odd_count1 = 0
for i in range(1, strLen + 1):
    if i % 2 == 0:
        if i == strLen:
            print(odd_count1)
            sys.exit(0)
    else:
        if i == strLen:
            t1 = '1'
            t1 += '0' * (i - 1)
            t3 = N - int(t1) + 1
            odd_count1 += t3
            print(odd_count1)
            sys.exit(0)
        else:
            t1 = '1' + '0' * (i - 1)
            t2 = '9' * i
            odd_count1 += (int(t2) - int(t1)+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e3+ 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, dp[N][N];
pii a[N];


main () {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].f; 
		a[i].s = i;
	}

	sort(a + 1, a + 1 + n);
	reverse(a + 1, a + 1 + n);
		
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= i; ++j) {
			dp[j][i - j] = max(dp[j][i - j], dp[j - 1][i - j] + abs(a[i].s - j) * a[i].f); 
			dp[i - j][j] = max(dp[i - j][j], dp[i - j][j - 1] + abs(a[i].s - (n + 1 - j)) * a[i].f);
			ans = max(ans, dp[j][i - j]);
			ans = max(ans, dp[i - j][j]);
		}


	cout << ans << endl;
}


Measured memory_bytes: 26332
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let s = get!(String);
    let mut counts = Vec::new();
    let mut count = 0;
    for c in s.chars() {
        match c {
            'A' | 'T' | 'C' | 'G' => {
                count += 1;
            },
            _ => {
                counts.push(count);
                count = 0;
            }
        }
    }
    counts.push(count);
    println!("{}", counts.into_iter().max().unwrap());
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;

    int fr[n][26] = {0};
    int ok[26] = {0};
    for(int i = 0;i < n;i++){
        string s;   cin >> s;
        for(int j = 0;j < s.size();j++)
            fr[i][s[j] - 'a']++;
        for(int j = 0;j < 26;j++)   ok[j] += (fr[i][j] > 0);
    }


    for(int i = 0;i < 26;i++){
        if(ok[i] != n)  continue;
        int mn = OO;
        for(int j = 0;j < n;j++)    mn = min(mn, fr[j][i]);
        while(mn--) cout << char('a'+ i);
    }
}

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

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s; cin >> s;
    int flag = 0;
    rep(i,s.size()-1){
        if(s[i]=='A'&&s[i+1]=='C')flag=1;
    }


    if(flag==1)yn;
    return 0;
}
 
 


Measured memory_bytes: 256
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    for(i in 0 until n){
        for(j in i + 1 until n){
            ans += d[i] * d[j]
        }
    }
    println(ans)
}


Measured memory_bytes: 37904
#include <iostream>
using namespace std;
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(void){
    int n; cin >> n;
    if (n % findSumOfDigits(n) == 0){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 2e5 + 10;


int main()
{
	LL n;
	cin >> n;
	cout << n + n*n + n*n*n << endl;
}


Measured memory_bytes: 3188
// AOJ 1619 Making Lunch Boxes
// 2018.2.12 bal4u

#include <stdio.h>
#include <string.h>

char b[503][503];
char d[503];
short dp[2][1 << 21];
int a[1 << 24];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bitcount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main()
{
	int n, m, i, j, k, f, cnt, lim, ans;
	int k1, k2;
	char *p;

	while (n = in()) {
		m = in();
		for (i = 0; i < n; i++) fgets(p=b[i], 503, stdin);

		ans = 0;
		if (m > 30) {
			lim = 1 << n;
			for (i = 0; i < lim; i++) {
				cnt = 0;
				memset(d, 0, m);
				for (j = 0; j < n; j++) if ((i >> j) & 1) {
					cnt++;
					p = b[j]; for (k = 0; k < m; k++) d[k] ^= (*p++ & 1);
				}
				f = 1; for (k = 0; k < m; k++) if (d[k]) { f = 0; break; }
				if (f && ans < cnt) ans = cnt;
			}
		} else if (n <= 24) {
			lim = 1 << n;
			a[0] = 0;
			for (j = 0; j < n; j++) {
				f = 0;
				p = b[j], k = m; while (k--) f = (f << 1) | (*p++ & 1);
				a[1 << j] = f;
			}
			for (j = 1; j < lim; j++) {
				f = j & -j;
				if (j > f) a[j] = a[f] ^ a[j-f];
			}
			for (j = 0; j < lim; j++) if (!a[j]) {
				f = bitcount(j);
				if (ans < f) ans = f;
			}
		} else {
			lim = 1 << m;
			memset(dp, -1, lim << 2);
			dp[0][0] = 0;
			for (k1 = 0, k2 = 1, j = 0; j < n; j++, k1 = k2, k2 = !k2) {
				f = 0;
				p = b[j], k = m; while (k--) f = (f << 1) | (*p++ & 1);
				memcpy(dp[k2], dp[k1], lim << 2);
				for (k = 0; k < lim; k++) if (dp[k1][k] >= 0) {
					int x = k ^ f;
					if (dp[k2][x] < dp[k1][k] + 1) dp[k2][x] = dp[k1][k] + 1;
				}
			}
			ans = dp[k1][0];
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 43024
#include <iostream>
  #include <queue>
  #include <iomanip>
using namespace std;
int main()
{
  
    int n;
    cin>>n;
  priority_queue<double, vector<double>, greater<double> >q;
  for (int i = 0; i < n; i++) {
      int x;
      cin>>x;
      /* code */q.push(x);
  }
  while(!(q.size()==1))
  {
      double x=q.top();
      q.pop();
      double y=q.top();
      q.pop();
      double z=(x+y)/2;
      q.push(z);
  }
  cout<<fixed<<setprecision(10)<<q.top()<<endl;
    
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  for(int i=0;i<m;i++){
    cin >> x.at(i);
  }
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  else{
    sort(x.begin(),x.end());
    int sa=x.at(m-1)-x.at(0);
    vector<int> a(m-1);
    for(int i=0;i<m-1;i++){
      a.at(i)=x.at(i+1)-x.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int sum=0;
    for(int i=0;i<n-1;i++){
      sum+=a.at(i);
    }
    cout << sa-sum << endl;
  }
}



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

int main(){
    string S,T;
    cin>>S>>T;
    int N=S.size();
    vector<int>change(26,-1);
    vector<int>change2(26,-1);
    bool flag=true;
    rep(i,N){
        int A=S.at(i)-'a';
        int B=T.at(i)-'a';
        if(change[A]==-1){
            change[A]=B;
        }
        else{
            if(change[A]!=B){
                flag=false;
            }
        }
    }
    rep(i,N){
        int A=S.at(i)-'a';
        int B=T.at(i)-'a';
        if(change2[B]==-1){
            change2[B]=A;
        }
        else{
            if(change2[B]!=A){
                flag=false;
            }
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int ans = 0;
	int now = 100;
	int X = 0;
	
	cin>>X;
	
	for(;now < X; ans++){
		now += now/100;
	}
	
	cout<<ans<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  int x;
  vector<int> v(n);
  for(int i=0; i<m*2; i++) {
    cin >> x;
    v[x-1] += 1;
  }
  
  for(int i=0; i<n; i++) cout << v[i] << endl;
  return 0;
}

Measured memory_bytes: 3612
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program
{


    static void Main(string[] args)
    {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

        //int val = int.Parse(Console.ReadLine());
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //string str = Console.ReadLine();
        //string[] strs = Console.ReadLine().Split(cs);

        //string res="";
        //int res = 0; ;
        //int t = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //int n = int.Parse(Console.ReadLine());
		//string res="";
		int res = 0;
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int k = vals[1];
		string str = Console.ReadLine();
		int[] points=new int[vals[0]];
		int p=0;
		int now = 0;

		int j=0;
		while(j<str.Length) {
			if ( str[j] == '1' ) { j++; p++; } else { break; }
		}
		now = p;

		int flg = 1;
		int pcnt = 0;
		for ( int i = j; i < str.Length; i++ ) {
			flg = 1;
			if ( str[i] == '0' ) { now++; points[pcnt] ++; continue; }
			flg = 0;
			//else
			points[pcnt] += p;
			pcnt++;
			k--;
			p = 0;
			while ( i<str.Length) {
				if ( str[i] == '1' ) { i++; p++;//1kaihatooru
				} else { break; }
				
			}
			i--;
			now += p;
			if ( k < 0 ) { now -= points[( k * ( -1 ) - 1 )]; }
			res = Math.Max(res, now);


		}
		if ( flg == 1 ) {
			points[pcnt] += p;
			pcnt++;
			k--;
			if ( k < 0 ) { now -= points[( k * ( -1 ) - 1 )]; }
		}
		res = Math.Max(res, now);


			Console.WriteLine(res);


        return;
    }

    //　String[]  ----->  int[]
    static int[] parseAry(string[] str)
    {
        int[] nums = new int[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
        return nums;
    }
    //　String[]  ----->  long[]
    static long[] parseAryL(string[] str)
    {
        long[] nums = new long[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
        return nums;
    }

    //文字列を1文字ずつString[]に入れる
    static string[] strAry(String str)
    {
        string[] re = new string[str.Length];
        for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
        return re;
    }

}


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

const int N = 3005;
int n1, n2, dp[N][N];
string s, t;

int solve(int i, int j)
{
    if (i >= n1 || j >= n2)
        return dp[i][j]=0;
    if (dp[i][j] == -1)
    {
        if (s[i] == t[j])
            dp[i][j] = 1 + solve(i + 1, j + 1);
        else
            dp[i][j] = max(solve(i + 1, j), solve(i, j + 1));
    }
    return dp[i][j];
}

int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> s >> t;
    n1 = s.size();
    n2 = t.size();
    solve(0, 0);
    string ans = "";
    int i = 0, j = 0;
    while (i < n1 && j < n2&&dp[i][j]>0)
    {
        // cout<<dp[i][j]<<" ";
        if (dp[i][j] == dp[i + 1][j])
            i++;
        else if (dp[i][j] == dp[i][j + 1])
            j++;
        else if (dp[i][j] == 1 + dp[i + 1][j + 1])
        {
            ans.push_back(s[i]);
            i++;
            j++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 35840
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	string s;cin>>s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<char, char>m;
bool use[27];
int main(){
    string s,t;
    cin>>s>>t;
    int len=s.size();
    for(int i=0;i<len;i++){
        if(m.count(s[i])==0&&!use[t[i]-'a']){
            m[s[i]]=t[i];
            use[t[i]-'a']=1;
        }else if(m.count(s[i])==0&&use[t[i]-'a']){
            puts("No");
            return 0;
        }else if(m[s[i]]!=t[i]){
            puts("No");
            return 0;
        }else{
            continue;
        }
    }
    puts("Yes"); return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
//a<=bとする。gcd(a,b)<=aが成り立つ。
//a=p*qとすると，最大公約数の候補は1,p,q,r。


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int ap = 0, bp = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (S.at(i) == 'a') {
            if (ap+bp < A+B) {
                cout << "Yes" << endl;
                ap++;
            }
            else cout << "No" << endl;
        }
        else if (S.at(i) == 'b') {
            if (ap + bp < A + B && bp < B) {
                cout << "Yes" << endl;
                bp++;
            }
            else cout << "No" << endl;
        }
        else if (S.at(i) == 'c')cout << "No" << endl;
    }
}


Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
l = a[:n]
m = a[n:2*n]
r = list(map(lambda x: -x, a[2*n:]))


import heapq
heapq.heapify(l)
heapq.heapify(r)
lremovesum = [0]
rremovesum = [0]


ruisekil = [sum(l)]
ruisekir = [sum(r)]
for i in range(n):
    ruisekil.append(ruisekil[-1] + m[i])
    ruisekir.append(ruisekir[-1] - m[-i - 1])
    # print(ruisekil,ruisekir)
ruisekir.reverse()

for i in range(n):
    heapq.heappush(l, m[i])
    lremovesum.append(lremovesum[-1] + heapq.heappop(l))
    heapq.heappush(r, -m[-i-1])
    rremovesum.append(rremovesum[-1] + heapq.heappop(r))
rremovesum.reverse()


# print(l,r)
# print(r)
# print(lremovesum)
# print(rremovesum)



ans = -10**20
for i in range(n + 1):
    # print(i, ruisekil[i],-lremovesum[i],+ruisekir[i],-rremovesum[i],ruisekil[i]-lremovesum[i]+ruisekir[i]-rremovesum[i])
    # print()
    ans = max(ans, ruisekil[i]-lremovesum[i]+ruisekir[i]-rremovesum[i])

print(ans)


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

struct Node {
	int key;
	Node *parent, *left, *right;
};

Node *NIL, *root;

void printPreOrder(Node *u);
void printInOrder(Node *u);
void insertTree(int k);
void isFound(int k);

int main() {
	int i, j, n, k;
	char com[10];
	cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'i') {
			cin >> k;
			insertTree(k);
		} else if(com[0] == 'f'){
			cin >> k;
			isFound(k);
		} else {
			printInOrder(root);
			cout << endl;
			printPreOrder(root);
			cout << endl;
		}
	}
	return 0;
}

void printPreOrder(Node *u) {
	if (u == NIL)return;
	cout << " " << u->key;
	printPreOrder(u->left);
	printPreOrder(u->right);
}

void printInOrder(Node *u) {
	if (u == NIL)return;
	printInOrder(u->left);
	cout << " " << u->key;
	printInOrder(u->right);
}

void insertTree(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = new Node;
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else if (z->key < y->key)y->left = z;
	else y->right = z;
}

void isFound(int k) {
	Node *x = root;
	while (x != NIL) {
		if (x->key == k) {
			cout << "yes\n";
			return;
		}
		else if (x->key < k)x = x->right;
		else x = x->left;
	}
	cout << "no\n";
	return;
	return;
}

Measured memory_bytes: 21764
import java.util.*;
class Main
{
    public static void main(String args[])
    {int n;long W;
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        int v[]=new int[n];
        int w[]=new int[n];
        W=sc.nextLong();int sum=0;
       
        for(int i=0;i<n;i++)
        {
           
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
            sum=sum+v[i];
        }
         long dp[]=new long[sum+1];
         for(int j=0;j<=sum;j++) dp[j]=1000000000000L;
        dp[0]=0;
        for(int i=0;i<n;i++)
        {
            for(int j=sum;j>=v[i];j--)
            {
                
       
                dp[j]=(long)Math.min(dp[j],dp[j-v[i]]+w[i]);
   
            
        }
    }
    for(int k=sum;k>=0;k--)
    {
        if(dp[k]<=W)
        {
        System.out.print(k);
        break;
    }
        
}
}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  priority_queue<ll,vector<ll>,greater<ll>> p,q,r;
  rep(i,a){int num;cin>>num;p.push(num);}
  rep(i,b){int num;cin>>num;q.push(num);}
  rep(i,c){int num;cin>>num;r.push(num);}

  int ok = 1;
  int cnx=0,cny=0;
  ll ans = 0;
  rep(i,a-x)p.pop();
  rep(i,b-y)q.pop();
  while(ok){
    ll pn = p.top(),qn=q.top();
    ll rn = r.top();
    p.pop();
    q.pop();
    r.pop();
    //cout<<pn<<qn<<rn<<endl;
    if(pn<qn&&pn<rn){
      pn = rn;
      p.push(pn);q.push(qn);
    }
    else if(qn<=pn&&qn<rn){
      qn = rn;
      p.push(pn);q.push(qn);
    }
    else {p.push(pn);q.push(qn);}
    if(r.empty())ok = 0;
  }
  rep(i,x){ll pn = p.top();p.pop();ans +=pn;} 
  rep(i,y){ll qn = q.top();q.pop();ans +=qn;} 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3316
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		
		for (int i = 0; i < N; i++) {
			switch (sc.next()) {
			case "AC" :
				AC++;
				break;
			case "WA" :
				WA++;
				break;
			case "TLE" :
				TLE++;
				break;
			case "RE" :
				RE++;
				break;
			}
		}
		
		// 結果の出力
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
		
		sc.close();
	}
}


Measured memory_bytes: 48956