akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readInt();
    auto m = new long[][](n, n);
    const long inf = long.max/n;
    foreach(i; iota(n)) {
        foreach(j; iota(n)) {
            m[i][j] = inf;
        }
        m[i][i] = 0;
    }
    foreach(i; iota(n)) {
        auto l = readInts();
        auto r = l[0];
        auto k = l[1];
        auto t = l[2..$];
        foreach(j; iota(k)) {
            m[r-1][t[j]-1] = 1;
        }
    }
    foreach(i; iota(n)) {
        foreach(j; iota(n)) {
            foreach(k; iota(n)) {
                m[j][k] = min(m[j][k], m[j][i] + m[i][k]);
            }
        }
    }
    auto p = readLong();
    foreach(i; iota(p)) {
        int s, d, v;
        readlnTo(s, d, v);
        auto u = m[s-1][d-1] + 1;
        writeln(u <= v ? u.to!string: "NA");
    }
}

Measured memory_bytes: 2704
n,x=map(int,input().split())
s=[1]*(n+1)
a=[1]*(n+1)
for i in range(1,n+1):
  s[i]=s[i-1]*2+3
  a[i]=a[i-1]*2+1
def p(l,d):
  if l==0:
    if d==0:
      return 0
    else:
      return 1
  elif d<=l:
    return 0
  elif d<=s[l-1]+1:
    return p(l-1,d-1)
  elif d<=s[l-1]*2+2:
    return a[l-1]+1+p(l-1,d-s[l-1]-2)
  else:
    return a[l]
print(p(n,x))

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	string S, T;
	cin >> S >> T;
	int ans = T.size();

	fx(S.size()-T.size()+1) {
		int sum = 0;
		fy(T.size()) {
			if (S[x+y]!=T[y]) {
				sum++;
			}
		}
		ans = min(ans, sum);
	}
	ce(ans)

    return 0;
}



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

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i<=n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
        }
    }
    return ret;
}

int main()
{
  ll N;cin>>N;
  
  vector<ll> a;
  a=divisor(N);
  //for(int i=0;i<a.size();i++)
   // cout<<a[i]<<" "<<N/a[i]<<endl;
  
  ll min = pow(10,12+1);
  for (int i=0; i<a.size() ;i++)
  {
     if(min > a[i]+(N/a[i]-2))
     {
       min = a[i]+(N/a[i])-2; 
     }
  }
  cout<< min <<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;
        for(int i = A; i <= B; i++){
            int a = i / 10000;
            int b = i % 10000 / 1000;
            int c = i % 100 / 10;
            int d = i % 10;
            if(a == d && b == c) ans++;
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    int N,K;

    cin >> N >> K;

    vector<bool> B(N);

    REP(i,N) B[i] = true;

    REP(i,K){
        int d;
        cin >> d;

        REP(j,d){
            int a;
            cin >> a;
            a--;
            B[a] = false;
        }
    }

    int ans = 0;

    REP(i,N){
        if(B[i]){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def prime_decomposition(n): #素因数分解
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

def make_divisors(n): #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors




n = onem()

k = make_divisors(n)
k.sort()

ans = Max

for i in range(len(k)):
    if ans >= n//k[i] + k[i] - 2:
        ans = n//k[i] + k[i] - 2
        
print(ans)




Measured memory_bytes: 39152
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		vector<set<char>> ss = {{'R', 'U', 'D'}, {'L', 'U', 'D'}};
		string ans = "Yes";
		REP(i, SZ(s)) {
			DEBUG(i);
			if(!ss[(i)%2].count(s[i])) {
				DEBUG(s[i]);
				ans = "No";
			}
		}
		cout << ans << endl;
	}	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i < n; i++) {
            x[i] = stdIn.nextInt();
        }
        for(int i = 0; i < n; i++) {
            y[i] = stdIn.nextInt();
        }
        for(int p = 1; p <= 3; p++) {
            double dis = 0.0;
            for(int i = 0; i < n; i++) {
                dis += Math.pow(Math.abs(x[i] - y[i]),p);
            }
            System.out.println(Math.pow(dis, 1.0/p));
        }
        int max = 0;
        for(int i = 0; i < n; i++) {
            max = Math.max(max, Math.abs(x[i] - y[i]));
        }
        System.out.println(max);
         
    }
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int Ales = 0, AB = 0 , Bov = 0;
  for (int i=0; i<N; i++){
    int P;
    cin >> P;
    if (P <= A) Ales++;
    else if (P<=B) AB++;
    else Bov++;
  }
  cout << min(Ales, min(AB, Bov)) << endl;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
ab = []
for i in range(n):
  a,b = list(map(int,input().split()))
  ab.append([a,b])
from operator import itemgetter
ab = sorted(ab,key=itemgetter(0))

ans = 0
for i in range(n):
  if m <= ab[i][1]:
    ans += m*ab[i][0]
    break
  else:
    ans += ab[i][1]*ab[i][0]
    m -= ab[i][1]
print(ans)

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

using namespace std;
const long long INF = 1e12;
long long dp[2][(1<<12)+5],v[105];

int main()
{
    int n,m;
    cin >> n >> m;
    for (int i = 1; i<(1<<n); i++)
        dp[0][i] = dp[1][i] = INF;
    bool t = 1;
    for (int i = 1; i<=m; i++, t^=1)
    {
        long long c, b = 0;
        int nr;
        cin >> c >> nr;
        for (int j = 1; j<=nr; j++)
        {
            int x;
            cin >> x;
            b|=(1<<(x-1));
        }
        for (int bit = 0; bit<(1<<n); bit++)
        {
            dp[t][bit] = dp[!t][bit];
            if ((bit&b))
                dp[t][bit] = min(dp[t][bit],dp[!t][(bit^(bit&b))]+c);
        }
    }
    if (dp[!t][(1<<n)-1] == INF)
        cout << -1;
    else
        cout << dp[!t][(1<<n)-1];
}


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

#define maxn 25000
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

char buf[maxn];
ll iR[maxn], iG[maxn], iB[maxn];
ll r = 0, g = 0, b = 0;

void slove()
{
	memset(iR, 0, sizeof(iR));
	memset(iG, 0, sizeof(iG));
	memset(iB, 0, sizeof(iB));
	int n; ll sum = 0;
	cin >> n;
	cin >> buf;
	if (buf[0] == 'R') iR[0] = 1;
	else if (buf[0] == 'G') iG[0] = 1;
	else iB[0] = 1;
	for (int i = 1; i < n; i++) {
		iR[i] = iR[i - 1], iG[i] = iG[i - 1], iB[i] = iB[i - 1];
		if (buf[i] == 'R') iR[i]++;
		else if (buf[i] == 'G') iG[i]++;
		else iB[i]++;
	}
	for (int i = 0; i < n; i++)	{
		if (buf[i] == 'R') {
			for (int j = i + 1; j < n; j++) {
				if (buf[j] == 'G') {
					sum += iB[n - 1] - iB[j];
					if (buf[j + j - i] == 'B') sum--;
				}
				else if (buf[j] == 'B') {
					sum += iG[n - 1] - iG[j];
					if (buf[j + j - i] == 'G') sum--;
				}
			}
		}
		else if (buf[i] == 'G') {
			for (int j = i + 1; j < n; j++) {
				if (buf[j] == 'R') {
					sum += iB[n - 1] - iB[j];
					if (buf[j + j - i] == 'B') sum--;
				}
				else if (buf[j] == 'B') {
					sum += iR[n - 1] - iR[j];
					if (buf[j + j - i] == 'R') sum--;
				}
			}
		}
		else {
			for (int j = i + 1; j < n; j++) {
				if (buf[j] == 'R') {
					sum += iG[n - 1] - iG[j];
					if (buf[j + j - i] == 'G') sum--;
				}
				else if (buf[j] == 'G') {
					sum += iR[n - 1] - iR[j];
					if (buf[j + j - i] == 'R') sum--;
				}
			}
		}
	}
	cout << sum;
}

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

	slove();

	return 0;
}

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

int main(){
	ll A, B, i;
    cin >> A >> B;
     
     for(i=1; i<=1000; i++){
     if(i*8/100==A && i*10/100==B){
       cout << i;return 0;
      }
     }
    cout << -1;
    return 0;
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> A(N + 1), B(N);
  for(int i = 0; i <= N; i++)cin >> A.at(i);
  for(int i = 0; i < N; i++)cin >> B.at(i);
  long count = 0;
  for(int i = N - 1; i >= 0; i--){
    if(A.at(i + 1) >= B.at(i)){
      count += B.at(i);
      A.at(i + 1) -= B.at(i);
      B.at(i) = 0;
    } else {
      count += A.at(i + 1);
      B.at(i) -= A.at(i + 1);
      A.at(i + 1) = 0;
    }
    if(A.at(i) >= B.at(i)){
      count += B.at(i);
      A.at(i) -= B.at(i);
      B.at(i) = 0;
    } else {
      count += A.at(i);
      B.at(i) -= A.at(i);
      A.at(i) = 0;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define true 1
#define false 0
struct node{
  int key;
  struct node *prev;
  struct node *left;
  struct node *right;
};
typedef struct node *NodePointer;
void insert(NodePointer);
NodePointer makenode(int);
void InorderPrint(NodePointer);
void PreorderPrint(NodePointer);
int Search(NodePointer, int);
NodePointer Node; 
int m;
NodePointer root = NULL;

int main()
{
  int i, key;
  char order[7];
  NodePointer NewNode;
  
  scanf("%d",&m);

  for(i = 0 ; i < m ; i++){
    scanf("%s",order);
    
    if(strcmp(order,"insert") == 0){
      scanf("%d",&key);
      NewNode = makenode(key);
      insert(NewNode); }
    if(strcmp(order,"print") == 0){
      InorderPrint(root);
      printf("\n");
      PreorderPrint(root);
      printf("\n"); }
    if(strcmp(order,"find") == 0){
      scanf("%d",&key);
      if(Search(root,key) == true) printf("yes\n");
      if(Search(root,key) == false) printf("no\n"); }
  }
  
  return 0;
}

void insert(NodePointer z)
{
  NodePointer y, x;
    
  y = NULL; /* xの親 */
  x = root;

  while(x != NULL){   
    y = x; /* 親を設定 */
    if(z->key < x->key) x = x->left;
    else x = x->right; }

  z->prev = y;

  if(y == NULL) root = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
    
}

NodePointer makenode(int key)
{
  NodePointer NewNode;

  NewNode = (NodePointer)malloc(sizeof(struct node));

  NewNode->key = key;
  NewNode->left = NULL;
  NewNode->right = NULL;
  
  return NewNode;
}

void InorderPrint(NodePointer u)
{
  if(u == NULL) return; 

  InorderPrint(u->left);
  printf(" %d",u->key);
  InorderPrint(u->right);
}

void PreorderPrint(NodePointer u)
{
  if(u == NULL) return;
  
  printf(" %d",u->key);

  PreorderPrint(u->left);
  PreorderPrint(u->right);
}

int Search(NodePointer x, int k)
{
  if(x == NULL || k == x->key){
    if(x == NULL) return false;
    else return true; }
  if(k < x->key) return Search(x->left,k);
  else return Search(x->right,k);
}



Measured memory_bytes: 20608
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Scan(&x)

	c := make([]int, n, n)
	a := make([][]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
		a[i] = make([]int, m, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	const F = 999999999
	answer := F

	for i := 1; i < (1 << n); i++ {
		achieved := true
		for j := 0; j < m; j++ {
			b := 0
			for k := 0; k < n; k++ {
				if i&(1<<k) == 1<<k {
					b += a[k][j]
				}
			}
			if b < x {
				achieved = false
				break
			}
		}
		if achieved {
			s := 0
			for j := 0; j < n; j++ {
				if i&(1<<j) == 1<<j {
					s += c[j]
				}
			}
			if s < answer {
				answer = s
			}
		}
	}

	if answer == F {
		fmt.Println(-1)
	} else {
		fmt.Println(answer)
	}
}


Measured memory_bytes: 1760
#include<iostream>
#define int long long
using namespace std;
int dp[101][100100] , v[101] , w[101] , n , W;
void init(){
	for(int i=0 ; i<101 ; ++i)
		for(int j=0 ; j<100100 ; ++j)
			dp[i][j] = 1e13;
	
	for(int i=0 ; i<n ; ++i) dp[i][0] = 0;

	dp[0][v[0]] = w[0];
}
signed main(){
	cin >> n >> W;
	for(int i=0 ; i<n ; ++i) cin >> w[i] >> v[i];

	init();

	for(int i=1; i<n ; ++i)
		for(int j=100099 ; j>=0 ; --j)
			if(j-v[i] >= 0) dp[i][j] = min(dp[i-1][j] , dp[i-1][j-v[i]]+w[i]);
			else dp[i][j] = dp[i-1][j];

	for(int j=100099 ; j>=0 ; --j)
		if(dp[n-1][j] <= W) return cout << j , 0;

}

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

int main(){
  string s;
  cin >> s;
  vector<bool> v(26, true);
  for (int i = 0; i < s.size(); ++i) v.at(s.at(i)-'a') = false;
  for (int i = 0; i < 26; ++i)
	if (v.at(i)) {
	  cout << (char)(i + 'a') << endl;
	    return 0;
	}
  puts("None");
  return 0;
}

Measured memory_bytes: 512
def main():
    n = int(input())
    h = list(map(int,input().split()))
    before = h[-1]
    for i in range(2,n+1):
        if before >= h[-i]:
            before = h[-i]
        elif before >= h[-i] - 1:
            before = h[-i] - 1
        else:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 14396
y = gets.chomp.to_i  #横棒の数
t = gets.chomp.to_i  #縦棒の数

arr = Array.new(y){|i| i + 1}  #または arr = (1..y).to_a でも可能

t.times do
    a,b = gets.split(",").map{|item| item.to_i}
    d = arr[b-1]
    arr[b-1] = arr[a-1]
    arr[a-1] = d
    #このバブルソートの方法を使ってもできるし、
    #arr[a-1], arr[b-1] = arr[b-1], arr[a-1]
    #この方法でも可能
end

arr.each do |n|
    puts n
end
    

#Array.new(Array)メソッド : 新しい配列を返す

#(例1)
#Array.new(size,obj) : sizeには配列のサイズ(要素数)を入れる。
#sizeを指定しなければ空の配列になる
#objを指定すると、新しい配列をそのオブジェクトで埋めることができる。
#objを指定しなければnilで埋まる。

#arr = Array.new
#p arr　　　　　　　→　[]
#arr = Array.new(4)
#p arr　　　　　　　→　[nil, nil, nil, nil]
#arr = Array.new(4, "hello")
#p arr　　　　　　　→　["hello", "hello", "hello", "hello"]

#(例2)
#Array.new(size) {|idx| block } : 引数objの代わりにブロックを渡すと、
#sizeの数だけブロックを繰り返し、ブロックが返す値を配列の要素する。

#arr = Array.new(10) {|idx| 2 ** idx }
#p arr　　　　→　[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

#(例3)
#Array.new(array) : newメソッドの引数に配列を指定すると、その配列をコピーした新しい配列を返す

#arr = Array.new(["dog", "mouse", "cat"])
#p arr　　　　→　["dog", "mouse", "cat"]

#puts arr[1]　→　mouse
#arr[2] = "rabbit"
#puts arr[2]　→　rabbit



#to_a(Array)メソッド : Array に変換したものを返す

#(例)
#def cat(a1, a2)
#  a1.to_a + a2.to_a
#end
#p cat([1, 2, 3], 4..6)
#→　[1, 2, 3, 4, 5, 6]

#(1..5).to_a　　→　 [1,2,3,4,5]
#(1..10).map{|i| i*2}　　→　[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]


#復帰文字，改行文字を取り除く chomp 
#文字列の切り出しは split("区切り文字") 

#スペース区切りの2つの数値を浮動小数点として変数b,cに読み込む
#b,c=gets.split(" ").map(&:to_f)


#変数 aを改行込みで出力する．
#print("#{a}\n")
#puts a
#変数 aを小数点以下10桁で改行込みで出力
#printf("%.10f\n",a) 
#配列 aをスペース区切りで出力
#puts a.join(" ")


Measured memory_bytes: 6844
$|=1;
$S = <STDIN>;chomp $S;
$T = <STDIN>;chomp $T;

$RS =reverse $S;
$RT =reverse $T;

$RTT=$RT; $RTT =~ s/([a-z])/($1|\\\?)/g;



if ($RS =~ s/$RTT/$RT/ ) {
 $RS=~s/\?/a/g;
 $SS = reverse $RS;
 print $SS;
} else {
 print 'UNRESTORABLE';
}


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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent = false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int solve(int n) {
    const int m = 1050;
    VI xs(m);
    iota(ALL(xs), 0);
    partial_sum(ALL(xs), xs.begin());
    
    int cnt = 0;
    rep(i, m) REP(j, i + 2, m) cnt += xs[j] - xs[i] == n;

    return cnt;
}

int main(void) {
    int n;
    while (cin >> n, n) cout << solve(n) << endl;

    return 0;
}

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

int main(){
    
    int n;
    cin >> n;
        
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout << " " << i;
        }else{
            for(int j=i; j>10; j/=10){
                if(j%10==3 || j/10==3){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3084
#あー統計のやつか、絶対値の和の最小値は平均の値
n=int(input())
s=input().split()
a=sorted([int(s[i])-i-1 for i in range(n)])
#ここまでの発想は流石にわかる
c=0
for i in range(n):
    if i<=n//2:
        c+=(a[n//2]-a[i])
    else:
        c+=(a[i]-a[n//2])
print(c)



'''
if n==1:
    print(0)
else:
    mi=[]
    h=sum(a)
    k=h
    for i in range(n-1):
        c,d=a[i],a[i+1]
        k-=2*a[i]
        m=k
        l=(i+1)-(n-i-1)
        if l>0:
            m+=(l*a[i+1])
        else:
            m+=(l*a[i])
        mi.append(m)
    mi.append(h-a[0]*n)
    mi.append(a[-1]*n-h)
    print(min(mi))
'''


Measured memory_bytes: 27488
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

#include<deque>

deque<int>Q;
deque<int>::iterator it;

const int mod=1e9+7;

int mod_pow(int x,int y) {
	int t=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) t=1ll*t*x%mod;
	return t;
}

int n,x,l[1000005],fac[1000005],inv[100005];

void work(int n) {
	fac[0]=1;
	For (i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=mod_pow(fac[n],mod-2);
	Dep (i,n-1,0) inv[i]=1ll*(i+1)*inv[i+1]%mod;
}

int C(int x,int y) {
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

void solve(int l,int r) {
	printf("%d\n",n),n++;
	For (i,2,n) {
		int t0=0,t1=0,t2=0;
		t0=C(n-2,i);
		t1=(C(n-2,i-1)*2%mod-C(n-(r-l+1),i-1)+mod)%mod;
		t2=C(n-2,i-2);
		printf("%lld\n",(1ll*t0+t1+t2)%mod);
	}
}


int main() {
	work(1e5);
	n=rd();
	For (i,1,n+1) {
		x=rd();
		if (l[x]) return solve(l[x],i),0; else l[x]=i;
	}
}






Measured memory_bytes: 3968
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
struct custom {
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=(y>>1);
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll p,x,i;
    cin>>x;
    p=100;
    for(i=1;i<=4000;i++)
    {
        p=p+(p/100);
        if(p>=x)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}


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


int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int n=s.size();
  map<char,char> ma,ima;
  bool ok=true;
  for(int i=0;i<n;++i){
    if(ma.count(s[i])) if(ma[s[i]]!=t[i]) ok=false;
    if(ima.count(t[i])) if(ima[t[i]]!=s[i]) ok=false;
    ma[s[i]]=t[i];
    ima[t[i]]=s[i];
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 776
#include <stdio.h>

unsigned long		n, x;
unsigned long long	ans = 0;

void eat(unsigned long *box, unsigned long eat)
{
	*box -= eat;
	ans += eat;
}

unsigned long checking(unsigned long a[], unsigned long i)
{
	if(i == 0)
		return a[i];
	else
		return a[i-1]+a[i];
}

int main(void)
{
	unsigned long a[100000];
	unsigned long i;
	
	scanf("%lu %lu", &n, &x);
	for(i=0; i<n; i++){
		scanf("%lu", &a[i]);
		
		if(a[i] > x)	//「x」より多いときは食べる
			eat(&a[i], a[i]-x);
	}
	
	for(i=0; i<n; i++){
		if(checking(a, i) > x){
			eat(&a[i], checking(a, i)-x);
		}else{	}
	}
	
	printf("%llu", ans);
	
	return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll x, a, b;
    cin >> x >> a >> b;

    if(b <= a) {
        out("delicious");
    }
    else if(b-a <= x) {
        out("safe");
    }
    else {
        out("dangerous");
    }

    re0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll INF = 1001001001001001001;
int N;
ll A[3100];
ll dp[3100][3100];

ll rec(int l, int r){
    if(l > r){
        return 0;
    }

    if(dp[l][r] != -INF){
        return dp[l][r];
    }

    ll res = std::max(A[l] - rec(l + 1, r),
                      A[r] - rec(l, r - 1));
    return dp[l][r] = res;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    std::fill(&dp[0][0], &dp[0][0]+3100*3100, -INF);

    ll res = rec(0, N - 1);
    std::cout << res << std::endl;
}


Measured memory_bytes: 75520
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline vector<ll> sieve(ll n){
  vector<ll> PrimeNumber;
  for(ll i = 1; i*i <= n; i++){
    if(n % i == 0){
      PrimeNumber.push_back(i);
      PrimeNumber.push_back(n/i);
    }
  }
  sort(all(PrimeNumber));
  return PrimeNumber;
}

inline int digit(ll x){
  int cnt = 0;
  while(0 < x){
    x /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n; cin >> n;
  vector<ll> res = sieve(n);
  int ans = INF;
  int k = res.size();
  for(int i = 0; i < k/2; i++){
    chmin(ans,max(digit(res[i]),digit(res[k-i-1])));
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

int main() {

  	long long N,A,B,C,D,E;
  int g=0;
  cin >>N>>A>>B>>C>>D>>E;
	long long x=min({A,B,C,D,E});
	cout << 4+((N+x-1)/x) << endl;	
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string S;
    cin >> S;
    int n = S.length();
    vector<long long> B(n);
    vector<long long> C(n);
    vector<long long> Z(n);
    vector<long long> BC(n);
    vector<long long> BZ(n);
    vector<long long> ZC(n);
    vector<long long> ZZ(n);

    vector<long long> M(n+1);
    long long m = 1;
    for ( int i = 0; i <= n; i++ ) {
        M[i] = m;
        m *= 3;
        m %= MOD;
    }

    long long Q = 0;
    for ( int i = 0; i < n; i++ ) {
        if ( S[i] == '?' ) { Q++; }
    }

    
    long long b,c,z;
    b = c = z = 0;
    for ( int i = n-1; i >= 0; i-- ) {
        if ( S[i] == 'B' ) { BC[i] = c; BZ[i] = z; }
        if ( S[i] == '?' ) { ZC[i] = c; ZZ[i] = z; }

        if ( S[i] == 'B' ) { b++; }
        if ( S[i] == 'C' ) { c++; }
        if ( S[i] == '?' ) { z++; }
    }

    for ( int i = n-2; i >= 0; i-- ) {
        BC[i] += BC[i+1];
        BZ[i] += BZ[i+1];
        ZC[i] += ZC[i+1];
        ZZ[i] += ZZ[i+1];
        BC[i] %= MOD;
        BZ[i] %= MOD;
        ZC[i] %= MOD;
        ZZ[i] %= MOD;
    }
    for ( int i = 0; i < n-1; i++ ) {
        BC[i] = BC[i+1];
        BZ[i] = BZ[i+1];
        ZC[i] = ZC[i+1];
        ZZ[i] = ZZ[i+1];
    }

    long long ans = 0;
    for ( int i = 0; i < n-2; i++ ) {
        if ( S[i] == 'A' ) {
            
            if ( BC[i] > 0 ) {
                ans += BC[i] * M[Q];
                ans %= MOD;
            }
            if ( BZ[i] > 0 ) {                
                ans += BZ[i] * M[Q-1];
                ans %= MOD;
            }
            if ( ZC[i] > 0 ) {
                ans += ZC[i] * M[Q-1];
                ans %= MOD;
            }
            if ( ZZ[i] > 0 ) {
                ans += ZZ[i] * M[Q-2];
                ans %= MOD;
            }            
        }
        if ( S[i] == '?' ) {
            
            if ( BC[i] > 0 ) {                    
                ans += BC[i] * M[Q-1];
                ans %= MOD;
            }
            if ( BZ[i] > 0 ) {
                ans += BZ[i] * M[Q-2];
                ans %= MOD;
            }            
            if ( ZC[i] > 0 ) {
                ans += ZC[i] * M[Q-2];
                ans %= MOD;
            }
            if ( ZZ[i] > 0 ) {
                ans += ZZ[i] * M[Q-3];
                ans %= MOD;
            } 
            
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6784
package main

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

func isAllEven(a []int) bool {
	for i := range a {
		if a[i]%2 == 1 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n, p := nextInt(), nextInt()
	a := nextInts(n)

	ans := 0
	if isAllEven(a) {
		if p == 0 {
			ans = (1 << uint(n))
		} else {
			ans = 0
		}
	} else {
		ans = (1 << uint(n-1))
	}

	puts(ans)

	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,curr=0;
    cin>>n;
    vector<ll> arr(n),ans(n);
    for(i=0;i<n;i++){
        cin>>arr[i];
        curr^=arr[i];
    }
    for(i=0;i<n;i++)
        ans[i]=curr^arr[i];
    for(i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 6288
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int sum = a + b + c;

    if(sum<=21){
      System.out.println("win");
    }else{
      System.out.println("bust");
    }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forr(i, a, b) for (int i = (int)(b); i >= (int)(a); --i)
#define sz(a) (int)((a).size())
 
using namespace std;

const int ooi = INT_MAX;
const long long ool = LLONG_MAX;
const int mod = 1e9 + 7;
const double PI = acos(-1);
 
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int a[500500];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    string s;
    cin >> s;
    int n = sz(s);
    for1(i, n){
        if(s[i - 1] == '<') uax(a[i], a[i - 1] + 1);
    }
    ford(i, n){
        if(s[i] == '>') uax(a[i], a[i + 1] + 1);
    }

    i64 res = 0;
    forn(i, n + 1) res += 1ll * a[i];
    cout << res << endl;
}

Measured memory_bytes: 2844
#include<iostream>

using namespace std;
int main()
{
	long long int m1, m2, a, b, c, d;
	cin >> a >> b >> c >> d;
	m1 = max(a*c, a*d);
	m2 = max(b*c, b*d);
	cout << max(m1, m2);
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e18;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 3005;

int dp[N][N];
string s, t;

int sol(int i, int j){

    if(i == s.length() || j == t.length()) return 0;

    int &ret = dp[i][j];

    if(ret != -1) return ret;

    if(s[i] == t[j]) {
        return ret = sol(i + 1, j + 1) + 1;
    }

    return ret = max(sol(i + 1, j), sol(i, j + 1));
}

int main(){
    fIO

    cin >> s >> t;


    memset(dp, -1, sizeof(dp));
    sol(0, 0);


    int i = 0, j = 0;

    while(i < s.length() && j < t.length()) {
        int ch1 = sol(i + 1, j);
        int ch2 = sol(i, j + 1);
        if(s[i] == t[j]) {
            cout << s[i];
            i++;
            j++;
        }else if(ch1 > ch2) {
            i++;
        }else {
            j++;
        }
    }
}










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

int main() {
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int start = h1*60+m1;
    int end = h2*60+m2;
    cout<<end-start-k<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
    int N;
    int a[101];
    int count = 0;

    cin >> N;
    for (size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (size_t i = 0; i < N - 1; i++)
    {
        int buf1, buf2;
        buf1 = a[i];
        buf2 = a[i + 1];

        if (buf1 == buf2)
        {
            a[i + 1] = 1000000000;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    double L;
    cin >> L;
    double X = L / 3;
    double Y = L / 3;
    double Z = L - X - Y;
    double V = X * Y * Z;
    // cout << X << " " << Y << " " << Z << endl;
    cout << fixed << setprecision(10) << V << endl;
    return 0;
}

Measured memory_bytes: 256
const main = input => {
  const inputs = input.trim().split('\n')
  const [H, W] = inputs[0].split(' ').map(x => parseInt(x))
  const picture = []
  for (let i = 0; i < H; i++) {
    console.log(inputs[i + 1])
    console.log(inputs[i + 1])
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BGoldenApple
    {
        static void Main(string[] args)
        {
            var nd = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int n = nd[0];
            int d = nd[1];

            int count = 0;
            for (int i = 1; i <= n; i++)
            {
                i += 2 * d;
                count++;
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
// Problem : D. Let's Play the Words?
// Contest : Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
// URL : https://codeforces.com/contest/1277/problem/D
// Memory Limit : 256.000000MB 
// Time Limit : 3000.000000milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)
 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
#define forn(i,a,b) for (int i = (a); i < (b); ++i)
#define fo(i,a) forn(i,0,a)
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
 
int main() {
 
	fast_cin();

	string s;
	cin >> s;
	
	ll count = 0;
	
	for (int i = 0; i < s.length()/2; ++i) {
		if (s[i] != s[s.length() - 1 - i]) {
			count++;
		}
	}
 
	cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		SortedSet<Integer> set = new TreeSet<>();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int op = sc.nextInt();
			int y = sc.nextInt();
			switch (op) {
				case 0:
					set.add(y);
					System.out.println(set.size());
					break;
				case 1:
					if (set.contains(y)) {
						System.out.println(1);
					} else {
						System.out.println(0);
					}
					break;
				case 2:
					set.remove(y);
					break;
				case 3:
					int z = sc.nextInt() + 1;
					Set<Integer> subset = set.subSet(y, z);
					for (int num : subset) {
						System.out.println(num);
					}
					break;
			}
		}
	}
}



Measured memory_bytes: 186472
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);    //整数の入力
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(A <= 8 && B <= 8){
        System.out.println("Yay!");
      } else {
        System.out.println(":(");
      }
  }
} 

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main() {
	int N;
	cin>>N;
	string S[3];
	for(int i=0;i<3;i++)
		cin>>S[i];
	int ans=0;
	for(int i=0;i<N;i++){
		set<char> tes;
		for(int j=0;j<3;j++){
			tes.insert(S[j][i]);
		}
		ans+=tes.size()-1;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
h=input().split()
H=[int(a) for a in h]
DP=[0]*N
DP[1]=abs(H[0]-H[1])
if N==2:
    print(abs(H[0]-H[1]))
elif N==3:
    if K==2:
        print(min(DP[1]+abs(H[2]-H[1]),abs(H[2]-H[0])))
    else:
        print(DP[1]+abs(H[2]-H[1]))
else:
    for a in range(2,N):
        number=0
        answers=[]
        if a-K<0:
            for z in range(a):
                zouka=abs(H[a]-H[z])
                answers.append(DP[z]+zouka)
        else:
            for z in range(a-K,a):
                zouka = abs(H[a] - H[z])
                answers.append(DP[z] + zouka)
        DP[a]=min(answers)
    print(DP[-1])
    

Measured memory_bytes: 53088