akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < n; i++) {
		if(a[i] % 2 == 0){
			if((a[i] % 3 == 0) || (a[i] % 5 == 0)){
				continue;
			}
			else{
				cout << "DENIED" << endl;
				return 0;
			}
		}
		else{
			continue;
		}
	}
	cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;

int main() {
	scanf("%lld", &N);
	printf("%lld\n", N * N * N);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
s = input()
y = int(s[:4])
m = int(s[5:7])
d = int(s[-2:])
if y < 2019:
    print("Heisei")
elif y == 2019 and m < 5:
    print("Heisei")
elif y == 2019 and m == 4 and d == 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3064
k = int(input())
lunlun = [1,2,3,4,5,6,7,8,9]
i = 0
while len(lunlun) < k:
  p = lunlun[i]
  if str(p)[-1] == '0':
    lunlun.append(p*10)
    lunlun.append(p*10+1)
  elif str(p)[-1] == '9':
    lunlun.append(p*10+8)
    lunlun.append(p*10+9)
  else:
    lunlun.append(p*10+p%10-1)
    lunlun.append(p*10+p%10)
    lunlun.append(p*10+p%10+1)
  i += 1

print(lunlun[k-1])


Measured memory_bytes: 7144
sub f{my($v,$d,$c)=@_;
	$c[$v]//=$c;
	if($d>$d[$v]&&$d>0){
		$d[$v]=$d;
		f($_,$d-1,$c)for@$v
	}
}
($N,$M)=glob<>;
map{push@$_,$_[--$|]for@_=split/\s/,<>}1..$M;
<>;
for(reverse<>){
	f(split)
}
print$_+0,$/for@c[1..$N]


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s, t;
    cin>> s>> t;

    int c=0;

    for(int i=0; i<s.size(); i++)
    {
        if(s[i]== t[i])
            c++;
    }

cout << c;
nl;
    return 0;
}




Measured memory_bytes: 3596
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(y, x, field, used):

    num_white, num_black = 0, 0
    que = deque()
    que.append((y, x))
    used[y][x] = True

    while len(que) != 0:
        now = que.pop()

        if field[now[0]][now[1]] == '.':
            num_white += 1
        else:
            num_black += 1

        for i in range(4):
            ny = now[0] + dy4[i]
            nx = now[1] + dx4[i]

            if inside(ny, nx, len(field), len(field[0])):
                if field[ny][nx] != field[now[0]][now[1]]:
                    if not used[ny][nx]:
                        que.append((ny, nx))
                        used[ny][nx] = True

    return num_white * num_black


def main():
    H, W = map(int, input().split())
    field = []
    for _ in range(H):
        field.append(input())

    used = [[False] * W for _ in range(H)]

    ans = 0
    for y in range(H):
        for x in range(W):
            if not used[y][x]:
                ans += solve(y, x, field, used)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50780
#include <stdio.h>
int main(void){
  int i=0,a,z;
  char s[200001];
  scanf("%s",s);
  while (s[i]!='A') i++;
  a=i;
  while (s[i]){
    if (s[i]=='Z') z=i;
    i++;
  }
  printf("%d\n",z-a+1);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[5418888];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			if(a[j]>a[i])
			{
				int tmp;
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
	int m=0;
	for(int i=1;i<=k;i++)
		m+=a[i];
	cout<<m<<endl;
	return 0;
 } 

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
    int a,b,c,max;
    cin>>a>>b>>c;
    if(a>=b && a>=c){
        max=a;
        printf("%d",max*10+b+c);
    }
    else if(b>=a && b>=c){
        max=b;
        printf("%d",max*10+a+c);
    }
    else{
        max=c;
        printf("%d",max*10+a+b);
    }
    
    
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n;
int V[55][30];

int main() {
   cin >> n;
   rep (i, n) {
      string s;
      cin >> s;
      rep (j, s.size()) {
         int index = s[j] - 'a';
         V[i][index]++;
      }
   }

   string ans;
   rep (i, 26) {
      int Min = 1e8;
      rep (j, n) {
         Min = min(Min, V[j][i]);
      }
      ans += string(Min, i+'a');
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<< c<<'\n';
}

Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
signed main()
{
    fasino
    ll n;
    cin>>n;
    cout<<n+n*n+n*n*n;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101];
int nm[8][8];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int dfs(int v,int N,int vis[8]) {
	bool avis = true;
	rep(i,N) {
		if (vis[i] == false) {
			avis = false;
		}
	}
	if (avis) {
		return 1;
	}
	int ret = 0;
	rep(i,N) {
		if (nm[v][i] == 0) continue;
		if(vis[i]) continue;
		vis[i] = true;
		ret += dfs(i,N,vis);
		vis[i] = false;
	}
	return ret;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		nm[a-1][b-1]++;
		nm[b-1][a-1]++;
	}
	int vis[8];
	rep(i,n) {
		vis[i] = false;
	}
	vis[0] = true;
	cout << dfs(0,n,vis) << endl;
}




Measured memory_bytes: 256
//BuyingSweets.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();

        int ans=0;
        int sum=x-a;
        //System.out.println(sum);
        for(int i=0; i<x; i++){
            ans=sum-b*i;
            if(ans<b){             
                break;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <cstdio>
//按顺序输出数组元素
void trace(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}
void swap(int &a, int &b) {
	int t = a;
	a = b;
	b = t;
}
void selectionSort(int a[], int n) {
	int minj, swapCount = 0;
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj]) minj = j;
		}
		if (i != minj) {
			swap(a[i], a[minj]);
			swapCount++;
		}
	}
	trace(a, n);
	printf("%d\n", swapCount);
} 

int main() {
    int N;
    scanf("%d", &N);
    int a[N];
    for (int i = 0; i < N; i++) {
    	scanf("%d", &a[i]);
	}
    selectionSort(a, N);
    return 0;
}


Measured memory_bytes: 2740
n,x,y=map(int,input().split())
l=[0 for _ in range(n)]

for i in range (1,n+1):
  for j in range(i+1,n+1):
    if i<=x:
      l[j-i if j<=x else min(x-i+1+(y-j), j-i) if x<j<y else j-i-(y-x)+1]+=1
    elif x<i<y:
       l[min(j-i,i-x+1+abs(j-y))]+=1
    else:
      l[j-i]+=1
    
for m in l[1:]:
  print(m)

    
    
    
    
          

Measured memory_bytes: 9340
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int[] ary = new int[4];
		
		for(int i = 0; i < 6; i++){
			ary[ni() - 1]++;
		}
		
		boolean flg = true;
		for(int i = 0; i < 4; i++){
			if(ary[i] > 2 || ary[i] < 1){
				flg = false;
				break;
			}
		}
		System.out.println(flg ? "YES":"NO");
	}

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22740
import scala.math.abs

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }


  //  val sc = new java.util.Scanner(System.in)
  //  val n = sc.nextInt
  //  val list: Array[Array[Int]] = Array.fill[Int](n, 3)(sc.nextInt)
  //  //  val b = Breaks
  //
  //  var before = Array[Int](0, 0, 0)
  //  val canTravel = list.forall {
  //    target =>
  //      val step = target(0) - before(0)
  //      val distance = abs(target(1) - before(1)) + abs(target(2) - before(2))
  //      before = target
  //      if (step < distance || step % 2 != distance % 2) {
  //        false
  //      } else {
  //        true
  //      }
  //  }


  //  b.breakable {
  //    for (i <- 1 until list.length) {
  //      val step = list(i)(0) - list(i - 1)(0)
  //      val distance = abs(list(i)(1) - list(i - 1)(1)) + abs(list(i)(2) - list(i - 1)(2))
  //
  //      if (step < distance || step % 2 != distance % 2) {
  //        canTravel = false
  //        b.break
  //      }
  //    }
  //  }

  //  println(if (canTravel) "Yes" else "No")

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt

    var (bt, bx, by) = (0, 0, 0)
    var canTravel = true
    for (i <- 1 to n) {
      if (canTravel) {
        val t, x, y = sc.nextInt
        val step = t - bt
        val distance = abs(x - bx) + abs(y - by)
        if (step < distance || step % 2 != distance % 2) {
          canTravel = false
        }
        bt = t
        bx = x
        by = y
      }
    }
    println(if (canTravel) "Yes" else "No")
  }
}


Measured memory_bytes: 90460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

bool	is_prime(int n)
{
	if (n < 2)
		return false;
	int sqrt_n = sqrt(n);
	for (int i = 2; i <= sqrt_n; i++)
		if (n % i == 0)
			return false;
	return true;
}

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	while (!is_prime(x))
		x++;
	cout << x << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	c := nextIntMat(3, 3)
	c00 := c[0][0]
	c01 := c[0][1]
	c02 := c[0][2]
	c10 := c[1][0]
	c11 := c[1][1]
	c12 := c[1][2]
	c20 := c[2][0]
	c21 := c[2][1]
	c22 := c[2][2]

	// Verify as
	if (c10-c00) == (c11-c01) &&
		(c10-c00) == (c12-c02) {
		if (c20-c00) == (c21-c01) &&
			(c20-c00) == (c22-c02) {
			// Verify bs
			if (c01-c00) == (c11-c10) &&
				(c01-c00) == (c21-c20) {
				if (c02-c00) == (c12-c10) &&
					(c02-c00) == (c22-c20) {
					fmt.Println("Yes")
					return
				}
			}
		}
	}

	fmt.Println("No")
	return

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextIntMat(a int, b int) [][]int {
	mat := make([][]int, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]int, b)
		for j := 0; j < b; j++ {
			mat[i][j] = nextInt()
		}
	}
	return mat
}


Measured memory_bytes: 1780
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - KEYENCE String
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 7;
const char T[] = "keyence";

/* typedef */

/* global variables */

char s[128];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  if (n < N) puts("NO");
  else {
    int i0 = 0, i1 = 0;
    while (i0 < N && s[i0] == T[i0]) i0++;
    while (i1 < N && s[n - 1 - i1] == T[N - 1 - i1]) i1++;

    if (i0 + i1 >= N) puts("YES");
    else puts("NO");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	int g = a / (b + c);
	int m = a % (b + c);
	ans += min(m, b);
	ans += g * b;
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll n,d,a;
    cin >> n >> d >> a;
    vector<pair<ll,ll>> x(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i).first >> x.at(i).second;
    }
    sort(all(x));
    ll ans = 0;
    queue<pair<ll,ll>> que;
    ll num = 0;
    for(i = 0;i < n;++i){
        while(!que.empty() && que.front().first < x.at(i).first){
            num -= que.front().second;
            que.pop();
        }
        x.at(i).second -= num;
        if(x.at(i).second <= 0) continue;
        ll tmp = ((x.at(i).second-1)/a+1)*a;
        ans += tmp/a;
        que.emplace(x.at(i).first + 2*d, tmp);
        num += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int ppp=2e9,ans=-1;
int N,T,A;
int main(){
	cin>>N>>T>>A;
	for (int i=0;i<N;i++){
		int h,temp;
		cin>>h;
		temp=T*1000-h*6;
		if (abs(temp-A*1000)<abs(ppp-A*1000)){
			ans=i+1;
			ppp=temp;
		}
	}
	cout<<ans;
	return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, pos[200005];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int px;
		scanf("%d", &px);
		pos[px] = i;
	}
	int res = 1, run = 1;
	for(int i = 2; i <= n; i++){
		if(pos[i] > pos[i - 1]){
			run++;
			res = max(res, run);
		}else{
			run = 1;
		}
	}
	printf("%d\n", n - res);
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int ans = 0;
  int cnt[4] = {0};
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; ++i) {
      ans += s[i] == 'A' and s[i + 1] == 'B';
    }
    int hs = 0;
    hs += (s.back() == 'A') * 1;
    hs += (s[0] == 'B') * 2;
    ++cnt[hs];
  }
  if (cnt[1] or cnt[2]) {
    ans += cnt[3], cnt[3] = 0;
    ans += min(cnt[1], cnt[2]);
  }
  else ans += max(0, cnt[3] - 1);
  cout << ans << '\n';

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
static const int N = 1000000;

void shellSort(int A[], int n);
void insertionSort(int A[], int n, int g);
vector<int> G;
int cnt;

int main() {
    int n;
    cin >> n;
    int A[N];
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    cnt = 0;
    shellSort(A, n);

    cout << G.size() << '\n';
    for (int i = G.size()-1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) printf("%d\n", A[i]);
}


void insertionSort(int A[], int n, int g) {
    int v, j;
    for (int i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 and A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}



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

int n,maxw;
long long w[128],v[128],dp[128000];

int main()
{
	ios::sync_with_stdio("false");
//	freopen(".in","r",stdin);
//	freopen(".out","r",stdout);
	memset(dp,0x3f3f3f3f,sizeof(dp));
	
	cin>>n>>maxw;
	dp[0]=0;
	for(int i=1;i!=n+1;++i)
	{
		cin>>w[i]>>v[i];
		for(int j=100100;j>-1;--j)
		{
			if(j>=v[i] && dp[j-v[i]]+w[i]<=maxw)
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			
//			else dp[i][j]=dp[i-1][j];
		}
	}
		

		
		
		
		
	for(int i=100009;i>0;--i)
		if(dp[i]<=maxw)
		{
			cout<<i<<"\n";
			break;
		}
//	cout<<"----------------"<<endl;
	
//	for(int i=0;i<n+1;++i)
//	{
//		for(int j=1;j<20;++j)
//		{
//			cout<<dp[j]<<"  ";
//		}
//		cout<<endl;
////	 } 
	return 0;
}


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

int parse(int &index, int level, const vector<string> &expressions) {
	switch(expressions[index][level]) {
	case '+':
	{
		const int next_level = level + 1;
		int res = 0;
		++index;
		while(index < expressions.size() && next_level + 1 == expressions[index].size()) {
			res += parse(index, next_level, expressions);
		}
		return res;
	}
	case '*':
	{
		const int next_level = level + 1;
		int res = 1;
		++index;
		while(index < expressions.size() && next_level + 1 == expressions[index].size()) {
			res *= parse(index, next_level, expressions);
		}
		return res;
	}
	case '.':
		assert(false);
	default:
		return expressions[index++][level] - '0';
	}
}

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

	for(int n; cin >> n && n;) {
		vector<string> expressions(n);
		for(auto &e : expressions) cin >> e;

		int index = 0;
		cout << parse(index, 0, expressions) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int main()
{
    int i;
    cin>>n>>k>>s;
    for(i=1;i<=k;i++)
        cout<<s<<" ";
    if(s<1000000000)
        for(i=k+1;i<=n;i++)
          cout<<"1000000000"<<" ";
    else for(i=k+1;i<=n;i++)cout<<"1"<<" ";
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
pos = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pos += 1
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        if pos != 0:
            print(noneg - 2*min(-neno[-1],pono[0]))
        else:
            print(noneg + 2*(neno[-1]))
    

Measured memory_bytes: 14496
//
// ABC121B
//
//

#include <iostream>
using namespace std;

int main() {
    int N,M,C;
    cin >> N >> M >> C;

    int B[M], A[M];
    for(int i =0; i<M; i++) cin >> B[i];

    int ans=0;
    for(int j=0; j<N;j++) {
    	int sum=0;
    	for(int i =0; i<M; i++) {
    		cin >> A[i];
    		sum += A[i]*B[i];
    	}
    	sum += C;
    	if (sum>0) ans++;
    }

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


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

const int N = 16;
int x[N], y[N], n;
long long ans;
int chk[N];
vector<int> a[N];
map<pair<int, int>, int> M;

void dfs(int step) {
	if (step == n / 2) {
		long long rlt = 0;
		for (int i = 0; i < N / 2; i++) a[i].clear();
		for (int i = 0; i < n; i++) a[chk[i]].push_back(i);
		M.clear();
		for (int i = 0; i < n / 2 + 1; i++) if (a[i].size() == 2) {
			int dx = abs(x[a[i][0]] - x[a[i][1]]);
			int dy = (y[a[i][0]] - y[a[i][1]]) * ((x[a[i][0]] - x[a[i][1]] < 0) ? -1 : 1);
			int gcd = __gcd(dx, dy);
			dx /= gcd, dy /= gcd;
			M[make_pair(dx, dy)]++;
		}
		for (map<pair<int, int>, int> :: iterator it = M.begin(); it != M.end(); it++) rlt += 1LL * it->second * (it->second - 1) / 2;
		ans = max(ans, rlt);
		return;
	}
	for (int i = 0; i < n; i++) {
		if (chk[i] != -1) continue;
		chk[i] = step;
		for (int j = i + 1; j < n; j++) {
			if (chk[j] != -1) continue;
			chk[j] = step;
			dfs(step + 1);
			chk[j] = -1;
		}
		chk[i] = -1;
		break;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	memset(chk, -1, sizeof chk);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i];	
	dfs(0);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;

int N,K;
int A[200005];
int cnt[200005];
int ans;

int main() {
	cin>>N>>K;
	Rep(i,N) cin>>A[i];
	Rep(i,200002) cnt[i]=0;
	Rep(i,N){
		cnt[A[i]]++;
	}
	sort(cnt,cnt+200001);
	ans = 0;
  int c=0;
  int d=0;
  Rep(i,200001){
    if(cnt[i]!=0){
      c = i;
      break;
    }
  }
  Rep(i,200001){
    if(cnt[i]!=0){
      d++;
    }
  }
	Rep(i,d-K){
		ans += cnt[i+c];
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    function<bool(int)> dfs = [&](int n){
        if(n<=0) return n==0;
        bool ret = false;
        ret |= dfs(n-4);
        ret |= dfs(n-7);
        return ret;
    };
    cout << (dfs(N) ? "Yes" : "No") << '\n';
    return 0;
}

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

int main() {
  int N;
  int count(0);
  int temp_max(0);
  cin>>N;
  
  vector <int> mochi(N);
  for (size_t i = 0; i < N; i++)cin>>mochi.at(i);  
  
  sort(mochi.begin(),mochi.end());
  
  for (size_t i = 0; i < N; i++){
    if( mochi.at(i) > temp_max ){
      temp_max = mochi.at(i);
      count++;
    }
  }
  
  cout<<count<<endl;
}

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

int main(){
	int num_inputs, A_input;
	cin >> num_inputs;
	
	set<int> A_set;
	for(int i=0;i<num_inputs;i++){
		cin >> A_input;
		A_set.insert(A_input);
	}
	
	// Test section
	// cout << A_set.size() << " " << num_inputs << endl;
	
	if(A_set.size() < num_inputs){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;


int main(){
	long long N;
	long long A[5];
	cin >> N;
	for(int i=0;i<5;i++){
		cin >> A[i];
	}
	long long mini = A[0];
	int num = 0;
	for(int i=1;i<5;i++){
		if(mini > A[i]){
			mini = A[i];
			num = i;
		}
	}
	long long ans = N / mini;
	if(N % mini) ans++;
	ans += 4;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int res = 0;
    int count = 0;
    int max = scan.nextInt();
    for (int i = 1; i < N; i++) {
      int h = scan.nextInt();
      if (max >= h) {
        count++;
      } else {
        count = 0;
      }
      res = Math.max(res, count);
      max = h;
    }
    scan.close();
    
    System.out.println(res);
  }
}

Measured memory_bytes: 49636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()
  a-=b
  return max(0,c-a)

# main()
print(main())


Measured memory_bytes: 8140
using System;


namespace ACTest
{
    class AOJDSL1A
    {

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int num = int.Parse(input[0]);
            int query = int.Parse(input[1]);
            int[] com = new int[query];
            int[] x = new int[query];
            int[] y = new int[query];
            for (int i = 0; i < query; i++)
            {
                input = Console.ReadLine().Split(' ');
                com[i] = int.Parse(input[0]);
                x[i] = int.Parse(input[1]);
                y[i] = int.Parse(input[2]);
            }
            // make set
            int[] p = new int[num];
            int[] rank = new int[num];
            for (int i = 0; i < num; i++)
            {
                p[i] = i;
                rank[i] = 0;
            }

            for (int i = 0; i < query; i++)
            {
                if (com[i] == 0)
                {
                    union(x[i], y[i], p, rank);
                }
                else
                {
                    Console.WriteLine(isSameSet(x[i], y[i], p));
                }
            }
            //while (true) ;

        }
        static void link(int x, int y, int[] p, int[] rank)
        {
            if (rank[x] > rank[y])
            {
                p[y] = x;
            }
            else
            {
                p[x] = y;
                if (rank[x] == rank[y])
                {
                    rank[y]++;
                }
            }
        }
        static int findSet(int x, int[] p)
        {
            if (x != p[x])
            {
                p[x] = findSet(p[x], p);
            }
            return p[x];
        }
        static int isSameSet(int x, int y, int[] p)
        {
            if (findSet(x, p) == findSet(y, p))
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        static void union(int x, int y, int[] p, int[] rank)
        {
            link(findSet(x, p), findSet(y, p), p, rank);
        }
    }
}

Measured memory_bytes: 19040
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int n,m,a[105],sum,ans;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(n);in(m);
    for (ri i=1;i<=n;++i) in(a[i]),sum+=a[i];
    if (sum%(m*4)==0) sum=sum/m/4;
    else sum=sum/m/4+1;
    for (ri i=1;i<=n;++i) if (a[i]>=sum) ++ans;
    if (ans<m) puts("No");
    else puts("Yes");
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
int K,n,i,j,z;
int main(){
	scanf("%d",&K);
	if(K==1){printf("1\n1\n");return 0;}
	n=(K+3)/4*2;
	printf("%d\n",n);
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)z=(i+j)%n+1,printf("%d%c",(i&1) && z+n<=K?z+n:z,j==n?'\n':' ');
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  long long X, res=0;

  unused = scanf("%lld", &X);

  if(X > 0){
    if(X >= 500){
      res += 1000*(X/500);
      X -= 500*(X/500);
    }
    if(X < 500 && X > 0) res += 5*(X/5);
    printf("%lld", res);
  }else{
    printf("%lld", 0);
  }

  return 0;
}

Measured memory_bytes: 128
n, q = gets.split( " " ).map { |val| val.to_i }
ps = []
t = []
n.times { |i|
	ps[i], ti = gets.split( " " )
	t[i] = ti.to_i
}

output = []
qsum = 0
while !t.empty?
	psi = ps.shift
	ti = t.shift
	if ti <= q
		qsum += ti	
		output.push( psi+" "+qsum.to_s )
	else
		t.push( ti-q )
		ps.push( psi )
		qsum += q
	end
end

puts( output.join( "\n" ) )

Measured memory_bytes: 14276
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	string s;
	cin >>  s ;
	int a;
	if (s == "SUN")a = 0;
	else if (s == "MON")a = 1;
	else if (s == "TUE")a = 2;
	else if (s == "WED")a = 3;
	else if (s == "THU")a = 4;
	else if (s == "FRI")a = 5;
	else if (s == "SAT")a = 6;

	ce(7 - a);
	
	

	
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


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


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
ll mod = INF;

double L;

int main(){
    cin >> L;
    cout << fixed<<setprecision(12)<<(L/3)*(L/3)*(L/3)<<endl;    
    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;


int main()
{      
    long long n, len;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    
    cin >> n;
    len = 26;
    
    int a;
    vector<int> k(0);
    
    n--;
    while(n >= 26){
        // あまり
        a = n % len;
        // 
        n /= len;
        n--;
        
        k.push_back(a);
    }
    k.push_back(n);
    
    for(int i=k.size()-1; i>=0; i--){
        cout << alp[k[i]];
    }
    cout << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,t,nt=1;
    string q;
    cin>>t>>q;
    for(g=1;q[g];g++)
        if(q[g]!=q[g-1])nt++;
    printf("%d\n",nt);
    return 0;
}


Measured memory_bytes: 512
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

int main()
{
    IOS;
    ll n, i;
    vector<ll> a(1e6), dp(1e6);
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(i=2;i<n;i++)
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1]<<"\n";

    return 0;
}


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

set<char> dict={'1','2','3','4','5','6','7','8','9','0'};

signed main(){
	int A,B; string S; cin>>A>>B>>S;
	bool ans=true;
	if(S.size()!=A+B+1)ans=false;
	if(ans){
		for(int i=0;i<S.size() and ans;i++){
			if(i==A){
				ans=(S[i]=='-' ? true : false);
			}
			else{
				ans=(dict.count(S[i]) ? true : false);
			} 
		}
	}
	cout<<(ans ? "Yes" : "No")<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int inputnum;
  int num1000;
  int num100;
  int num10;
  int num1;
  string judge = "Good";
 
  cin >> inputnum;
  num1000 = inputnum / 1000;
  num100 = (inputnum - (num1000*1000)) / 100;
  num10 = (inputnum - (num1000*1000) - (num100*100)) / 10;
  num1 = inputnum - (num1000*1000) - (num100*100) - (num10*10);
    
  if (num1000 == num100 || num100 == num10 || num10 == num1) {
    judge = "Bad";
  }
 
  cout << judge << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60,lmod=1e9+7;
const int MAX_N=302;

ll dp[MAX_N][MAX_N][MAX_N];
pair<P,int> rlx[MAX_N];

int main(){
  int N,M;
  cin >> N >> M ;
  rep(i,M) scanf("%d%d%d",&rlx[i].first.second,&rlx[i].first.first,&rlx[i].second);
  sort(rlx,rlx+M);
  //dp[0][0][0]=1LL;
  dp[1][0][0]=dp[0][1][0]=dp[0][0][1]=1LL;
  rep(i,N){
    rep(j,i) rep(k,i){
      (dp[i+1][j][k] += dp[i][j][k])%=lmod;
      (dp[i][i+1][k] += dp[i][j][k])%=lmod;
      (dp[i][j][i+1] += dp[i][j][k])%=lmod;
      (dp[i+1][i][k] += dp[j][i][k])%=lmod;
      (dp[j][i+1][k] += dp[j][i][k])%=lmod;
      (dp[j][i][i+1] += dp[j][i][k])%=lmod;
      (dp[i+1][j][i] += dp[k][j][i])%=lmod;
      (dp[k][i+1][i] += dp[k][j][i])%=lmod;
      (dp[k][j][i+1] += dp[k][j][i])%=lmod;
    }
    
    //範囲チェック
    int m_start = lower_bound(rlx,rlx+M,make_pair(P(i+1,0),0))-rlx;
    int m_end = lower_bound(rlx,rlx+M,make_pair(P(i+2,0),0))-rlx;
    //cout << m_start << "," << m_end << endl;
    REP(m,m_start,m_end){
      int _left = rlx[m].first.second;
      int _x = rlx[m].second;
      rep(j,i+1) rep(k,i+1){
        if(_x==1){
          if(j>=_left || k>=_left){
            dp[i+1][j][k] = 0;
            dp[j][i+1][k] = 0;
            dp[j][k][i+1] = 0;
          }
        }else if(_x==2){
          if((j>=_left&&k>=_left)||(j<_left&&k<_left)){
            dp[i+1][j][k] = 0;
            dp[j][i+1][k] = 0;
            dp[j][k][i+1] = 0;
          }
        }else{
          if(!(j>=_left && k>=_left)){
            dp[i+1][j][k] = 0;
            dp[j][i+1][k] = 0;
            dp[j][k][i+1] = 0;
          }
        }
      }
    }
  }
  ll ans=0;
  rep(i,N) rep(j,N){
    //cout << "i,j:" << i << "," << j << "->" << dp[N][i][j] << endl;
    ans += dp[N][i][j];
    ans += dp[i][N][j];
    ans += dp[i][j][N];
    ans %= lmod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 214656
import heapq

N = int(input())
V = list(map(int, input().split()))
q = []
for v in V:
    heapq.heappush(q, v)

while len(q) > 1:
    x = (heapq.heappop(q) + heapq.heappop(q)) / 2
    heapq.heappush(q, x)

print(q[0])


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

struct point{
	int x,y,cost;
};
typedef struct point P;

P setP(int x_,int y_,int cost_){
	P p; p.x = x_; p.y = y_; p.cost = cost_;
	return p;
}

int main(){
	int t,n,sx,sy,ans;
	int dx[] = {0,1,1,0,-1,-1};
	int dy[] = {1,1,0,-1,-1,0};
	
	while( cin >> t >> n , t||n ){
		int f[200][200] = {0};
		
		for(int i=0 ; i<n ; i++ ){
			int x,y;
			cin >> x >> y;
			f[y+100][x+100] = -1;
		}
		
		cin >> sx >> sy;
		P sp = setP( sx+100 , sy+100 , 0 );
		queue<P> que;
		que.push( sp );
		f[ sp.y ][ sp.x ] = 1;
		ans = 1;
		while( !que.empty() ){
			P p = que.front();
			que.pop();
			if( p.cost+1 > t )
				continue;
			
			for(int i=0 ; i<6 ; i++ ){
				int mx = p.x + dx[i];
				int my = p.y + dy[i];
				if( /*abs(mx-100) > 30 || abs(my-100) > 30 ||*/ f[my][mx] != 0 ){
					continue;
				}else{
					P p_ = setP( mx , my , p.cost+1 );
					f[my][mx] = 1;
					ans++;
					que.push( p_ );
				}
			}
		}
		
		//cout << "ans : " << ans << endl;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

string beautify(string str) {
	string ret = "";
	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];
		if ('a' <= c && c <= 'z') ret += c;
		else if ('A' <= c && c <= 'Z') ret += (char)(c-'A'+'a');
	}
	return ret;
}

class Dice {
private:
	int v[6];

public:
	int GetTop() {
		return v[0];
	}
	void Rotate(char op) {
		int newV[6];
		switch (op) {
		case 'N':
			newV[0] = v[1];
			newV[1] = v[5];
			newV[2] = v[2];
			newV[3] = v[3];
			newV[4] = v[0];
			newV[5] = v[4];
			break;

		case 'S':
			newV[0] = v[4];
			newV[1] = v[0];
			newV[2] = v[2];
			newV[3] = v[3];
			newV[4] = v[5];
			newV[5] = v[1];
			break;

		case 'E':
			newV[0] = v[3];
			newV[1] = v[1];
			newV[2] = v[0];
			newV[3] = v[5];
			newV[4] = v[4];
			newV[5] = v[2];
			break;

		case 'W':
			newV[0] = v[2];
			newV[1] = v[1];
			newV[2] = v[5];
			newV[3] = v[0];
			newV[4] = v[4];
			newV[5] = v[3];
			break;
		}
		for (int i = 0; i < 6; ++i) v[i] = newV[i];
	}
	Dice(int v1, int v2, int v3, int v4, int v5, int v6) {
		v[0] = v1;
		v[1] = v2;
		v[2] = v3;
		v[3] = v4;
		v[4] = v5;
		v[5] = v6;
	}
};

int main() {
	int v[6];
	for (int i = 0; i < 6; ++i) cin >> v[i];
	Dice dice(v[0], v[1], v[2], v[3], v[4], v[5]);

	string str; cin >> str;
	for (int i = 0; i < str.size(); ++i) {
		dice.Rotate(str[i]);
	}
	cout << dice.GetTop() << endl;
}

Measured memory_bytes: 1204
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0

ma = max(A)
first = [0]*(ma+3)
seen = [False]*(ma+3)
seens = set()
for i in range(N):
    a = A[i]
    if first[a] == 0:
        seens.add(a)
        ans += 1
        for j in range(a, ma + 3, a):
            first[j] += 1
    elif first[a] == 1 and (a in seens):
        ans -= 1
        first[a] += 1
    else:
        first[a] += 1

    #
    # if not seen[a]:
    #     print(i+1,a)
    #     ans += 1
    # for j in range(a,ma+3,a):
    #     seen[j] = True

print(ans)




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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }

  sort(v.begin(), v.end());
  for (int i = 0; i < N - 1; i++) {
    if (v.at(i) == v.at(i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}



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

long long ans;

long long func(long long l, long long r)
{
    return (r + l) * (r - l + 1) / 2;
}

int main(void)
{
    //input
    int n, k;
    cin >> n >> k;

    //calculate
    long long mod=pow(10,9)+7;
    for (int i = k; i <= n + 1; ++i)
    {
        long long min = func(0, i - 1);
        long long max = func(n - i + 1, n);
        ans += (max - min + 1) % mod;
    }
    //output
    cout << ans % mod << endl;
    return 0;
}


Measured memory_bytes: 3624
# b ABC129
# input
n = int(input())
w = list(map(int, input().split()))
o = 100*1000
for i in range(1, n):
    if o > abs(sum(w[:i])-sum(w[i:])):
        o = abs(sum(w[:i])-sum(w[i:]))
# output
print(o)


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

int main(){
    double a[200],m,n,sum=0,mark,ans=0;
    int i;
    cin>>n>>m;
    for(i=0;i<n;i++) {cin>>a[i];sum+=a[i];}
    mark=sum/4.0/m;
    for(i=0;i<n;i++){
        if(a[i]>=mark) ans++;
    }
    if(ans>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<ll> enumdiv(ll n) {
	vector<ll> S;
	for (ll i = 1; i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
	sort(S.begin(), S.end());
	return S;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	ll ans = infl;
	auto ed = enumdiv(2 * N);
	fore(x, ed) {
		ll y = 2 * N / x;

		vector<ll> r(2), m(2);
		r[0] = 0, m[0] = x;
		r[1] = -1, m[1] = y;

		auto p = crt(r, m);
		if (p.first != 0 && p.second != 0) chmin(ans, p.first);
	}

	cout << ans << endl;
}







Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	
	u64 S, W;
	cin >> S >> W;
	
	if(W >= S) {
		cout << "unsafe";
	} else {
		cout << "safe";
	}
	
	return 0;
}

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

bool check (string s){
    if ( s.size () %2 != 0 )
        return false;

    int size = s.size () /2;

    for (int i=0 ; i<size ; i++){
        if (s[i] != s[size+i]){
            return false;
        }
    }
    return true;
}


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

    if (check (s))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int l,r,d;
	cin>>l>>r>>d;
	int num=0;
	for(int i=l;i<=r;i++){
		if(i%d==0) num++;
	}
	cout<<num<<endl;
	return 0;
} 

Measured memory_bytes: 3636