akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s1: Vec<_> = scan!().chars().collect();
    let s2: Vec<_> = scan!().chars().collect();
    let s3: Vec<_> = scan!().chars().collect();

    let mut b = 'a';
    let (mut i, mut j, mut k) = (0, 0, 0);
    loop {
        match b {
            'a' => {
                if i == s1.len() {
                    println!("A");
                    return;
                }
                b = s1[i];
                i += 1
            }
            'b' => {
                if j == s2.len() {
                    println!("B");
                    return;
                }

                b = s2[j];
                j += 1
            }
            'c' => {
                if k == s3.len() {
                    println!("C");
                    return;
                }

                b = s3[k];
                k += 1
            }
            _ => (),
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (bool t = true; ; t = !t) {
        if (t) {
            c -= b;
        } else {
            a -= d;
        }
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        } else if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

vector<int>E[300000];
ll ans[300000];
ll cnt[300000];

void dfs(int v,int p,ll d){
	ans[v]=cnt[v]+d;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,ans[v]);
	}
}
int main(){
	int n,q;cin>>n>>q;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	rep(i,q){
		int p,x;scanf("%d%d",&p,&x);p--;
		cnt[p]+=x;
	}
	dfs(0,-1,0);
	rep(i,n){
		cout<<ans[i]<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 29056
import java.io.*;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      final int MAX = 100000;
      int n = Integer.parseInt(in.readLine());

      int[] table = new int[MAX+1];
      in.lines()
        .limit(n)
        .map(s -> s.split(" "))
        .map(a -> Arrays.stream(a).parallel().mapToInt(Integer::parseInt).toArray())
        .forEach(a -> IntStream.rangeClosed(a[0],a[1])
          .parallel()
          .forEach(i -> table[i] = 1)
        );

      final int ans = Arrays.stream(table).sum();
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main() {
    int n;cin >> n;
    vector<int> A(n+5);
    int ans = 0;
    for(int i = 1; i <= n; i++)cin >> A[i];
    for(int i = 1; i <= n; i++)if(i%2 == 1 && A[i]%2 == 1)ans++;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  long double ra = sqrt(a);
  long double rb = sqrt(b);
  long double rc = sqrt(c);
  long double eps = 1.0e-14;
  Yes(rc - (ra + rb) >= eps);

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input()
print(a)
a = [int(x) for x in a.split(' ')]

for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
    print(' '.join([str(x) for x in a]))

Measured memory_bytes: 7688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	for (int i = 0; i < (int)s.length(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			cout << "No\n";
			return 0;
		}
		if (i % 2 == 1 && s[i] == 'R') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

	return 0;
}


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

int main(void){
    ll N,A;
    cin >> N;
    map<ll,ll> m,l;
    ll ans = 0;
    REP(i,N){
        cin >> A;
        ans +=m[i - A];
        m[A + i]++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vector<pint> ab(n), cd(n);

    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    rep(i, n)
    {
        int c, d;
        cin >> c >> d;
        cd[i] = make_pair(c, d);
    }

    sort(ALL(ab));
    sort(ALL(cd));
    auto itr = ab.begin();

    set<pint> s;
    int ans = 0;

    for (const auto blue : cd)
    {
        while (itr != ab.end() && (*itr).first < blue.first)
        {
            s.insert(*itr);
            ++itr;
        }

        pint p = {-1, -1};
        for (auto red : s)
        {
            if (red.second < blue.second)
            {
                if (p.first == -1)
                {
                    p = red;
                }
                else
                {
                    if (p.second < red.second)
                    {
                        p = red;
                    }
                }
            }
        }
        if (p.first != -1)
        {
            ++ans;
            s.erase(s.find(p));
        }
    }

    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int a, b;
int main() {
	//x * 8/100 = a
	//x * 2/25 = a
	//x = (25 * a) / 2
	//G[x] = (25 * a + 1) / 2
	//x = 10 * b
	scanf("%d %d", &a, &b);
	int c = max((25 * a + 1) / 2, b * 10);
	if (c * 8 / 100 == a && c / 10 == b)
		printf("%d\n", c);
	else
		printf("-1\n");
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static final int MAX = 100;

    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int h = scn.nextInt(), w = scn.nextInt();
        int[] ary = new int[MAX];
        int[][] tbl = new int[MAX][MAX];
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; tbl[i][j++] = scn.nextInt());
        }
        for(int i = 0; i < w; ary[i++] = scn.nextInt());
        for(int i = 0; i < h; i++) {
            int v = 0;
            for(int j = 0; j < w; v += tbl[i][j] * ary[j++]);
            System.out.println(v);
        }
    }
}

Measured memory_bytes: 31872
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	set<string> st;
	for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
	}
	cout << st.size();
	return 0;
}


Measured memory_bytes: 19228
#include<stdio.h>

#define MAX 44

int main(){
  int A[MAX],n,i;

  scanf("%d",&n);

  A[0] = A[1] = 1;

  for(i=2;i<=n;i++)
    A[i] = A[i-1] + A[i-2];

  printf("%d\n",A[n]);
  return 0;
}

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

int main(){
  int N,M; cin >> N >> M;
  vector<int> L(M,0),R(M,0);
  int maxL = 0,minR = 10000001;
  for(int i = 0; i < M; i++){
      cin >> L.at(i);
      cin >> R.at(i);
      maxL = max(maxL,L.at(i));
      minR = min(minR,R.at(i));
  }
  
  int ans = minR - maxL + 1;
  if(ans < 0) ans = 0;
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

vector<string> a = {"AC", "WA", "TLE", "RE"};

void solve() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  for (string s: a) {
    cout << s << " x " << mp[s] << endl;
  }
}

int main() {
  solve();
  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    int a[1001][1001] = {};
    int cnt = 0;

    if( N%2 )
        Rep(i,M){
            printf ("%lld %lld\n", i+1, N-i-1);
            Rep(j,N){
                a[(i+j)%N][(N-i-2+j)%N]++;
                a[(N-i-2+j)%N][(i+j)%N]++;
            }
        }
    else{
        int k = 0;
        Rep(i,M){
            if( N-i-i-1 <= N/2 ) k = 1;
            printf ("%lld %lld\n", i+1, N-i-k );
            Rep(j,N){
                a[(i+j)%N][(N-i-1+j-k)%N]++;
                a[(N-i-1+j-k)%N][(i+j)%N]++;
            }
        }
    }


    return 0;
}



Measured memory_bytes: 3828
import kotlin.math.pow

fun main(args: Array<String>) {
    //val people_count = 7
    //val coordinates = arrayOf(14, 14, 2, 13, 56, 2, 37).sorted()
    val people_count = readLine()!!.toInt()
    val coordinates = readLine()!!.split(" ").map { it.toInt() }

    val answer = (1..100).map { temp_p ->
        coordinates.map { (it - temp_p).toDouble().pow(2).toInt() }.sum()
    }.min()


    println("$answer")
}


Measured memory_bytes: 36760
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
   int A,B,M;
   cin>>A>>B>>M;
   int Mini_a=200000;
   int Mini_b=200000;
   vector<int> a(A),b(B);
   for(int i=0;i<A;i++){
      cin>>a[i];
      Mini_a=min(Mini_a,a[i]);
   }
   for(int i=0;i<B;i++){
      cin>>b[i];
      Mini_b=min(Mini_b,b[i]);
   }
   vector<int> x(M),y(M),c(M);
   for(int i=0;i<M;i++){
      cin>>x[i]>>y[i]>>c[i];
   }
   int ans=1000007;
   for(int i=0;i<M;i++){
      int sum=a[x[i]-1]+b[y[i]-1]-c[i];
      ans=min(ans,sum);
   }
   cout<<min(ans,Mini_a+Mini_b)<<endl;
   return 0;
}

Measured memory_bytes: 5000
#include <stdio.h>

int main() {

  int i, x[10001];
  i = 0;
  while(1) {
    scanf("%d", &x[i]);
    if ( x[i] == 0 )
      break;
    i++;
  }
  
  i = 0;
  while(1) {
    if ( x[i] == 0 )
      break;
    printf("Case %d: %d\n", i + 1, x[i]);
    i++;
  }

  return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

set<int>s[200005];
int mm[200005];

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

  int n,k;
  cin>>n>>k;
  int a[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s[a[i]].insert(i);    
  }
  int cnt=1;
  int z=0;
  while (cnt<k && mm[z]==0)
  {
    mm[z]=cnt;
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      if(k==cnt)
        break;
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      cnt++;
      if(z==n)
      {
        z=0;
        cnt++;        
      }
      if(cnt==k)
      {
        break;
      }
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        cnt++;
      }
    }    
  }

  if(cnt==k+1)
    return 0;
  if(mm[z]==0)
  {
    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      
    return 0;
  }
  else
  {
    int per=cnt-mm[z];
    k-=mm[z];
    k%=per;
  }

  while (k>0)
  {
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      k--;
      if(z==n)
      {
        z=0;
        k--;
        if(k==-1)
          return 0;
      }
      if(k==0)
        break;
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        k--;
      }
    }    
  }

    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      

}


Measured memory_bytes: 27200
import sys
read=sys.stdin.buffer.readline

class BIT:
    def __init__(self,N):
        self.N=N
        self.bit=[0]*N
    def add(self,a,w):
        x=a
        while(x<self.N):
            self.bit[x]+=w
            x|=x+1
    def get(self,a):
        ret,x=0,a-1
        while(x>=0):
            ret+=self.bit[x]
            x=(x&(x+1))-1
        return ret
    def cum(self,l,r):
        return self.get(r)-self.get(l)

def update(x,i):
    if good[x]==-1:
        good[x]=i
        bit.add(i,1)
    else:
        bit.add(good[x],-1)
        good[x]=i
        bit.add(good[x],1)
    return
    
N,Q=map(int,read().split())
c=tuple(map(int,read().split()))
Query=[]
for i in range(Q):
    l,r=map(lambda x:int(x)-1,read().split())
    Query.append(r*10**12+l*10**6+i)
Query.sort()
ans=[-1]*Q
good=[-1]*(N+1)
bit=BIT(N)

i=0
for w in Query:
    R=w//10**12
    w%=10**12
    L=w//10**6
    w%=10**6
    while(i<=R):
        update(c[i],i)
        i+=1
    ans[w]=bit.cum(L,R+1)

print(*ans,sep='\n')

Measured memory_bytes: 184796
class TreasureHunter
  def initialize
    @x = 0
    @y = 0
    @deg = 0
  end

  def to_rad(deg)
    return Math::PI * deg / 180.0
  end
  
  def walk(distance)
    @x += Math.sin(to_rad(@deg)) * distance
    @y += Math.cos(to_rad(@deg)) * distance
  end

  def turn(direction)
    @deg += direction
  end

  def dumpXY
    return [@x.to_i, @y.to_i]
  end
end

t = TreasureHunter.new
$<.each_line do |line|
  distance, direction = line.split(/,/).map(&:to_i)
  t.walk(distance)
  t.turn(direction)
end
puts t.dumpXY

Measured memory_bytes: 8880
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        double a = 0.0;
        double b = 0.0;
        double c = 0.0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (x == 1) {
                a++;
            } else if (x == 2) {
                b++;
            } else if (x == 3) {
                c++;
            }
        }
        double[][][] dp = new double[310][310][310];
        for (int i = 0; i < 310; i++) {
            for (int j = 0; j < 310; j++) {
                for (int k = 0; k < 310; k++) {
                    dp[i][j][k] = -1.0;
                }
            }
        }
        System.out.println(solve(dp, a, b, c, n));
    }

    private static double solve(double[][][] dp, double a, double b, double c, double n) {
        if ((a + b + c) == 0) {
            return 0.0;
        }
        if (dp[(int) a][(int) b][(int) c] >= 0) {
            return dp[(int) a][(int) b][(int) c];
        }
        double ret = (n / (a + b + c));
        if (a > 0) {
            ret += (solve(dp, a - 1, b, c, n)) * (a / (a + b + c));
        }
        if (b > 0) {
            ret += (solve(dp, a + 1, b - 1, c, n)) * (b / (a + b + c));
        }
        if (c > 0) {
            ret += (solve(dp, a, b + 1, c - 1, n)) * (c / (a + b + c));
        }
        return dp[(int) a][(int) b][(int) c] = ret;
    }
}


Measured memory_bytes: 303804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	string s;
	rep(i,h){
		rep(j,w){
			cin >> s;
			if(s=="snuke"){
				char c='A'+j;
				cout << c << i+1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
n = gets.chomp.to_i
t, a = gets.split(" ").map(&:to_i)
ary = gets.split(" ").map(&:to_i)
tmp = []

n.times do |i|
    tmp << t - ary[i] * 0.006
end

puts tmp.index(tmp.min_by{|x| (x - a).abs}) + 1


Measured memory_bytes: 3836
X = int(input())
if (400<=X<=599):
  print(8)
elif (600<=X<=799):
  print(7)
elif (800<=X<=999):
  print(6)
elif (1000<=X<=1199):
  print(5)
elif (1200<=X<=1399):
  print(4)
elif (1400<=X<=1599):
  print(3)
elif (1600<=X<=1799):
  print(2)
elif (1800<=X<=1999):
  print(1)
else:
  print(0)
      
      
      
      
      
      
     

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int xo=0;
	FOR(i,N) {
		cin>>A[i];
		xo^=A[i];
	}
	FOR(i,N) cout<<(xo^A[i])<<" ";
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4440
#include<stdio.h>

int main()
{
	int x, y, z, hasil;
		scanf("%d %d %d", &x, &y, &z);
		hasil=x+y+z;
		if(hasil < 22){
			printf("win\n");
		}
		else if(hasil >= 22){
			printf("bust\n");
		}
	return 0;	
} 

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll gcd(ll x, ll y){
	if(x<y) swap(x, y);
	if(y==0) return x;
	return gcd(y, x%y);
}

int main(){
	ll n, m;
	string a, b;
	cin >> n >> m;
	cin >> a >> b;
	ll g = gcd(n, m), l = n*m/g;
	ll s1 = n/g, s2 = m/g;
	REP(i, g){
		if(a[i*s1]!=b[i*s2]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/perl
my ($a,$b,$c) = map { $_ - 0 } split(/\s+/,<STDIN>);
my $max_c = ( $c > ( $a + $b + 1 ) ? $a + $b + 1 : $c );
my $r = $max_c + $b;
print "$r\n";


Measured memory_bytes: 640
#include <stdio.h>

typedef struct _dice {
	int label[6];
} DICE, *PDICE;

int rotation[6][5] =
	{
		{ /* N */ 1, 2, 6, 5},
		{ /* S */ 1, 5, 6, 2},
		{ /* E */ 1, 4, 6, 3},
		{ /* W */ 1, 3, 6, 4},
		{ /* L */ 2, 3, 5, 4},
		{ /* R */ 2, 4, 5, 3}
	};

int RN[] = { 'N', 'S', 'E', 'W', 'L', 'R' };

int aid(int c) {
	switch (c) {
	case 'N': return 0;
	case 'S': return 1;
	case 'E': return 2;
	case 'W': return 3;
	case 'L': return 4;
	case 'R': return 5;
	default: return -1;
	}
}

void rotate(PDICE dice, int c) {
	int a = aid(c);
	int t, i;
	
	if (a < 0) {
		return;
	}
	
	t = dice->label[rotation[a][0] - 1];
	for (i = 0; i < 3; i++) {
		dice->label[rotation[a][i] - 1] =
			dice->label[rotation[a][i + 1] - 1];
	}
	dice->label[rotation[a][3] - 1] = t;
}

void fit(PDICE dice, int p, int n) {
	int i;
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'N');
	}
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'W');
	}
	for (i = 0; i < 4; i++) {
		if (dice->label[p] == n) {
			return;
		}
		rotate(dice, 'L');
	}
}

int matchDice(PDICE dice1, PDICE dice2) {
	int i;
	for (i = 0; i < 6; i++) {
		if (dice1->label[i] != dice2->label[i]) {
			return 0;
		}
	}
	return -1;
}

int matchDiceTurn(DICE dice1, DICE dice2, int c) {
	int i;
	for (i = 0; i < 4; i++) {
		if (matchDice(&dice1, &dice2)) {
			return 1;
		}
		rotate(&dice1, c);
	}
	return 0;
}

int main(void) {
	DICE dice1, dice2, temp;
	int i;
	int f = 1;
	
	for (i = 0; i < 6; i++) {
		scanf("%d", &dice1.label[i]);
	}

	for (i = 0; i < 6; i++) {
		scanf("%d", &dice2.label[i]);
	}
	
	if (matchDiceTurn(dice1, dice2, 'L')) {
		f = 0;
	}
	
	if (f) {
		temp = dice1;
		rotate(&temp, 'N');
		rotate(&temp, 'N');
		if (matchDiceTurn(temp, dice2, 'L')) {
			f = 0;
		}
	}
	
	if (f) {
		for (i = 0; i < 4; i++) {
			temp = dice1;
			rotate(&temp, RN[i]);
			if (matchDiceTurn(temp, dice2, 'L')) {
				f = 0;
				break;
			}
		}
	}
	

	if (!f) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 580
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = vec![];
    for _ in 0..n {
        a.push(read());
    }

    let mut head = 0;
    let mut tail = 0;
    let mut bitsum = 0;
    let mut valsum = 0;
    let mut ans = 0;

    while head < n {
        valsum += a[head];
        bitsum = bitsum ^ a[head];
        if valsum != bitsum {
            while tail < head {
                valsum -= a[tail];
                bitsum = bitsum ^ a[tail];
                tail += 1;
                if valsum == bitsum {
                    break;
                }
            }
        }
        ans += head - tail + 1;
        head += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		BigInteger max = new BigInteger("1000000000000000000");
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		if(a[0] == 0) {
			System.out.println(0);
		}else {
			BigInteger ans = BigInteger.ONE;
			for(int i = n-1; i >= 0; i--) {
				ans = ans.multiply(BigInteger.valueOf(a[i]));
				if(ans.compareTo(max) == 1) {
					ans = new BigInteger("-1");
					break;
				}
			}
			System.out.println(ans);
		}
		
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    for(int i=0;i<N;i++){
        printf("node %d: key = %d, ",i+1,a[i]);
        if(i>0) printf("parent key = %d, ",a[(i-1)/2]);
        if(2*i+1<N) printf("left key = %d, ",a[2*i+1]);
        if(2*i+2<N) printf("right key = %d, ",a[2*i+2]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int n;
ll k;
ll freq[2][55];
ll mem[55][2];

ll solve(int i, bool isAllPossible)
{
    if (i == -1)
        return 0LL;
    ll &ret = mem[i][isAllPossible];
    if (~ret)
        return ret;
    // put 0, isAllPossible 1 if k had one, win 1's
    ret = freq[1][i] * (1LL<<i) + solve(i - 1, isAllPossible|((1LL<<i)&k));
    if (isAllPossible || (1LL<<i)&k)
    {
        ret = max(ret, freq[0][i] * (1LL<<i) + solve(i - 1, isAllPossible));
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    clr(mem, -1);
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,0,n)
    {
        cin >> a[i];
        rep(j,0,50)
        {
            if ((1LL<<j) & a[i])
                freq[1][j]++;
            else
                freq[0][j]++;
        }
    }

    cout << solve(49, 0);

    return  0;

}

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

def main():
    n, a, b = map(int, input().split())
    ans = 0

    for i in range(1, n + 1):
        sum = 0
        for num in str(i):
            sum += int(num)
        if a <= sum <= b:
            ans += i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n, x, za = 0, bd = 0, ans = 0;
    cin >> n >> x;
    vector<int> l(n);
    for(int i = 0;i < n;i++){
        cin >> l[i];
    }

    ans++;

    for(int i = 0;i < n;i++){
        za += bd + l[i];
        ans++;
        if(za > x){
            ans--;
            break;
        }
    }


    cout << ans;
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X;
    while(cin>>N>>X, N!=0){
        int ans=0;
        FOR(i,1,N)FOR(j,i+1,N){
            if (j<X-(i+j) && X-(i+j)<=N){
                ans++;
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool x[1001];
int n,i,j;
int main(){
	cin>>n;
	memset(x,0,sizeof(x));
	x[1]=1;
	for(i=1;i<=31;i++){
		for(j=2;j<=10;j++){
			if(pow(i,j)<=1000){
				x[(int)(pow((double)i,(double)j))]=1;
			}
			else break;
		}
	}
	for(i=n;i>0;i--){
		if(x[i]==1){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main (void)
{ 
  int n, i;
  scanf("%d", &n);
  int array[n];
  for(i=0; i <= n-1; i++){
  	scanf("%d", &array[i]);
  }
  for(i=n-1; i >= 1; i--){
  	printf("%d ", array[i]);
  }
  printf("%d\n", array[0]);
  return 0;
}

Measured memory_bytes: 596
import heapq
from collections import deque
n , k = map(int,input().split())
v = list(map(int,input().split()))
ans = 0
for i in range(n+1):
    for j in range(n+1):
        if i+j > n or i+j > k:
            continue
        p = v[:]
        d = deque(p)
        a = []
        heapq.heapify(a)
        for t in range(i):
            heapq.heappush(a,d.popleft())
        for l in range(j):
            heapq.heappush(a,d.pop())
        nokori = k-i-j
        for s in range(nokori):
            if a:
                now = heapq.heappop(a)
                if now > 0:
                    heapq.heappush(a,now)
                    break
            else:
                break
        ans = max(ans,sum(a))
print(ans)

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

int main()
{
    std::string input;
    std::cin >> input;
    if (input.at(2) != input.at(3))
    {
        std::cout << "No";
    }
    else if (input.at(4) != input.at(5))
    {
        std::cout << "No";
    }
    else
    {
        std::cout << "Yes";
    }
    return 0;
}

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

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

auto input() {
    return InputType();
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

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

int main() {
    string s = input();
    if (s[0] == s[1] && s[1] == s[2])
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter
import itertools

mask = (1 << 10) - 1

symmetry = dict()
decode = dict()
counter = defaultdict(int)

def encode(a,b,c,d):
    t = 1 << 40
    for _ in range(4):
        a,b,c,d = b,c,d,a
        x = a + (b << 10) + (c << 20) + (d << 30)
        if t > x:
            t = x
    return t

N = int(input())
tiles = []
for _ in range(N):
    a,b,c,d = map(int,input().split())
    t = encode(a,b,c,d)
    tiles.append(t)
    counter[t] += 1
    if a == b == c == d:
        symmetry[t] = 4
    elif a == c and b == d:
        symmetry[t] = 2
    else:
        symmetry[t] = 1
    decode[t] = (a,b,c,d)

P = [(1,n,n*(n-1),n*(n-1)*(n-2),n*(n-1)*(n-2)*(n-3)) for n in range(N+1)]
P += [(0,0,0,0,0)] * (N+1) # 負数代入対策

power = [[n ** e for e in range(5)] for n in range(5)]

answer = 0
for bottom, top in itertools.combinations(tiles,2):
    counter[bottom] -= 1
    counter[top] -= 1
    a,b,c,d = decode[bottom]
    e,f,g,h = decode[top]
    for _ in range(4):
        e,f,g,h = f,g,h,e
        # a,b,c,d
        # e,h,g,f 
        tiles = [encode(p,q,r,s) for p,q,r,s in [(b,a,e,h), (c,b,h,g), (d,c,g,f), (a,d,f,e)]]
        need = Counter(tiles)
        x = 1
        for tile, cnt in need.items():
            have = counter[tile]
            if have < cnt:
                x = 0
                break
            x *= P[counter[tile]][cnt] # 残っている個数、必要枚数
            x *= power[symmetry[tile]][cnt]
        answer += x
    counter[bottom] += 1
    counter[top] += 1

# 上下を固定した分
answer //= 3
print(answer)

Measured memory_bytes: 91612
d = {
    2: 'hon',
    4: 'hon',
    5: 'hon',
    7: 'hon',
    9: 'hon',
    0: 'pon',
    1: 'pon',
    6: 'pon',
    8: 'pon',
    3: 'bon'
}

n = input()

print(d[int(n[-1])])

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define fore_(i, s, e) for(int i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int dp[3500][3500];
string s, t, rr;
int r;

int solve(int pos_s, int pos_t) {
    if(pos_s == s.length() or pos_t == t.length()) return 0; // Exito
    if(dp[pos_s][pos_t] != -1) return dp[pos_s][pos_t]; // Calculado

    int ret = 0;

    if(s[pos_s] == t[pos_t]) {
        ret = 1 + solve(pos_s + 1, pos_t + 1);
    } else {
        ret = max(solve(pos_s + 1, pos_t), solve(pos_s, pos_t + 1));
    }

    dp[pos_s][pos_t] = ret;
    return ret;
}

int main() {
    FIN;
    cin >> s >> t;
    memset(dp, -1, sizeof(dp));
    r = solve(0, 0);

    int i = 0, j = 0;
    while(rr.size() != r){
        if(dp[i][j] > -1) {
            if(s[i] == t[j]) {rr += s[i]; i++; j++;}
            else if(i < s.size() && j < t.size() && dp[i + 1][j] > dp[i][j + 1]) i++;
            else j++;
        }
    }

    cout << rr << endl;

    return 0;
}

Measured memory_bytes: 48384
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
bool bellman_ford(graph &g, Int s, vector<Int> &d){
	d.resize(g.size(), 1e18);
	d[s] = 0;
	bool updated = false;
	for(size_t i=0; i<g.size(); ++i){
		updated = false;
		for(edges j:g)
			for(edge k:j)
				if((d[k.from] + k.cost < 1e18 / 2) && d[k.from] + k.cost < d[k.to]){
					d[k.to] = d[k.from] + k.cost;
					updated = true;
				}
		if(!updated) break;
	}
	return updated;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int v, e, s; cin >> v >> e >> s;
	graph g(v);
	readgraph(g, e, true, true, true);
	vector<Int> dist;
	if(bellman_ford(g, s, dist)){
		cout << "NEGATIVE CYCLE\n";
		return 0;
	}
	for(auto i:dist) cout << (i > 1e18 / 2 ? "INF" : to_string(i)) << "\n";
}


Measured memory_bytes: 3300
#123456789
#255456376
n, m = map(int, input().split())
a = list(map(int , input().split()))
a.sort()
t = [2,5,5,4,5,6,3,7,6]
cost = []
for i in range(m):
    cost.append(t[a[i]-1])
#print(a)
#print(cost)
min_c = min(cost)
digit = n // min_c # 最大桁数
s = n % min_c # 最大桁まで作った余りの本数

max_ai = 0
import itertools
for i in itertools.product(list(range(m+1)), repeat=min(digit, 5)):
    #print(i)
    t = list(i)
    ci = sum(list(map(lambda j: cost[j-1] if j != 0 else 0, t)))
    ai = ''.join(map(lambda j: str(a[j-1]) if j != 0 else '', t))
    if digit <= 5:
        if ci == n:
            max_ai = max(max_ai, int(ai))
    else:
        if ci == (n - min_c * (digit - 5)):
            max_ai = max(max_ai, int(ai))
    #print(ci, max_ai)
min_chr = ''
for i in reversed(range(m)):
    if min_c == cost[i]:
        min_chr = a[i]
        break

if digit <= 5:
    print(max_ai)
else:
    ans = list(str(max_ai)) + ([str(min_chr)] * (digit - 5))
    ans.sort(reverse=True)
    print(''.join(ans))


"""
chg = []
while s > 0:
    #print(s, chg)
    for i in reversed(range(m)):
        if min_c + s == cost[i]:
            chg.append(a[i])
            s = 0
            break
    for i in reversed(range(m)):
        if min_c < cost[i] and cost[i] < min_c + s:
            chg.append(a[i])
            s = min_c + s - cost[i]
            break

#print(chg)
min_chr = ''
for i in reversed(range(m)):
    if min_c == cost[i]:
        min_chr = a[i]
        break

ans = chg + ([min_chr] * (d - len(chg)))
ans.sort(reverse=True)
print(''.join(map(str, ans)))
"""

Measured memory_bytes: 46428
#include<stdio.h>
#include<math.h>

int main(){

  int i,n;
  double a,u;
  double x[1001]={0};
  double y[1001]={0};
  double d1=0,d2=0,d3=0,max=0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%lf", &x[i]);
  for(i=0;i<n;i++)
    scanf("%lf", &y[i]);

  for(i=0;i<n;i++){
    d1 +=fabs(x[i]-y[i]);
    d2 +=pow(fabs(x[i]-y[i]),2);
    d3 +=pow(fabs(x[i]-y[i]),3);
    if(max<fabs(x[i]-y[i]))
      max=fabs(x[i]-y[i]);
  }

  printf("%f\n%f\n%f\n%f\n", d1, sqrt(d2), cbrt(d3), max);

  return 0;
}

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

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

	string S;
	cin >> S;
	if (S[2]==S[3] && S[4]==S[5])
	{
		cout << "Yes";
	} else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<int> d(N);
    rep(i, N) cin >> d[i];
    sort(all(d));
    int ans = 0;
    rep(i,N){
        if(i==0)++ans;
        else {
            if(d[i] != d[i-1]) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, a, b, c, d;
  double ans = 0.0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    double x;
    char s[10];
    scanf("%lf %s", &x, s);
    if(s[0] == 'J') ans += x;
    else ans += x * 380000.0;
  }
  printf("%f", ans);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#define ll long long
#define MAXN 100005
using namespace std;
template <typename T>
inline void read(T& a)
{
    T ret(0),f(1);char ch(getchar());
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){ret = ret * 10 + (ch ^ 48);ch = getchar();}
    a = ret * f;
}
inline int Min(int x,int y){return x < y ? x : y;}
inline int Max(int x,int y){return x > y ? x : y;}
struct pref
{
	int year,id;
	pref(int year = 0,int id = 0):year(year),id(id){}
	inline bool operator < (const pref& t) const
	{
		return year < t.year;
	}
};
vector<pref> a[MAXN];
int p[MAXN],y[MAXN],x[MAXN];
int main()
{
 	int n,m;
 	read(n),read(m);
	for(int i(1);i <= m;i++)
		read(p[i]),read(y[i]),a[p[i]].push_back(pref(y[i],i));
	for(int i(1);i <= n;i++)
		if(a[i].size()) sort(a[i].begin(),a[i].end());
	for(int i(1);i <= n;i++)
	{
		int k = a[i].size();
		for(int j(0);j < k;j++)
			x[a[i][j].id] = j + 1;
	}
	for(int i(1);i <= m;i++)
		printf("%06d%06d\n",p[i],x[i]);
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll dp[1005][1005];
int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=0;i<=w;++i)dp[0][i]=0;
    for(int i=0;i<=h;++i)dp[i][0]=0;
    dp[1][1]=1;
    char temp;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            cin>>temp;
            if(i==1&&j==1)continue;
            if(temp=='#')dp[i][j]=0;
            else
			{
                dp[i][j]=(dp[i-1][j]%MOD)+(dp[i][j-1]%MOD);
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 11428