akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

#define MAX_N 10000

int par[MAX_N]; // ???
int rank[MAX_N]; // ??¨?????±???
// ?????????
void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    rank[i] = 0;
  }
}
// ??¨??????????±???????
int find(int x){
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
// x??¨y????±??????????????????????
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  // ??¨??????????????????????????£??¨??????????????????
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}
// x??¨y?????????????????????true
bool same(int x,int y){
  return find(x) == find(y);
}

int main(){

  int n,q;
  cin >> n >> q;
  init(n);
  bool t[MAX_N];

  for(int i = 0;i < q;i++){
    int a,x,y;
    cin >> a >> x >> y;
    if(a == 0){
      unite(x,y);
    }
    else{
      bool u;
      u = same(x,y);
      if(u == true){
	cout << "1" << endl;
      }
      else{
	cout << "0" << endl;
      }
    }
  }

  

}

Measured memory_bytes: 3148
def ABC_88_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    A.sort()
    alice=0
    bob=0

    for i in range(len(A)):
        if i%2==0:
            alice+=A[i]
        else:
            bob+=A[i]

    print(abs(alice-bob))


if __name__ == '__main__':

    ABC_88_B()

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int n;
int ver[105][105]={0};
int main(){
	int K;
	cin>>K;
	if(K<=2){
		cout<<K<<endl;
		rep(i,K){
			rep(j,K)cout<<i+1<<" ";
			cout<<endl;
		}
		
	}else{
		int n=((K+3)/4)*2;
		cout<<n<<endl;
		int ans[1005][1005];
		rep(i,n){
			rep(j,n){
				ans[i][j]=(i+j)%n;
				if(i%2==1)ans[i][j]+=n;
				ans[i][j]++;
				if(ans[i][j]>K)ans[i][j]-=n;
			}
		}
		rep(i,n){
			rep(j,n)cout<<ans[i][j]<<" ";
			cout<<endl;
			
		}
	}
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

int get(int i, ll t, vector<long long> S, vector<long long> F) {
  if (t >= S[i])
    return t;

  if (t <= S[i]) {
    return S[i];
  }

  return (max(t, S[i]) - S[i] + F[i] - 1) / F[i] * F[i] + S[i];
}

void solve(long long N, vector<long long> C, vector<long long> S,
           vector<long long> F) {

  REP(i, N) {
    int t = 0;

    FOR(j, i, N - 1) {
      if (t < S[j])
        t = S[j];
      else if (t % F[j] == 0)
        ;
      else {
        t = t + F[j] - t % F[j];
      }
      t += C[j];
    }
    cout << t << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> S((N - 1) - 1 + 1);
  vector<long long> F((N - 1) - 1 + 1);
  vector<long long> C((N - 1) - 1 + 1);
  for (int i = 0; i <= (N - 1) - 1; i++) {
    cin >> C[i];
    cin >> S[i];
    cin >> F[i];
  }
  solve(N, C, S, F);
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations

s = [int(i) for i in list(str(input()))]
t = list(range(len(s) - 1))

ans = 0
for i in range(len(s)): #+を入れる個数
    tmp = list(combinations(t, i))
    for j in range(len(tmp)):
        plus = 0
        #print(s, tmp[j])
        for k in range(len(s)):
            if k - 1 in tmp[j]:
                ans += plus
                #print(plus)
                plus = s[k]
            else:
                plus = 10 * plus + s[k]
        ans += plus
        #print(plus)
print(ans)


Measured memory_bytes: 3064
// Sort I - Bubble Sort
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A
using System;
using System.Linq;

namespace ALDS1_2_A {
	class Program {
		int[] p, rank;
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var info = Input.Split(' ')
							.Select(i => int.Parse(i))
							.ToArray();
			p = new int[info[0]];
			rank = new int[info[0]];
			for(int i = 0; i < info[0]; i++) {
				makeSet(i);
			}
			for(int i = 0; i < info[1]; i++) {
				var query = Input.Split(' ')
								.Select(j => int.Parse(j))
								.ToArray();
				if(query[0] == 0)
					unite(query[1], query[2]);
				else {
					bool flag = isSameSet(query[1], query[2]);
					Output(flag ? "1" : "0");
				}
					
			}
			
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}

		void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}

		void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		int findSet(int x) {
			if(x != p[x])
				p[x] = findSet(p[x]);
			return p[x];
		}

		bool isSameSet(int x, int y) {
			return findSet(x) == findSet(y);
		}

		void link(int x, int y) {
			if(rank[x] > rank[y])
				p[y] = x;
			else {
				p[x] = y;
				if(rank[x] == rank[y])
					rank[y]++;
			}
		}

	}
}

Measured memory_bytes: 9688
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    x = ii()
    print(0 if x else 1)



if __name__ == '__main__':
    main()


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

int main() { 
    string s; 
    cin >> s;
    if(s.size()%2 == 1) {
        cout << "No" << '\n';
        return 0;
    }
    for(int i = 0; i < s.size()-1; i += 2) {
        if(s[i] == 'h' && s[i+1] == 'i') continue;
        else {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+2)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)

Measured memory_bytes: 44996
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var abck = ReadLine().Split().Select(long.Parse).ToArray();
        var a = abck[0];
        var b = abck[1];
        var c = abck[2];
        var k = abck[3];

        var n = (1 - k) / (1 - k - 2 * k * k);
        var A = k % 2 == 0 ? a * n + b * (n - 1) + c * (n - 1) : a * n + b * (n + 1) + c * (n + 1);
        var B = k % 2 == 0 ? a * (n - 1) + b * n + c * (n - 1) : a * (n + 1) + b * n + c * (n + 1);
        WriteLine(A - B > (long)1e18 ? "Unfair" : $"{A - B}");
    }
}

Measured memory_bytes: 13396
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;


int main(){

  int n; cin >> n;
  vector<int> h(n);
  for (int i=0; i<n; i++) cin >> h[i];
  int count=0;
  int ans=0;

  for (int i=1; i<n; i++){
    if (h[i-1]>=h[i]) {
      count++;
    } else {
      ans = max(count,ans);
      count=0;
    }
  }

  ans = max(count, ans);

  cout << ans;
 
  return 0;
}


Measured memory_bytes: 640
import functools
MOD=10**9+7

def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)

def gcd(nums):
  return functools.reduce(euclid, nums)

n=int(input())
t=[]
for i in range(n):
    a,b=map(int,input().split())
    t.append((a,b))
z=0
y={}
for i in range(n):
    if t[i][0]==0 and t[i][1]==0:
        z+=1
    else:
        g=abs(gcd([t[i][0],t[i][1]]))
        if t[i][1]==0:
            a=(1,0)
        elif t[i][1]>0:
            a=(t[i][0]//g , t[i][1]//g)
        else:
            a=(-t[i][0]//g , -t[i][1]//g)
        if a not in y:
            y[a]=1
        else:
            y[a]+=1

cnt=0
x=1
for i in y:
    if (-i[1],i[0]) in y:
        x  *= pow(2,y[(-i[1],i[0])],MOD) + pow(2,y[(i[0],i[1])],MOD)-1
        cnt+= y[(-i[1],i[0])] + y[(i[0],i[1])]

ans = pow(2,n-z-cnt,MOD) *x -1
print((ans+z)%MOD)


Measured memory_bytes: 73824
#include <stdio.h>

int main() {
	int i, j, n, m;
	int k[30], a[31][30];
	int jsoe;
	int count = 0;

	scanf("%d %d", &n, &m);

	for (i = 0; i < 31; i++) {
		for (j = 0; j < 30; j++) {
			a[i][j] = 0;
		}
	}

	for (i = 0; i < n; i++) {
		scanf("%d", &k[i]);
		for (j = 0; j < k[i]; j++) {
			scanf("%d", &jsoe);
			a[i][jsoe - 1] = 1;
		}
	}

	for (j = 0; j < 30; j++) {
		for (i = 0; i < 30; i++) {
			a[30][j] += a[i][j];
		}
		if (a[30][j] == n) count++;
	}
	
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (abs(a - b) <= d && abs(b - c) <= d)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <cctype>
#include <cstdio>
#include <vector>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1001001001;

struct Data {
	int y, x;
	int cost;
	bool nextr;
	Data(int y, int x, int c, bool n) : y(y), x(x), cost(c), nextr(n) {}
	bool operator< (const Data& d)const {
		return cost > d.cost;
	}
};

int w, h;
bool valid(int y, int x) {
	return 0<=y && y<h && 0<=x && x<w;
}

const int dy[] = {-2, -1, -1, 0, 0, 0, 1, 1, 2};
const int drx[] = {-1, -2, -1, -3, -2, -1, -2, -1, -1};
bool visited[2][100][100];
int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, 2) rep(j, 100) rep(k, 100)
			visited[i][j][k] = false;

		char field[100][100];
		rep(i, h) rep(j, w){
			char tmp[100];
			scanf("%s", tmp);
			field[i][j] = tmp[0];
		}

		priority_queue<Data> Q;
		rep(i, w){
			if(field[h-1][i] == 'S'){
				Q.push(Data(h-1, i, 0, false));
				Q.push(Data(h-1, i, 0, true));
			}
		}

		int ans = -1;
		while(!Q.empty()){
			Data d = Q.top();
			Q.pop();
			if(visited[d.nextr][d.x][d.y])
				continue;
			visited[d.nextr][d.x][d.y] = true;
			if(field[d.y][d.x] == 'T'){
				ans = d.cost;
				break;
			}
			rep(i, 9){
				int py = d.y + dy[i];
				int px = d.x + drx[i] * (d.nextr ? 1 : -1);
				if(!valid(py, px))
					continue;

				char c = field[py][px];
				if(c == 'X')
					continue;

				int pc = d.cost + (isdigit(c) ? c-'0' : 0);
				Q.push(Data(py, px, pc, !d.nextr));
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1176
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int bag=sc.nextInt();
        int n=sc.nextInt();
        int dp[][]=new int[n+1][bag+1];
        int sh[]=new int[n+1];
        int xs[]=new int[n+1];
        for(int i=1;i<=n;i++){
            int p=sc.nextInt();
            int q=sc.nextInt();
            if(p<sh[0]&&q>xs[0])
                n--;
            else {
                sh[i] = p;
                xs[i] = q;
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=bag;j++){
                int c=j/sh[i];
                if(j%sh[i]!=0&&i==1)
                    c++;
                if(dp[i][j]==0) {
                    if(i==1)
                        dp[i][j] = c * xs[i];
                    else
                    if(j<=sh[i])
                        dp[i][j]=Math.min(dp[i-1][j],xs[i]);
                    else
                        dp[i][j]=dp[i-1][j];
                }
                if(i>1&&j>=sh[i]) {
                    for (int k = c; k >=1; k/=2) 
                        dp[i][j] = Math.min(dp[i][j], dp[i][j - k * sh[i]] + k * xs[i]);
                }
            }
        }
      System.out.println(dp[n][bag]);
    }
}

Measured memory_bytes: 84612
def GCD(x,y):
    if y == 0:
        return x
    else:
        return GCD(y,x%y)


N = int(input())
if N == 2:
    print(-1)
    exit()
if N == 7:
    ans = [".aabbcc",
           "c..ddee",
           "c..ffgg",
           "hij....",
           "hij....",
           "klm....",
           "klm...."]
    for i in ans:
        print("".join(i))
    exit()
if N == 3:
    print(".aa")
    print("a..")
    print("a..")
    exit()

four = ["aacd",
        "bbcd",
        "efgg",
        "efhh"]
five = ["aabbc",
        "h.iic",
        "hj..d",
        "gj..d",
        "gffee"]
six = ["aacd..",
       "bbcd..",
       "ef..gg",
       "ef..hh",
       "..iikl",
       "..jjkl"]
ans = [list("."*N) for i in range(N)]
a,b,c = [[0,N//5,0],[0,N//5-1,1],[0,N//5-2,2],[2,N//5-1,0],[1,N//5,0]][N%5]
p = 0
for i in range(a):
    for x in range(4):
        for y in range(4):
            ans[p+x][p+y] = four[x][y]
    p += 4

for i in range(b):
    for x in range(5):
        for y in range(5):
            ans[p+x][p+y] = five[x][y]
    p += 5

for i in range(c):
    for x in range(6):
        for y in range(6):
            ans[p+x][p+y] = six[x][y]
    p += 6
for i in ans:
    print("".join(i))

Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int MN = 100100;
const int INF = 1e9+100;
vector<ii> w,x;
ii fp[MN],rp[MN];
vector<int> ra,rb;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int a,b;
		cin >> a >> b;
		w.push_back({a,b});
	}
	ll ma = 0;
	sort(w.begin(),w.end());
	for(int i=0;i<n;i++) {
		fp[i] = w[i];
		if(i > 0) {
			fp[i].first = max(fp[i].first,fp[i-1].first);
			fp[i].second = min(fp[i].second,fp[i-1].second);
		}
	}
	for(int i=n-1;i>=0;i--) {
		rp[i] = w[i];
		if(i < n-1) {
			rp[i].first = max(rp[i].first,rp[i+1].first);
			rp[i].second = min(rp[i].second,rp[i+1].second);
		}
	}
	for(int i=0;i<n;i++) {
		ii bs = {-INF,INF};
		if(i > 0) {
			bs.first = max(bs.first,fp[i-1].first);
			bs.second = min(bs.second,fp[i-1].second);
		}
		if(i < n-1) {
			bs.first = max(bs.first,rp[i+1].first);
			bs.second = min(bs.second,rp[i+1].second);
		}
		ll val = max(bs.second-bs.first+1,0);
		ma = max(ma,val+w[i].second-w[i].first+1);
	}
	ll ok = -INF;
	for(int i=0;i<n;i++) {
		if(!x.empty() && x.back().first == w[i].first) {
			ok = max(ok,ll(w[i].second-w[i].first+1));
			continue;
		}
		while(!x.empty() && x.back().second >= w[i].second) {
			ok = max(ok,ll(x.back().second-x.back().first+1));
			x.pop_back();
		}
		x.push_back(w[i]);
	}
	ra.assign(x.size(),-INF);
	rb.assign(x.size(),INF);
	for(int i=x.size()-1;i>=0;i--) {
		ra[i] = x[i].first;
		rb[i] = x[i].second;
		if(i < x.size()-1) {rb[i] = min(rb[i],rb[i+1]);
			ra[i] = max(ra[i],ra[i+1]);
		}
	}
	ll ba = x[0].first,bb = x[0].second;
	ma = max(ma,max(rb[0]-ra[0]+1,0)+ok);
	ll wh = -INF;
	for(int i=1;i<x.size();i++) {
		ma = max(ma,max(bb-ba+1,0LL)+max(rb[i]-ra[i]+1,0));
		ba = max(ba,ll(x[i].first));
		bb = min(bb,ll(x[i].second));
	}
	cout << ma << '\n';
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,a[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	int ans=1e18;
	for(int i=1;i<=100;i++)
	{
		int res=0;
		for(int j=1;j<=n;j++)
			res=res+(a[j]-i)*(a[j]-i);
		ans=min(ans,res);
	}
	cout<<ans;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005];
ll ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i){
        if(a[i-1]&&a[i])++ans,--a[i];
        ans+=a[i]/2;
        a[i]&=1;
    }
    printf("%lld\n",ans);
   // system("pause");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

const long MOD=1000000007;


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

    vector< vector<int> > vbo(N, vector<int>(2, 0));
    for(int i=0;i<N;i++) cin >> vbo[i][0] >> vbo[i][1];

    int minU = vbo[0][0]+vbo[0][1];
    int maxU = vbo[0][0]+vbo[0][1];
    int minV = vbo[0][0]-vbo[0][1];
    int maxV = vbo[0][0]-vbo[0][1];

    for(int i=1;i<N;i++){
        minU = min(minU, vbo[i][0]+vbo[i][1]);
        maxU = max(maxU, vbo[i][0]+vbo[i][1]);
        minV = min(minV, vbo[i][0]-vbo[i][1]);
        maxV = max(maxV, vbo[i][0]-vbo[i][1]);
        
        //cout << "x : " << vbo[i][0] << ", y : " << vbo[i][1] << endl;
    }
    cout << max(maxV-minV, maxU-minU) << endl;

    return 0;
}

Measured memory_bytes: 14332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FStringsOfEternity {
public:

    void Zalgorithm(vector<int>& A, string& S) {
      A[0] = S.size();
      int i = 1, j = 0;
      while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
      }
    }

    void solve(istream& cin, ostream& cout) {
      string s, t; cin >> s >> t;
      auto ssize = s.size();
      auto tsize = t.size();
      string r = t;
      r.push_back('*');
      auto len = 0;
      while(len < tsize) {
        r += s;
        len += ssize;
      }
      r += s;

      vector<int> a;
      a.resize(r.size());

      Zalgorithm(a, r);
      bool flag1 = false;
      vector<int> vec(ssize);
      vector<int> cnt(ssize);
      rep(i, ssize) {
        int pos = i+tsize+1;
        if (a[pos] == tsize) {
          auto to = (i+tsize)%ssize;
          vec[i] = to;
          cnt[to]++;
          flag1 = true;
        } else {
          vec[i] = -1;
        }
      }

      int ans = 0;
      rep(i, ssize) {
        if (cnt[i] == 0 && vec[i] != -1) {
          int now = i;
          int c = 0;
          while(vec[now] != -1) {
            now = vec[now];
            c++;
          }
          chmax(ans, c);
        }
      }

      if (flag1 && (ans==0)) {
        ans = -1;
      }
      cout << ans << endl;
    }
};

signed main() {
  FStringsOfEternity solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 15048
program main
  implicit none
  integer(8) :: a, b
  read (*, *) a, b

  write (*, "(i0)") a * b / gcd(a, b)
  contains

  function gcd(x, y) result(a)
    integer(8), intent(in) :: x, y
    integer(8) :: a, b, r
    a = max(x, y)
    b = min(x, y)
    do while (b > 0)
      r = mod(a, b)
      a = b
      b = r
    end do
  end function gcd
end program main


Measured memory_bytes: 384
h, w, k = gets.chomp.split(' ').map(&:to_i)

CUT = 1_000_000_007

list = Array.new(h + 1) { Array.new(w + 2) { 0 } }

hash = {
  0 => 1,
  1 => 1,
  2 => 2,
  3 => 3,
  4 => 5,
  5 => 8,
  6 => 13,
  7 => 21,
  8 => 34
}

list[0][1] = 1
1.upto(h).each do |i|
  1.upto(w).each do |j|
    list[i][j] += (list[i - 1][j - 1] * hash.fetch(j - 2, 1) * hash[w - j]) % CUT
    list[i][j] += (list[i - 1][j] * hash[j - 1] * hash[w - j]) % CUT
    list[i][j] += (list[i - 1][j + 1] * hash[j - 1] * hash.fetch(w - (j + 1), 1)) % CUT
  end
end

puts list[h][k] % CUT


Measured memory_bytes: 1916
n=int(input())
h = list(map(int,input().split())) + [0]
th = 0
ans = 0
for i in range(n+1):
    if h[i] > th:
        th = h[i]
    elif h[i] < th:
        ans += th-h[i]
        th = h[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<char> c(2*N+1);
   V<int> a(2*N+1);
   FORE(i, 1, 2*N) {
      cin >> c[i] >> a[i];
   }

   V<int> W_inv(N+1), B_inv(N+1);
   FORE(i, 1, 2*N) {
      if (c[i] == 'W') {
         W_inv[a[i]] = i;
      } else {
         B_inv[a[i]] = i;
      }
   }

   V<V<int>> cntW(2*N+1, V<int>(N+1)), cntB(2*N+1, V<int>(N+1));
   FORE(w, 1, N) {
      FOR(i, 1, 2*N) {
         cntW[i+1][w] = cntW[i][w] + (c[i] == 'W' && a[i] <= w ? 1 : 0);
      }
   }
   FORE(b, 1, N) {
      FOR(i, 1, 2*N) {
         cntB[i+1][b] = cntB[i][b] + (c[i] == 'B' && a[i] <= b ? 1 : 0);
      }
   }

   V<V<int>> dp(N+1, V<int>(N+1));
   FOR(w, 0, N) {
      int p = W_inv[w+1];
      dp[w+1][0] = dp[w][0] + (p-1 - cntW[p][w]);
   }
   FOR(b, 0, N) {
      int p = B_inv[b+1];
      dp[0][b+1] = dp[0][b] + (p-1 - cntB[p][b]);
   }
   FOR(w, 0, N) {
      FOR(b, 0, N) {
         int wp = W_inv[w+1], bp = B_inv[b+1];
         dp[w+1][b+1] = min(dp[w][b+1] + (wp-1 - cntW[wp][w] - cntB[wp][b+1]),
                            dp[w+1][b] + (bp-1 - cntB[bp][b] - cntW[bp][w+1]));
      }
   }
   cout << dp[N][N] << endl;

   return 0;
}


Measured memory_bytes: 159104
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#define F first
#define S second

using namespace std;

typedef long long ll;

ll n;
ll a[55];
ll b[55];
map<pair<ll, ll>, ll> ma;
ll ans;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &a[i], &b[i]);
        for(ll j = 0; j < i; j++)
        {
            if(a[i] > a[j]) ma[make_pair(a[i] - a[j], b[i] - b[j])]++;
            else if(a[i] == a[j]) ma[make_pair(0, abs(b[i] - b[j]))]++;
            else ma[make_pair(a[j] - a[i], b[j] - b[i])]++;
        }
    }
    for(auto i:ma)
    {
        ans = max(ans, i.S);
    }
    printf("%lld\n", n - ans);
    return 0;
}


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

#define    ll     long long int

int ara1[111];
int ara2[111];

int main( )
{
    int n, i, j, k;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara1[i];
    }
    for (i = 1; i <= n; i++) {
        cin >> ara2[i];
    }
    for (i = 2; i <= n; i++) {
        ara1[i] += ara1[i - 1];
    }
    for (i = n - 1; i >= 1; i--) {
        ara2[i] += ara2[i + 1];
    }
    int mx = 0;
    for (i = 1; i <= n; i++) {
        mx = max(mx, ara1[i] + ara2[i]);
    }
    cout << mx << '\n';
    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine().Split()[0]);
            int[] X = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            if (n == 1)
            {
                Console.WriteLine(X.Last() - X.First());
                return;
            }

            var diffs = X.Zip(X.Skip(1), (left, right) => right - left)
                         .Select((diff, i) => new { Diff = diff, LeftIndex = i })
                         .OrderByDescending(x => x.Diff)
                         .Take(n - 1)
                         .OrderBy(x => x.LeftIndex);

            int ans = 0;
            int index = 0;
            foreach (var diff in diffs)
            {
                ans += X[diff.LeftIndex] - X[index];
                index = diff.LeftIndex + 1;
            }

            ans += X.Last() - X[index];
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 33116
import java.util.Scanner;

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

     int max = Integer.MIN_VALUE;
     int min = Integer.MAX_VALUE;
     Scanner in = new Scanner(System.in);
     int N = in.nextInt();
     while(in.hasNext()){
         int cur = in.nextInt();
         max = Math.max(max,cur);
         min = Math.min(min,cur);
     }
        System.out.println(max-min);
    }
}

Measured memory_bytes: 21716
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    if N == 3:
        print(2)
        print(1,3)
        print(2,3)
    elif N == 4:
        print(4)
        print(1,2)
        print(1,3)
        print(4,2)
        print(4,3)
    else:
        if N%2 == 0:
            print(N*2)
            for i in range(N//2-1):
                print(i+1,i+2)
                print(i+1,N-i-1)
                print(N-i,i+2)
                print(N-i,N-i-1)
            for i in range(2):
                print(N//2+i,1)
                print(N//2+i,N)
        else:
            print(N*2-2)
            for i in range(N//2-1):
                print(i+1,i+2)
                print(i+1,N-i-2)
                print(N-i-1,i+2)
                print(N-i-1,N-i-2)
            print(N//2,N)
            print(N//2+1,N)
            print(N,1)
            print(N,N-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

bool maze[1005][1005];
int dp[1005][1005];
const int mod = 1000000007;


int main() {
	int h, w;
	char ch;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> ch;
			if (ch == '.') {
				maze[i][j] = true;
			}
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!maze[i][j]) { continue; }
			if (i  > 0) {
				if (maze[i - 1]) {
					dp[i][j] += dp[i - 1][j];
					dp[i][j] %= mod;
				}
			}
			if (j  > 0) {
				if (maze[i][j - 1]) {
					dp[i][j] += dp[i][j - 1];
					dp[i][j] %= mod;
				}
			}
		//	cout << dp[i][j] << " " ;
		}//cout << endl;
	}
	cout << dp[h - 1][w - 1]%mod << endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
    int N; cin >> N;
    map<long long, long long> mp;
    mp[0] = 1;
    long long sum = 0;
    long long res = 0;
    for(int i=0;i<N;i++){
        long long a; cin >> a;
        sum += a;
        if(mp.count(sum)){
            res += mp[sum];
            mp[sum]++;
        } else {
            mp[sum] = 1;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] grid = new char[H][W];
        for(int i = 0; i < H; i++) grid[i] = sc.next().toCharArray();
        sc.close();
        DJSet ds = new DJSet(H*W);
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(i+1 < H && grid[i][j] != grid[i+1][j]){
                    ds.union(i*W +j, (i+1)*W +j);
                }
                if(j+1 < W && grid[i][j] != grid[i][j+1]){
                    ds.union(i*W +j, i*W +j +1);
                }
            }
        }
        int[] b = new int[H*W];
        int[] w = new int[H*W];
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(grid[i][j] == '.') w[ds.root(i*W +j)]++;
                else b[ds.root(i*W +j)]++;
            }
        }
        long ans = 0;
        for(int i = 0; i < H*W; i++){
            ans += (long)b[i]*w[i];
        }
        System.out.println(ans);
    }

}

class DJSet {
    public int[] upper;

    public DJSet(int n){
        upper = new int[n];
        Arrays.fill(upper, -1);
    }

    /*
     * 要素xが含まれる集合のrootを求める.
     * rootを求める過程で経路圧縮しrootが親になるようにする.
     */
    public int root(int x){
        return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
    }

    /*
     * 要素xと要素yが同じ集合か判定する.
     */
    public boolean same(int x, int y){
        return root(x) == root(y);
    }

    /*
     * 要素xと要素yを含むそれぞれの集合を合併する.
     * 要素数の多い集合のrootを残し、少ないほうのrootをその下に合併する.
     */
    public boolean union(int x, int y){
        x = root(x);
        y = root(y);
        if(x != y){
            if(upper[y] < upper[x]){
                int t = x;
                x = y;
                y = t;
            }
            upper[x] += upper[y];
            upper[y] = x;
        }
        return x == y;
    }

    /*
     * 集合の数を数える.
     */
    public int count(){
        int c = 0;
        for(int u :upper){
            if(u < 0) c++;
        }
        return c;
    }
}


Measured memory_bytes: 30168
#include <iostream>

int main()
{
  int x, a;
  using namespace std;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> x >> a;
  int result = 10;
  if (x < a)
    result = 0;
  cout << result << endl;

  return 0;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;


	static void Main(string[] args) {

		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());

		//int num = vals[0];

		long res = -1;
		int[] vs = parseAry(Console.ReadLine().Split(cs));
		int n = vs[0];
		int k = vs[1];
		List<long> mem = new List<long>();
		int[] vals = parseAry(Console.ReadLine().Split(cs));



		for ( int g = 1; g <= n; g++ ) {
			mem.Add(vals[g - 1]);
			for ( int i = g; i < n; i++ ) {
				mem.Add(mem[mem.Count - 1] + vals[i]);
			}
		}

		List<long> temp = new List<long>();

		for ( int b = 62; b >= 0; b-- ) {
			temp = new List<long>();
			for ( int i = 0; i < mem.Count; i++ ) {
				if ( ( ( (long)1 << b ) & mem[i] ) != 0 ) {
					temp.Add(mem[i]);
				}
			}
			if ( temp.Count >= k ) {
				mem = temp;
			}
		}

		if ( mem.Count == 0 ) { Console.WriteLine(0); return; }

		res = mem[0];
		for ( int i = 1; i < mem.Count; i++ ) {
			res = res & mem[i];
		}



		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: 30028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max({b*d,a*d,b*c,a*c})<<endl;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

from heapq import *
n=int(input())
v=map(int,input().split())
u=[]
for i in v:
  heappush(u,i)
#print(u)
for j in range(n-1):  
  a1=heappop(u)
  a2=heappop(u)
  ave=(a1+a2)/2
  heappush(u,ave)
print(u[0])
  

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct DisjointSet {
	vector<int>p, rank;
	DisjointSet(int n) {
		rank.assign(n, 0);
		p.resize(n);
		rep(i, 0, n)p[i] = i;
	}
	int findset(int x) {
		if (x != p[x])p[x] = findset(p[x]);
		return p[x];
	}
	int same(int x, int y) {
		return findset(x) == findset(y);
	}
	void unite(int x, int y) {
		if (same(x, y))return;
		x = findset(x), y = findset(y);
		if (rank[x] < rank[y])p[x] = y;
		else {
			p[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	DisjointSet uf(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << uf.same(x, y) << endl;
		else uf.unite(x, y);
	}
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
vector<long long int> hoge;
void saiki(string s){
  long long int huga=stoll(s);
  int i=s.at(s.size()-1)-'0';
  if(huga>3234566667){
    return;
  }
  hoge.push_back(huga);
  if(i==0){
    saiki(s+to_string(0));
    saiki(s+to_string(1));
  }else if(i==9){
    saiki(s+to_string(9));
    saiki(s+to_string(8));
  }else{
    saiki(s+to_string(i-1));
    saiki(s+to_string(i));
    saiki(s+to_string(i+1));
  }
}
int main(void){
  long long int k;
  cin>>k;
  for(int i=1; i<=9; i++){
    saiki(to_string(i));
  }
  sort(hoge.begin(),hoge.end());
  cout<<hoge.at(k-1)<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+20;
int n,m,vis[N],ans;
vector<int> e[N];
void dfs(int u,int cnt)
{
	if(cnt==n)
	{
		ans++;
		return;
	}
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(!vis[v])
		{
			vis[v]=1;
			dfs(v,cnt+1);
			vis[v]=0;
		}
	}
}
int main()
{
	
	while(cin>>n>>m)
	{
		ans=0;
		memset(vis,0,sizeof(vis));
		for(int i=0;i<m;i++)
		{
			int u,v;
			cin>>u>>v;
			e[u].push_back(v);
			e[v].push_back(u);
		}
		vis[1]=1;
		dfs(1,1);
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
			e[i].clear();
	}
	return 0;	
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll over_power = 0;
  ll ans = 0;
  rep(i, n) {
    if (a[i] <= over_power) {
      ans += a[i];
      over_power = b[i];
    } else {
      ans += min(a[i], over_power + b[i]);
      over_power = max((ll)0, over_power + b[i] - a[i]);
    }
  }
  if (over_power){
    ans += min(a[n], over_power);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define rep(i,n) for(long long i = n-1;i>=0;i--)
#define repp(i,m,n) for(long long i = n-1; i >= m; i--)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int S = 100100;
int N,M;
int x,y;
int dp[S];
int h[S];
vector<int> V[S],W;

void solve(int X){
    if(h[X] != 0) return;
    else{
        REP(i,V[X].size()){
            --h[V[X][i]];
            dp[V[X][i]] = max(dp[V[X][i]],dp[X] + 1);
            solve(V[X][i]);
        }
    }
	return;
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i,M){
        cin >> x >> y;
      	--x;--y;
        V[x].pb(y);
        ++h[y];
    }
  	REP(i,N) if(h[i] == 0){W.pb(i);}
    REP(i,W.size()) solve(W[i]);
    int maxv = 0;
    REP(i,N){maxv = max(maxv,dp[i]);}
    cout << maxv << endl;
}

Measured memory_bytes: 11264
N = int(input())


d={}


for a in range(100):
	for b in range(100):
		z=(a+1)**2+(b+1)**2+(a+1)*(b+1)
		for c in range(100):
			gokei=z+(c+a+3+b)*(c+1)
			if gokei in d:
				d[gokei]+=1
			else:
				d[gokei]=1

for i in range(N):
	if i+1 in d:
		print(d[i+1])
	else:
		print(0)





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

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

int main(){
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z <<" "<< x <<" "<< y << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int ary[10];
	for(int i = 0; i < 10; i++) {
		cin >> ary[i];
	}

	sort(ary, ary + 10);

	for(int i = 9; i > 6; i--) {
		cout << ary[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std ; 
#define ll long long
#define flp(i ,a ,b) for(int  i = a ; i<b ; i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define blp(i, a , b) for(int  i = a ; i>=b ; i--)
#define lol 1000000007

 
long long binpow(long long a, long long b, long long m) {
	a %= m;
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}

int dp[3004][3004] ; 


int main()
{	
	string s , t ; 
	cin>>s>>t ;
	for(int i = 0 ; i<=s.length() ; i++)
	{
		for(int j = 0 ; j<=t.length() ; j++)
		{
			if(i==0 || j==0 )
			{
				dp[i][j] = 0 ; 
			}
			else if (s[i-1]==t[j-1])
			{
				dp[i][j] = 1 + dp[i-1][j-1] ; 
			}
			else
			{
				dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
			}

		}
	}

	int i = s.length() ; 
	int j = t.length() ; 
	string ans = "";
	while(i>0 && j>0 )
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1] ;
			i-- ; 
			j-- ; 

		}
		else if (dp[i-1][j]>dp[i][j-1])
		{
			i--;
		}
		else
		{
			j-- ; 
		}

	}
	reverse(ans.begin() , ans.end()); 
	cout<<ans<<"\n";
}

Measured memory_bytes: 35456
import java.util.Scanner;

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

        	String n=scanner.next();
        	int t=0;
               for(int i=0;i<3;i++){
            char str=n.charAt(i);
    		if(str=='R'){
                t=1;
            }}

        	for(int j=0;j<2;j++) {
          	char str1=n.charAt(j);
              char str2=n.charAt(j+1);

              if(str1==str2 && str1=='R'){
              t=t+1;
             }
        	}
        	System.out.println(t);
        	 }
        }

Measured memory_bytes: 35536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  string s,ans;
  cin >> s;
  ans="";
  for (int i=0;i < s.size();i++){
    ans+="x";
  }
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
	Scanner scanner = new Scanner(System.in);

	int n=scanner.nextInt();
	int i=0;
	int m=0;

		
			i=n/500;
			n=n-500*i;
		
			m=n/5;
			
			System.out.println(1000*i+5*m);
	

	 }
}

Measured memory_bytes: 35640
stdin.ReadLine()
|> fun x -> x.Split(' ')
|> Array.map int
|> fun x -> (x.[0], x.[1], x.[2], x.[3], x.[4])
|> fun (a, b, c, x, y) -> (
  (x * a + y * b)
  |> fun std ->
    if a + b <= c * 2
    then std
    else
      [1..(max x y)]
      |> List.fold (
        fun ret i ->
          a * (max (x - i) 0) +
          b * (max (y - i) 0) +
          c * i * 2
          |> min ret
      ) std
)
|> printfn "%d"


Measured memory_bytes: 16212
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int h, w;
    cin >> h >> w;
    h += 2;
    w += 2;

    vector<vector<char>> map(h, vector<char>(w));
    // init
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            map[i][j] = '.';
        }
    }
    // input
    for (int i = 1; i < h - 1; i++)
    {
        for (int j = 1; j < w - 1; j++)
        {
            cin >> map[i][j];
        }
    }

    // debug
    // for (int i = 0; i < h; i++)
    // {
    //     for (int j = 0; j < w; j++)
    //     {
    //         printf("%c", map[i][j]);
    //     }
    //     printf("\n");
    // }

    for (int i = 1; i < h - 1; i++)
    {
        for (int j = 1; j < w - 1; j++)
        {
            if (map[i][j] == '#')
            {
                if (!(map[i - 1][j] == '#' || map[i][j + 1] == '#' || map[i + 1][j] == '#' || map[i][j - 1] == '#'))
                {
                    cout << "No" << endl;
                    return (0);
                }
            }
        }
    }
    cout << "Yes" << endl;
    return (0);
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int a, b, k; cin >> a >> b >> k;
  if (b-a+1 <= 2*k) {
    loop(i,a,b+1) cout << i << endl;
    return 0;
  }
  
  loop(i,a,a+k) cout << i << endl;
  loop(i,b-k+1,b+1) cout << i << endl;
  return 0;
}


Measured memory_bytes: 3628