akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


int main(){
    ll H,N; cin>>H>>N;
    ll a[N],b[N];
    REP(i,N){
        cin >> a[i] >> b[i];
    }
    ll dp[100000];
    REP(i,100000){
        dp[i] = MOD;
    }
    dp[0] = 0;
    REP(i,N){
        for(int hp=0;hp<H;++hp){
            if(dp[hp]<MOD){
                dp[hp+a[i]] = min(dp[hp+a[i]],dp[hp]+b[i]);
            }
        }
    }
    cout << *min_element(dp+H,dp+100000) << "\n";
}

Measured memory_bytes: 1024
class MyNode
  attr_accessor :v, :parent, :left_child, :right_child

  def initialize v, parent, left_child, right_child
    @v = v
    @parent = parent
    @left_child = left_child
    @right_child = right_child
  end
end

def insert(root_node, v)
  p = nil
  x = root_node
  while x
    p = x
    if v < x.v
      x = x.left_child
    else
      x = x.right_child
    end
  end
  node = MyNode.new(v, p, nil, nil)
  if p
    if node.v < p.v
      p.left_child = node
    else
      p.right_child = node
    end
  else
    root_node = node
  end

  return root_node
end

def find(root_node, v)
  return true if root_node.v == v
  if v < root_node.v && root_node.left_child
    return find(root_node.left_child, v)
  end
  if v > root_node.v && root_node.right_child
    return find(root_node.right_child, v)
  end
  return false
end

def get_minimum(root_node)
  get_minimum(root_node.left_child) if root_node.left_child
  root_node
end

def delete(root_node, v)
  if root_node.v == v
    if root_node.left_child.nil? && root_node.right_child.nil?
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = nil
      else
        root_node.parent.right_child = nil
      end
    elsif root_node.left_child && root_node.right_child
      successor = get_minimum(root_node.right_child)
      root_node.v = successor.v
      delete(successor, successor.v)
    elsif root_node.left_child
      root_node.left_child.parent = root_node.parent
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = root_node.left_child
      else
        root_node.parent.right_child = root_node.left_child
      end
    elsif root_node.right_child
      root_node.right_child.parent = root_node.parent
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = root_node.right_child
      else
        root_node.parent.right_child = root_node.right_child
      end
    end
    return
  end
  if v < root_node.v && root_node.left_child
    delete(root_node.left_child, v)
  end
  if v > root_node.v && root_node.right_child
    delete(root_node.right_child, v)
  end
end

def make_pre node, vs
  vs << node.v
  make_pre node.left_child, vs if node.left_child
  make_pre node.right_child, vs if node.right_child
  vs
end

def make_in node, vs
  make_in node.left_child, vs if node.left_child
  vs << node.v
  make_in node.right_child, vs if node.right_child
  vs
end

_ = gets
root = nil
while l = gets
  command, val = l.chomp.split(' ')
  if command == 'insert'
    root = insert(root, val.to_i)
  elsif command == 'print'
    puts ' ' + make_in(root, []).join(' ')
    puts ' ' + make_pre(root, []).join(' ')
  elsif command == 'find'
    puts find(root, val.to_i) ? 'yes' : 'no'
  elsif command == 'delete'
#    puts ' ' + make_in(root, []).join(' ')
    delete(root, val.to_i)
  end
end


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

int n, m;
int an[200010];
long long ans;

int cmp(int a, int b)
{
	return a > b;
}

int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> an[i];
	}
	sort(an, an + n, cmp);
	int k = 0;
	while (m--) {
		an[k++] = 0;
	}
	for (int i = 0; i < n; i++) {
		ans += an[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int age = sc.nextInt();
		if(age == 1){
			System.out.println("Hello World");
		}else{
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a + b);
		}
	}
}


Measured memory_bytes: 23124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int H = in.nextInt();
            int N = in.nextInt();
            int gain[] = new int[N];
            int cost[] = new int[N];
            for (int i = 0; i < N; i++)
            {
                gain[i] = in.nextInt();
                cost[i] = in.nextInt();
            }

            int dp[] = new int[H + 1];
            for (int i = 1; i <= H; i++)
            {
                dp[i] = Integer.MAX_VALUE;
            }
            dp[0] = 0;
            for (int i = 0; i <= H; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (i >= gain[j])
                    {
                        dp[i] = Math.min(dp[i], dp[i - gain[j]] + cost[j]);
                    } else
                    {
                        dp[i] = Math.min(dp[i], dp[0] + cost[j]);
                    }
                }
            }
            out.print(dp[H]);
        }

    }
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

#define INF 10000000000000000

struct edge{
  int s;
  int t;
  LL c;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<struct edge> e(m);
  vector<LL> d(n,INF);
  d[0]=0;
  for(int i=0;i<m;i++){
    cin >> e[i].s >> e[i].t >> e[i].c;
    e[i].s--;
    e[i].t--;
    e[i].c*=-1;
  }
  for(int i=0;i<n-1;i++){
    for(int j=0;j<m;j++){
      d[e[j].t]=min(d[e[j].t],d[e[j].s]+e[j].c);
    }
  }
  // for(int i=0;i<n;i++){
  //   cout << d[i] << endl;
  // }
  vector<int> x(n,0);
  for(int j=0;j<n;j++){
    for(int i=0;i<m;i++){
      if(d[e[i].s]+e[i].c<d[e[i].t]){
        x[e[i].t]=1;
      }
      if(x[e[i].s]) x[e[i].t]=1;
    }
  }
  if(x[n-1]==1){
    cout << "inf" << endl;
    return 0;
  }
  cout << -d[n-1] << endl;
  return 0;
}


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

int main(){
  ll n;
  cin >> n;
  if( n%10 == 2 ||
      n%10 == 4 ||
      n%10 == 5 ||
      n%10 == 7 ||
      n%10 == 9  ){
        cout << "hon" << endl;
      }else if( n%10 == 0 ||
                n%10 == 1 ||
                n%10 == 6 ||
                n%10 == 8 ){
                  cout << "pon" << endl;
                }else{
                  cout << "bon" << endl;
                }
  return 0;
}

Measured memory_bytes: 3600
r, c = map(int, input().split())
l = []
for i in range(r):
  l.append(list(map(int, input().split())))
  l[i] += [sum(l[i])]
  print(*l[i])
l = list(zip(*l))
for i in range(c): print(sum(l[i]), end = " ")
print(sum(l[c]))


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

class Program
{
    static void Main()
    {
        int[] NM = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = NM[0];
        int M = NM[1];

        var cakes =
            Enumerable.Repeat(0, N)
            .Select(n => Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray())
            .Select(arr => new { x = arr[0], y = arr[1], z = arr[2] })
            .ToArray();

        //x, y, z それぞれについて、＋が得な場合と－が得な場合の両方を考える必要がある。
        //つまり、2^3で8パターン
        List<int[]> lis = new List<int[]>()
        {
            new int[]{ 1,  1, 1 },
            new int[]{ 1,  1, -1 },
            new int[]{ 1,  -1, 1 },
            new int[]{ -1,  1, 1 },
            new int[]{ 1,  -1, -1 },
            new int[]{ -1,  1, -1 },
            new int[]{ -1,  -1, 1 },
            new int[]{ -1,  -1, -1 },
        };

        long max = 0;

        foreach(var pattern in lis)
        {
            List<long> points = new List<long>();

            foreach (var cake in cakes)
            {
                long pt = 0;
                pt += cake.x * pattern[0];
                pt += cake.y * pattern[1];
                pt += cake.z * pattern[2];
                points.Add(pt);
            }

            points.Sort((x,y) => Comparer<long>.Default.Compare(y, x));

            max = Math.Max(max, points.Take(M).Sum());
        }

        Console.WriteLine(max);
    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 13920
using System;
class Program
{
	static void Main(string[] args)
	{
            var stations = Console.ReadLine();

            var a = false;
            var b = false;

            foreach(var station in stations)
            {
                if(station == 'A')
                {
                    a = true;
                }
                if(station == 'B')
                {
                    b = true;
                }
            }

            if (a == true && b == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin>>N>>M;
    priority_queue<ll> A;
    ll a;
    FOR(i,0,N){
        cin>>a;
        A.push(a);
    }
    ll ma=0;
    FOR(i,0,M){
        ma=A.top();A.pop();
        A.push(ma/2);
    }
    ll sum=0;
    FOR(i,0,N){
        sum+=A.top();A.pop();
    }
    cout<<sum<<endl;


    return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#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)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n == 1) {
      cout << "Hello World" << '\n';
    } else {
      int a, b;
      cin >> a >> b;
      cout << a + b << '\n';
    }

    return 0;
}


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

long modpow(long a, long n, long mod){
	if (n == 0) {
		return 1;
	}
	long answer;
	if (n%2 == 0) {
		answer = modpow(a, n/2, mod);
		answer *= answer;
	} else {
		answer = modpow(a, n-1, mod);
		answer *= a;
	}
	answer %= mod;
	return answer;
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long mod = pow(10,9)+7;
  int prime_list[1001];
  for (int i = 2; i <= 1000; i++) {
    prime_list[i] = 1;
  }
  for (int i = 2; i <= 1000; i++) {
    if (prime_list[i] == 1) {
      for (int j = 2; i*j <= 1000; j++) {
        prime_list[i*j] = 0;
      }
    }
  }
  int lcm_factor[1000001];
  for (int i = 0; i <= 1000000; i++) {
    lcm_factor[i] = 0;
  }
  long number;
  int factor_count;
  for (long i = 0; i < n; i++) {
    number = a[i];
    for (int j = 2; j*j <= a[i]; j++) {
      if (prime_list[j] == 1) {
        factor_count = 0;
        while (number%j == 0) {
          factor_count++;
          number /= j;
        }
        if (factor_count > lcm_factor[j]) {
          lcm_factor[j] = factor_count;
        }
      }
    }
    if (number != 1 && lcm_factor[number] == 0) {
      lcm_factor[number] = 1;
    }
  }
  long mod_lcm = 1;
  for (long i = 2; i <= 1000000; i++) {
    mod_lcm *= modpow(i,lcm_factor[i],mod);
    mod_lcm %= mod;
  }
  long ans = 0;
  long mod_b;
  for (long i = 0; i < n; i++) {
    mod_b = mod_lcm;
    mod_b *= modpow(a[i],mod-2,mod);
    mod_b %= mod;
    ans += mod_b;
    ans %= mod;
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 4096
s = str(input())
tmp = 0
flag = False
if 0 < int(s[0]+s[1]) <= 12:
    tmp += 1
    flag = True
if 0 < int(s[2]+s[3]) <= 12:
    tmp += 1

if tmp == 2:
    print('AMBIGUOUS')
elif tmp == 1:
    if flag:
        print('MMYY')
    else:
        print('YYMM')
else:
    print('NA')

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


// int dp(vector<vector<int>>& v, vector<vector<int>>& mem, int n, int pos) {
//     if(n == 0) {
//         mem[0][pos] = v[0][pos];
//         return mem[0][pos];
//     }
//     if(pos == 0) {
//         int x = mem[n-1][1] > -1?mem[n-1][1]: dp(v, mem, n-1, 1);
//         int y = mem[n-1][2] > -1?mem[n-1][2]: dp(v, mem, n-1, 2);
//         mem[n][0] = v[n][0] + max(x, y);
//         return mem[n][0];
//     }
//     else if(pos == 1) {
//         int x = mem[n-1][0] > -1?mem[n-1][0]: dp(v, mem, n-1, 0);
//         int y = mem[n-1][2] > -1?mem[n-1][2]: dp(v, mem, n-1, 2);
//         mem[n][1] = v[n][1] + max(x, y);
//         return mem[n][1];
//     }
//     else if(pos == 2) {
//         int x = mem[n-1][0] > -1?mem[n-1][0]: dp(v, mem, n-1, 0);
//         int y = mem[n-1][1] > -1?mem[n-1][1]: dp(v, mem, n-1, 1);
//         mem[n][2] = v[n][2] + max(x, y);
//         return mem[n][2];
//     }
// }

int main() {
    int n, a, b, c;
    cin >> n;
    vector<vector<int>> v(n);
    vector<vector<int>> mem(n, vector<int>(3, -1));
    for(int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        v[i].push_back(a);
        v[i].push_back(b);
        v[i].push_back(c);
    }
    // int ans = max(dp(v, mem, n-1, 0), dp(v, mem, n-1, 1));
    // ans = max(ans, dp(v, mem, n-1, 2));
    for(int i = 0; i < 3; i++) {
        mem[0][i] = v[0][i];
    }
    
    for(int i = 1; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            if(j == 0) {
                mem[i][j] = v[i][j] + max(mem[i-1][1], mem[i-1][2]);
            }
            else if(j == 1) {
                mem[i][j] = v[i][j] + max(mem[i-1][0], mem[i-1][2]);
            }
            else {
                mem[i][j] = v[i][j] + max(mem[i-1][0], mem[i-1][1]);
            }
        }
    }
    int ans = max(mem[n-1][0], mem[n-1][1]);
    ans = max(ans, mem[n-1][2]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  if(s[k-1] == 'A') s[k-1] = 'a';
  else if(s[k-1] == 'B') s[k-1] = 'b';
  else if(s[k-1] == 'C') s[k-1] = 'c';
  
  cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)


vector<int> adj[1000002];
int vis[1000002],dep[1000002],siz[1000002];


// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;
//     siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }


void solve()
{
    ll n;cin>>n;
    // ll m;cin>>m;
    // ll k;cin>>k;
    // string s="",s1="",s2="";
    // ll tmp=0,cnt=0,ans=0,tmp1=0,fg=0,fg1=0;
    // ll a[n];
    cout<<setprecision(12)<<float(n)*2*3.1415926535897932384626;
    
    
    
}
    
int main()
{
    IOS;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 27244
N = int(input())
H = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[-1])


Measured memory_bytes: 13928
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N,ans=1,mul=1;
    cin >> N;
    while(N>1){
        N/=2;
        mul*=2;
        ans+=mul;
    }
    P(ans);
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
s = h.times.map{gets.chomp}

dx = [1, 0]
dy = [0, 1]
dp = Array.new(h){Array.new(w, 10 ** 6)}
if s[0][0] == '#'
  dp[0][0] = 1
else
  dp[0][0] = 0
end

h.times do |i|
  w.times do |j|
    2.times do |k|
      nx = i + dx[k]
      ny = j + dy[k]
      next if nx >= h || ny >= w
      if s[i][j] == '.' && s[nx][ny] == '#'
        dp[nx][ny] = [dp[nx][ny], dp[i][j] + 1].min
      else
        dp[nx][ny] = [dp[nx][ny], dp[i][j]].min
      end
    end
  end
end

puts dp[h - 1][w - 1]


Measured memory_bytes: 3964
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	ll n, l;
	ll a[100001] = {};
	cin >> n >> l;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

	int lastIndex = INF;
	for(int i = 0;i < n - 1;i++){
		ll ret = a[i] + a[i + 1];
		if(ret >= l){
			lastIndex = i;
			break;
		}
	}

	if(lastIndex == INF){
		cout << "Impossible" << endl;
	}else{
		cout << "Possible" << endl;
		for(int i = 0;i < lastIndex;i++){
			cout << i + 1 << endl;
		}
		for(int i = n - 1;i >= lastIndex + 1;i--){
			cout << i << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec as(n);
    Vec ds(n);
    rep(i,n){
        ll a;
        cin>>a;
        as[i]=a;
    }
    sort(ALL(as));
    ds = as;
    reverse(ALL(ds));
    ll ans=0;

    rep(i,n/2){
        if(i==0){
            ans += ds[0]-as[0];
        }else{
            ans += ds[i-1]-as[i];
            ans += ds[i]-as[i-1];
        }
    }
    if(n%2==1){
        ans += max(as[n/2]-as[n/2-1],-as[n/2]+ds[n/2-1]);
    }
    
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"errors"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var o, e []rune

func main() {
	o = NextRunesLine()
	e = NextRunesLine()
	for i := 0; i < len(e); i++ {
		fmt.Printf("%c", o[i])
		fmt.Printf("%c", e[i])
	}
	if len(o)-len(e) == 1 {
		fmt.Println(string(o[len(o)-1]))
	} else {
		fmt.Println("")
	}
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int h,m,s,a,b;
	scanf("%d",&a);
	h=a/3600;
	a=a%3600;
	m=a/60;
	s=a%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n + 1), b(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    while (k--) {
        for (int i = 0; i <= n; i++) {
            b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            b[max(i - a[i], 0)]++;
            b[min(i + a[i] + 1, n)]--;
        }
        for (int i = 0; i < n; i++) {
            b[i + 1] += b[i];
        }
        a.swap(b);

        int t = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] < n) t = 0;
        }
        if (t) break;
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 4788
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: i32 = s.trim().parse().unwrap();
	let k = (n / 100) * 100 + (n / 100) * 10 + (n / 100);
	let nk = k + 111;
	if n < k || n == k {
		println!("{}", k);
	} else {
		println!("{}", nk);
	}
}


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

int  main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	map<int, int> mp;
	rep(i, n)
	{
		cin >> d[i];
		mp[i+1] = d[i];
	}
	int sum = 0;
	rep1(i, n-1)
	{
		rep1(j, n)
		{
			if (i < j)
			{
				sum += mp[i]*mp[j];
			}
		}
	}
	cout << sum << endl;
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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 x,y;
    cin >> x >> y;
    for(int i=0;i<=x;i++){
        if(2*i+4*(x-i)==y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll h,w; cin>>h>>w;
    vector<string> grid(h);
    rep(i,h) cin>>grid[i];
    vector<vector<ll>> a(h, vector<ll>(w, 0)), b(h, vector<ll>(w, 0));
    rep(i,h){
        ll tmp=0;
        rep(j,w){
            if(grid[i][j]=='#'){
                tmp=0;
                a[i][j]=-1;
            }else{
                tmp++;
                a[i][j]=tmp;
            }
        }
        rep(j,w-1){
            if(a[i][w-2-j]==-1) continue;
            chmax(a[i][w-2-j], a[i][w-1-j]);
        }
    }

    rep(j, w){
        ll tmp=0;
        rep(i,h){
            if(grid[i][j]=='#'){
                tmp=0;
                b[i][j]=-1;
            }else{
                tmp++;
                b[i][j]=tmp;
            }
        }
        rep(i,h-1){
            if(b[h-2-i][j]==-1) continue;
            chmax(b[h-2-i][j], b[h-1-i][j]);
        }
    }
    ll res=0;
    rep(i,h){
        rep(j,w){
            chmax(res, a[i][j] + b[i][j]);
        }
    }
    cout<<res-1<<endl;
    return 0;
}

Measured memory_bytes: 68864
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r; cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}

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

using namespace std;

double p[3005];
double dp[3005][30005];

int main(){

	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> p[i];
	dp[1][1] = p[1];
	dp[1][0] = 1-p[1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0)
				dp[i][j] = dp[i-1][j]*(1-p[i]);
			else
				dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
		}
	}
	double ans = 0;
	for(int i=n/2+1; i<=n;i++)
		ans+=dp[n][i];
	cout << fixed << setprecision(10) << ans;

}

Measured memory_bytes: 700800
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const ll inf = 1e15;


int main(void){
  int n;
  cin >> n;
  VL a(3 * n);
  REP(i, 0, 3 * n) {
    cin >> a[i];
  }
  VL left(3 * n, -inf);
  {
    priority_queue<ll, vector<ll>, greater<ll> > que;
    ll sum = 0;
    REP(i, 0, 3 * n) {
      sum += a[i];
      que.push(a[i]);
      if (i >= n) {
	ll t = que.top(); que.pop();
	sum -= t;
      }
      if (i >= n - 1) {
	left[i] = sum;
      }
    }
  }
  VL right(3 * n, inf);
  {
    priority_queue<ll, vector<ll>, less<ll> > que;
    ll sum = 0;
    for (int i = 3 * n - 1; i >= 0; --i) {
      sum += a[i];
      que.push(a[i]);
      if (i <= 2 * n - 1) {
	ll t = que.top(); que.pop();
	sum -= t;
      }
      if (i <= 2 * n) {
        right[i] = sum;
      }
    }
  }
  if (0) {
    REP(i, 0, 3 * n) {
      cerr << left[i] << " ";
    }
    cerr << endl;
    REP(i, 0, 3 * n) {
      cerr << right[i] << " ";
    }
    cerr << endl;
  }
  ll ma = -inf;
  REP(i, 0, 3 * n - 1) {
    ma = max(left[i] - right[i + 1], ma);
  }
  cout << ma << endl;
}


Measured memory_bytes: 9068
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;


int main(void) {
	int n, m, i, a, s;

	scanf("%d%d", &n, &m);
	s = 0;
	for (i = 0; i < m; i++) {
		scanf("%d", &a);
		s += a;
	}

	if (s > n) {
		printf("-1\n");
	}
	else {
		printf("%d\n", n - s);
	}

	return 0;
}

Measured memory_bytes: 3816
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(i64, i64); n],
        w: [(i64, i64); m]
    }
    for i in 0..n {
        let mut c = 0;
        let mut d = manhattan(v[i], w[0]);
        for j in 1..m {
            let t = manhattan(v[i], w[j]);
            if d > t {
                c = j;
                d = t;
            }
        }
        println!("{}", c + 1);
    }
}

fn manhattan(a: (i64, i64), b: (i64, i64)) -> usize {
    (a.0 - b.0).abs() as usize + (a.1 - b.1).abs() as usize
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<int64_t>> a(h + 1, vector<int64_t>(w + 1)),
            b(h + 1, vector<int64_t>(w + 1));
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> a[i][j];
        }
    }
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            cin >> b[i][j];
        }
    }

    constexpr auto kOffset = 160 * 80;
    vector<vector<bitset<2 * 160 * 80 + 1>>> dp(
            h + 1L, vector<bitset<2 * 160 * 80 + 1>>(w + 1L));
    dp[0][1].set(kOffset);
    for (auto i : irange(1L, h + 1L)) {
        for (auto j : irange(1L, w + 1L)) {
            auto diff = a[i][j] - b[i][j];
            if (diff < 0) {
                diff *= -1;
            }

            dp[i][j] = (dp[i - 1][j] << diff);
            dp[i][j] |= (dp[i - 1][j] >> diff);
            dp[i][j] |= (dp[i][j - 1] << diff);
            dp[i][j] |= (dp[i][j - 1] >> diff);
        }
    }

    int64_t ans = numeric_limits<int64_t>::max();
    for (auto i = 0L; i <= 2 * 160 * 80; ++i) {
        if (dp[h][w][i]) {
            ans = min(ans, abs(i - kOffset));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 21376
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	q := readInt()
	sx := []byte(readString())
	t := make([]int, q)
	d := make([]string, q)

	s := make([]int, n+2)
	s[0] = -1
	for i := 1; i <= n; i++ {
		s[i] = int(sx[i-1] - 'A')
	}
	s[n+1] = -1

	for i := 0; i < q; i++ {
		t[i] = int([]byte(readString())[0] - 'A')
		d[i] = readString()
	}

	l := 0
	r := n + 1
	for i := q - 1; i >= 0; i-- {
		ti := t[i]
		di := d[i]
		//eprintln(string([]byte{byte(ti) + 'A'}), di, l, r)

		if di == "L" {
			if ti == s[l+1] {
				l++
			}
			if ti == s[r] {
				r++
			}
		} else {
			if ti == s[r-1] {
				r--
			}
			if ti == s[l] {
				l--
			}
		}

		if l+1 == r {
			println(0)
			return
		}

	}

	println(r - l - 1)
}

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


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

int N, M, C;
int a[25][25], b[25];

int main(){
	cin >> N >> M >> C;
	for (int i = 1; i <= M; ++i) cin >> b[i];
	for (int i = 1; i <= N; ++i){
		for (int j = 1; j <= M; ++j){
			cin >> a[i][j];
		}
	}
	ll sum;
	int ans = 0;
	for (int i = 1; i <= N; ++i){
		sum = 0;
		for (int j = 1; j <= M; ++j) sum += a[i][j] * b[j];
		if (sum + C > 0) ans++;
	}
 	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int A, B, K; cin >> A >> B >> K;
  for(int i = A; i <= B; i++){
    if(i <= A+K-1 || i >= B-K+1) cout << i << endl;
  }
}


Measured memory_bytes: 256
n,l = map(int,input().split())

length = [int(input()) for i in range(n)]
pare = [(length[i], i) for i in range(n)]
pare.sort(reverse=True)
ind = [p[1] for p in pare]
dp = [0] * (n + 1)
for i in ind:
  if i == 0:
    dp[i] = dp[i + 1] + (l - length[i])
  else:
    dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])
print(max(dp))


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

int main(){ 
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  auto makedp = [&](string s){
    vector<int> dp(n,0);

    for (int i = 0; i < n; i++) {
      if (i <= c) dp[i] = 1;
      else {
        if (s[i] == 'x') dp[i] = dp[i - 1]; 
        else dp[i] = max(dp[i - c - 1] + 1, dp[i - 1]);
      }
    }
    return dp;
  };

  auto dp1 = makedp(s);
  reverse(s.begin(), s.end());
  auto dp2 = makedp(s);
  
  for (int i = 0; i < n; i++) {
    int l = (i == 0 ? 0 : dp1[i - 1]);
    int r = (i == n - 1 ? 0 : dp2[n - i - 2]);
    //cout << l + r << endl;
    if (l + r < k) {
      cout << i + 1 << endl;
    } 
  }

  return 0; 
} 

Measured memory_bytes: 3520
n = gets.to_i
te = n.times.map{ gets.split.map(&:to_i) }.sort_by!{|x|x[1]}

b = 0
f = true
n.times do |i|
  
  t = te[i][0]
  e = te[i][1]
  
  if e < b + t
    f = false
    break
  else
    b = b + t
  end
end

puts f ? "Yes" : "No" 

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    string s;
    cin>>n>>m>>s;
    if(!(s[0]=='0' && s[n]=='0')){cout<<-1<<endl;return 0;}
    vector<int> res;

    int cur=n;
    int nextpos=n;

    while(cur > 0){
        
        res.eb(0);
        cur = nextpos;
        bool is0exist=false;

        rep(i,m){
            --cur;
            if(cur<0)break;

            if(s[cur] == '0'){
                is0exist = true;
                nextpos = cur;
                res.back() = i+1;
            }
        }

        if(!is0exist){cout<<-1<<endl;return 0;}
    }

    reverse(all(res));
    for(int a:res)cout<<a<<" ";ln;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		char s[] = scan.next().toCharArray();
		int count = 0;
		int ans = 0;

		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
				count++;
			} else {
				if (ans < count) {
					ans = count;
					count = 0;
				}
			}
		}


		if (ans < count) {
			ans = count;

		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22740