akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

alias Tuple!(int, "a", int, "l", int, "r") Seg;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = new int[](N+1);
    foreach (i; 0..N) B[A[i]] = i;

    auto st1 = new SegmentTree(N + 1);
    auto st2 = new SegmentTree(N + 1);

    for (int i = 0; i < N; i += 2) st1.assign(i, A[i]);
    for (int i = 0; i < N; i += 2) st2.assign(i+1, A[i+1]);

    int query(int l, int r) {
        if (l % 2 == 0) return st1.query(l, r);
        else return st2.query(l, r);
    }

    auto ans = new int[](N);
    int p = 0;

    auto pq = new BinaryHeap!(Array!Seg, "a[0] > b[0]");
    pq.insert(Seg(query(0, N-1), 0, N-1));

    while (!pq.empty) {
        auto seg = pq.front;
        pq.popFront;
        auto l = seg.l;
        auto r = seg.r;
        int a = seg.a;
        int ai = B[a];
        int b = query(ai+1, r);
        int bi = B[b];
        ans[p++] = a;
        ans[p++] = b;
        if (ai != l) pq.insert(Seg(query(l, ai-1), l, ai-1));
        if (bi != r) pq.insert(Seg(query(bi+1, r), bi+1, r));
        if (ai + 1 != bi) pq.insert(Seg(query(ai+1, bi-1), ai+1, bi-1));
    }

    ans.map!(a => a.to!string).join(" ").writeln;
}


class SegmentTree {
    int[] table;
    int size;
    immutable int INF = 1 << 29;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new int[](size);
        fill(table, INF);
    }

    void assign(int pos, int num) {
        return assign(pos, num, 0, 0, size/2-1);
    }

    void assign(int pos, int num, int i, int left, int right) {
        if (left == right) {
            table[i] = num;
            return;
        }
        auto mid = (left + right) / 2;
        if (pos <= mid)
            assign(pos, num, i*2+1, left, mid);
        else
            assign(pos, num, i*2+2, mid+1, right);
        table[i] = min(table[i * 2 + 1], table[i * 2 + 2]);
    }

    int query(int pl, int pr) {
        return query(pl, pr, 0, 0, size/2-1);
    }

    int query(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return INF;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                min(query(pl, pr, i*2+1, left, (left+right)/2),
                    query(pl, pr, i*2+2, (left+right)/2+1, right));
    }
}


Measured memory_bytes: 18704
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using triple=pair<int,pair<int,int> >;
#define tm first
#define src second.first
#define dst second.second
const int MAX_N=20010;
int n,m;
triple tp[MAX_N];
bool infected[MAX_N];

int main(){ _;
  while(cin>>n>>m,(n|m)!=0){
    REP(i,m){
      cin>>tp[i].tm>>tp[i].src>>tp[i].dst;
      tp[i].src--;
      tp[i].dst--;
    }
    sort(tp,tp+m);
    REP(i,n)infected[i]=false;
    infected[0]=true;
    REP(i,m)infected[tp[i].dst]|=infected[tp[i].src];
    int cnt=0;
    REP(i,n){
      if(infected[i])cnt++;
    }
    cout<<cnt<<endl;
  }
}

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

using namespace std;

int main(){
	int n, k; cin >> n >> k;
	long long ans = 0;
	vector<int> h(n);
	for(int i = 0; i < n; ++i) cin >> h[i];
	sort(h.begin(), h.end(), greater<int>());
	for(int i = k; i < n; ++i) ans += h[i];
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1000
int main(){
    double n;
    while(cin>>n){
        if(n<=48.0) cout<<"light fly"<<endl;
        else if(n<=51)cout<<"fly"<<endl;
        else if(n<=54)cout<<"bantam"<<endl;
        else if(n<=57)cout<<"feather"<<endl;
        else if(n<=60)cout<<"light"<<endl;
        else if(n<=64)cout<<"light welter"<<endl;
        else if(n<=69)cout<<"welter"<<endl;
        else if(n<=75)cout<<"light middle"<<endl;
        else if(n<=81)cout<<"middle"<<endl;
        else if(n<=91)cout<<"light heavy"<<endl;
        else cout<<"heavy"<<endl;
    }
}

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

ll n, k;
int main(){
	cin >> n >> k;
	cout << min(n-(n/k-1)*k, min(abs(n-(n/k-1)*k - k), abs(abs(n-(n/k-1)*k)-k-k))) << "\n";	
}


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

namespace aoj1
{
    class Program
    {
        static void Main()
        {
            int[] num = IntInput();
            Array.Sort(num);
            for (int i = 0; i < num.Length; i++)
            {
                if (i > 0)
                {
                    Console.Write(" ");
                }
                Console.Write(num[i]);
            }
            Console.WriteLine();
        }

        static int[] IntInput()
        {
            string[] strs = Console.ReadLine().Split(' ');
            int[] numbers = new int[strs.Length];
            for (int i = 0; i < strs.Length; i++)
            {
                numbers[i] = int.Parse(strs[i]);
            }
            return numbers;
        }
    }
}

Measured memory_bytes: 5740
num = int(input())
h = input().split()
hi = sorted(h)
#print(hi)

#print(num)
#print(h)
ans = 0
 
for i in range(num):
    if i == 0:
        ans = ans + int(hi[i])
    else:
        ans = ans * int(hi[i])
        if ans > 10**18 or ans == 0:
            break
if ans <= 10**18:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 19504
#include <stdio.h>
#include <algorithm>

using namespace std;

int n, k, x, sum=0;

int main(){
  scanf("%d %d", &n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&x);
    sum+= min(x,x-k>0 ? x-k : k-x);
  }
  printf("%d\n",sum *2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,a;
	cin>>n;
	a=n%1000;
	if (a==0){
		cout<<0<<endl;
		return 0;	
	} else {
		cout<<1000-a<<endl;
	}
	return 0;
}

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

int main() {
    int r, g;
    cin >> r >> g;

    cout << 2*g-r;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>


int main()
{
  int A, B;
  std::cin >> A >> B;
  std::string code;
  std::cin >> code;

  bool is_postal = std::all_of(code.begin(), code.begin()+A,
                               [](char u) -> bool { return std::isdigit(u); });
  // std::cout << is_postal;

  is_postal = is_postal && code[A] == '-';
  // std::cout << is_postal;

  is_postal = is_postal && std::all_of(code.begin()+A+1, code.end(),
                                       [](char u) -> bool { return std::isdigit(u); });
  // std::cout << is_postal;

  std::cout << (is_postal ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << ((x == 3 || x == 5 || x == 7) ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 764
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ps <- getIntList
    print . sum $ zipWith3 check ps (drop 1 ps) (drop 2 ps)

check x y z | x < y && y < z = 1
            | z < y && y < x = 1
            | otherwise = 0

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    a.append(b);
    int x = atoi(a.c_str());
    for (int i = 4; i <= 1000; ++i)
    {
        if (i * i == x)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	unsigned long long N, K;
	cin >> N >> K;
	vector<pair<unsigned long long, unsigned long long>> sushi(N);
	for (auto i = 0; i < N; ++i)
	{
		auto& p = sushi[i];
		cin >> p.second >> p.first;
	}

	sort(sushi.begin(), sushi.end(), greater<pair<unsigned long long, unsigned long long>>());

	set<unsigned long long> exist;
	vector<unsigned long long> dup;
	auto sumD = 0llu;
	auto maxVal = 0llu;
	for (auto i = 0; i < K; ++i)
	{
		auto& p = sushi[i];
		if (exist.find(p.second) != exist.end())
		{
			dup.push_back(p.first);
		}
		else
		{
			exist.insert(p.second);
		}
		sumD += p.first;
	}
	maxVal = sumD + exist.size() * exist.size();
	sort(dup.begin(), dup.end());

	auto dupIndex = 0;
	for (auto i = K; i < N; ++i)
	{
		if (dupIndex >= dup.size())
		{
			break;
		}
		auto& p = sushi[i];

		if (exist.find(p.second) != exist.end())
		{
			continue;
		}
		exist.insert(p.second);
		sumD += p.first - dup[dupIndex];
		++dupIndex;
		maxVal = max(maxVal, sumD + exist.size() * exist.size());
	}

	cout << maxVal << endl;

	return 0;
}


Measured memory_bytes: 5244
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
import math
from decimal import *
# read = sys.stdin.buffer.read
# readline = sys.stdin.buffer.readline
# readlines = sys.stdin.buffer.readlines
input = sys.stdin.readline

temp = input()
print(temp[0:3])


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct RangeMinimumQuery {
	int n;
	vector<int> d;
	void init(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, INF);
	}
	void update(int i, int x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)
			d[j] = min(d[j * 2], d[j * 2 + 1]);
	}
	//[l, r)
	int query(int l, int r) {
		int mi = get(l);
		for (; l && l + (l&-l) <= r; l += l&-l)
			mi = min(mi, d[(n + l) / (l&-l)]);
		for (; l < r; r -= r&-r)
			mi = min(mi, d[(n + r) / (r&-r) - 1]);
		return mi;
	}
	int get(int i) { return d[n + i]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> idx(N + 1);
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
		idx[a[i]] = i;
	}
	using T = tuple<int, int, int, int, int, int, bool>;
	priority_queue<T, vector<T>, greater<T>>pq;
	vector<RangeMinimumQuery> rmq(2);
	rmq[0].init(N);
	rmq[1].init(N);
	rep(i, 0, N) {
		if (i % 2 == 0)
			rmq[0].update(i, a[i]);
		else
			rmq[1].update(i, a[i]);
	}
	int vl = rmq[0].query(0, N);
	int vr = rmq[1].query(idx[vl], N);
	dump(vl, vr);
	pq.emplace(vl, vr, idx[vl], idx[vr], 0, N - 1, 0);
	vector<int> ans;
	while (pq.size()) {
		int cl, cr, l, r, L, R;
		bool flag;
		tie(cl, cr, l, r, L, R, flag) = pq.top(); pq.pop();
		dump(cl, cr, l, r, L, R, flag);
		ans.emplace_back(cl);
		ans.emplace_back(cr);
		int nl, nr;
		if (l + 1 != r) {
			dump(1);
			nl = rmq[!flag].query(l + 1, r);
			nr = rmq[flag].query(idx[nl], r);
			pq.emplace(nl, nr, idx[nl], idx[nr], l + 1, r - 1, !flag);
		}
		if (l != L) {
			dump(1);
			nl = rmq[flag].query(L, l);
			nr = rmq[!flag].query(idx[nl], l);
			pq.emplace(nl, nr, idx[nl], idx[nr], L, l - 1, flag);
		}
		if (r != R) {
			dump(1);
			nl = rmq[flag].query(r + 1, R + 1);
			nr = rmq[!flag].query(idx[nl], R + 1);
			pq.emplace(nl, nr, idx[nl], idx[nr], r + 1, R, flag);
		}
	}
	cout << ans[0]; rep(i, 1, ans.size()) { cout << " " << ans[i]; } cout << endl;
	return 0;
}

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

int main(){
  int n,m;	cin >> n >> m;
  vector<int>	A(n);
  double sum=0;
  for(int i=0;i<n;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  sort(A.rbegin(),A.rend());
  int c=0;
  for(int x:A){
    if(x<sum/4/m)	continue;
    c++;
  }
  if(c>=m)	cout << "Yes";
  else cout << "No";
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

int H, W;
vector<string> S;

void searchAndWrite(int _i, int _j) {
  int ans = 0;
  FOR(i, _i - 1, _i + 2) {
    FOR(j, _j - 1, _j + 2) {
      if (i >= 0 && i < H && j >= 0 && j < W)
        if (S[i][j] == '#')
          ans++;
    }
  }
  S[_i][_j] = (char)(0x30 + ans);
}

signed main() {
  H = read();
  W = read();
  REP(i, H) { S.PB(readString()); }
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] == '.')
        searchAndWrite(i, j);
    }
  }
  REP(i, H) { cout << S[i] << endl; }

  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>

int main(void){
    int i;
    char str[4];
    scanf("%s", str);

    if(str[0] ==str[1]&& str[2]== str[3] &&str[1] !=str[2]){
        printf("Yes");
    }else if(str[0]==str[2]&&str[1] ==str[3] && str[0]!=str[1] ){
        printf("Yes");
    }else if(str[0]==str[3]&&str[1]==str[2]&& str[0]!=str[1] ){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
if (input[0] === input[1]) { return console.log(0); }
const s = Array.from(input[0]);
const t = Array.from(input[1]);
let count = 0;
for (let i=0; i < s.length; i++) { 
    if (s[i] !== t[i]) { count++ };
}
console.log(count);


Measured memory_bytes: 36408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1LL << 60;

ll N, M;
vector<P> v;
int main() {
    cin >> N >> M;
    v.resize(M);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            ll c; cin >> c;
            c--;

            s += (1LL << c);
        }

        v[i] = P(s, a);
    }

    vector<ll> dp(1LL << N, INF);
    dp[0] = 0;

    // ある集合から移動
    for (int i = 0; i < 1LL << N; i++) {
        for (int j = 0; j < M; j++) {
            ll target = v[j].first;
            ll cost = v[j].second;
            dp[i | target] = min(dp[i | target], dp[i] + cost);
        }
    }

    ll ans = dp.back();
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

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

bool isPrime(int x){
    bool res = true;
    for(int i = 2;i*i <= x;i++){
        if(x%i==0) res = false;
    }
    return res;
}

int main() {
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x << endl;
 }

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int A, P;
  cin >> A >> P;
  cout << (3 * A + P) / 2 << endl;
}

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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    bool dp[k+1]={0};
    for(int i=1;i<k+1;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0)
            {
                if(dp[i-a[j]]==0)
                    dp[i]=1;
            }
        }
    }
    if(dp[k])
        cout << "First";
    else
        cout << "Second";
    return 0;
}


Measured memory_bytes: 384
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e4+5;
const int M = 1e2+5;

const int mod = 1e9+7;

int n;
string s;
int mem[N][3][M];

int add_self(int & a , int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

//state 0 for equal numbers
//1 for smaller
//2 for bigger

int go(int idx , int sta , int sum){
    if(idx == s.size()){
        return sum == 0 && (sta == 0 || sta == 1);
    }
    if(~mem[idx][sta][sum])
        return mem[idx][sta][sum];
    int ways = (sum == 0) && (idx != 0);
    for(int i = ((idx == 0) ? 1 : 0); i <= 9; i++){
        //if(sta == 1){
         //  add_self(ways , go(idx + 1 , 1 , (sum + i) % n));
        //}
        int new_sta = 0;
        if( (sta == 0 && s[idx] - '0' < i) || sta == 2 ){
            new_sta = 2;
        } else if( (sta == 0 && s[idx] - '0' > i) || sta == 1 ){
            new_sta = 1;
        }
        add_self(ways , go(idx + 1 , new_sta , (sum + i) % n));
    }
    return mem[idx][sta][sum] = ways;
}

int main(){
    cin >> s >> n;
    memset(mem , -1 , sizeof mem);
    cout << go(0 , 0 , 0) << endl;
}


Measured memory_bytes: 13312
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderB
{
    static void Main()
    {
        string s = Console.ReadLine();

        for (int i = 0; i < s.Length; i++)
        {
            string str = s.Substring(i, 1);
            if (i % 2 == 0)
            {
                if ("L".Equals(str))
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            else
            {
                if ("R".Equals(str))
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

int main(){  
  char ch[1001];
  while(1){
    cin >> ch;
    if (ch[0] == '0') break;
    int sum = 0;
    for (int i = 0; i < strlen(ch) ; i++)
    {
      sum += ch[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

main = do
  x <- readLn
  print $ head $ dropWhile (< x) primes

--
-- Sieve of Eratosthenes
--

infixr 5 !:
(!:) :: a -> [a] -> [a]
(!x) !: xs = x : xs

-- | エラトステネスの篩により、 max 以下の素数の一覧を構築して返す
-- >>> sieve 100
-- [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
sieve :: Int -> [Int64]
sieve !max = 2 : U.ifoldr (\i isPrime xs -> if isPrime then fromIntegral (2 * i + 1) !: xs else xs) [] vec
  where
    vec = U.create $ do
      vec <- UM.replicate ((max - 1) `quot` 2 + 1) True
      UM.write vec 0 False -- 1 is not a prime
      -- vec ! i : is (2 * i + 1) prime?
      let clear !p = forM_ [3*p,5*p..max] $ \n -> UM.write vec (n `quot` 2) False
          factorBound = floor (sqrt (fromIntegral max) :: Double)
          loop !i | 2 * i + 1 > factorBound = return ()
                  | otherwise = do b <- UM.read vec i
                                   when b $ clear (2 * i + 1)
                                   loop (i + 1)
      loop 1
      return vec

-- |
-- >>> takeWhile (< 100) primes
-- [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
primes :: [Int64]
primes = sieve 100003


Measured memory_bytes: 1276
#include <stdio.h>
long int GCD(long int A, long int B) {
	if (B == 0) return A;
	return GCD(B, A % B);
}

int main() {
	int long x, y;
	scanf("%ld %ld", &x, &y);

	printf("%ld\n", GCD(x,y));

	return 0;
}


Measured memory_bytes: 2100
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

string s;

void input(){
	cin>>s;
}

void solve(){
	int cnt=0;
	rep(i,0,3)
		if(s[i]=='A')
			cnt++;
	if(cnt==1 || cnt==2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

main(){
	fastio;
	int t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include <string>
#include<stdio.h>

using namespace std;

int main(){
    int n,y,m,d,sum;

    cin>>n;

    for(int i=0; i<n; i++){
            sum=0;
            cin>>y>>m>>d;

            if(y%3==0 || m%2==1){
                sum += 20-d;
            }else{
                sum += 19-d;
            }

            for(int j=m+1; j<=10; j++ ){
                if(y%3==0 || j%2==1){
                    sum+=20;
                }else{
                    sum+=19;
                }
            }

            for(int j=y+1; j<1000; j++){
                if(j%3==0){
                    sum+=200;
                }else{
                    sum+=195;
                }
            }
            printf("%d\n", sum+1);
    }
    return 0;
}



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

int gcd(int a, int b);
int gcd(const std::vector<int>& arr);

int main() {

        int n = 0;
        std::cin >> n;
        std::vector<std::tuple<std::string, int, int>> restrants(n);

        for (std::size_t i = 0; i < n; ++i) {
                std::string s;
                int p = 0;
                std::cin >> s >> p;
                restrants[i] = std::make_tuple( s, p, i + 1 );
        }

        std::sort(std::begin(restrants), std::end(restrants),
                        [](auto a, auto b) {
                                if (std::get<0>(a) == std::get<0>(b)) {
                                        return std::get<1>(a) > std::get<1>(b);
                                }
                                else {
                                        return std::get<0>(a) < std::get<0>(b);
                                }
                        });

        for (const auto& r : restrants) {
                std::cout << std::get<2>(r) << std::endl;
        }



        return 0;
}

int gcd(int a, int b) {
        if (a > b) {
                std::swap(a, b);
        }

        for (int r = b % a; r != 0; b = a, a = r, r = b % a)
                ;

        return a;
}

int gcd(const std::vector<int>& arr) {
        const int size = arr.size();
        if (size == 0) {
                return 0;
        }
        else if (size == 1) {
                return arr[0];
        }

        int ret = gcd(arr[0], arr[1]);

        for (std::size_t i = 2; i < size && ret != 1; ++i) {
                ret = gcd(arr[i], ret);
        }

        return ret;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> myvec;
  int test;
  while (N--) {
    cin >> test;
    myvec.push_back(test);
  }
  int min = *min_element(myvec.begin(), myvec.end());
  int max = *max_element(myvec.begin(), myvec.end());
  cout << max-min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  ll ans = 0;
  for(ll i=1; i<=N; i++) {
    if(i%3!=0 and i%5!=0)
      ans+=i;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define INF (1<<30)
#define MOD 1000000007

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

   int D,G;
   cin>>D>>G;
   vector<int>p(D),c(D);
   for(int i=0;i<D;i++)cin>>p[i]>>c[i];

   ll res = INF;
   int bit = pow(2,D);
   for(int i=0;i<bit;i++){
      ll ans = 0;
      ll cc = 0;
      for(int j=0;j<D;j++){
         if(i & (1<<j)){
            ans += 100*(j+1)*p[j]+c[j];
            cc += p[j];
         }
      }

      if(ans < G){
         int max=-1;
         int a = -1;
         for(int j=D-1;j>=0;j--){
            if(!(i & (1<<j))){
               max = j;
               break;
            }
         }
         if(max == -1)continue;
         else{
            for(int k=0;k<p[max]-1;k++){
               if(ans >= G)break;
               ans += 100*(max+1);
               cc++;
            }
         }
      }
      if(ans >= G)res = min(res,cc);
   }
   cout<<res<<endl;
   return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    ans = {}

    for i in range(len(A)):
        if A[i] in ans:    # Confirm existence of key
            ans[A[i]] += 1
        else:
            ans[A[i]] = 1
    
    for i in range(1, N):
        if i in ans:
            # print('{}'.format(ans[A[i]]))
            print('{}'.format(ans[i]))
        else:
            print('{}'.format(0))

    print('{}'.format(0))

if __name__ == '__main__':
    main()


Measured memory_bytes: 33516
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n)
	{
		int m,hit,d;
		cin>>m>>hit>>d;

		string f[d];
		for(int i = 0; i < d; ++i)
		{
			cin>>f[i];
		}

		int x=m,y=1;
		while(y<=d)
		{
			if(x-2>=0&&f[y-1][x-2]=='1')
			{
				x=x-1;
			}
			else if(x-1<f[0].size()&&f[y-1][x-1]=='1')
			{
				x=x+1;
			}
			y++;
		}
		if(x==hit)
		{
			cout<<0<<endl;
			continue;
		}
		bool flag=false;
		for(int i = 0; i < d; ++i)
		{
			for(int j = 0; j < f[0].size(); ++j)
			{
				x=m; y=1;
				if(f[i][j]=='1'||(j>0&&f[i][j-1]=='1')||(j<f[0].size()-1&&f[i][j+1]=='1')) continue;
				f[i][j]='1';
				while(y<=d)
				{
					if(x-2>=0&&f[y-1][x-2]=='1')
					{
						--x;
					}
					else if(x-1<f[0].size()&&f[y-1][x-1]=='1')
					{
						++x;
					}
					y++;
				}
				if(x==hit)
				{
					cout<<i+1<<" "<<j+1<<endl;
					flag=true;
					break;
				}
				f[i][j]='0';
			}
			if(flag) break;
		}
		if(!flag) cout<<1<<endl;
	}
  return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		Scanner sc = new Scanner(System.in);
		//		String s = sc.nextLine();
		//
		//		char[] array = s.toCharArray();
		//
		//		for (int i = 0; i < s.length(); i++) {
		//			if (array[i] == 'B') {
		//				if (array[i + 1] == 'W') {
		//					char temp = array[i + 1];
		//					array[i + 1] = array[i];
		//					array[i] = temp;
		//
		//				} else {
		//					int firstB = i;
		//					findW(array, i, firstB);
		//				}
		//
		//			}
		//		}

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		char[] array = s.toCharArray();

		long countB = 0;
		long ans = 0;

		for (char c : array) {

			if (c == 'B') {
				countB++;
			} else {
				ans += countB;
			}

		}

		System.out.println(ans);

	}
	//
	//	private static void findW(char[] array, int i, int firstB) {
	//		// TODO 自動生成されたメソッド・スタブ
	//		if (array[i] == 'B') {
	//			if (array[i + 1] == 'W') {
	//				char temp = array[i + 1];
	//				array[i + 1] = array[i];
	//				array[i] = temp;
	//				count++;
	//
	//			} else {
	//				findW(array, i, firstB);
	//			}
	//
	//		}
	//	}

}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int k;
	cin>>k;

	int cur=0;
	vector<bool> cov(k+1);
	int ans=0;

	while(1)
	{
		ans++;
		cur*=10;
		cur+=7;
		cur%=k;
		if(cov[cur])
		{
			cout << -1 << endl;
			return 0;
		}
		cov[cur]=1;
		if(cur==0)
		{
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3780
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        ans += A[i]
        ans %= m
    ans = ans**2
    ans %= m
    for i in range(N):
        ans -= pow(A[i],2,m)
        ans %= m
    
    ans = ans * pow(2,m-2,m) % m
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32512
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int A[] = new int[N];
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
    }
    for(int i=0;i<N;i++){
      //i番目の人は結局何個食べたのか
      if(D%A[i]==0){
        X=X+(D/A[i]);//割り切れるなら商の数食べれる
      }else{
        X=X+(1+D/A[i]);//割り切れないなら商+1個
      }
    }
    System.out.println(X);
  }
  

  
}

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

using namespace std;

int main()
{
    long int N, W;
    long long d[2][100020], w[102], v[102];

    cin >> N >> W;

    long int sv = 0;

    for(int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
        sv += v[i];
    }

     for(int j = 0; j <= sv; j++)
     {
         d[0][j] = -1;
         d[1][j] = -1;
     }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= sv; j++)
        {
            
            if(j == v[i]){
                if(d[i%2][j]==-1)
                    d[i%2][j] = w[i];
                else
                    d[i%2][j]=min(d[i%2][j],w[i]);
            }
            else
            { 
                if(j <= v[i])
                    d[i%2][j] = d[!(i%2)][j];
                else
                {
                    if(d[!(i%2)][j-v[i]] == -1 && d[!(i%2)][j] == -1)
                        d[i%2][j] = -1;
                    else if(d[!(i%2)][j-v[i]] != -1 && d[!(i%2)][j] == -1)
                        d[i%2][j] = d[!(i%2)][j-v[i]] + w[i];
                    else if(d[!(i%2)][j-v[i]] == -1 && d[!(i%2)][j] != -1)
                        d[i%2][j] = d[!(i%2)][j];
                    else
                    {
                    d[i%2][j] = min(d[!(i%2)][j-v[i]] + w[i], d[!(i%2)][j]);
                    }
                    
                }          
            }
        }
    }
    for(int q = sv; q > 0; q--)
    {
        if(d[(N-1)%2][q] <= W && d[(N-1)%2][q] != -1)
        {
            cout << q; 
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
s1 = input()
s2 = input()

def levenshtein_distance(a, b):
    m = [ [0] * (len(b) + 1) for i in range(len(a) + 1) ]

    for i in range(len(a) + 1):
        m[i][0] = i

    for j in range(len(b) + 1):
        m[0][j] = j

    for i in range(1, len(a) + 1):
        for j in range(1, len(b) + 1):
            if a[i - 1] == b[j - 1]:
                x = 0
            else:
                x = 1
            m[i][j] = min(m[i - 1][j] + 1, m[i][ j - 1] + 1, m[i - 1][j - 1] + x)
    # print m
    return m[-1][-1]

ans = levenshtein_distance(s1,s2)
print(ans)


Measured memory_bytes: 43076
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  int num;
  struct node *prev;
  struct node *next;
}node;
typedef struct node *d_l_list;
d_l_list head;
d_l_list last;
void insert(int);
void num_search_an_delete(int);
void delete(d_l_list);
void d_first();
void d_last();
void printnode();
int main(){
  int n;
  char command[12];
  int v;
  int i;
  head=malloc(sizeof(node));
  last=malloc(sizeof(node));
  head->num=last->num=0;
  head->next=last;
  last->prev=head;
  head->prev=last->next=NULL;
  d_l_list getnode(int);
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(!strcmp(command,"insert")){
      scanf("%d",&v);
      insert(v);
    }
    else if(!strcmp(command,"delete")){
      scanf("%d",&v);
      num_search_an_delete(v);
    }
    else if(!strcmp(command,"deleteFirst"))d_first();
    else if(!strcmp(command,"deleteLast"))d_last();
  }
  printnode();
  return 0;
}
d_l_list getnode(int x){
  d_l_list newnode;
  newnode=malloc(sizeof(node));
  newnode->num=x;
  newnode->prev=NULL;
  newnode->next=NULL;
  return newnode;
}
void insert(int v){
  d_l_list newnode=getnode(v);
  newnode->next=head->next;
  newnode->prev=head;
  head->next=newnode;
  newnode->next->prev=newnode;
}
void num_search_an_delete(int x){
  d_l_list searchnode;
  searchnode=head->next;
  while(searchnode!=last){
    if(searchnode->num==x){
      delete(searchnode);
      break;
    }
    searchnode=searchnode->next;
  }
  return;
}
void d_first(){
  d_l_list f_node=head->next;
  delete(f_node);
}
void d_last(){
  d_l_list l_node=last->prev;
  delete(l_node);
}
void delete(d_l_list del){
  d_l_list delprev=del->prev;
  d_l_list delnext=del->next;
  delnext->prev=del->prev;
  delprev->next=del->next;
  free(del);
}
void printnode(){
  d_l_list p_node;
  p_node=head->next;
  while(p_node!=last){
    printf("%d%c",p_node->num,((p_node->next==last)?'\n':' '));
    p_node=p_node->next;
  }
}



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;

const ll MOD = 1000 * 1000 * 1000 + 7;

ll pw(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n /= 2) {
        if (n & 1)
            res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

ll inv(ll x) {
    ll r = pw(x, MOD - 2);
    assert (r * x % MOD == 1);
    return r;
}

const int N = 111 * 1000;

ll f[N];
ll rf[N];

void init() {
    f[0] = 1;
    for (int i = 1; i < N; i++)
        f[i] = f[i - 1] * i % MOD;
    for (int i = 0; i < N; i++)
        rf[i] = inv(f[i]);
}

ll cnk(ll n, ll k) {
    if (k > n)
        return 0;
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

int main() {
#ifdef LOCAL
    // freopen("input", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    map<int, ll> was;
    int n;
    cin >> n;
    int pref = 0;
    int suf = 0;
    init();
    for (int i = 0; i < n + 1; i++) {
        int x;
        cin >> x;
        if (was.count(x)) {
            pref = was[x];
            suf = n - i;
        } else {
            was[x] = i;
        }
    }
    for (int i = 1; i <= n + 1; i++) {
        ll all = cnk(n + 1, i);
        ll bad = cnk(pref + suf, i - 1);
        cout << (all - bad + MOD) % MOD << "\n";
    }
}

Measured memory_bytes: 9216
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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)
    return divisors


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    a_set = set()
    memo = set()
    for ai in A:
        if ai in a_set:
            memo.add(ai)
            if ai == 1:
                print(0)
                return
        else:
            a_set.add(ai)
    if 1 in a_set:
        print(1)
        return
    
    counter = [0] * (10 ** 6 + 1)
    for ai in A:
        for m in range(ai, 10 ** 6 + 1, ai):
            counter[m] += 1
    
    ans = 0
    for ai in A:
        if counter[ai] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 119824
#include <iostream>
#include <string.h>
using namespace std;

int main(){
int n;
string a;
string b;
string c;
int num=0;

cin>>n>>a>>b>>c;

for(int i=0;i<n;i++){
if(a[i]!=b[i]){
 num++;
if(b[i]==c[i]){
num--;
}
}
if(a[i]!=c[i]){
  num++;
}

}
cout<<num;
}

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

using namespace std;

int n, len;
long long x[N], y[N], d[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%lld %lld", &x[i], &y[i]);
	int flag = x[1] + y[1] & 1;
	for(int i = 1; i <= n; ++i)
		if((x[i] + y[i] & 1) != flag) {
			puts("-1");
			return 0;
		}

	if(!flag) d[++len] = 1;
	d[++len] = 1;
	for(int i = 1; i <= 32; ++i) {
		++len;
		d[len] = d[len - 1] << 1;
	}
	reverse(d + 1, d + len + 1);
	
	printf("%d\n", len);
	for(int i = 1; i <= len; ++i)
		printf("%lld%c", d[i], " \n"[i == len]);
	
	for(int i = 1; i <= n; ++i) {
		long long x = 0, y = 0;
		for(int j = 1; j <= len; ++j) {
			long long dL = abs((x - d[j]) - ::x[i]) + abs(y - ::y[i]);
			long long dR = abs((x + d[j]) - ::x[i]) + abs(y - ::y[i]);
			long long dU = abs(x - ::x[i]) + abs((y + d[j]) - ::y[i]);
			long long dD = abs(x - ::x[i]) + abs((y - d[j]) - ::y[i]);
			long long mic = min(min(dL, dR), min(dU, dD));
			if(dL == mic) {
				putchar('L');
				x -= d[j];
			} else if(dR == mic) {
				putchar('R');
				x += d[j];
			} else if(dU == mic) {
				putchar('U');
				y += d[j];
			} else if(dD == mic) {
				putchar('D');
				y -= d[j];
			}
		} putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
from math import ceil,sqrt
def prime_judge(n):
    if n==2:
        return True
    if n<2 or n%2==0:
        return False
    for i in range(3,int(ceil(sqrt(n)))+1,2):
        if n%i==0:
            return False
    return True

x=int(input())
while not prime_judge(x):
    x+=1
print(x)

Measured memory_bytes: 38460
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())

const int N = 100005, inf = 1e9 + 7;

int f[N], a[N];

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int n, k;
    std::cin >> n >> k;
    rep(i, 0, n) {
        std::cin >> a[i];
    }
    rep(i, 1, n) {
        f[i] = inf;
        int lim = std::max(i - k, 0);
        rep(j, i, lim) {
            f[i] = std::min(f[i], f[j] + abs(a[i] - a[j]));
        }
    }
    std::cout << f[n - 1] << std::endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,cnt1=0,cnt2;
	cin >> n;
	vll a(n);
	vd b(n);
	rep(i,n){
		cin >> a[i];
		chmax(cnt1,a[i]);
		b[i]=(double)a[i];
	}
	sort(all(a));
	sort(all(b));
	double tmp=(double)cnt1/2,tmp2=INF;
	rep(i,n){
		if(chmin(tmp2,abs(tmp-b[i]))) cnt2=a[i];
	}
	cout << cnt1 << " " << cnt2 << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	ll A,B,C; cin >> A >> B >> C;
    ll ans = min(B+C,A+2*B+1);
    cout << ans << endl;

}
   


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;
const int N = 3005;
int n, tot, a[N], lnk[N], son[N << 1], nxt[N << 1]; bool win[N];
void add(int x, int y) {
    nxt[++tot] = lnk[x];
    lnk[x] = tot;
    son[tot] = y;
    
}
void dfs(int x, int p) {
       win[x] = 0;
       for (int j = lnk[x]; j; j = nxt[j]) {
                 if (son[j] == p) continue;
                if (a[x] > a[son[j]]) {
                         dfs(son[j], x);
                         if (!win[son[j]]) win[x] = 1;
            
        }
        
    }
    
}
 int main() {
     while (cin >> n) {
         for (int i = 1; i <= n; i++) {
             std::cin >> a[i];
         }
         for (int i = 1, x, y; i < n; i++) {
             cin >> x >> y;
             add(x, y);
             add(y, x);
         }
         for (int i = 1; i <= n; i++) {
             dfs(i, 0);
             if (win[i]) cout << i << " ";
         }
     }
     return 0;
}

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

int main(){
    int k;
    int A[3];
    cin >> A[0] >> A[1] >> A[2] >> k;
    sort(A,A+3);
    for(int i = 0; i < k; i++){
        A[2] = A[2] * 2;
    }
    cout << A[0] + A[1] + A[2] << endl;
    return 0;
}


Measured memory_bytes: 256