akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int main (){
  int a,b;  cin >> a >> b;
  int c,d;
  c = min (a,b);
  d = max (a,b);
  if((a+b)%2==1){
      cout << "IMPOSSIBLE" << endl;
      return 0;
  }

  else{
      cout << (a+b)/2 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
 string str;
  cin>>str;
  int cnt=0;
  for(int i=0;i<n-2;i++)
  {
    if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C')
    {
     cnt++; 
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<iostream>
int main(){
int n,sum;
  std::cin>>n;
  for(int i=1;i<=n;i*=10){
    sum+=(n%(10*i))/i;
  }
  if(sum==1&&n!=1){
  std::cout<<10<<std::endl;
  }
  else{
  std::cout<<sum<<std::endl;
  }
}


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

#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

int main()
{
  Bint a, b, c, d;

  cin >> a >> b >> c >> d;

  Bint r1, r2, r3, r4;

  r1 = a*c;
  r2 = a*d;
  r3 = b*c;
  r4 = b*d;

  cout << std::max({r1, r2, r3, r4}) << endl;

  return 0;
}

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

using namespace std;

const int DIM = 107;

vector <int> vec1[DIM];
vector <int> vec2[DIM];
vector <int> vec3[DIM];
vector <int> vec4[DIM];

int n, m;
int ans;

int st[DIM];;

void bkt(int nivel = 1, int val = 1, int sum = 0)
{
    if(nivel == n + 1) 
		return ;
    
	for(int i = val; i <= m; ++i)
    {
        st[nivel] = i;
        
		for(int j = 0; j < vec1[nivel].size(); ++j)
        {
            int x = vec1[nivel][j];
            int z = vec3[nivel][j];
            int t = vec4[nivel][j];
            
			if(st[nivel] - st[x] == z) 
				sum += t;
        }
		
        ans = max(ans, sum);
        bkt(nivel + 1, i, sum);
		
        for(int j = 0; j < vec1[nivel].size(); ++j)
        {
            int x = vec1[nivel][j];
            int z = vec3[nivel][j];
            int t = vec4[nivel][j];
			
            if(st[nivel] - st[x] == z) 
				sum -= t;
        }
    }
}

main()
{
	int q;
	cin >> n >> m >> q;
	
	for(int i = 1; i <= q; ++i)
    {
		int x, y, z, t;
        cin >> x >> y >> z >> t;
        
		vec1[y].emplace_back(x);
        vec3[y].emplace_back(z);
        vec4[y].emplace_back(t);
    }
    
	bkt();
	
	cout << ans << '\n';
}

Measured memory_bytes: 3640
sx,sy,tx,ty = list(map(int, input().split()))
ans = []
#一回目
for i in range(ty - sy):
    ans.append("U")
for i in range(tx - sx):
    ans.append("R")
for i in range(ty - sy):
    ans.append("D")
for i in range(tx - sx):
    ans.append("L")
#二回目
ans.append("L")
for i in range(ty + 1 - sy):
    ans.append("U")
for i in range(tx + 1 - sx):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(ty + 1 - sy):
    ans.append("D")
for i in range(tx + 1 - sx):
    ans.append("L")
ans.append("U")
print("".join(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const int mn=2000000+2000+2;
bitset<mn> b;
void solve(int n, vector<int> a){
	b[0]=1;
	int sum=0;
	for (auto &w:a) {
		sum+=w;
		b|=(b<<w);
	}
	int mid=(sum+1)/2;
	//printf("mid:%d\n",mid);
	for (int x=mid;x<mn;x++) {
		if (b[x]) {
			printf("%d\n",x);
			return;
		}
	}

}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N;
	scanf("%d",&N);
	vector<int> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%d",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll n,f[101][101],jc[101],ny[101];
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
int main(){
	ll i,j,k,l,x;
	scanf("%lld",&n);
	jc[0]=ny[0]=1;
	f[1][1]=f[1][0]=n;
	for(i=1;i<=n;i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2);
	for(i=1;i<n;i++)
	 for(j=1;j<=n-i;j++)
	  for(k=0;k<=j;k++){
	  	if((j-k)%2)continue;
	  	x=(j-k)/2;
	  	for(l=0;l<=j;l++)(f[i+j][abs(x-l)]+=f[i][k]*C(n-i,j)%p*C(j,l))%=p;
	  }
	printf("%lld",f[n][0]);
}

Measured memory_bytes: 3852
include Math
a, b, C = gets.split.map(&:to_i)

rad = C * PI / 180.0

S = 0.5 * a * b * sin(rad)
h = b * sin(rad)
L = a + b + (h**2 + (a - (b * cos(rad)))**2 )**0.5

printf("%.4f\n", S)
printf("%.4f\n", L)
printf("%.4f\n", h)


Measured memory_bytes: 6976
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int X[N];
ll DP[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));


	int n, e, t; cin >> n >> e >> t;
	for (int i = 1; i <= n; i++) cin >> X[i];
	ll mn = INF;
	int p = 1;
	for (int i = 1; i <= n; i++) {
		while (t <= 2 * (X[i] - X[p])) mn = min(mn, DP[p - 1] - 2 * X[p]), p++;
		DP[i] = min(mn + 2 * X[i], DP[p - 1] + t);
	}
	cout << e + DP[n] << endl;

	return 0;
}


Measured memory_bytes: 4836
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{

    int a,b;
    long long k;
    int x,y;
    cin>>a>>b;
    for(k=1;k<=1000000000;k++)
    {
        x=abs(a-k);
        y=abs(b-k);
        if(x==y)
        {
            cout<<k;
           break;
        }


    }
    if(x!=y)
    {
        cout<<"IMPOSSIBLE";
    }
}

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


int main(){
    int N; cin >> N;
    vector<int> l(N); rep(i,N) cin >> l[i];
    sort(l.begin(), l.end());

    int sum = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < i; ++j){
            int key; key = l[i] + l[j];
            int right = lower_bound(l.begin(), l.end(),key) - l.begin();
            int left = i + 1;
            sum += (right - left);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
class Heap
  def initialize
    @heap = [nil] # 1-origin
  end

  def push(n)
    @heap << n
    i = @heap.size - 1
    while i > 1 && @heap[parent(i)] < @heap[i]
      @heap[parent(i)], @heap[i] = @heap[i], @heap[parent(i)]
      i = parent(i)
    end
  end

  def pop
    return nil if @heap.size <= 1
    max = @heap[1]
    tmp = @heap.pop
    return max if @heap.size == 1
    @heap[1] = tmp
    max_heapify(1)
    max
  end

  def empty?
    @heap.size == 1
  end

  def inspect
    @heap[1..-1]
  end

  private

  def left(i)
    2 * i
  end

  def right(i)
    2 * i + 1
  end

  def parent(i)
    i / 2
  end

  def max_heapify(i)
    l = left(i)
    r = right(i)
    largest = i
    largest = l if l < @heap.size && @heap[l] > @heap[i]
    largest = r if r < @heap.size && @heap[r] > @heap[largest]
    if largest != i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      max_heapify(largest)
    end
  end
end

def powerful_discount_tickets(m, a)
  heap = Heap.new
  a.each { |n| heap.push(n) }
  m.times do
    n = heap.pop
    heap.push(n / 2)
  end

  heap.inspect.inject(:+)
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
puts powerful_discount_tickets(m, a)


Measured memory_bytes: 10252
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>

#define MAX_N (1000000000L)
#define MAX_K (100L)
#define NUM_MOD (1000000007L)

using namespace std;

long mod(long n, long k) {
  return n % k >= 0 ? n % k : n % k + k;
}

int main(int argc, char *argv[]) {
  // read inputs
  long N, K;
  scanf("%ld %ld", &N, &K);

  // divide region
  const long num1 = sqrt(N) - 1, num0 = N / (num1 + 1);

  // solve dp
  vector<long> acc0s(num0 + 1, 0), acc1s(num1 + 1, 0);
  vector<vector<long>> dp0ss(K + 1, vector<long>(num0 + 1, 0)),
      dp1ss(K + 1, vector<long>(num1 + 1, 0));
  // initialize (k = 1)
  for (long i = 1; i <= num0; i++) {
    dp0ss[1][i] = 1;
  }
  acc0s[0] = 0;
  for (long i = 1; i <= num0; i++) {
    acc0s[i] = mod(acc0s[i - 1] + dp0ss[1][i], NUM_MOD);
  }
  for (long i = 1; i <= num1; i++) {
    dp1ss[1][i] = mod(N / i - N / (i + 1), NUM_MOD);
  }
  for (long i = 1; i <= num1; i++) {
    acc1s[i] = mod(acc1s[i - 1] + dp1ss[1][i], NUM_MOD);
  }
  // update
  for (long k = 2; k <= K; k++) {
    // update dp0ss
    for (long i = 1; i <= num0; i++) {
      if (i <= num1) {
        dp0ss[k][i] = mod(acc0s[num0] - acc0s[0] + acc1s[num1] - acc1s[i - 1], NUM_MOD);
      } else {
        dp0ss[k][i] = mod(acc0s[N / i] - acc0s[0], NUM_MOD);
      }
    }
    // update dp1ss
    for (long i = 1; i <= num1; i++) {
      dp1ss[k][i] = mod((N / i - N / (i + 1)) * (acc0s[i] - acc0s[0]), NUM_MOD);
    }
    // update acc0s
    acc0s[0] = 0;
    for (long i = 1; i <= num0; i++) {
      acc0s[i] = mod(acc0s[i - 1] + dp0ss[k][i], NUM_MOD);
    }
    // update acc1s
    for (long i = 1; i <= num1; i++) {
      acc1s[i] = mod(acc1s[i - 1] + dp1ss[k][i], NUM_MOD);
    }
  }

  // print
  // printf("N = %ld, num0 = %ld, num1 = %ld\n", N, num0, num1);
  // printf("dp0ss:\n");
  // for (long k = 1; k <= K; k++) {
  //   for (long i = 1; i <= num0; i++) {
  //     printf("%ld ", dp0ss[k][i]);
  //   }
  //   printf("\n");
  // }
  // printf("dp1ss:\n");
  // for (long k = 1; k <= K; k++) {
  //   for (long i = 1; i <= num1; i++) {
  //     printf("%ld ", dp1ss[k][i]);
  //   }
  //   printf("\n");
  // }

  // print answer
  printf("%ld\n", mod(acc0s[num0] + acc1s[num1], NUM_MOD));

  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000000]={false};
 
 
void makeERA(){
    for(int i=2;i<1000001;i++){
        if(era[i]!=true)continue;
        for(int j=2;;j++){
            if(i*j<=1000000)
                era[i*j]=false;
            else break;
        }
    }
    era[2]=true;
}
int main(){
    rep(i,10000000)era[i]=true;
    era[0]=false;era[1]=false;
	makeERA();
	int n;
	while(cin>>n){
		if(n==0)break;

		int sum=0;
		for(int i=2;i<=(int)n/2;i++){
			if(era[i]){
				if(era[ n-i ]){
					sum++;
				}
			}
		}
		cout<<sum<<endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    bool flag = true;
    rep(i, n) if (a[i] % 2 != 0) flag = false;
    if (!flag) cout << "first" << endl;
    else cout << "second" << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>
#define N (1<<17)

using namespace std;
typedef long long ll;
ll dat[1<<18];
int id[1<<18];
int n,r,l;
int d[1000001],t[1000001],x[1000001];
int timel[100001];

void init(){
	memset(dat,0,sizeof(dat));
	for(int i=N;i<N*2;i++)id[i]=i-N;
}

void update(int k,ll a){
	k+=N-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		if(dat[k*2+1]>=dat[k*2+2]){
			dat[k]=dat[k*2+1];
			id[k]=id[k*2+1];
		}else{
			dat[k]=dat[k*2+2];
			id[k]=id[k*2+2];
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&r,&l);
	for(int i=0;i<r;i++)scanf("%d%d%d",&d[i],&t[i],&x[i]);
	int nt=0;
	init();
	for(int i=0;i<r;i++){
		timel[id[0]]+=t[i]-nt;
		nt=t[i];
		update(d[i],x[i]);
	}
	timel[id[0]]+=l-nt;
	int sum=0,rid=0;
	for(int i=0;i<n;i++){
		if(sum<timel[i])sum=timel[i],rid=i;
	}
	printf("%d\n",rid+1);
	return 0;
}

Measured memory_bytes: 16116
def min_cost(n, hs):
    costs = [0 for _ in range(n)]
    costs[1] = abs(hs[1] - hs[0])
    for i in range(2, n):
        costs[i] = min(costs[i-1] + abs(hs[i]-hs[i-1]), costs[i-2] + abs(hs[i] - hs[i-2]))
    
    return costs[n-1]

N = int(input())
Hn = list(map(int, input().split(' ')))

print(min_cost(N, Hn))

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define MN 200000
#define pa pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
priority_queue<pa> q;
int n,a[MN+5],b[MN+5];long long ans;
inline int lst(int x){return x==1?n:x-1;}
inline int nxt(int x){return x==n?1:x+1;}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read();
    for(int i=1;i<=n;++i)
    {
        b[i]=read();
        if(b[i]<a[i]) return 0*puts("-1");
        if(b[i]!=a[i]) q.push(mp(b[i],i));
    }
    while(!q.empty())
    {
        int x=q.top().second;q.pop();
        int per=b[lst(x)]+b[nxt(x)];
        int mx=q.empty()?int(1e9):((b[x]-max(b[lst(x)],b[nxt(x)]))/per+1);
        mx=min(mx,(b[x]-a[x]+per-1)/per);
        b[x]-=mx*per;
        if(b[x]<a[x]) return 0*puts("-1");
        if(b[x]!=a[x]) q.push(mp(b[x],x));
        ans+=mx;
    }
    printf("%lld\n",ans);
    return 0;
}


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

const int MOD = 1000000007;
const int MAX =200000;

int main() {
  int n = 0;
  cin >> n;
  for (int i = 9; i >= 2; i--){
    if(n % i == 0){ 
      n /= i;
      break;
    }
  }
  cout << (n < 10 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int d[300000];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		d[z]++;
	}
	ll ans = 1;
	for (int i = 0; i < num / 2; i++)ans = ans * 2 % mod;
	if (num % 2 == 0)
	{
		for (int i = 1; i < num; i += 2)if (d[i] != 2)ans = 0;
	}
	else
	{
		for (int i = 0; i < num; i += 2)
		{
			if (i == 0) { if (d[i] != 1)ans = 0; }
			else if (d[i] != 2)ans = 0;
		}
	}
	printf("%lld\n", ans);
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

vector<int> sw(100010,0);
const int dx[] = {1,0,1,0};
const int dy[] = {1,1,0,0};
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	rep(i,4){
		sw[0] = dx[i];
		sw[1] = dy[i]; 
		for(int j = 1; j < n -1; j++){
			if(sw[j]){
				// j匹目が羊の時、発言は真
				if(s[j]=='o'){
					sw[j+1] = sw[j-1];
				} else {
					sw[j+1] = 1 - sw[j-1];
				}
			} else {
				// j匹目が狼の時、発言は偽
				if(s[j] == 'o'){
					sw[j+1] = 1 - sw[j-1];
				} else {
					sw[j+1] = sw[j-1];
				}
			}
		}
		// n - 1 匹目の証言があっているかを確かめる。
		if(sw[0]){
			if(s[0] == 'o'){
				if(sw[1] == sw[n-1]){
					// OK
				} else {
					// NO
					continue;
				}
			} else {
				if(sw[1] != sw[n-1]){
				} else {
					// NO
					continue;
				}
			}
		} else {
			// n - 1 匹目狼
			if(s[0] == 'x'){
				if(sw[1] == sw[n-1]){
				} else {
					// NO
					continue;
				}
			} else {
				if(sw[1] != sw[n-1]){
				} else {
					// NO
					continue;
				}
			}
		}// n - 1 匹目の証言があっているかを確かめる。
		if(sw[n-1]){
			if(s[n-1] == 'o'){
				if(sw[0] == sw[n-2]){
					// OK
				} else {
					// NO
					continue;
				}
			} else {
				if(sw[0] != sw[n-2]){
				} else {
					// NO
					continue;
				}
			}
		} else {
			// n - 1 匹目狼
			if(s[n-1] == 'x'){
				if(sw[0] == sw[n-2]){
				} else {
					// NO
					continue;
				}
			} else {
				if(sw[0] != sw[n-2]){
				} else {
					// NO
					continue;
				}
			}
		}
		rep(j,n){
			if(sw[j]){
				cout << 'S';
			} else {
				cout << 'W';
			}
		} cout << endl;
		return 0;
	} 
	cout << -1 << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final var scanner = new Scanner(System.in);
		final var age = scanner.nextInt();
		final var charge = scanner.nextInt();
		var modifiedCharge = 0;
		if(age >= 13) {
			modifiedCharge = charge;
		}else if (age >= 6) {
			modifiedCharge = charge /2;
		}else {
		}
		System.out.println(modifiedCharge);
		scanner.close();
	}

}


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

vector<int> vec;

int memo[100010][30];

int dp(int i, int j){
    if(i == 0){
        return 0;
    }

    if(memo[i][j] != -1) return memo[i][j];

    if(i < vec[j]){
        return memo[i][j] = dp(i, j-1);
    }

    if(j == 0){
        return memo[i][j] = dp(i-vec[j], j)+1;
    }

    return memo[i][j] = min(dp(i, j-1), dp(i-vec[j], j)+1);
}


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

    vec.push_back(1);

    int cnt = 6;
    while(cnt <= n){
        vec.push_back(cnt);
        cnt *= 6;
    }

    cnt = 9;
    while(cnt <= n){
        vec.push_back(cnt);
        cnt *= 9;
    }

    memset(memo, -1, sizeof(memo));

    cout << dp(n, vec.size()-1) << endl;

    return 0;
}

Measured memory_bytes: 11904
/* http://ufcpp.net/study/algorithm/o_days.html */
#include <iostream>
using namespace std;

int GetDays(int y, int m, int d)
{
  if (m <= 2)y-- , m += 12;
  int dy = 365 * (y - 1);
  int c = y / 100;
  int dl = (y >> 2) - c + (c >> 2);
  int dm = (m * 979 - 1033) >> 5; 
  return dy + dl + dm + d - 1;
}

int main(){
	int a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f , a != -1){
		cout << GetDays(d,e,f) - GetDays(a,b,c) << endl;
	}
}

Measured memory_bytes: 0
N, M = map(int, input().split())
P = []
Y = []
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)


pref_map = {}
for i in range(1, N+1):
    pref_map[i] = []

for i in range(M):
    pref_map[P[i]].append([i, Y[i]])


city_list = []
for k in pref_map.keys():
    pref_map[k].sort(key=lambda x: x[1])
    idx = 1
    for c in pref_map[k]:
        city_list.append([c[0], k, idx])
        idx += 1

city_list.sort(key=lambda x:x[0])

for city in city_list:
    print(format(city[1], '06d') + format(city[2], '06d'))

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

bool islower(char c) {
	return ('a' <= c) && (c <= 'z');
}

bool isac(string s) {
	if(s[0] != 'A')        return false;
	if(!islower(s[1]))     return false;
	if(!islower(s.back())) return false;

	bool ret = false;
	repd(i, 2, s.length()) {
		debug(s[i]);
		if(islower(s[i])) {
			continue;
		}

		if(s[i] == 'C') {
			if(ret) {
				debug(ret);
				return false;
			} else {
				ret = true;
				continue;
			}
		}

		debug(false);
		return false;
	}
	return ret;
}

int main(int argc, const char* argv[]) {
	string s;
	cin >> s;

	cout << ( isac(s) ? "AC" : "WA" ) << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := false
	for i := 0; i < 3; i++ {
		if s[i] == s[i+1] {
			ans = true
		}
	}
	if ans {
		fmt.Println("Bad")
	} else {
		fmt.Println("Good")
	}
}


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

int main(){
    string w, t;
    cin>>w;
    int n=w.size(), cnt=0;
    for(int i=0;i<n;i++){
        if('A'<=w[i]&&w[i]<='Z')w[i]+='a'-'A';
    }
    cin>>t;
    while(t!="END_OF_TEXT"){
        
        for(int i=0;i<t.size();i++){
            if('A'<=t[i]&&t[i]<='Z')t[i]+='a'-'A';
        }
        if(t==w) cnt++;
        cin>>t;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>
#include <string.h>

#define MAX 2000

int main(){
  int a, i, j, A[20], dp[MAX+1], in;

  memset(dp,0,sizeof(dp));

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

  dp[0] = 1;
  for(i = 0;i < a;i++){
    for(j = MAX ; j >= 0 ; j--){
      if(dp[j] && j + A[i] <= MAX){
        dp[j + A[i]] = 1;
      }
    }
  }

  scanf("%d" ,&a);
  for(i = 0;i < a;i++){
    scanf("%d" ,&in);
    if(dp[in]){
      puts("yes");
    }else{

      puts("no");
    }
  }

  return 0;
}



Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int d;
 
  while(cin >> d && d){
    int n,m,k,tmp,ret=0;
    vector<int> stores;
    stores.push_back(d);
    stores.push_back(0);

    cin >> n >> m;
    for(int i=0;i<n-1;i++){
      cin >> tmp;
      stores.push_back(tmp);
    }

    sort(stores.begin(), stores.end());
    vector<int>::iterator it,jt;  
    for(int i=0;i<m;i++){
      cin >> k;
      if(k==0) continue;
      it = lower_bound(stores.begin(),stores.end(),k);
      jt = it;
      jt--;
      ret += min(k - (*jt), (*it) - k);
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005

vector<int> dp(200005,Inf);
vector<int> a;
vector<int> ans;

void dfs(auto &E,int now,int parent,int t){
	int ok = distance(dp.begin(),upper_bound(dp.begin(),dp.end(),a[now]-1));
	t = max(t,ok+1);
	ans[now] = t;
	int p = dp[ok];
	dp[ok] = min(dp[ok],a[now]);
	
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==parent)continue;
		dfs(E,to,now,t);
	}
	dp[ok] = p;
}

int main(){
	
	int N;
	cin>>N;
	ans.resize(N);
	
	for(int i=0;i<N;i++){
		a.push_back(0);
		scanf("%d",&a[i]);
	}
	
	vector<vector<int>> E(N,vector<int>());
	for(int i=0;i<N-1;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		u--;v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	dfs(E,0,-1,0);
	
	for(int i=0;i<N;i++)printf("%d\n",ans[i]);
	
	return 0;
}


Measured memory_bytes: 30852
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int a, b, c, d, count = 0;
	cin >> a >> b >> c >> d;
	vector<bool> v1(101, false);
	vector<bool> v2(101, false);
	for (int i = a; i < b; i++) {
		v1[i] = true;
	}
	for (int i = c; i < d; i++) {
		v2[i] = true;
	}
	for (int i = 0; i < 101; i++) {
		if (v1[i] && v2[i]) {
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int main(){
    int count;
    while(1){
        
       count = 0;
       string str;
       getline(cin,str);
       if(str == "END OF INPUT") break;
        for(int i = 0; i < str.length(); i++){
            
            if(str[i] == ' '){
                printf("%d",count);
                count = 0;
                
            }
            else count++;
        }
        printf("%d\n",count);
    }
    return 0;
}


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

int main() {
    int n; cin >> n;
    string s,t; cin >> s >> t;
    int res = n*2;

    //iはtをみぎにずらせる回数
    for(int i=0;i<n;i++){
        int ans = n*2;
        for(int j=i;j<n;j++){
            if(s[j] == t[j-i])ans--;
            else break;
        }
        res = min(res,ans);
    }
    
    cout << res << endl;
}   


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

 
int main(void){
char S[100];
int s;
scanf("%s",S);
s = strlen( S );
char T[s];
scanf("%s",T);
if(strcmp(S,T)!=0){
for (int i = 0; i < s-1;i++){
    char t;
     t = S[s-1];
    for (int i = s - 1; i > 0; i--)
    {
        S[i] = S[i-1];
    }
    S[0] = t;
    if(strcmp(S,T)==0){
        printf("Yes\n");
        break;
    }
    if(i==s-2){
        printf("No\n");
    }
}
}else
printf("Yes\n");
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	int a,b,maxx=0;
	scanf("%d",&n);
	int num=0;
	scanf("%d",&a);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&b);
		if(b<=a)num++,a=b;
		else {
			maxx=max(maxx,num);
			a=b;
			num=0;
		}
	}
	maxx=max(maxx,num);
	cout<<maxx<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int n;
    bool ans=true;
    for(char c='a';c<='z';++c){
        int cnt=0;
        for(int i=0;i<s.length();++i){
            if(s[i]==c){
                ++cnt;
            }
        }
        if (cnt%2==1) ans=false;
    }
    cout << ( ans ? "Yes" : "No") << endl;
}

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

int main(){
   int n;
   cin >> n;
   int h[22];
   rep(i,n) cin>>h[i];

   int count =1;
   int maxhight = h[0];
   for(int i=1; i<n;++i){
       if (h[i]>= maxhight){
           maxhight = h[i];
           count ++;
       }
   }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <algorithm>
#include <queue>
#define NIL -1
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MAX 10003
int n, m, money[20], retu[50001] = { NIL };
int maisuu = 0;
bool hantei = false;
int main() {
	retu[0] = 1;
	cin >> n >> m;
	REP(i, m) {
		cin >> money[i];
	}
	queue <int>q; q.push(0);
	while (1) {
		int siz = q.size();
		REP(i, siz) {
			int front = q.front();// cout << maisuu << endl;
			if (q.empty()) { hantei = true; break; }
			q.pop();
			REP(i, m) {
				if (front + money[i] < n) {
					if (retu[front + money[i]] == false) {
						retu[front + money[i]] = 1;
						q.push(front + money[i]);
					}
				}
				if (front + money[i] == n) {
					/*cout << maisuu << endl;*/ hantei = true; break;
				}
			}
			if (hantei) { break; }
		}
		if (hantei) { break; }
		maisuu++;
	}
	cout << maisuu + 1 << endl;;
	return 0;
}

Measured memory_bytes: 3404
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

ll gcd(ll a, ll b) {
	if(a*b == 0)return max(a, b);
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

//最小公倍数
//gcd関数を使用
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	int a,b;
	cin >> a >> b;
	cout << lcm(a,b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl '\n'
double dp[3003][3003];

double p[3002];
ll vis[3002][3002];
double funct(ll pos, ll h)
{
    if (h < 0)
        return 0.0;
    if (pos == 0)
        // if
        return (h == 0);
    // else
    // return 0;
    if (vis[pos][h])
        return dp[pos][h];
    vis[pos][h] = 1;
    dp[pos][h] = p[pos] * funct(pos - 1, h - 1) + (1.0 - p[pos]) * funct(pos - 1, h);
    return dp[pos][h];
}

int main()
{
    FASTIO
    ll n;
    cin >> n;
    fw(i, 1, n + 1)
    {
        cin >> p[i];
    }
    memset(dp, 0, sizeof(dp));
    double tot = 0;
    fw(i, 0, n + 1)
    {
        if (2 * i > n)
        {
            tot += funct(n, i);
        }
    }
    printf("%.10lf\n", tot);
    return 0;
}

Measured memory_bytes: 141312
#include<iostream>
#include<math.h>

using namespace std;

int main(void){
    long int n,d;
    cin >> n >> d;
    long int r[n][2];
    double dis[n];
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=0;j<2;j++){
            cin >> r[i][j];
        }
        dis[i] =  sqrt( (r[i][0])*(r[i][0])+(r[i][1])*(r[i][1] ));
    }
    for(int i=0; i<n;i++){
        if(dis[i]<=d)
            ans++;
    }
    cout << ans;
    return 0;
}

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


# ランレングス化 (ex. "RLL.." => [['R',1],['L',2],..]
def runLength(s):
    a = []
    for c in s:
        if len(a) == 0 or a[-1][0] != c:
            a.append([c, 1])
        else:
            a[-1][1] += 1
    return a


def main():
    _ = int(input())
    S = input().strip()
    print(len(runLength(S)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13300
#include <iostream>
#include <algorithm>
//#include <tuple>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
using namespace std;

int a,b;

int main() {
	cin >>a >>b;
  	
	if(a*b%2) cout <<"Yes\n";
  	else cout <<"No\n";
  
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <bits/stdc++.h>

using namespace std;
int K,A,B;
string S;

int main() {

  cin >> S;

  if (S == "ABC")
    printf("ARC\n");
  else
    printf("ABC\n");

  return 0;
}


Measured memory_bytes: 3592
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a * b / gcd(a, b)
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: u64 = read(&mut stdin_lock, &mut buf, b' ');
    let b: u64 = read(&mut stdin_lock, &mut buf, b' ');
    let c: u64 = read(&mut stdin_lock, &mut buf, b' ');
    let d: u64 = read(&mut stdin_lock, &mut buf, b'\n');
    let p = a - 1;
    let px = p - (p / c) - (p / d) + (p / lcm(c, d));
    let bx = b - (b / c) - (b / d) + (b / lcm(c, d));
    let ans = bx - px;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n,k;
ll Ans=0;

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)//a
	{
		int b=k-i%k,c=k-i%k,cnt=(n/k)+(n%k>=b);
		if((b+c)%k==0) Ans+=1ll*cnt*cnt;
	}
	cout<<Ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vector<vector<P>> G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].emplace_back(make_pair(b, 1));
        G[b].emplace_back(make_pair(a, 1));
    }
    
    vl dist1(n, -1);  // dist1[v] : 頂点vの頂点0からの距離
    queue<ll> Q1; 
    dist1[0] = 0;
    Q1.push(0);
    while(!Q1.empty()) {
        ll v = Q1.front();
        Q1.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist1[u] != -1) {
                continue;
            }
            dist1[u] = dist1[v] + cost;
            Q1.push(u);
        }
    }
    
    ll vertex1 = 0;  // 頂点0からの距離が最大の頂点
    rep(v, n) {
        if(dist1[vertex1] < dist1[v]) {
            vertex1 = v;
        }
    }
    
    vl dist2(n, -1);  // dist2[v] : 頂点vの頂点vertex1からの距離
    queue<ll> Q2;
    dist2[vertex1] = 0;
    Q2.push(vertex1);
    while(!Q2.empty()) {
        ll v = Q2.front();
        Q2.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist2[u] != -1) {
                continue;
            }
            dist2[u] = dist2[v] + cost;
            Q2.push(u);
        }
    }
 
    ll vertex2 = vertex1;  // 頂点vertex1からの距離が最大の頂点
    ll TreeDiameter = 0;  // 木の直径
    rep(v, n) {
        if(dist2[vertex2] < dist2[v]) {
            vertex2 = v;
            TreeDiameter = dist2[v];
        }
    }
    
    if(TreeDiameter%3 == 1) {
        out("Second");
    }
    else {
        out("First");
    }
    
    re0;
}

Measured memory_bytes: 19180
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long 
#define il inline
const int maxn=1000010;
il int read(){
    char ch=getchar();
    while (ch<'0'||ch>'9') ch=getchar();
    return ch-'0';
}
int n,a[maxn];
int odd1,occured1,odd2;
int main(){
    scanf("%d",&n); n--;
    for (int i=0;i<=n;++i){
        a[i]=read()-1; if (a[i]==1) occured1=1;
    }
    for (int i=0;i<=n;++i){
        if ((i&n)==i){
            if (a[i]==1) {odd1^=1;}
            else if (a[i]==2) odd2^=1;
        }
    }
    if (odd1){printf("1"); exit(0);}
    if (odd2&&!occured1){printf("2"); exit(0);}
    printf("0");
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>

int main( void ){
	int n, i, k;
	int counter;
	int current[3];
	char str[10];
	while(1){
		counter = 1;
		current[0] = 1;
		current[1] = 2;
		current[2] = 3;
		scanf("%d", &n);
		if(n == 0){break;}
		for( i = 0; i < n; i++ ){
			scanf("%s", str);
			if( !strcmp( str, "North" ) ){
				k = current[0];
				current[0] = current[1];
				current[1] = 7 - k;
			}else if( !strcmp( str, "East" ) ){
				k = current[2];
				current[2] = current[0];
				current[0] = 7 - k;
			}else if( !strcmp( str, "West" ) ){
				k = current[0];
				current[0] = current[2];
				current[2] = 7 - k;
			}else if( !strcmp( str, "South" ) ){
				k = current[1];
				current[1] = current[0];
				current[0] = 7 - k;
			}else if( !strcmp( str, "Right" ) ){
				k = current[1];
				current[1] = current[2];
				current[2] = 7-k;
			}else{ /* Left */
				k = current[2];
				current[2] = current[1];
				current[1] =7-k;
			}
			counter += current[0];
		}
		printf("%d\n",counter);
	}

		return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
double dp[3000][3000], a[3000], ans;
bool solved[3000][3000];
int n;
double calc(int m, int cntr)
{

    if (m == n)
    {
        return a[m]*(cntr*2+2 > n?1 : 0) + (1-a[m])*(cntr*2 > n ? 1 : 0);
    }
    if(solved[m][cntr])
        return dp[m][cntr];

    solved[m][cntr] = 1;
    return dp[m][cntr] = calc(m+1, cntr+1) * a[m] + calc(m+1, cntr) * (1-a[m]);

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


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

    cout << setprecision(10) << fixed << calc(1, 0) << endl;
    return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[3300][3300];
int main()
{
    string s,t;
    cin >> s;
    cin >> t;
    rep(i,s.size())rep(j,t.size()){
        if(s[i] == t[j])dp[i+1][j+1] = dp[i][j] +1;
        else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
    }
    int i = s.size(),j = t.size();
    string res = "";
    while(i>0 && j>0){
        if(dp[i][j]  == dp[i-1][j])i--;
        else if(dp[i][j] == dp[i][j-1])j--;
        else {
            res = s[i-1] + res;
            i--;j--;
        }
    }
    cout << res << endl;
    
    return 0;
}

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

int main()
{
    int N;
    string c;

    cin >> N;
    cin >> c;

    int r_count = 0;
    for(int i = 0; i < N; i++) {
        if(c[i] == 'R') {
            r_count += 1;
        }
    }

    int count = 0;
    for(int i = 0; i < r_count; i++) {
        if(c[i] == 'W') {
            count += 1;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main() {
  	long n, ac = 0, wa = 0, tle = 0, re = 0;
  	std::cin >> n;
  	std::string x;
  	for ( long l = 0; l < n; l++ ) {
      	std::cin >> x;
      	if ( x == "AC" )
          	ac++;
      	else if ( x == "WA" ) 
          	wa++;
      	else if ( x == "TLE" )
          	tle++;
      	else if ( x == "RE" )
          	re++;
    }
  	std::cout << "AC x " << ac << std::endl;
  	std::cout << "WA x " << wa << std::endl;
  	std::cout << "TLE x " << tle << std::endl;
  	std::cout << "RE x " << re << std::endl;
  	return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

/* dp[i][j]: i(1-indexed)枚目まででj枚表の確率 */
double dp[3000][3000];

int main(){
    int n;
    cin >> n;
    vector<double> p(n);
    REP(i, n) cin >> p[i];
    dp[1][0] = 1-p[0];
    dp[1][1] = p[0];

    REPN(i, 2, n+1) REPN(j, 1, i+1) {
        dp[i][j-1] += dp[i-1][j-1] * (1-p[i-1]);
        dp[i][j] += dp[i-1][j-1] * p[i-1];
        //cout << i << j << dp[i][j] << endl;
    }

    double ans = 0;

    REPN(i, n/2+1, n+1) {
        ans += dp[n][i];
        //cout << n << i << dp[n][i] << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 68992
#encoding utf-8

import copy
import numpy as np
import random


s = list(str(input()))
k = int(input())

substrings = []
for length in range(1,len(s)+1):
    if length > 5:
        break
    for i in range(len(s)-length+1):
        word = "".join(s[i:i+length])
        # print(word)
        if word in substrings:
            pass
        else:
            substrings.append(str(word))

substrings.sort()
# print(substrings)
print(substrings[k-1])


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

using namespace std;

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),l(n+1);
    rep(i,n)cin>>a[i];
    ll lt=0,sg=1;
    l[0]=0;
    for(int i=1; i<=n; i++){
        l[i]=l[i-1]+a[i-1]*sg;
        sg*=-1;
    }
    sg=1;
    for(int i=1; i<=n; i++){
        cout<<l[n]*sg-2*l[i-1]*sg<<" ";
        sg*=-1;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

vector<bool> getPrimeTable(int n) {
  vector<bool> prime(n+1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = 2 * i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

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

  vector<bool> prime_table = getPrimeTable(n);
  vector<int> primes;
  rep1(i, n+1) {
    if(prime_table[i]) primes.pb(i);
  }

  vector<int> prime_cnt(n + 1);
  fill(prime_cnt.begin(), prime_cnt.end(), 1);
  rep1(i, n+1) {
    int x = i;
    for(int p : primes) {
      while(x % p == 0) {
        x /= p;
        prime_cnt[p]++;
      }
    }
  }

  ll ans = 1;
  for(int pc : prime_cnt) {
    ans = ((ans * pc) % MOD);
  }
  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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(){
	ll int n,a,b;
	cin >> n >> a >> b;
	if(a > b){
		cout << 0 << endl;
		return 0;
	}
	if(n == 1){
		if(a != b) cout << 0 << endl;
		else cout << 1 << endl;
		return 0;
	}
	if(n == 2){
		cout << 1 << endl;
		return 0;
	}
	cout << (n-2) * (b - a) + 1 << endl;
	

}


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

int dfs(int n, int s, int num) {
    if (s == 0 && n == 0) return 1;
    if (num >= 10 || s < 0 || n < 0) return 0;

    int ret = 0;
    // numを選ぶ
    ret += dfs(n-1, s-num, num+1);
    // numを選ばない
    ret += dfs(n, s, num+1);
    return ret;
}

int main(void) {
    int n, s;
    while (1) {
        cin >> n >> s;
        if (n == 0 && s == 0) break;

        int ret = dfs(n, s, 0);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
def main():
    f, t = [int(v) for v in input().split(' ')]
    count = 0
    d = 1
    tmp = f
    while True:
        tmp = tmp * 2
        if tmp > t:
            break
        count += 1

    print(count + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n,a = map(int, input().split())
x = list(map(int, input().split()))
for i in range(n):
    x[i] -= a
#x.sort()
#print(x)
#dp[i][j]: i枚目まで、値ｊ
dp = [[0]*5001 for _ in range(n+1)]
dp[0][2500]=1
for i in range(0,n):
    for j in range(0,5001):
        if (dp[i][j]!=0):
            dp[i+1][j] += dp[i][j]
            dp[i+1][j+x[i]] += dp[i][j]
print(dp[n][2500]-1)

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

const ll INF = 1LL << 60;

ll n;
vector<ll> a;

const int mod = 1e9 + 7;


int main() {
    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];

    ll max_a = *max_element(a.begin(), a.end());
    ll tmp = INF;
    // cout << max_a << endl;

    ll b = -1;
    for (int i = 0; i < n; i++) {
        if (a[i] == max_a) continue;

        if (abs(max_a / 2 - a[i]) < tmp) {
            tmp = abs(max_a / 2 - a[i]);
            b = a[i];
        }
    }

    cout << max_a << " " << b << endl;
}

Measured memory_bytes: 4024
#include<stdio.h>
int main(){
for(;;){
	int ap=0,bp=0,a,b,t,d;
	scanf("%d",&d);
	if(d==0)
	break;
	for(t=0;t<d;t++){
		scanf("%d %d",&a,&b);
		if(a==b){
			ap+=a;
			bp+=b;
		}
		else if(a<b)
		bp+=a+b;
		else
		ap+=a+b;
	}
	printf("%d %d\n",ap,bp);
}
return 0;
}

Measured memory_bytes: 2736
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
    char s[15];
    scanf("%s",s);
    int len = strlen(s);
    int ans = 100000000;
    for(int i = 0; i <= len - 3; i++)
    {
        int tp = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
        ans = min(ans,abs(tp-753));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int temp = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = n-1; j > i; j--)
        {
            if (a[j] < a[j - 1])
            {
                temp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = temp;
                cnt++;
            }
        }
    }
    for (int k = 0; k < n; k++)
    {
        cout << a[k];
        if (k == n - 1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096