akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(){
  char rev[100000];
  int cnt=0;
  for(int i = 0; i<100000; i++) rev[i] = 'N';

  std::cin >> rev;

  for(int i = 0; i<100000; i++){
    if(rev[i] == 'B' && rev[i+1] == 'W') cnt++;
    if(rev[i] == 'W' && rev[i+1] == 'B') cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


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

int main(){
    multiset<int> phrases;
    for(int i = 0; i < 3; ++i){
        int a;
        cin >> a;
        phrases.insert(a);
    }

    if(phrases.count(5)==2 && phrases.count(7) == 1){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

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

int main() {
	char a,b;
	cin>>a>>b;
	string s1(a-48,b);
	string s2(b-48,a);
	if(s1.compare(s2)>0)
	    cout<<s2<<"\n";
	else if(s1.compare(s2)<0)
	    cout<<s1<<"\n";
	else
	    cout<<s1<<"\n";
	    s1.clear();
	    s2.clear();
	return 0;
}


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

using namespace std;


int main()
{
   long long n;
   cin >>n;
    long long co=0;
  vector<long long> ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      co++;
      if(i * i != n){ret.push_back(n / i);
                        co++;
      }

    }
  }
  sort(begin(ret), end(ret));
    long long a=co/2;
    long long ans=(ret[a]-1)+(n/ret[a])-1;
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <array>
#include <vector>

using namespace std;

typedef long long ll;

array<ll, 100000> index_of;

vector<vector<ll>> accum;

int distance_of(int a, int b)
{
    int ax = index_of[a] % 300;
    int ay = index_of[a] / 300;
    int bx = index_of[b] % 300;
    int by = index_of[b] / 300;

    return abs(ax - bx) + abs(ay - by);
}

int main()
{
    fill(index_of.begin(), index_of.end(), 0);

    int h, w, d;
    cin >> h >> w >> d;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            int v;
            cin >> v;
            v--;
            index_of[v] = i * 300 + j;
        }
    }

    accum.resize(d);
    for (auto &v : accum)
    {
        v.resize((h * w + d - 1) / d);
    }

    for (int i = d; i < h * w; i += d)
    {
        for (int j = 0; j < d && i + j < h * w; j++)
        {
            accum[j][i / d] = accum[j][i / d - 1] + distance_of(i - d + j, i + j);
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << (accum[r % d][r / d] - accum[l % d][l / d]) << endl;
    }
}

Measured memory_bytes: 6144
import itertools
import sys
H, W = [int(i) for i in input().split(' ')]

cross = [[0] * (H + W -1) for _ in range(H + W - 1)]
for i, line in enumerate(sys.stdin):
    for j, c in enumerate(line.strip()):
        if c == "#":
            cross[i+j][i-j+W-1] = 1

across = [[0] + list(itertools.accumulate(xs)) for xs in cross]
r_cross = [[xs[i] for xs in cross] for i in range(H + W - 1)]
across2 = [[0] + list(itertools.accumulate(xs)) for xs in r_cross]

r = 0
for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[i][j] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[i][k] == 1:
                if i - (k-j) >= 0:
                    r += across[i - (k - j)][k+1] - across[i - (k - j)][j]
                if i + (k-j) < H + W - 1:
                    r += across[i + (k - j)][k+1] - across[i + (k - j)][j]

for i in range(H+W-1):
    for j in range(H+W-1):
        if cross[j][i] != 1:
            continue
        for k in range(j+1, H+W-1):
            if cross[k][i] == 1:
                if i - (k-j) >= 0:
                    r += across2[i - (k - j)][k] - across2[i - (k - j)][j+1]
                if i + (k-j) < H + W - 1:
                    r += across2[i + (k - j)][k] - across2[i + (k - j)][j+1]

print(r)


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

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static class DSU {
        int[] root;
        int[] rank;

        public DSU(int n) {
            root = new int[n];
            rank = new int[n];
            for(int i=0;i<n;i++) {
                root[i] = i;
            }
        }

        public int find(int x) {
            if(root[x] == x) {
                return x;
            }
            else {
                return find(root[x]);
            }
        }

        public void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if(x == y) {
                return;
            }
            if(rank[x] < rank[y]) {
                root[x] = y;
            }
            else {
                root[y] = x;
                if(rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        long a = sc.nextLong(), b = sc.nextLong();
        int ans = 0;

        for(int i=0;i<n;i++) {
            long t = sc.nextLong();
            ans += (t < a || t >= b) ? 1 : 0;
        }

        pw.println(ans);
        pw.close();
	}

}


Measured memory_bytes: 22612
input = gets.split(" ").map(&:to_i)
W = input[0]
H = input[1]
x = input[2]
y = input[3]
r = input[4]

if ( x >= r && y >= r ) && ( W - x >= r && H - y >= r )
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N_MAX = 2e5+5;

ll N, K;
ll A[N_MAX], F[N_MAX], T[N_MAX];

bool C(ll key) {
	ll sum = 0;
	for(int i=0;i<N;i++) {
		if(T[i] <= key) continue;
		ll tmp = T[i] - key;
		sum += (tmp + F[i] - 1) / F[i];
	}
	return K >= sum;
}

int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> F[i];
	sort(A,A+N);
	sort(F,F+N, greater<ll>());
	for(int i=0;i<N;i++) T[i] = A[i]*F[i];

	ll left = -1, right = A[N-1]*F[0]+1;
	while(right - left > 1) {
		// cout << left << " " << right << endl;
		ll mid = (left + right)/2;
		if(C(mid)) right = mid;
		else left = mid;
	}
	cout << right << endl;
}

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

int main(){
	long long x,sum=100,y,k=0,h=0;
	cin>>x;
	
	while(sum<x){
		k=0;
		y=sum*0.01;
		if(k<10){
			sum+=y;
			k++;
		}
		h++;
	}
	
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split();

            string answer;
            if (items[0] == items[1] &&
                items[1] == items[2])
            {
                answer = "Yes";
            }
            else
            {
                answer = "No";
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13){
        cout<<b<<endl;
    }
    else if(a>=6){
        cout<<b/2<<endl;
    }
    else{
        cout<<0<<endl;
    }

    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define     sc(a)       scanf("%d",&a)
#define     sc2(a,b)    scanf("%d%d",&a,&b)
#define     line        "\n"
#define     space       " "
#define     MAX         100010
#define     MOD         1000000007
#define     Q           int nn ; scanf("%d",&nn); for (int xx=0;xx<nn;xx++)
#define     ff          first
#define     ss          second
#define     pf(a)       printf("%d\n",a)
#define     pfs(a)      printf("%d ",a)
#define     pf2(a,b)    printf("%d %d\n",a,b)
#define     itm(it)     map<int,int>:: iterator it
#define     its(it)     set<int>:: iterator it
#define     ac_sort(v)  sort(v.begin(),v.end())
#define     dc_sort(v)  sort(v.rbegin(),v.rend())
typedef long long lld;
using namespace std;
int main()
{
    int n ; sc(n);
    int k = n/2;
    int arr[n];
    for (int x=0;x<n;x++) sc(arr[x]);
    sort(arr,arr+n);
    int a = arr[k-1],b=arr[k];
    int c = b-a;
    pf(c);
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int A, B;
    scanf("%d%d",&A, &B);

    if(A+B>=A-B && A+B>=A*B)
    {
        printf("%d",A+B);
    }

    else if(A-B>=A+B && A-B>=A*B)
    {
        printf("%d",A-B);
    }

    else if(A*B>=A+B && A*B>=A-B)
    {
        printf("%d",A*B);
    }

    return 0;
}

Measured memory_bytes: 128
place_count = int(input())
position_list = [0] + list(map(int, input().split()))
position_list.append(0)

all_sum = 0

for i in range(0, place_count+1):
	all_sum += abs(position_list[i+1] - position_list[i])

for x in range(1, place_count+1):
	print(all_sum - abs(position_list[x-1] - position_list[x]) - abs(position_list[x+1] - position_list[x]) + abs(position_list[x+1] - position_list[x-1]))

Measured memory_bytes: 14172
S = list(input())

zenhan = []
kouhan = []
result1 = True
result2 = True
result3 = True


for i in range(len(S)//2):
    zenhan.append(S[i])

for i in range(len(S)//2+1,len(S)):
    kouhan.append(S[i])

for i in range(len(S)//2):
    if S[i] != S[len(S)-i-1]:
        result1 = False
        break

for i in range(len(zenhan)//2):
    if zenhan[i] != zenhan[len(zenhan)-i-1]:
        result2 = False
        break

for i in range(len(kouhan)//2):
    if kouhan[i] != kouhan[len(kouhan)-i-1]:
        result3 = False
        break
#print(zenhan)
#print(kouhan)
#print(result1,result2,result3)

if result1 and result2 and result3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define ITR(x, c) for(__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
    cin>>h>>w>>n;
    a=max(h,w);
    cout<<(n+a-1)/a<<endl;
}

Measured memory_bytes: 256
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");
	
	int N;
	scanf("%d", &N);
	vector <int> neg, pos;
	int zero = 0;
	for (int i = 0; i < N; i++) {
		int A;
		scanf("%d", &A);
		if (A > 0) pos.push_back(A);
		else if (A < 0) neg.push_back(A);
		else zero++;
	}
	while (zero > 0) {
		if (neg.size() < pos.size()) neg.push_back(0);
		else pos.push_back(0);
		zero--;
	}
	sort(ALL(neg));
	sort(ALL(pos));
	deque <int> negd, posd;
	for (int &num : neg) negd.push_back(num);
	for (int &num : pos) posd.push_back(num);

	vector <PII> opes;
	while (negd.size() + posd.size() > 1) {
		if (negd.size() == 0) {
			int a = posd.front(); posd.pop_front();
			int b = posd.front(); posd.pop_front();
			negd.push_back(a - b);
			opes.emplace_back(a, b);
		}
		else if (posd.size() == 0) {
			int a = negd.back(); negd.pop_back();
			int b = negd.back(); negd.pop_back();
			posd.push_back(a - b);
			opes.emplace_back(a, b);
		}
		else if (posd.size() > 1) {
			int a = negd.front(); negd.pop_front();
			int b = posd.front(); posd.pop_front();
			negd.push_back(a - b);
			opes.emplace_back(a, b);
		}
		else{
			int a = posd.front(); posd.pop_front();
			int b = negd.front(); negd.pop_front();
			posd.push_back(a - b);
			opes.emplace_back(a, b);
		}
	}
	int res = posd.front();
	printf("%d\n", res);
	for (PII& ope : opes) printf("%d %d\n", ope.X, ope.Y);
	return 0;
}

Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String[] list = new String[N];
        output(0);
        list[0] = scan.next();
        if (is_finished(list[0])) {
            return;
        }
        output(N-1);
        list[N-1] = scan.next();
        if (is_finished(list[N-1])) {
            return;
        }
        int left = 0;
        int right = N - 1;
        while (left < right) {
            int mid = (left + right) / 2;
            output(mid);
            list[mid] = scan.next();
            if (is_finished(list[mid])) {
                break;
            }
            if (list[mid].equals(list[right]) &&  (right - mid) % 2 == 1) {
                left = mid;
                continue;
            }
            if (!list[mid].equals(list[right]) &&  (right - mid) % 2 == 0) {
                left = mid;
                continue;
            }
            right = mid;
        }
    }
    private void output(int x) {
        System.out.println(x);
        System.out.flush();
    }
    private boolean is_finished(String x) {
        return "Vacant".equals(x);
    }
}

Measured memory_bytes: 24132
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		ArrayList<Rect> rects = new ArrayList<Rect>();
		for (int i = 1; i < 151; i++) {
			for (int j = i+1; j < 151; j++) {
				rects.add(new Rect(j,i));
			}
		}
		Collections.sort(rects);
		while(true){
			int h = stdin.nextInt();
			int w = stdin.nextInt();
			if(h == 0) break;
			int idx = getIndex(h,w,rects);
			Rect rect = rects.get(idx+1);
			System.out.println(rect.h + " " + rect.w);
		}
		stdin.close();

	}
	static int getIndex(int h, int w, ArrayList<Rect> rects){
		for(int i = 0; i < rects.size(); i++){
			if(rects.get(i).h == h && rects.get(i).w == w){
				return i;
			}
		}
		return -1;
	}
}
class Rect implements Comparable<Rect>{
	int h, w;
	int diagonal;
	Rect(int w, int h){
		this.h = h;
		this.w = w;
		diagonal = w*w+h*h;
	}
	@Override
	public int compareTo(Rect o) {
		// TODO ?????????????????????????????????????????????
		if(diagonal != o.diagonal){
			return diagonal - o.diagonal;
		}else{
			return h - o.h;
		}
	}
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var H = input[0];
            var W = input[1];
            List<List<char>> row = new List<List<char>>();
            for (int i = 0; i < H; i++)
            {
                var tmp = Console.ReadLine();
                if (tmp.Any(x => x == '#'))
                {
                    row.Add(tmp.ToList());
                }
            }

            for (int i = W - 1; i >= 0; i--)
            {
                bool delFlg = true;
                for (int j = 0; j < row.Count; j++)
                {
                    if (row[j][i] == '#')
                    {
                        delFlg = false;
                        break;
                    }
                }

                if (delFlg)
                {
                    for (int j = 0; j < row.Count; j++)
                    {
                        row[j].RemoveAt(i);
                    }
                }
            }

            foreach (var r in row)
            {
                Console.WriteLine(new string(r.ToArray()));
            }
        }
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);

    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;

        int count = 0;
        for (int i=1; i<=N; ++i) {
            for (int j=i+1; j<=N; ++j) {
                int sum = (i+j)*(j-i+1)/2;
                if (sum == N) {
                    count ++;
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include <iostream> 
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
#define MAX_N 50
#define MAX_M 50

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (c <= b && c >= a){
		cout << "Yes";
	} else {
		cout << "No";
	}
    return 0;
 }

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    
    int N;
    cin >> N;
    vector<long long>A(N+1,0);
    vector<long long>B(N,0);
    long long ans = 0;
    
    rep(i, 0, N+1){
        cin >> A[i];
    }
    rep(i, 0, N){
        cin >> B[i];
    }
    rep(i, 0, N){
        long long left = min(A[i], B[i]);
        ans += left;
        A[i] -= left;
        B[i] -= left;
        
        long long right = min(A[i+1], B[i]);
        ans += right;
        A[i + 1] -= right;
        B[i] -= right;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int m,n;
string S,T;
int mem[2002][2002]={0};
int dfs(int s,int t);
main(){
  cin>>m>>n>>S>>T;
  memset(mem,-1,sizeof(mem));
  int maxs=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(S[i]=='I'){
    maxs=max(maxs,dfs(i+1,j)+1);
      }
      if(T[j]=='I'){
    maxs=max(maxs,dfs(i,j+1)+1);
      }
    }
  }
  cout<<maxs<<endl;
}
int dfs(int s,int t){
  if(mem[s][t]!=-1){
    return mem[s][t];
  }
  else{
    int maxs=0;
    if(s<=m-1&&t<=n-1&&S[s]!=T[t]){
      maxs=max(maxs,dfs(s+1,t+1)+2);
    }
    if(s<=m-2&&S[s]=='O'&&S[s+1]=='I'){
      maxs=max(maxs,dfs(s+2,t)+2);
    }
    if(t<=n-2&&T[t]=='O'&&T[t+1]=='I'){
      maxs=max(maxs,dfs(s,t+2)+2);
    }
    return mem[s][t]=maxs;
  }
}

Measured memory_bytes: 16996
import sys

N , W = map(int, input().split())

WV = [list(map(int, sys.stdin.readline().split())) for i in range(N)]

INF = 10**11+1

dp = [[0]*(1+W) for i in range(N+1)]

for i in range(1, N+1):
    for j in range(1, W+1):
        if j-WV[i-1][0]>=0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-WV[i-1][0]]+WV[i-1][1])
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-1])

print(dp[N][W])

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

typedef long long ll;
typedef pair <int, int> ii;

const int Maxn = 200005;
const int mod = 998244353;

int pw2[Maxn];
int n;
ii p[Maxn];
vector <int> un;
int my[Maxn];
int BIT[Maxn];
int res;

void Add(int x)
{
    x++;
    for (int i = x; i < Maxn; i += i & -i)
        BIT[i]++;
}

int Get(int x)
{
    x++;
    int res = 0;
    for (int i = x; i > 0; i -= i & -i)
        res += BIT[i];
    return res;
}

bool Less(const ii &a, const ii &b)
{
    return a.second < b.second;
}

int main()
{
    pw2[0] = 1;
    for (int i = 1; i < Maxn; i++)
        pw2[i] = pw2[i - 1] * 2 % mod;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &p[i].first, &p[i].second);
        un.push_back(p[i].first);
    }
    sort(un.begin(), un.end());
    sort(p, p + n, Less);
    for (int i = 0; i < n; i++) {
        int ind = lower_bound(un.begin(), un.end(), p[i].first) - un.begin();
        int a = Get(ind - 1);
        my[i] = (my[i] - (pw2[a] - 1) + mod) % mod;
        int b = Get(n - 1) - Get(ind);
        my[i] = (my[i] - (pw2[b] - 1) + mod) % mod;
        my[i] = (my[i] + (pw2[ind] - 1)) % mod;
        my[i] = (my[i] + (pw2[n - 1 - ind] - 1)) % mod;
        int all = Get(n - 1);
        my[i] = (my[i] + (pw2[all] - 1)) % mod;
        Add(ind);
    }
    fill(BIT, BIT + Maxn, 0);
    for (int i = n - 1; i >= 0; i--) {
        int ind = lower_bound(un.begin(), un.end(), p[i].first) - un.begin();
        int a = Get(ind - 1);
        my[i] = (my[i] - (pw2[a] - 1) + mod) % mod;
        int b = Get(n - 1) - Get(ind);
        my[i] = (my[i] - (pw2[b] - 1) + mod) % mod;
        int all = Get(n - 1);
        my[i] = (my[i] + (pw2[all] - 1)) % mod;
        Add(ind);
        my[i] = (pw2[n] - 1 - my[i] + mod) % mod;
        res = (res + my[i]) % mod;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 5236
#include "stdio.h"

int main(){
    int N;
    int i;
    int cnt = 0;
    char s[100];
    scanf("%d",&N);
    scanf("%s",s);
    for (i = 0 ; i < N ; i++){
        if (s[i] == 'R'){
            cnt++;
        }
    }
    if (cnt > (N/2)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

int main() {
    int X; cin >> X;
    int Y = -1;
    if (X < 600) Y = 8;
    else if (X < 800) Y = 7;
    else if (X < 1000) Y = 6;
    else if (X < 1200) Y = 5;
    else if (X < 1400) Y = 4;
    else if (X < 1600) Y = 3;
    else if (X < 1800) Y = 2;
    else if (X < 2000) Y = 1;
    cout << Y << endl;
    return 0;
}


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

using namespace std;

const long long INF = 1e18 +7;
int A[500];
long long sm[500];

long long sum(int l,int r){
	return sm[r]-(l>0?sm[l-1]:0);
}

int main(){
	int n;cin>>n;
	long long dp[n][n];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			dp[i][j] = INF;
		}
	}
	for(int i=0; i<n; i++)cin>>A[i];
	sm[0] = A[0];
	for(int i=1; i<n; i++){
		sm[i] =sm[i-1]+A[i];
	}
	
	for(int l=n-1; l>=0; l--){
		for(int r = l; r<n; r++){

			if(l==r){dp[l][r] = 0;continue;}
			long long s = sum(l,r);
			for(int k = l; k<=r; k++){
				dp[l][r] = min(dp[l][r],dp[l][k]+(k+1<=r?dp[k+1][r]:0)+s);
			}
		}
	}
	
	cout<<dp[0][n-1]<<endl;
	return 0;
}



Measured memory_bytes: 1536
def christmasEve():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    strees = sorted(h)
    result=10**9
    for i in range(N-K+1):
        result = min(result, strees[i+K-1] - strees[i])
    print(result)

if __name__ == "__main__":
    christmasEve()

Measured memory_bytes: 8280
#include<stdio.h>
 
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

using namespace std;

int main(void){

    int n;
    cin >> n;
    
    vector<int> t(n);
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0; i<n; i++) cin >> t[i] >> x[i] >> y[i];

    int x_index = 0, y_index = 0;
    for(int i=0; i<n; i++) {

        int x_distance = x_index-x[i] > 0 ? x_index-x[i] : -(x_index-x[i]);
        int y_distance = y_index-y[i] > 0 ? y_index-y[i] : -(y_index-y[i]);

        int delta_t;
        if(i==0) delta_t = t[i];
        else delta_t = t[i]-t[i-1];

//cout << x_distance << "," << y_distance << " " << delta_t << endl;

        if(x_distance + y_distance > delta_t) {
            cout << "No" << endl;
            return 0;
        }
//        cout << "check1" << endl;
        int temp_t = delta_t - (x_distance + y_distance);
//        cout << temp_t << endl;
        if(temp_t%2!=0) {
            cout << "No" << endl;
            return 0;
        }
        
        x_index = x[i];
        y_index = y[i];
    }
    
    cout << "Yes" << endl;

    return 0;
    
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


int h, w;
LL blackCnt, whiteCnt;
string s[410];
bool visit[410][410];

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

void go(int x, int y) {
  // cout << "go: " << x << " " << y << endl;
  visit[x][y] = true;
  if(s[x][y] == '.') whiteCnt++;
  else blackCnt++;
  REP(i, 4) {
    int _x = x + dx[i];
    int _y = y + dy[i];
    // cout << "_x:" << _x << " _y:" << _y << endl;
    if (_x >= 0 && _x < h && _y >= 0 && _y < w && !visit[_x][_y] && s[x][y] != s[_x][_y]) {
      go(_x, _y);
    }
  }
}

void init() {

}

void input() {
  cin >> h >> w;
  REP(i, h) cin >> s[i];
  REP(i, h) REP(j, w) visit[i][j] = false;
}

void solve() {
  LL res = 0;
  REP(i, h) REP(j, w) {
    if (!visit[i][j] && s[i][j] == '#') {
      blackCnt = 0;
      whiteCnt = 0;
      // cout << i << " " << j << endl;
      go(i, j);
      // cout << blackCnt << " " << whiteCnt << endl << endl;
      res += blackCnt*whiteCnt;
    }
  }
  cout << res << endl;
}

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


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

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

ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

//実行部
void Main()
{
  ll w, h, x, y; cin >> w >> h >> x >> y;
  cout << w * h / 2. << " " << (w / 2. == x * 1.&&h / 2. ==y * 1.? 1 : 0);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
d, x = nums[0], nums[1]

a = []
for i in range(n):
  a.append(int(input()))

num_choco = []
for i in range(n):
  nc = 0
  for j in range(d):
    if 1+a[i]*j <= d:
      nc += 1
    else:
      break
  num_choco.append(nc)
print(sum(num_choco)+x)


Measured memory_bytes: 3060
using System;

public class Program{
    public static void Main(){
        string input1=Console.ReadLine();
        int N=int.Parse(input1);
        int[] NumArr=new int[N];
        for(int i=0;i<N;i++) {
            string input2=Console.ReadLine();
            NumArr[i]=int.Parse(input2);
        }
        
        Array.Sort(NumArr);
        int count=1;

        for(int i=0;i<N-1;i++) {
            if(NumArr[N-i-1]>NumArr[N-i-2]) {
                count++;
            }
        }
        
        Console.WriteLine(count);


    }
    
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vi p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];

    sort(all(p));
    sort(all(q));
    sort(all(r));
    reverse(all(p));
    reverse(all(q));
    reverse(all(r));

    minheap <int> choosed;
    rep(i,x) choosed.push(p[i]);
    rep(j,y) choosed.push(q[j]);

    rep(i, c) {
        int p = choosed.top();
        if(p < r[i]) {
            choosed.pop();
            choosed.push(r[i]);
        }
    }
    ll ans = 0;
    while (choosed.size()) {
        ans += choosed.top();
        choosed.pop();
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

int main() {
	
	string s, p;
	cin >> s >> p;
	
	s += s;
	if (s.find(p) <= s.size()) {
		cout << "Yes\n";
	} else cout << "No\n";
	
		
	return 0;
}


Measured memory_bytes: 3232
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let n:usize = scan.next();

	let mut r = 1;

	for i in 1..(n+1) {
		r = (r * i) % (pow(10,9) + 7);
	}

	println!("{}",r);
}
fn pow(n:usize,e:usize) -> usize {
	if e > 1 {
		let a = pow(n,e/2);

		if e % 2 == 0 {
			a * a
		} else {
			a * a * n
		}
	} else {
		n
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,Q;
  cin >> n >> Q;
  atcoder::fenwick_tree<ll> ft(n);
  rep(i,n){
    ll k;cin >> k;
    ft.add(i,k);
  }
  while(Q--){
    ll T,l,r;cin >> T >> l >> r;
    if(!T){
      ft.add(l,r);
    }else{
      cout << ft.sum(l,r) << "\n";
    }
  }

  


  return 0;
}

Measured memory_bytes: 8220
import java.util.*;
import java.io.*;
 
public class Main {
    static long[] a;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int k = sc.nextInt()-1;
        for(int i = 0; i < n; i++){
            sb.append(s[i] == s[k] ? s[k] : "*");
        }
        pw.println(sb.toString());
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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


Measured memory_bytes: 25444
ans=0
x,y=map(float,input().split(","))
k1,k2=map(float,input().split(","))
while 1:
    try:
        k3,k4=map(float,input().split(","))
        a=((k1-x)**2+(k2-y)**2)**0.5
        b=((k3-x)**2+(k4-y)**2)**0.5
        c=((k1-k3)**2+(k2-k4)**2)**0.5
        z=(a+b+c)/2
        ans+=(z*(z-a)*(z-b)*(z-c))**0.5
        k1,k2=k3,k4
    except:break
print(ans)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define sz size() 
#define len length() 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI 3.14159265358979323846
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n;cin>>n;if(n%10==7) cout<<"Yes";
    else if((n/10)%10==7) cout<<"Yes";
    else if(n/100==7) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int main(){
    IOS;
    ll n; cin>>n;
    ll mul=n/500;
    if(n!=0){
        ll d=n/500;
        n=n-d*500;
        ll mul1=n/5;
        cout<<(mul*1000)+(mul1*5);
    }
    else{
        mul=n/5;
        cout<<5*(mul);
    }
    return 0;
}

Measured memory_bytes: 256
loop :: Int -> Int -> Int -> Int
loop _ 0 0 = 0
loop q a b
  |a == b = f q a (rem (b * 10) q)
  |otherwise = loop q (rem (a * 10) q) (rem (b * 100) q)
  where
    f :: Int -> Int -> Int -> Int
    f n r s
      |r == s = 1
      |otherwise = 1 + f n r (rem (s * 10) n)

loopSize :: Int -> Int -> Int
loopSize p q = loop q p (rem (p * 10) q)

timesDo :: Int -> Int -> Int -> Int
timesDo 0 _ r = r
timesDo t q r = timesDo (t - 1) q (rem (r * 10) q)

endSize :: Int -> Int -> Int -> Int
endSize p q d
  |p == d = 0
  |otherwise = 1 + endSize (rem (p * 10) q) q (rem (d * 10) q)

culDigit :: Int -> Int -> Int -> [Int]
culDigit _ _ 0 = []
culDigit p q t = div (p * 10) q : culDigit (rem (p * 10) q) q (t - 1)

solve :: Int -> Int -> String
solve p q
  |lsize == 0 = flat (culDigit p q esize)
  |otherwise = flat (culDigit p q (lsize + esize)) ++ (getStr esize lsize)
  where
    lsize = loopSize p q
    esize = endSize p q (if lsize == 0 then 0 else (timesDo lsize q p))
    getStr :: Int -> Int -> String
    getStr 0 0 = "\n"
    getStr 0 r = '^' : getStr 0 (r - 1)
    getStr n r = ' ' : getStr (n - 1) r

flat :: [Int] -> String
flat [] = "\n"
flat (a:xr) = (show a) ++ (flat xr)

split :: Char -> String -> [String]
split _ [] = [""]
split c (h:t)
  |h == c = [h] : (split c t)
  |otherwise = (h : (head $ split c t)) : (tail $ split c t)

main = do
  input <- getContents
  mapM_ putStr (map (\(a:xr) -> solve a (head xr)) (map ((map read) . (split ' ')) (lines input)))

Measured memory_bytes: 4176
s = str(input())
t = str(input())

DP = [[0] * (3100) for i in range(3100)]


def chmax(a, b):
    if a < b:
        a = b
    return a


for i in range(len(s)):
    for j in range(len(t)):

        if s[i] == t[j]:
            DP[i + 1][j + 1] = chmax(DP[i + 1][j + 1], DP[i][j] + 1)
        DP[i + 1][j + 1] = chmax(DP[i + 1][j + 1], DP[i][j + 1])
        DP[i + 1][j + 1] = chmax(DP[i + 1][j + 1], DP[i + 1][j])

Str = ""
i = len(s)
j = len(t)

while i > 0 and j > 0:

    if DP[i][j] == DP[i-1][j]:
        i -= 1
    elif DP[i][j] == DP[i][j-1]:
        j -= 1
    else:
        Str = s[i-1] + Str
        i -= 1
        j -= 1

print(Str)

Measured memory_bytes: 119132
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	string s,t="keyence";
	cin>>s;
	bool b=false;
	int j=0;
	f(i,s.size()){
		if(s[i]!=t[j]){
			if(b){
				puts("NO");
				return 0;
			}
			else i+=s.size()-t.size()-1;
			b=true;
			j--;
		}
		j++;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    ans = 0
    for i in range(1, n+1):
        if i % 3 == 0 and i % 5 == 0:
            ans += 0
        elif i % 3 == 0:
            ans += 0
        elif i % 5 == 0:
            ans += 0
        else:
            ans += i
    print(ans)
    return


if __name__ == "__main__":
    solve()

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

int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        if(a%2==0)
        {
            printf("%d\n",a);
        }
        else
        {
            printf("%d\n",a*2);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

int in(){
	int x;
	cin>>x;
	return x;
}

signed main(){
	int a=in(),b=in(),c=in();
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
    */
}

string S;

int main(){
    cin >> S;
    int N = S.length();
    vector<int> Data(N,0);
    int count = 0;
    int odd = 0,even = 0;
    int oddmem,evenmem;
    for(int i=0;i<N;i++){
        if(i%2==0)odd++;
        else even++;
        count++;
        if(i!=(N-1)&&S[i]=='R'&&S[i+1]=='L'){
            if(i%2==0){
                oddmem = i;
                evenmem = i+1;
            }else{
                oddmem = i+1;
                evenmem = i;
            }
        }
        if(i!=(N-1)&&S[i]=='L'&&S[i+1]=='R'){
            Data[oddmem] = odd;
            Data[evenmem] = even;
            oddmem = 0;
            evenmem = 0;
            odd = 0;
            even = 0;
        }else if(i==N-1){
            Data[oddmem] = odd;
            Data[evenmem] = even;
        }
    }
    rep(i,N)cout << Data[i] << " ";
    cout << endl;
    return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int t;
  cin >> t;
  double ma = 0;
  while ( t-- ) {
    int n, m;
    cin >> n >> m;
    double ave = 0;    
    double sum_r = 0;
    for ( int i = 0; i < m; i++ ) {
      int v;
      double r;
      cin >> v >> r;
      ave += v*r;      
      sum_r += r;      
    }
    ave *= (1.0 / sum_r);
    ma = max(ma, ave);    
  }

  int p, q;
  cin >> p >> q;
  double ave = 0;    
  double sum_r = 0;
  for ( int i = 0; i < q; i++ ) {
    int v;
    double r;
    cin >> v >> r;
    ave += v*r;      
    sum_r += r;      
  }
  ave *= (1.0 / sum_r);

  if ( ma-0.0000001 >= ave ) cout << "YES" << endl;
  else cout << "NO" << endl;  

  return 0;
}



Measured memory_bytes: 3276
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{int n,m,i,x[100],s=0,k=0;
cin>>n>>m;
for(i=0;i<n;i++)
	{cin>>x[i];s=s+x[i];}
for(i=0;i<n;i++)
	if(x[i]*4*m>=s)
	k++;
if(k>=m)
cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 256
N, K, Q = [int(nkq) for nkq in input().split()]
score = [K-Q] * N

for q in range(Q):
  A = int(input())
  score[A-1] += 1

for n in range(N):
  s = score[n]
  if s > 0:
    print("Yes")
  else: # s <= 0:
    print("No")

Measured memory_bytes: 6596