akhauriyash/Code-Regression huggingface dataset:
import math
n, m = map(int, input().split())
t = (n-m) * 100 + m * 1900
pas = 0.5 ** m
ans = t * pas
cnt = 1

while True:
  ans += (cnt + 1) * t * pas * ((1 -pas) ** cnt)
  cnt += 1
  if cnt > 1000000:
    break
  
print(round(ans))
  

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
using namespace std;
static const int size_n = 4;
string input_s;
vector<int> input_i(size_n);
vector<int> operator_list = {0, 1};

int main(){
    cin >> input_s;
    input_i.resize(size_n);
    for(int i=0;i<size_n;i++){
        input_i[i] = (int)(input_s[i]) - '0';
    }
    int score1, score2, score3;
    vector<string> ops = {"+", "-"};
    vector<int> op_idx;
    for(auto &i1: operator_list){
        if(i1==0){
            score1 = input_i[0] + input_i[1];
        }else{
            score1 = input_i[0] - input_i[1];
        }
        for(auto &i2:operator_list){
            if(i2==0){
                score2 = score1 + input_i[2];
            }else{
                score2 = score1 - input_i[2];
            }
            for(auto &i3:operator_list){
                if(i3==0){
                    score3 = score2 + input_i[3];
                }else{
                    score3 = score2 - input_i[3];
                }
                if(score3==7){
                    op_idx = {i1, i2, i3};
                    break;
                }
            }
        }
    }
    string ans = "";
    for(int i=0;i<size_n-1;i++){
        ans += input_s[i] + ops[op_idx[i]];
    }
    ans += input_s[size_n-1];
    ans += "=7";
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    rep(i,100) rep(j,100){
        if(4*i + 7*j == N){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n= int(input())
a= list(map(int,input().split()))
adict = {}
for c in a:adict[c] = adict.get(c,0) + 1
twos=0
moreodd=0
moreeven=0
for num in adict.keys():
    if adict[num]==2:twos+=1
    elif adict[num]>2:
        if adict[num]%2==0:moreeven+=1
        else:moreodd +=1
if moreeven%2==1:twos+=1
if twos%2==0:print(len(adict))
else:print(len(adict)-1)

Measured memory_bytes: 21712
S = list(map(int,input()))

UN2 = 10 * S[-2] + S[-1]
UP2 = 10 * S[0] + S[1]

if ((1000*UP2)+UN2) == 0 or ((UP2 >= 13) and (UN2 >= 13)) or ((UP2 >= 13) and UN2 == 0) or ((UP2 == 0) and UN2 >= 13) :
    print('NA')
elif (1 <= UP2 <= 12) and (1 <= UN2 <= 12) :
    print('AMBIGUOUS')
elif UP2 == 0 or UP2 >= 13 :
    print('YYMM')
else :
    print('MMYY')

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    string ans = "Good";
    REP(i, size(s) - 1){
        if(s[i] == s[i+1]){
            ans = "Bad";
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var a = ReadLineStringSplit();
            var b = ReadLineIntSpilit();
            var c = ReadLine();

            var d = new Dictionary<string, int>();

            for (int i = 0; i < a.Length; i++) {
                d.Add(a[i], b[i]);
            }

            d[c] = d[c] - 1;

            foreach(var item in d) {
                Console.Write(item.Value + " ");
            }

            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
using namespace std;
typedef long long ll;
int N, W, V_[100], W_[100];
int memo[100][10001];
int rec(int id, int w) {
	if (id == N) return 0;
	if (w < 0) return 0;
	if (memo[id][w] != -1) return memo[id][w];
	int coe = w < W_[id] ? 0 : 1;
	return memo[id][w] = max(rec(id + 1, w), (rec(id + 1, w - W_[id]) + V_[id]) * coe);
}
int main(void) {
	cin >> N >> W;
	rep(i, N) cin >> V_[i] >> W_[i];
	rep(i, N) REP(j, W) memo[i][j] = -1;
	cout << rec(0, W) << endl;
	return 0;
}

Measured memory_bytes: 6980
import java.util.*;

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

      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());
      String s = sc.next();

      char[] c = new char[n];

      int ans = 0;

      int numRL = 0;

      for(int i=0;i<n;i++){
        c[i] = s.charAt(i);
        if(i!=0 && c[i]==c[i-1]){
          ans++;
        }
        if(i!=0 && c[i-1]=='R' && c[i]=='L' ){
          numRL++;
        }
      }

      if(numRL>k){
        ans += 2*k;
      }
      else if(numRL<k){
        ans = n -1;
      }
      else{
        ans = n -1;
        if(c[0]=='L' && c[n-1]=='R'){
          ans--;
        }
      }


      System.out.println(ans);


    }
}


Measured memory_bytes: 26832
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, D, X;
  while (cin >> N >> D >> X) {
    int res = X;
    for (int i = 0; i < N; i++) {
      int A;
      cin >> A;
      res += (D - 1) / A + 1;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  deque<char> S;
  {
    string s;
    cin >> s;
    S.insert(end(S), all(s));
  }

  int Q;
  cin >> Q;
  int dir = 0;
  while (Q--) {
    int T;
    cin >> T;
    if (T == 1) {
      dir ^= 1;
    } else {
      int F;
      char C;
      cin >> F >> C;
      F--;
      if (dir ^ F)
        S.push_back(C);
      else
        S.push_front(C);
    }
  }
  if (dir) {
    reverse(all(S));
  }
  for (char x : S) cout << x;
  cout << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 876
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
  int n;
  int H[30];
  cin >> n;
  rep(i, n)cin >> H[i];
  int tmp = H[0];
  int ans = 1;
  for(int i=1;i<n;i++){
    
	if(tmp>H[i])continue;
    ans++;
    tmp = max(tmp, H[i]);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < 4; ++i) {
        vector<int> d(n + 1);
        d.at(0) = (i & 1), d.at(1) = ((i & 2) >> 1);
        for (int i = 1; i < n; ++i) d.at(i + 1) = ((s.at(i) == 'x') ^ d.at(i) ^ d.at(i - 1));
        if (d.at(0) == d.at(n) && ((d.at(1) != d.at(n - 1)) ^ d.at(0) ^ (s.at(0) == 'o'))) {
            for (int i = 0; i < n; ++i) cout << (d.at(i) ? 'W' : 'S');
            cout << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 924
import java.io.*;
import java.util.*;
import java.math.*;

public class Main implements Runnable {
	private static BufferedReader in;
	private static PrintWriter out;
	private static StringTokenizer st;
	private static Random rnd;

	private void solve() throws IOException {
		int n = nextInt();
		int p = nextInt();
		
		long zero = 1, one = 0;
		
		for (int i = 0; i < n; i++) {
			int a = nextInt() % 2;
			
			long newZero = 0;
			long newOne = 0;
			
			if (a == 0) {
				newZero = 2 * zero;
				newOne = 2 * one;
			} else {
				newZero = (zero + one);
				newOne = (zero + one);
			}
			
			zero = newZero;
			one = newOne;
		}
		
		long result = (p == 0 ? zero : one);
		out.println(result);
	}

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

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

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23252
def main():
    N, M = list(map(int, input().split()))
    ans = list()
    if N % 2 == 1:
        for k in range(min(N // 2, M)):
            ans.append((k + 1, N - k))
    else:
        K = N // 2 - 1
        for k in range((K + 1) // 2):
            if len(ans) >= M:
                break
            ans.append((k + 1, N - k))
        for k in range(K // 2):
            if len(ans) >= M:
                break
            b = N - (K + 1) // 2 - k
            a = b - 2 * (K // 2 - k)
            ans.append((a, b))
    for row in ans:
        print('{} {}'.format(row[0], row[1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20820
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;

#define N  100005
signed main()
{
	fast;
    int n;
    cin>>n;
    int num=0;
    int x=100;
    while(x<n)
    {
    	x+=x/100;
    	num++;
	}
	cout<<num<<endl;
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
vll p;

template<class T>
class sg_tree : public vector<T>{
private:
    lli n;
    T default_value;
    T _query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return default_value;
        if(a <= l && r <= b) return (*this)[k];
        else {
            T vl = _query(a,b,k*2+1,l,(l+r)/2);
            T vr = _query(a,b,k*2+2,(l+r)/2,r);
            return func(vl,vr);
        }
    }
public:
    sg_tree():vector<T>(){

    }
    sg_tree(lli n,T d = INT_MAX):vector<T>(n*4,d){
		this->n = 1;
        while(n > this->n) this->n <<= 1;
        this->default_value = d;
    }
    void update(lli i,lli x){
        i += n - 1;
        (*this)[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            (*this)[i] = func((*this)[i * 2 + 1],(*this)[i * 2 + 2]);
        }

    }
    T query(lli a,lli b){
        return _query(a,b,0,0,n);
    }
    T func(T a,T b){
        return min(a,b);
    }
};

sg_tree<lli> sg_even;
sg_tree<lli> sg_odd;
vll res;
vll maping;
priority_queue<vll,vector<vll>,greater<vll>> pq;


vll dfs(lli from,lli to){
	lli r,l;
	lli r_index,l_index;
	if(from % 2 == 0){
		l = sg_even.query(from,to);
		l_index = maping[l];
		r = sg_odd.query(l_index,to);
		r_index = maping[r];
	}else{
		l = sg_odd.query(from,to);
		l_index = maping[l];
		r = sg_even.query(l_index,to);
		r_index = maping[r];
	}
	return vll({l,r,from,to,l_index,r_index});
}

int main(){
	cin >> n;
	p = vll(n);
	maping = vll(n+1);
	for(lli i = 0;i < n;i++) cin >> p[i];
	for(lli i = 0;i < n;i++){
		maping[p[i]] = i;
	}
	sg_even = sg_tree<lli>(n);
	for(lli i = 0;i < n;i+=2){
		sg_even.update(i,p[i]);
	}
	sg_odd = sg_tree<lli>(n);
	for(lli i = 1;i < n;i+=2){
		sg_odd.update(i,p[i]);
	}
	pq.push(dfs(0,n));
	while(!pq.empty()){
		vll p = pq.top();
		pq.pop();
		res.push_back(p[0]);
		res.push_back(p[1]);
		lli from = p[2];
		lli to = p[3];
		lli l_index = p[4];
		lli r_index = p[5];
		if(from < l_index) pq.push(dfs(from,l_index));
		if(l_index+1 < r_index) pq.push(dfs(l_index+1,r_index));
		if(r_index+1 < to) pq.push(dfs(r_index+1,to));
	}
	for(lli i = 0;i < res.size();i++){
		cout << res[i];
		if(i+1 < res.size()) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 22180
#include<cstdio>
#include<algorithm>
#include<map>
#define MOD 1000000007
using namespace std;
map<long long,long long> ma;
long long n;
long long DP(long long x)
{
	if(ma[x]) return ma[x];
	ma[x]=(DP(x/2)+DP((x-1)/2)+DP((x-2)/2))%MOD;
	return ma[x];
}
int main()
{
	for(int i=0;i<=10;i++)
	{
		long long re=0;
		for(int u=0;u<=i;u++)
			for(int v=0;v<=i;v++)
			{
				for(int j=0;j<=v;j++)
					if((j^(v-j))==u)
					{
						re++;
						break;
					}
			}
		ma[i]=re;
	}
	scanf("%lld",&n);
	printf("%lld",DP(n));
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    ll N;
    cin >> N;

    ll num3 = N/3;
    ll num5 = N/5;
    ll num15 = N/15;

    ll total = N*(N+1)/2;
    total -= 3 * num3*(num3+1)/2;
    total -= 5 * num5*(num5+1)/2;
    total += 15 * num15*(num15+1)/2;

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3632
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string S;
  sc.scan(S);

  auto y = S[0 .. 4];
  foreach (i; 0 .. 5)
    S.popFront;
  auto m = S[0 .. 2];
  foreach (i; 0 .. 3)
    S.popFront;
  auto d = S[0 .. 2];

  if (to!int(y) > 2019) {
    writeln("TBD");
    return;
  } else {
    if (to!int(m) > 4) {
      writeln("TBD");
      return;
    }
  }

  writeln("Heisei");
}


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

using namespace std;

int main() {
    long long N, D;
    cin >> N >> D;

    int ans = 0;
    D = pow(D, 2);
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        if(pow(x, 2) + pow(y, 2) <= D) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3532
n, k = map(int, input().split())
lst = list(map(int, input().split()))
temp = sum(lst[:k])
m = sum(lst[:k])
for i in range(k, n):
  temp = temp - lst[i - k] + lst[i]
  m = max(m, temp)
print((m + k) / 2)

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

int main() {
  int ans = 0;
  int R, G, B, N;
  // cin >> R >> G >> B >> N;
  scanf("%d %d %d %d", &R, &G, &B, &N);

  FOR(i, 0, N + 1) {
    FOR(j, 0, N + 1) {
      int temp = N - (R * i + G * j);

      if (temp < 0) {
        continue;
      }

      if ((temp % B) == 0) {
        ans++;
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	vector<int> l(n);
	for (int& v : l)
	{
		cin >> v;
	}

	ALL(sort, l, greater<int>());

	int ans = 0;
	REP(i, n - 2)
	{
		FOR(j, i + 1, n - 1)
		{
			FOR(k, j + 1, n)
			{
				if (l[i] < l[j] + l[k] &&
					l[j] < l[i] + l[k] &&
					l[k] < l[i] + l[j])
				{
					ans++;
				}
			}
		}
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define X first
#define Y second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=998244353;
const ll MAXN=2e5+5;
const ll inf=1e17;

int main()
{
    fastio;
    ll h,n;
    cin>>h>>n;
    vector<ll > dp(h+1,inf);
    dp[0]=0;
    vector<ll > a(n+1),b(n+1);
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=h;i++){
        for(int j=1;j<=n;j++){
            if(i-a[j]>=0) dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
            else dp[i]=min(dp[i],b[j]);
        }
    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {

    void solve() {
	int N = sc.nextInt();

	int a[] = new int[N];

	for (int i = 0; i < N; i++) {
	    a[i] = sc.nextInt();
	}


	int ans = 1000000;
	for (int i = -100; i <= 100; i++) {
	    int cost = 0;
	    for (int ii = 0; ii < N; ii++) {
		cost += (a[ii]-i)*(a[ii]-i);
	    }
	    ans = Math.min(ans, cost);
	}

	System.out.println(ans);


    }

    void print(int[] a) {
	out.print(a[0]);
	for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
	out.println();
    }

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

    MyScanner sc = null;
    PrintWriter out = null;
    public void run() throws Exception {
	sc = new MyScanner(System.in);
	out = new PrintWriter(System.out);
	for (;sc.hasNext();) {
	    solve();
	    out.flush();
	}
	out.close();
    }

    class MyScanner {
	String line;
	BufferedReader reader;
	StringTokenizer tokenizer;

	public MyScanner(InputStream stream) {
	    reader = new BufferedReader(new InputStreamReader(stream));
	    tokenizer = null;
	}
	public void eat() {
	    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
		try {
		    line = reader.readLine();
		    if (line == null) {
			tokenizer = null;
			return;
		    }
		    tokenizer = new StringTokenizer(line);
		} catch (IOException e) {
		    throw new RuntimeException(e);
		}
	    }
	}
	public String next() {
	    eat();
	    return tokenizer.nextToken();
	}
	public String nextLine() {
	    try {
		return reader.readLine();
	    } catch (IOException e) {
		throw new RuntimeException(e);
	    }
	}
	public boolean hasNext() {
	    eat();
	    return (tokenizer != null && tokenizer.hasMoreElements());
	}
	public int nextInt() {
	    return Integer.parseInt(next());
	}
	public long nextLong() {
	    return Long.parseLong(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;
	}
    }
}


Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 30;
char str[MaxN];

int main() {
    scanf("%s",str);
    int l=strlen(str);
    if (l<26) {
        bool o[26];
        memset(o,0,sizeof o);
        for (int i=0;i<l;++i) o[str[i]-'a']=true;
        for (int i=0;i<26;++i) if (!o[i]) {
            str[l]='a'+i;
            break;
        }
        str[l+1]=0;
        puts(str);
    } else {
        bool cant=true;
        for (int i=0;i<l;++i) if (str[i]!='z'-i) {
            cant=false;
            break;
        }
        if (cant) {
            puts("-1");
            return 0;
        }
        for (int i=l-2;i>=0;--i) {
            char t='z'+1;
            for (int j=i+1;j<l;++j) if (str[j]>str[i]) t=min(t,str[j]);
            if (t!='z'+1) {
                str[i]=t;
                str[i+1]=0;
                puts(str);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q;
int ans[100003];
vector<int>v[100003];
int main(){
	int n,a,b,k;
	cin>>n;
	ans[0]=-1;
	for(int i=1;i<n;i++)
	{
		ans[i]=-1;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin>>k;
	for(int i=0;i<k;i++)
	{
		int p,x;
		cin>>p>>x;
		p--;
		ans[p]=x;
		q.push(make_pair(x,p));
	}
	while(!q.empty()){
		pair<int,int>tmp=q.top();
		q.pop();
		//cout<<tmp.second<<' '<<tmp.first<<endl;
		for(int i=0;i<v[tmp.second].size();i++)
			if(ans[v[tmp.second][i]]==-1)
			{
				ans[v[tmp.second][i]]=tmp.first+1;
				q.push(make_pair(ans[v[tmp.second][i]],v[tmp.second][i]));
			}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<v[i].size();j++)
			if(fabs(ans[i]-ans[v[i][j]])!=1)
			{
				cout<<"No";
				return 0;
			}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    ll h;
    cin >> h;
    ll ans = 0;
    for(int i = 0; i < 100; i++) {
        h /= 2;
        ans += (1LL << i);
        if(h == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<int>B(M);
	vector<vector<int>>A(N, vector<int>(M));
	rep(i, M)cin >> B[i];
	rep(i, N)rep(j, M)cin >> A[i][j];
	int ans = 0;
	rep(i, N)
	{
		int sum = C;
		rep(j, M)
		{
			sum += (A[i][j] * B[j]);
		}
		if (sum > 0)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,d;
	cin>>n>>d;
	int c[11][11];
	for(int i=0;i<n;i++) {
			for(int j=0;j<d;j++) {
					cin>>c[i][j];
			}

	}
	int cnt =0;
	for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
					double ans = 0;
					for(int k=0;k<d;k++) {
							ans += (c[i][k] - c[j][k])*(c[i][k] - c[j][k]);
					}
					if(ceil(sqrt(ans)) == floor(sqrt(ans))) cnt++;
			}
	}
	cout<<cnt;
	return 0;
}





Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        WriteLine(Math.Pow(Int(Math.Sqrt(N)), 2))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20560
#include<bits/stdc++.h>
#define ll       	long long
#define pi       	pair<int,int>
#define pl       	pair<ll,ll>
#define ps       	pair<string,string>
#define mod      	1000000007
#define inf      	1e18
#define PI       	acos(-1)
#define si(a)    	scanf("%d",&a)
#define ss(a)           scanf("%s",a);
#define sii(a,b)  	scanf("%d%d",&a,&b)
#define siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define sl(a)    	scanf("%lld",&a)
#define sL(a)    	scanf("%I64d",&a)
#define sll(a,b) 	scanf("%lld%lld",&a,&b)
#define sLL(a,b)        scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c)     scanf("%lld%lld%lld",&a,&b,&c)
#define sLLL(a,b,c)    scanf("%I64d%I64d%I64d",&a,&b,&c)

//geometry
#define EPS 1e-12
#define _abs(x)    (((x)>0)?(x):-(x))
#define _max(x,y)  ( ((x)>(y))?(x):(y))
#define _min(x,y)  ( ((x)<(y))?(x):(y))

#define E(x,y)	(_abs((x)-(y)) < EPS)
#define Z(x)	(_abs(x) < EPS)
#define ZN(x)	(x < 0 || Z(x))
#define ZP(x)	(x > 0 || Z(x))

//END
#define FR(i,a,b) 	for(ll i=(a);i<(b);i++)
#define F       	first
#define S        	second
#define pb       	push_back

#define mp       	make_pair
#define bg       	begin()
#define en       	end()
#define mem(a,b) 	memset(a,b,sizeof(a))
#define vsort(v)        sort(v.begin(),v.end())
#define  _               ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
#define M 110
vector<int>adj[M];
int color[M];
int ans=0;
void dfs(int s)
{
    color[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        int v=adj[s][i];
        if(color[v]==color[s])
        {
            ans=1;
            return;
        }
        else{
            if(color[v]==0)dfs(v);

        }
    }
    color[s]=2;
}
int main()
{
    int n,e;
    sii(n,e);
    for(int i=0;i<e;i++)
    {
        int a,b;
        sii(a,b);
        adj[a].pb(b);

    }
    bool f=0;
    for(int i=0;i<n;i++)
    {
        if(color[i]==0)dfs(i);
        if(ans==1)
        {
            printf("1\n");
            f=1;
            break;
        }
    }
    if(f==0)printf("0\n");
    return 0;
}

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

#define MAX_N 100002
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[MAX_N], y[MAX_N], cum1, cum2, ans1, ans2;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    y[0] = x[0];
    for(int i=1;i<n;i++){
        x[i] += x[i-1];
        y[i] = x[i];
    }
    for(int i=0;i<n;i++){
        x[i] = x[i] + cum1;
        y[i] = y[i] + cum2;
        //cout << cum2  << " " << y[i] << "\n";
        if(i%2){
            cum1 = (x[i] < 0) ? cum1 : cum1 - (x[i] + 1);
            ans1 = (x[i] < 0) ? ans1 : ans1 + (x[i] + 1);
            cum2 = (y[i] > 0) ? cum2 : cum2 + (abs(y[i]) + 1);
            ans2 = (y[i] > 0) ? ans2 : ans2 + (abs(y[i]) + 1);
        }
        else{
            cum1 = (x[i] > 0) ? cum1 : cum1 + (abs(x[i]) + 1);
            ans1 = (x[i] > 0) ? ans1 : ans1 + (abs(x[i]) + 1);
            cum2 = (y[i] < 0) ? cum2 : cum2 - (y[i] + 1);
            ans2 = (y[i] < 0) ? ans2 : ans2 + (y[i] + 1);
        }
    }
    cout << (ll)min(ans1, ans2);
    return 0;
}


Measured memory_bytes: 1792
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1000;

int n,P;
int F[N][N];

int f(int i){
    return sqrt(n*n-i*i-1)+1;
}
int g(int i){
    return min(n*2,(int)sqrt(4*n*n-i*i)+1);
}
int sig(int x){
    return 1-2*(x&1);
}
pair<int,int> A[N*3];
int lh;
int b[N];

signed main(){
    scanf("%d%d",&n,&P);
    FOR(i,0,n-1)A[++lh]={f(i),1};//a
    FOR(i,0,n-1)A[++lh]={g(i),3};//b
    //FOR(i,0,n-1)printf("f(%d)=%d <= P_%d < g(%d)=%d\n",i,f(i),i,i,g(i));
    FOR(i,n,n*2-1)A[++lh]={g(i),2};//c
    //FOR(i,n,n*2-1)printf("0 <= P_%d < g(%d)=%d\n",i,i,g(i));
    sort(A+1,A+lh+1);
    int pos=n*2;
    FOR(i,1,n*2){
        assert(A[i].se!=3);
        if(A[i].se==1){
            b[i]=++pos;
            //printf("b[%d]=%d\n",i,b[i]);
        }
    }
    //FOR(i,1,lh)printf("(%d,%c)%c",A[i].fi,"acb"[A[i].se-1]," \n"[i==lh]);
    assert(pos==n*3);
    int ans=0;
    FOR(k,0,n){
        //printf("\033[33mk=%d\033[0m\n",k);
        int C=0;//统计之前出现过多少个c
        //memset(F,0,sizeof(F));
        F[0][0]=1;
        //printf("F[%d,%d]=%d\n",0,0,F[0][0]);
        FOR(i,1,n*2){
            FOR(j,0,k){
                F[i][j]=0;
            }
            //printf("C=%d\n",C);
            if(A[i].se==1){//a
                FOR(j,0,k) {
                    F[i][j]=(1ll*F[i-1][j]*(A[b[i]].fi-((i-1-C-j)+n+k))%P+(j==0?0ll:1ll*F[i-1][j-1]*(A[i].fi-(j-1+C))))%P;
                    //printf("F(%d,%d) = F(%d,%d) * %d + F(%d,%d) * %d\n",i,j,i-1,j, (A[b[i]].fi-((i-1-C-j)+n+k)), i-1,j-1,(A[i].fi-(j-1)));
                }
            }else {//c
                //printf("C=%d\n",C);
                FOR(j,0,k) F[i][j]=F[i-1][j]*1ll*(A[i].fi-(j+C))%P;
                ++C;
            }
            //FOR(j,0,k){ if(F[i][j])printf("F[%d,%d]=%d\n",i,j,F[i][j]); }
        }
        ans=(ans+F[n*2][k]*sig(k))%P;
    }
    ans=(ans+P)%P;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2176
n,q=map(int,input().split());s="_"+input()+"_";l,r=0,n+1
for(m,h)in[input().split()for i in range(q)][::-1]:L=h=="L";R=h=="R";l,r=[l,l-1,l+1][(m==s[l]and R)-(m==s[l+1]and L)],[r,r-1,r+1][(m==s[r-1]and R)-(m==s[r]and L)]
print(max(0,r-l-1))

Measured memory_bytes: 40892
#68 不足しているカードの発見

n = int(input())

s = "SHCD"
card = [[0] * 13 for i in range(4)]
for i in range(n):
    a, b = input().split()
    card[s.find(a)][int(b) - 1] = 1     
for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(s[i], j + 1)


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
 string s;
 cin >>s;
 string t;
 string  p[4]={"dream","dreamer","erase","eraser"};
 reverse(s.begin(),s.end());
 for(int i=0;i<4;i++) reverse(p[i].begin(),p[i].end());
 for(int i=0;i<s.size();){
   bool c1=false;
   for(int j=0;j<4;j++){
     string r=p[j];
     if(s.substr(i,r.size())==r){
       c1=true;
       i+=r.size();
     }
   }
   if(c1==false) {
     cout <<"NO"<<endl;
     return 0;
   }
 }
 cout << "YES"<<endl;
 }


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int compare( const void* a, const void* b)
{
     unsigned long int_a = * ( (unsigned long*) a );
     unsigned long int_b = * ( (unsigned long*) b );

     if ( int_a == int_b ) return 0;
     else if ( int_a < int_b ) return -1;
     else return 1;
}


int main()
{
    unsigned long n, c, k, i, b, s, cs;
    unsigned long *t;
    scanf("%lu %lu %lu", &n, &c, &k);
    t = malloc( n * sizeof( long ) );
    for( i = 0; i < n; i ++)
    {
        scanf( "%lu", &t[i] );
    }
    qsort( t, n, sizeof(unsigned long), compare );
    
    i = 0;
    b = 0;
    while( i < n)
    {
        b++;
        s = t[i];
        cs = i;
        do
        {
            i++;
        }
        while( i < n 
               && i - cs < c 
               && t[i] - s <= k );
    }
    
    printf( "%lu", b);
    free( t );
    return 0;
}

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
       int a = int.Parse(Console.ReadLine());
       int b = a/3600;
       int c = (a%3600)/60;
       int d = a-b*3600-c*60;
       Console.WriteLine("{0}:{1}:{2}",b,c,d);
      }
      }
      }

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

using namespace std;

struct edge
{
	int from;
	int to;
	int cost;
};

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

	vector<vector<edge> > E_list(N+1,vector<edge>() ); 
	vector<long long > d(N+1,1e18);

	int u, v, w;
	edge e;
	for (int ni = 1; ni < N; ni++) {
		cin >> u >> v >> w;
		E_list[u].push_back(edge{ u,v,w });
		E_list[v].push_back(edge{ v,u,w });
	}

	priority_queue< pair<int, int> > pq;

	pq.push(make_pair(0,1));

	pair<int, int> p_buf;
	int from;
	int to;
	d[1] = 0;
	while (pq.size() > 0) {

		//探す
		p_buf = pq.top();
		pq.pop();
		from = p_buf.second;
		if (p_buf.first > d[from]) continue;

		//更新
		for (int ti = 0; ti < E_list[from].size(); ti++) {
			e = E_list[from][ti];
			to = e.to;
			if (d[to] > d[from] + e.cost){
				d[to] = d[from] + e.cost;
				pq.push(make_pair(d[to],to));
			}
		}
	}

	printf("%d\n", 0);
	for (int vi = 2; vi <= N; vi++) {
		if (d[vi] % 2 == 0) {
			printf("%d\n", 0);
		}
		else {
			printf("%d\n", 1);
		}
	}



	return 0;
}



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


int main()
{
	set<string> st;
	int lines = 0;
	cin >> lines;

	while (lines--) {
		string str;
		cin >> str;
		st.insert(str);
	}
	
	cout << st.size();
	return 0;
}

Measured memory_bytes: 19240
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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

		String s = sc.nextLine();
		String ptn = sc.nextLine();
		ptn = ptn.replaceAll("_", ".");

		Matcher m = Pattern.compile(ptn).matcher(s);

		if (m.find()) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 28148
import java.util.*;

class Main {
	
	static long eights[] = new long[20];
	static long tens[]   = new long[20];
	static long coef[]   = {0,1,2,3,3,4,4,5,6,7};

	public static void main(String args[]){
		eights[0] = 1;
		for(int i=1; i<20; i++){
			eights[i] = eights[i-1]*8;
		}
		tens[0] = 1;
		for(int i=1; i<20; i++){
			tens[i] = tens[i-1]*10;
		}
		Scanner in = new Scanner(System.in);
		for(;;){
			long n = in.nextInt();
			if(n==0) return ;
			long low=1, high = 50000000000L, mid=0;
			for(;;){
				mid = getLowerNum((low + high)/2);
				long nn = n + count(mid);
				if(nn == mid){
					break;
				}
				else if(nn>mid){
					low = getUpperNum(mid+1);
				}
				else{
					high = getLowerNum(mid-1);
				}
			}
			System.out.println(mid);
		}
	}

	private static long count(long x){
		long ans = 0;
		for(int d = 0; x/tens[d]>0; d++){
			int dig = (int)(x/tens[d]%10);
			ans += eights[d]*coef[dig];
		}
		return x - ans;
	}
	
	private static long getLowerNum(long x){
		long ans = 0;
		for(int d = 19; d >= 0; d--){
			int dig = (int)((x/tens[d])%10);
			if(dig != 4 && dig != 6){
				ans += tens[d]*dig;
			}
			else{
				ans += dig*tens[d]-1;
				break;
			}
		}
		return ans;
	}

	private static long getUpperNum(long x){
		long ans = 0;
		for(int d = 19; d>=0; d--){
			int dig = (int)((x/tens[d])%10);
			if(dig != 4 && dig!= 6){
				ans += tens[d]*dig;
			}
			else{
				ans += (dig+1)*tens[d];
				break;
			}
		}
		return ans;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

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

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

	double ans = (double)(n-(n/2))/ (double)n;

	cout << ans << endl;

}


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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)
#define pb push_back

#define test if(!true)
#define N 100007
#define MOD (ll)(1e9 + 7)

int main()
{
    int n, l;
    cin >> n >> l;

    int sum = n * (l - 1);
    sum+=((n * (n+1))/2);

    //cout << sum << "\n";
    if((1-l)>=1 && (1-l)<=n)
    {
        cout << sum << "\n";
        return 0;
    }

    int one = sum - l;
    int two = sum - (l + n - 1);

    if(abs(sum - one) > abs(sum - two))
    {
        cout << two << "\n";
    }
    else
    {
        cout << one << "\n";
    }
    return 0;
}

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

int n;
int a = 100000000;
int x[8];

int main() {

	int o;
	int y = 0;
	int z;

	scanf("%d", &n);

	o = n;

	x[0] = (n / a);
//	printf("x[1] = %d\n", x[0]);
	o = o - x[0] * a;
//	printf("o = %d\n", o);
	a = a / 10;
	y = y + x[0];
//	printf("y = %d\n", y);
//	getch();
	for (int i = 1; i < 9; i++) {
		x[i] = (o / a);
//		printf("x[%d] = %d\n", i, x[i]);
		o = o - x[i] * a;
//		printf("o = %d\n", o);
		a = a / 10;
		y = y + x[i];
//		printf("y = %d\n", y);
//		getch();
	}
	z = n % y;
//	printf("z = %d\n", z);



	if (z == 0) {
		printf("%s\n", "Yes");
	}
	else
	{
		printf("%s\n", "No");
	}

//	getch();
	return 0;
}

Measured memory_bytes: 128