akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using i64 = long long;
using P = std::pair<i64, int>;

enum { U, D, L, R };

int main() {
    constexpr i64 inf = std::numeric_limits<i64>::max() / 2;
    int n, m, k, sx, sy, tx, ty;
    std::cin >> n >> m >> k
        >> sx >> sy >> tx >> ty;
    --sx; --sy; --tx; --ty;
    std::vector<int> b;
    for (int i = 0; i < n; i++) {
        std::string in;
        std::cin >> in;
        for (const char c : in) b.push_back(c == '.');
    }

    const int size = n * m;
    const auto get = [m](const int i, const int j) { return i * m + j; };
    std::vector<std::vector<std::pair<int, int>>> g(4 * size);
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        const int v = get(i, j);
        if (!b[v]) continue;
        for (int dir = U; dir <= R; dir++) {
            for (int o = U; o <= R; o++) if (o != dir) {
                g[dir * size + v].emplace_back(o * size + v, 1);
            }
        }
        if (i > 0 && b[v - m]) g[U * size + v].emplace_back(U * size + v - m, 0);
        if (i + 1 < n && b[v + m]) g[D * size + v].emplace_back(D * size + v + m, 0);
        if (j > 0 && b[v - 1]) g[L * size + v].emplace_back(L * size + v - 1, 0);
        if (j + 1 < m && b[v + 1]) g[R * size + v].emplace_back(R * size + v + 1, 0);
    }

    std::vector<i64> dist(g.size(), inf);
    std::priority_queue<P, std::vector<P>, std::greater<>> q;
    const int s = get(sx, sy), t = get(tx, ty);
    for (int dir = U; dir <= R; dir++) {
        const int v = dir * size + s;
        dist[v] = 0;
        q.emplace(0, v);
    }
    while (!q.empty()) {
        const auto [c, v] = q.top();
        q.pop();
        if (dist[v] < c) continue;
        for (const auto [to, ty] : g[v]) {
            const i64 nc = ty ? (c + k - 1) / k * k : c + 1;
            if (dist[to] <= nc) continue;
            dist[to] = nc;
            q.emplace(nc, to);
        }
    }

    i64 ret = inf;
    for (int dir = U; dir <= R; dir++) {
        const int v = dir * size + t;
        if (dist[v] < ret) ret = dist[v];
    }

    std::cout << (ret == inf ? -1 : (ret + k - 1) / k) << std::endl;

    return 0;
}

Measured memory_bytes: 318620
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<queue>
#include<set>

using namespace std;

set<long long> candidates;
priority_queue< pair<long double, long long> > snuke;

void push_candidates() {
    for(int i=1;i<=136;++i) {
        int d = (i<10 ? 15 : (i<100 ? 14 : 13));
        long long candidate = (long long)i;
        candidates.insert(candidate);
        if(i == 1) continue;
        candidate *= 10LL;
        for(int j=1;j<=d;j++) {
            candidates.insert(candidate-1);
            candidate *= 10LL;
            if(candidate > 1e15) break;
        }
    }
}

void calc() {
    for(long long candidate: candidates) {
        
        string s = to_string(candidate);
        long double sum = 0;
        for(int i=0;i<s.length();i++) {
            sum += (long double)(s[i] - '0');
        }
        // cerr << candidate/sum << " " << candidate << endl;
        snuke.emplace(-candidate/sum, -candidate);
    }
}

int main(){
    int K;
    cin >> K;
    push_candidates();
    calc();

    long long min_ = 0;
    int cnt = 0;
    while(cnt < K) {
        pair<long double, long long> p = snuke.top(); snuke.pop();
        // cerr << p.first << " " << p.second << endl;
        while(-p.second < min_) {
            p = snuke.top();
            // cerr << p.first << " " << p.second << endl;
            snuke.pop();
        }
        min_ = -p.second;
        cout << -p.second << endl;
        cnt++;
    }
}

Measured memory_bytes: 512
import java.util.*;

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

    int n = sc.nextInt();
    int y = sc.nextInt();

    int s1 = -1;
    int s2 = -1;
    int s3 = -1;
    
    LABEL: for (int i = 0; i <= n; i++) {
      int x1 = n - i;
      for (int j = 0; j <= x1; j++) {
        int k = x1 - j;
        int sum = 1000 * i + 5000 * j + 10000 * k;
        if (sum == y) {
          s3 = i;
          s2 = j;
          s1 = k;
          break LABEL;
        }
      }
    }
    
    System.out.println(s1 + " " + s2 + " " + s3);
  }
}

Measured memory_bytes: 23508
#include<stdio.h>
int main()
{
int m[1000],f[1000],r[1000],i,sum;
for(i=0;i<1000;i++){
scanf("%d %d %d",&m[i],&f[i],&r[i]);
if((m[i]==-1)&&(f[i]==-1)&&(r[i]==-1))
break;
}
for(i=0;i<1000;i++){
if((m[i]==-1)&&(f[i]==-1)&&(r[i]==-1))
break;
sum=0;
sum=m[i]+f[i];
if((m[i]==-1)||(f[i]==-1)){
printf("F\n");
}else{
if(sum>=80)
printf("A\n");
else if(sum>=65)
printf("B\n");
else if(sum>=50)
printf("C\n");
else if(sum>=30){
if(r[i]>=50){
printf("C\n");
}else
printf("D\n");
}else
printf("F\n");
}}
return 0;
}

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

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

using namespace std;

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

    int N;
    cin >> N;
    REP(_, N) {
        char S;
        cin >> S;
        if (S == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;

    return 0;
}


Measured memory_bytes: 3616
import java.io.*;
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		while(s.hasNext()){
			Integer student_num = Integer.parseInt(s.next());
			if(student_num == 0){
				break;
			}

			ArrayList<Integer> score_list = new ArrayList<Integer>();
			for(int i = 0; i < student_num; i++){
				score_list.add(Integer.parseInt(s.next()));
			}
			Integer total = 0;
			for(int i = 0; i < student_num; i++){
				total += score_list.get(i);
			}
			double m = (double)total / student_num;
			double dev = 0;
			for(int i = 0; i < student_num; i++){
				dev += Math.pow(score_list.get(i) - m, 2);
			}
			double standard_dev = Math.sqrt(dev / student_num);
			System.out.println(String.format("%.8f", standard_dev));
		}

	}

}

Measured memory_bytes: 20888
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {

	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String line = br.readLine();
	    //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
	    line = line.trim();
	    //半角スペースを区切り文字として扱う
	    String[] readLineArray = line.split("[\\s+]");
	    //変数に配列を代入
	    double r = Double.parseDouble(readLineArray[0]);
	    double S = Math.PI *r*r;
	    double L = 2 * Math.PI * r;
	    
	    System.out.printf("%.5f %.5f",S,L);
	}

}

Measured memory_bytes: 16928
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define BIG 2000000007
#define VERYBIG 200000000000007LL

#define MOD 1000000007
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 2000
#define M_MAX 200000

ull n, m;

ull a[N_MAX];
ull b[N_MAX];

bool isreached[100][100];
bool isreachable[100][100];

void set1nize (ull v, bool *array[]) {
	sll i, j, ki;

	for (i = 0; i < n; i++) {
		for (j = 0; j < v; j++) {
			for (ki = j; ki <= 50; ki += v) {
				if (array[i][ki]) {
					array[i][j] = true;
					break;
				}
			}
		}

		// (j-k loop) =~ 50
	}

	return;
}

bool is0able (ull v) {
	sll i, j;

	bool *isreachable_ARG[100];
	for (i = 0; i < n; i++) {
		isreachable_ARG[i] = isreachable[i];

		for (j = 0; j <= 50; j++) {
			isreachable[i][j] = isreached[i][j];
		}
	}

	while (--v) {
		set1nize(v, isreachable_ARG);
	}

	for (i = 0; i < n; i++) {
		if (!isreachable[i][b[i]]) return false;
	}
	return true;
}

ull solve () {
	sll i, j, ki;
	// ull result = 0;
	sll result = 0;
	// double result = 0;
	// ull maybe = 0;
	sll maybe = 0;
	// ull sum = 0;
	sll sum = 0;
	ull item;
	ull *dpcell;

	bool *isreached_ARG[100];
	for (i = 0; i < n; i++) {
		isreached_ARG[i] = isreached[i];
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j <= 50; j++) {
			isreached[i][j] = false;
		}
		isreached[i][a[i]] = true;
	}

	if (!is0able(51)) goto fail;

	result = 0;
	for (i = 50; i >= 1; i--) {
		if (!is0able(i)) {
			result |= (1ULL << i);
			set1nize(i, isreached_ARG);
		}
	}

	printf("%llu\n", result);

	return 0;

	fail:
	puts("-1");
	return 1;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%llu", &n);
	for (i = 0; i < n; i++) {
		scanf("%llu", &a[i]);
	}
	for (i = 0; i < n; i++) {
		scanf("%llu", &b[i]);
	}
	solve();

	return 0;
}


Measured memory_bytes: 128
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

ll gcd(ll a, ll b)
{
  if (a % b == 0)
  {
    return (b);
  }
  else
  {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

int main()
{
  ll n, m;
  cin >> n >> m;
  ll a[n], b[n], c[m], d[m];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> c[i] >> d[i];
  }
  ll ans[n];
  ll dist = 0;
  for (int i = 0; i < n; i++)
  {
    dist = 4*100000000 + 1;
    ll num = 0;
    for (int j = 0; j < m; j++)
    {
     ll kyori = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist > kyori)
      {
        dist = kyori;
        num = j + 1;
      }
    }
    ans[i] = num;
  }
  for (int i = 0; i < n; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3572
import numpy as np


def f(n):
    dp = np.zeros(n * 10 ** 4 + 1, dtype="i8")
    bs = [list(map(int, input().split())) for _ in range(n)]
    bs.sort(key=lambda x: x[0] + x[1])
    for w, s, v in bs:
        np.maximum(dp[w:s + w + 1], dp[:s + 1] + v, out=dp[w:s + w + 1])
    print(np.max(dp))


n = int(input())
f(n)


Measured memory_bytes: 12740
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

// #define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// #define SIZE_OF_ARRAY(pro2) (sizeof(pro2)/sizeof(pro2[0]))

int main(){
    // sort(pro1, pro1 + SIZE_OF_ARRAY(pro1));
    // sort(pro2, pro2 + SIZE_OF_ARRAY(pro2)); 照準そーと
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    double ra =0;
    for(int j=0;j<n;j++){
        ra += a[j];
    }
    ra = ra / n;//平均
    double min=2*n;
    int num;
    double sub;
    for(int k=n-1;k>=0;k--){
        sub = abs(ra - a[k]);
        // printf("k:%d",k);
        if(min >= sub){
            min = sub;
            num = k;
        }
    }
    printf("%d",num);
}


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

#define ALPHABET_SIZE 26
#define LOWERCASE_OFFSET 97

struct Character {
	std::string ch;
	int freq;
	bool operator > (const Character& x) const { return this->freq > x.freq; }
};

// bool greaterFreq(const Character& c, const Character& d) { return c.freq > d.freq; }
// bool lessFreq(const Character& c, const Character& d) { return c.freq < d.freq; }

int main()
{
	std::string input;
	std::cin >> input;
	
	Character alphabet[ALPHABET_SIZE];
	for (int i=0; i<ALPHABET_SIZE; i++) {
			alphabet[i].ch = {(char)(i + LOWERCASE_OFFSET)}; alphabet[i].freq = 0;
	}
	for (int i=0; i<input.length(); i++) alphabet[input[i] - LOWERCASE_OFFSET].freq++;
	/*
	for (int i=0; i<ALPHABET_SIZE; i++) {
		std::cout << alphabet[i].ch << " : freq = " << alphabet[i].freq << std::endl;
	}
	*/
	std::priority_queue<Character, std::vector<Character>, std::greater<std::vector<Character>::value_type>> pq;
	for (int i=0; i<ALPHABET_SIZE; i++) {
		if (alphabet[i].freq==0) continue;
		pq.push(alphabet[i]);
	}
	
	while (pq.size() >= 2) {
		Character x, y;
		x = pq.top(); pq.pop();
		y = pq.top(); pq.pop();
		Character xy;
		xy.ch = "(" + x.ch + y.ch + ")";
		xy.freq = x.freq + y.freq;
		pq.push(xy);
	}
	Character z = pq.top();
	
	// std::cout << z.ch << std::endl;
	
	if (z.ch[0] != '(') z.ch = "(" + z.ch + ")";
	
	int code_length[ALPHABET_SIZE];
	int depth = 0;
	for (int i=0; i<z.ch.length(); i++) {
		if (z.ch[i] == '(') depth++;
		else if (z.ch[i] == ')') depth--;
		else code_length[z.ch[i]-LOWERCASE_OFFSET] = depth;
	}
	/*
	for (int i=0; i<ALPHABET_SIZE; i++) {
		if (alphabet[i].freq == 0) continue;
		std::cout << "CodeLength(" << (char)(i+LOWERCASE_OFFSET) << ") = " << code_length[i] << std::endl;
	}
	*/
	int total_code_length = 0;
	for (int i=0; i<input.length(); i++) {
		total_code_length += code_length[input[i]-LOWERCASE_OFFSET];
	}
	std::cout << total_code_length << std::endl;
	
	return 0;
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  
  int pre_t = 0, pre_x = 0, pre_y = 0;
  rep(i, n){
    int t, x, y;
    cin >> t >> x >> y;
    ll dist = abs(pre_x - x) + abs(pre_y - y);
    int delt_t = t - pre_t;
    if(delt_t < dist){
      cout << "No" << endl;
      return 0;
    }
    if(dist % 2 != delt_t % 2){
      cout << "No" << endl;
      return 0;
    }
    pre_t = t;
    pre_x = x;
    pre_y = y;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
*a, = map(int, input().split())
*b, = map(int, input().split())

knock = 0
ex = 0
for i in range(n):
    if a[i] < b[i]:
        ex = b[i] - a[i]
        knock += a[i]
    else:
        ex = 0
        knock += b[i]

    if ex != 0:
        if a[i+1] - ex <= 0:
            knock += a[i+1]
            a[i+1] = 0
        else:
            knock += ex
            a[i+1] -= ex

print(knock)


Measured memory_bytes: 18476
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;

int main()
{
	int N; cin >> N;
	vector<pair<int, int>> R(N);
	for (int i = 0; i < N; ++i) {
		int x, l; cin >> x >> l;
		R[i] = make_pair(x - l, x + l);
	}
	auto cmpr = [](pair<int, int> a, pair<int, int> b) {
		if (a.second != b.second) return a.second < b.second;
		else return a.first < b.first;
	};
	sort(R.begin(), R.end(), cmpr);
	int ans = 0;
	int cur = 1 << 31; cur *= -1;
	for (int i = 0; i < N; ++i) {
		if (cur > R[i].first) continue;
		cur = R[i].second;
		++ans;
	}
	cout << ans << endl;
}


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

int main()
{
    string S;
    cin >> S;

    for( int i = S.length()-2; 0 < i; i-=2 ){
        string ss = S.substr(0, i);        
        int len = ss.length();
        if( ss.substr(0, len/2) == ss.substr(len/2, len) ){
            cout << len << endl;
            break;
        }
    }


    return 0;
}


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

using namespace std;

using ll = long long;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n)  rep(i,0,n)

const double EPS = 1e-5;
const int MOD = 1e9+7;

int main(){
  int n;

  cin >> n;

  cout << pow(n,3) << endl;

  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

struct trie
{
	int nxt[26], cnt[26];
	trie() : nxt{}, cnt{} {}
} node[1111111];

vector<string> S;
int node_cnt, V[1000000];
long long ans;

void add_trie(const string &s)
{
	int p=0, j=s.back()-'a', N=s.size()-1;
	for(int i=0;i<N;i++) {
		for(int c=0;c<26;c++) if(V[i]&(1<<c)) node[p].cnt[c]++;
		if(node[p].nxt[s[i]-'a']==0) node[p].nxt[s[i]-'a']=++node_cnt;
		p=node[p].nxt[s[i]-'a'];
	}
	ans+=node[p].cnt[j];
	for(int c=0;c<26;c++) if(V[N]&(1<<c)) node[p].cnt[c]++;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N; S.resize(N);
	for(int i=0;i<N;i++) cin>>S[i];
	sort(S.begin(),S.end(),[](const string &a, const string &b){return a.size()>b.size();});
	for(auto &s: S) {
		reverse(s.begin(),s.end());
		V[s.size()-1]=1<<(s.back()-'a');
		for(int i=s.size()-2;i>=0;i--) V[i]=V[i+1]|(1<<(s[i]-'a'));
		add_trie(s);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 235196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int a;
	std::cin >> a;
	std::cout << a*a*a << std::endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var M = NextInt;
        var D = NextInt;
        var c = 0;
        for (int m = 1; m <= M; m++)
        {
            for (int d = 1; d <= D; d++)
            {
                var d1 = d % 10;
                var d10 = d / 10;
                if (2 <= d1 && 2 <= d10 && d1 * d10 == m) c++;
            }
        }
        Console.WriteLine(c);
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


Measured memory_bytes: 11092
import numpy as np

n, w = map(int, input().split())
DP = np.zeros((n, w + 1), dtype="int64")
for i in range(n):
    weight, value = map(int, input().split())
    DP[i, :weight] = DP[i - 1, :weight]
    DP[i, weight:] = np.fmax(DP[i - 1, weight:], DP[i - 1, : w - weight + 1] + value)

print(DP[-1][w])

Measured memory_bytes: 91948
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = 0;
    if (b <= a + 2 || k < a){
        ans = k + 1;
    }else{
        k -= a - 1;
        ans = a;
        ans += (b - a) * (k / 2);
        if (k % 2) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts arr[n - 1]


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

const int KMAX = 100005;
const int NMAX = 105;

int dp[KMAX][5];
int a[NMAX],top;
int minim = 1e5+5,N,K;
//dp[i] = given a pile of i stones => 1 if Jiro wins,2 if Taro wins
//player = 1 = Jiro , 2 = Taro
//it doesn't work recursively???

inline int DFS(int node,int player)
{
    int i;
    if(dp[node][player])
        return dp[node][player];
    if(node < minim)
    {
        dp[node][player] = ((player-1)^1)+1;
        return dp[node][player];
    }
    else
    {
        bool ok = 0;
        for(i = 1 ; !ok && i <= N ; ++i)
        {
            if(node - a[i] >= 0)
            {
                if(player == DFS(node-a[i] , ((player - 1)^1)+1))
                    dp[node][player] = player,ok = 1;
            }
        }
        if(!ok)
            dp[node][player] = ((player- 1)^1)+1;
        return dp[node][player];
    }
}

int main()
{
    int i,j;
    cin>>N>>K;
    for(i = 1 ; i <= N ; ++i)
    {
        cin>>a[i];
        minim = min(a[i] , minim);
    }

    if(DFS(K,2) == 1)
        cout<<"Second";
    else
        cout<<"First";

    return 0;
}




Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n;
  int c = 10000000000;
  
  for (int i = 0; i < n; i++) {
    cin >> a;
    int d = 0;
    while (a%2 == 0) {
      d++;
      a = a/2;
    }
    if (d < c)
      c = d;
  }
 
  cout << c << endl;
}

Measured memory_bytes: 256
import sys

def solve():
    N = int(input())
    S = input()
    sdict = dict()
    lens = len(S)
    for i in range(lens): sdict[i] = S[i]
    
    DP = [[0 for j in range(lens)] for i in range(lens - 1)]
    maxlength = 0
    for i in reversed(range(lens - 1)):
        for j in reversed(range(i + 1, lens)):
            if sdict[i] == sdict[j]:
                if j == lens - 1: DP[i][j] = 1
                else: DP[i][j] = DP[i+1][j+1] + 1
                maxlength = max(maxlength, min(DP[i][j], j - i))

    print(maxlength)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 248072
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int a, b, c, d, e;
	string s, ss, sss;
	cin >> a>>b>>c;
	cout<<  (a*b>c?c:a*b) <<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			h = scanner.nextInt();
			w = scanner.nextInt();
			if ((h | w) == 0)
				break;
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] == 'A') {
						ay = i;
						ax = j;
					} else if (map[i][j] == 'B') {
						by = i;
						bx = j;
					}
				}
			}
			int[][] dp = new int[h][w];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 30);
			Deque<Point> deque = new ArrayDeque<Main.Point>();
			deque.push(new Point(ay, ax, 0));
			dp[ay][ax] = 0;
			while (!deque.isEmpty()) {
				Point p = deque.poll();
				int y = p.y;
				int x = p.x;
				int step = p.step;

				for (int[] m : move) {
					int ny = y + m[0];
					int nx = x + m[1];
					if (!isOK(ny, nx))
						continue;
					if (map[ny][nx] == '#')
						continue;
					if (dp[ny][nx] <= step + 1)
						continue;
					dp[ny][nx] = step + 1;
					deque.offer(new Point(ny, nx, step + 1));
				}

			}
			char[] p = scanner.next().toCharArray();
			int e;
			for (e = 0; e < 1000; e++) {
				if (dp[by][bx] <= e)
					break;
				char o = p[e % p.length];
				int ny = by + (o == '2' ? 1 : 0) - (o == '8' ? 1 : 0);
				int nx = bx + (o == '6' ? 1 : 0) - (o == '4' ? 1 : 0);
				if (!isOK(ny, nx))
					continue;
				by = ny;
				bx = nx;
			}
			System.out.println(e < 1000 ? e + " " + by + " " + bx
					: "impossible");
		}
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int ay, ax, by, bx, h, w;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

	}
}

Measured memory_bytes: 24364
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pb(a) push_back(a)
#define in(a) insert(a)
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;


void Main() {
  int n,m;
  cin >> n >> m;
  ll d[n],e[m];
  mem(d);
  rep(i,m) R e[i];
  rep(i,m-1) {
    d[min(e[i],e[i+1])-1]++;
    d[max(e[i],e[i+1])-1]--;
  }
  ll x=0,ans=0;
  rep(i,n-1) {
    x+=d[i];
    int a,b,c;
    cin >> a >> b >> c;
    ans+=min(a*x,b*x+c);
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);Main();
  return 0;
}


Measured memory_bytes: 2772
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s,t;
    cin >> s;
    cin >> t;
    int a, b;
    cin >> a;
    cin >> b;
    string u;
    cin >> u;

    if(s == u) {
        --a;
    }else{
        --b;
    }
    cout << a << " " << b << endl;

    return 0;
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a,b;
    cin>>a>>b;
    cout<<a-b+1<<endl;
}

// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int q1 = sc.nextInt();
			if(q1==0) break;
			
			int b = sc.nextInt();
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int q2 = sc.nextInt();
			
			int ansA = -1;
			int ansB = -1;
			if(c1>c2 && (double)b/c2<q1);
			else{
				for(int i=q2;i>0;i--){
					if(b-c1*i>=0 && i+(b-c1*i)/c2>=q1){
						ansA = i;
						ansB = (b-c1*i)/c2;
						break;
					}
				}
			}
			
			if(ansA==-1) System.out.println("NA");
			else System.out.println(ansA + " " + ansB);
		}	
	}	
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a = 0;
    rep(i, m) {
        ll ai;
        cin >> ai;
        a += ai;
    }
    if (a > n) {
        cout << -1 << endl;
    } else {
        cout << n - a << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;

int main() {
	cin >> N;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (N == i*j) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    A.sort()
    dic = {}
    
    for i,val in enumerate(A):
        if val in dic:
            dic[val] += 1
        else:
            dic[val] = 1
            
    delet = []
    for k, v in dic.items():
        if v > 1:
            tmp = v - 1
            for _ in range(tmp):
                delet.append(k)
                
    tmp = -(-len(delet) // 2)
    ans = N
    ans = ans - (tmp * 2)
        
    print(ans)
    
            
            
if __name__ == "__main__":
	main()


Measured memory_bytes: 65456
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>

const long long INF = 1e13;

int main() {
	int n; std::cin >> n;
	std::vector<int> a(n);
	for (auto& x: a) {
		std::cin >> x;
	}

	int parity = n % 2;

	std::vector<std::vector<long long>> dp(n, std::vector<long long>(n));
	for (int i = n - 1; i >= 0; i--) {
		if (parity == 0) {
			dp[i][i] = -a[i];
		} else {
			dp[i][i] = a[i];
		}

		for (int j = i + 1; j < n; j++) {
			int curr_parity = (j - i + 1) % 2;

			//  Compute accordingly
			if (curr_parity == parity) {
				dp[i][j] = std::max(a[i] + dp[i + 1][j], a[j] + dp[i][j - 1]);
			} else {
				dp[i][j] = std::min(-a[i] + dp[i + 1][j], -a[j] + dp[i][j - 1]);
			}
		}
	}
	std::cout << dp[0][n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
#include <regex>
using namespace std;

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

	x = b - a;
	cout << (x * (x - 1) / 2) - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  set<char> st;
  rep(i, s.size()) st.insert(s[i]);

  cout << (s.size() == st.size() ? "yes" : "no") << endl;

  return 0;
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int a, b;

int main()
{
	scanf("%d%d", &a, &b);

	if(a==b) {
		printf("Draw\n");
	} else if(a==1) {
		printf("Alice\n");
	} else if(b==1) {
		printf("Bob\n");
	} else if(a>b) {
		printf("Alice\n");
	} else {
		printf("Bob\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll cnt1(ll a) {
	ll rv = 0;
	while (a) {
		if (a % 2) rv++;
		a /= 2;
	}
	return rv;
}
ll getval(ll a, ll b) {
	if (a > b) return LL_INF;
	
	ll rv = cnt1(a);
	for (; a <= b; a += a & (-a)) rv = min(rv, cnt1(a));
	return rv;
}
map < vector<ll>, pll> Mx;
void mpush(vector<ll> Vu, ll K) {
	if (K < 0) return;
	vector <ll> Vu2;
	for (int i = 0; i < Vu.size(); i++) Vu2.push_back(Vu[i] - Vu[0]);
	if (!Mx.count(Vu2)) Mx[Vu2] = pll(LL_INF, -1);
	Mx[Vu2].second = max(Mx[Vu2].second, Vu[0]);
	Mx[Vu2].first = min(Mx[Vu2].first, max(0ll, Vu[0] - K));
}

vector<ll> Vin;
int main() {
	int N, i, j;
	ll K;
	scanf("%d %lld", &N, &K);
	for (i = 0; i < N; i++) {
		ll t;
		scanf("%lld", &t);
		Vin.push_back(t);
	}
	sort(all(Vin));
	Vin.erase(unique(all(Vin)), Vin.end());

	j = 0;
	for (ll t = 1;; t *= 2) {
		vector <ll> Vu;
		vector <pll> Vu2;
		for (i = 0; i < N; i++) {
			Vu.push_back(Vin[i] / t);
			Vu2.emplace_back(Vin[i] % t, i);
		}
		sort(all(Vu2));
		mpush(Vu, K - j);
		for (i = 0; i < N; i++) {
			if (Vu[Vu2[i].second]-- == 0) break;
			if (i + 1 == N || Vu2[i].first != Vu2[i + 1].first) {
				ll s = Vu2[i].first + 1;
				ll e = t - 1;
				if (i + 1 != N) e = Vu2[i + 1].first;
				mpush(Vu, K - j - getval(s, e));
			}
		}
		if (t > Vin.back()) break;
		j++;
	}
	
	ll ans = 0;
	for (auto it : Mx) {
		//printf("(");
		//for (auto it2 : it.first) printf("%lld ", it2);
		//printf(") : %lld %lld\n", it.second.first, it.second.second);
		ans += it.second.second - it.second.first + 1;
		ans %= MOD;
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 16128
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

#define MAX(a, b) ((a>b) ? a : b)
#define MAX3(a, b, c) (MAX(MAX(a, b), c))

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", MAX3(a+b, a-b, a*b));
  return 0;
}


Measured memory_bytes: 128
s=input()
s=list(s)
n=len(s)
acnt=1
bcnt=1
flag=False
for i in range(n):
    if i!=n-1 and s[i]==s[i+1]:
        flag=True
        a=s[:]
        if s[i]=='0':
            s[i]='1'
        else:
            s[i]='0'
        for j in range(n):
            if j!=n-1 and s[j]==s[j+1]:
                if s[j]=='0': 
                    s[j+1]='1'
                    acnt+=1
                else:
                    s[j+1]='0'
                    acnt+=1
                        
        if a[i]=='0':
            a[i+1]='1'
        else:
            a[i+1]='0'
        for k in range(n):
            if k!=n-1 and a[k]==a[k+1]:
                if a[k]=='0':
                    a[k+1]='1'
                    bcnt+=1
                else:
                    a[k+1]='0'
                    bcnt+=1
                    
        break
if n==1 or flag==False: print(0)
else: print(min(bcnt,acnt))

Measured memory_bytes: 4780
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, x, max;
    int a, b, c;
    int ans;
    
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
        
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 2028
s = input()
n = len(s)-1
ls = list()

for bit in range(2**n):
    s_calc = s
    for i in reversed(range(n)):
        if (1 << i) & bit:
            ls.append(int(s_calc[i+1:]))
            s_calc = s_calc[:i+1]
    if s_calc:
        ls.append(int(s_calc))
print(sum(ls))

Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 5000 + 10;

int n, m, s[mx];
int dep[mx][mx];
bool sudah[mx][mx];

vector<int> g[mx];

int lev[mx];
vector<vector<int>> ve;
vector<int> tmp;
void dfs(int now, int a){
    lev[now] = a;
    tmp.pb(now);
    for(int i : g[now]){
        if(lev[i] == -1) dfs(i, a ^ 1);
        else if(lev[i] == a){
            cout << 0 << endl;
            exit(0);
        }
    }
}

int idx = 0, a[mx], b[mx];
int pref[mx];
int dp(int now, int satu){
    int dua = 0;
    if(now > 0) dua = pref[now - 1] - satu;
    if(max(satu, dua) > m) return 0;
    if(now == idx) return 1;
    int &ret = dep[now][satu];
    if(sudah[now][satu]) return ret;
    ret = 0;
    sudah[now][satu] = 1;
    ret = (ret + dp(now + 1, satu + a[now])) % MOD;
    ret = (ret + dp(now + 1, satu + b[now])) % MOD;
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> s[i];
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(s[i] > s[j]){
                g[i].pb(j);
                g[j].pb(i);
            }
        }
    }
    reset(lev, -1);
    
    for(int i = 1; i <= n; i++){
        if(lev[i] == -1){
            tmp.clear();
            dfs(i, 0);
            if(idx > 0) pref[idx] += pref[idx - 1];
            pref[idx] += sz(tmp);
            for(int x : tmp){
                if(lev[x] == 0) a[idx] += 1;
                else b[idx] += 1;
            }
            idx += 1;
        }
    }
    cout << dp(0, 0) << endl;
}


Measured memory_bytes: 71704
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

vc = []
for i, j in zip(v, c):
    vc.append(i-j)
vc = sorted(vc, reverse=True)
ans = 0
for i in vc:
    if i <= 0:
        break
    ans += i
print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  string s ;
  cin >> s ;
  cout << s.substr(0,4)<<" "<<s.substr(4,8)<<endl ;


  return 0 ;
}




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

typedef long long ll;
const int MOD = 1000000007;

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx;
  int y = ty - sy;
  for(int i = 0; i < y; i++){
    cout << 'U';
  }
  for(int i = 0; i < x; i++){
    cout << 'R';
  }
  for(int i = 0; i < y; i++){
    cout << 'D';
  }
  for(int i = 0; i < x; i++){
    cout << 'L';
  }
  cout << 'L';
  for(int i = 0; i < y + 1; i++){
    cout << 'U';
  }
  for(int i = 0; i < x + 1; i++){
    cout << 'R';
  }
  cout << "DR";
  for(int i = 0; i < y + 1; i++){
    cout << 'D';
  }
  for(int i = 0; i < x + 1; i++){
    cout << 'L';
  }
  cout << 'U' << endl;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
if b-a+1 <= k*2:
	for i in range(a,b+1):
		print(i)
else:
	list=[]
	for i in range(a,a+k):
		list.append(i)
	for i in range(b-k+1,b+1):
		list.append(i)
	for i in list:
		print(i)
	

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

const ll inf = 0x3f3f3f3f3f3f3f3f;
const int mx = 100005;

ll dist[mx];
vector<pair<ll, int> > adj[mx];
bitset<mx> inq;
int v, e, r;
int q[mx], qh, qt, ct = 0;

int qpop() {
  int v = q[qh++];
  if (qh > mx) qh = 0;
  return v;
}

void qpush(int v) {
  ct++;
  q[qt++] = v;
  if (qt > mx) qt = 0;
}

int main() {
  qh = qt = 0;
  cin >> v >> e >> r;
  for (int i = 0; i < v; i++)
    dist[i] = inf;
  for (int i = 0; i < e; i++) {
    int s, t, d; cin >> s >> t >> d;
    adj[s].push_back({ d, t });
  }
  dist[r] = 0;
  qpush(r);
  while (qh != qt) {
    if (ct > 2 * v * e + 5) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    int p = qpop();
    inq[p] = false;
    for (auto h : adj[p]) {
      int t = h.second;
      ll d = h.first + dist[p];
      if (d < dist[t]) {
	dist[t] = d;
	if (!inq[t])
	  inq[t] = true, qpush(t);
      }
    }
  }
  for (int i = 0; i < v; i++) {
    if (dist[i] < inf / 2) cout << dist[i] << endl;
    else cout << "INF" << endl;
  }
}



Measured memory_bytes: 5864
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

int N, A[202020], B[202020];
int AA[202020], BB[202020];



int check(int d) {
	int msk = 1 << d;
	vector<int>AA(N);
	vector<int>BB(N);
	rep(i, 0, N) { 
		AA[i] = A[i] % (msk * 2); 
		BB[i] = B[i] % (msk * 2);
	}
	sort(BB.begin(), BB.end());


	int cnt = 0;
	rep(i, 0, N) {
		int s_1 = lower_bound(BB.begin(),BB.end(),2*msk-AA[i])-BB.begin();
		int t_1 = lower_bound(BB.begin(), BB.end(),msk-AA[i])-BB.begin();
		int s_2 = lower_bound(BB.begin(), BB.end(), 4 * msk-AA[i])-BB.begin();
		int t_2 = lower_bound(BB.begin(), BB.end(), 3 * msk-AA[i])-BB.begin();
		cnt += (s_1-t_1)+(s_2-t_2);
	}


	if (cnt % 2 != 0)return 1;
	else return 0;
}



int main() {
	cin >> N;
	rep(i, 0, N)cin >> A[i];
	rep(i, 0, N)cin >> B[i];

	int ans = 0;
	rep(d, 0, 29)if (check(d))ans += 1 << d;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH, vector<bool>& visited)
{
  visited[V] = 1;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    int V_n = GRAPH[V][i];
    if(visited[V_n] == 0)
    DFS(V_n,GRAPH,visited);
  }
  return;
}
void solve(void)
{
  int N,M;
  cin>>N>>M;

  vector<pair<int,int> > EDGE(M);
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;
    B--;
    EDGE[i].first = A;
    EDGE[i].second = B;
  }
  int ANS = 0;
  for (int i = 0; i < M; i++)
  {
    vector<vector<int> > GRAPH(N);
    vector<bool> visited(N,0);

    for (int j = 0; j < M; j++)
    {
      if(i == j) continue;
      int A,B;
      A = EDGE[j].first;
      B = EDGE[j].second;
      GRAPH[A].push_back(B);
      GRAPH[B].push_back(A);
    }
    bool check = 1;
    DFS(0,GRAPH,visited);
    for (int i = 0; i < visited.size(); i++)
    {
      check *= visited[i];
    }
    if(check == 0)ANS++; 
  }
  cout<<ANS<<endl;
  
  
  
  
  return;

   
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>

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

using namespace std;

int n;
char s[101];

bool is_vowel(int i){
	return s[i]=='a' || s[i]=='i' || s[i]=='u' || s[i]=='e' || s[i]=='o';
}

bool is_voiceless_consonant(int i){
	return s[i]=='k' || s[i]=='s' || s[i]=='t' || s[i]=='h' || s[i]=='p';
}

bool is_voiceless_vowel(int i){
	if(s[i]=='i' || s[i]=='u'){
		return (i>0 && is_voiceless_consonant(i-1)
			||  i>1 && is_voiceless_consonant(i-2) && s[i-1]=='y')
			&& (i==n-1 || is_voiceless_consonant(i+1));
	}
	else if(s[i]=='a' || s[i]=='o'){
		return (i>0 && is_voiceless_consonant(i-1)
			||  i>1 && is_voiceless_consonant(i-2) && s[i-1]=='y')
			&& (i<n-2 && is_voiceless_consonant(i+1) && s[i+2]==s[i]
			||  i<n-3 && is_voiceless_consonant(i+1) && s[i+2]=='y' && s[i+3]==s[i]);
	}
	else return false;
}

int main(){
	for(;scanf("%s",s),s[0]!='#';){
		n=strlen(s);
		bool pre=false;
		rep(i,n){
			if(is_vowel(i)){
				if(!pre && is_voiceless_vowel(i)){
					putchar('(');
					putchar(s[i]);
					putchar(')');
					pre=true;
				}
				else{
					putchar(s[i]);
					pre=false;
				}
			}
			else putchar(s[i]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 0