akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#define int long long int
#define mod 1000000007
#define inf 20001
int function(string &str,int initial,int final,int k,int r,int s,int p,int status,int memo[][4])
{
	if(initial>final)
	   return 0;
	if(memo[initial][status]!=-1)
	   return memo[initial][status];
	else
	{
		if(status==0)
		{
			int answer1=0,answer2=0,answer3=0;
			if(str[initial]=='s')
			   answer1=r;
			if(str[initial]=='p')
			    answer2=s;
			if(str[initial]=='r')
			   answer3=p;
			int x=answer1+function(str,initial+k,final,k,r,s,p,1,memo);
			int y=answer2+function(str,initial+k,final,k,r,s,p,2,memo);
			int z=answer3+function(str,initial+k,final,k,r,s,p,3,memo);
			memo[initial][status]=max(x,max(y,z));
			return memo[initial][status];
		}
		else if(status==1)
	    {
			int answer2=0,answer3=0;
			if(str[initial]=='p')
			    answer2=s;
			if(str[initial]=='r')
			   answer3=p;
			//int x=answer1+function(str,initial+k,final,k,r,s,p,1,memo);
			int y=answer2+function(str,initial+k,final,k,r,s,p,2,memo);
			int z=answer3+function(str,initial+k,final,k,r,s,p,3,memo);
			memo[initial][status]=max(y,z);
			return memo[initial][status];
		}
		else if(status==2)
		{
			int answer1=0,answer3=0;
			if(str[initial]=='s')
			   answer1=r;
			if(str[initial]=='r')
			   answer3=p;
			int x=answer1+function(str,initial+k,final,k,r,s,p,1,memo);
			//int y=answer2+function(str,initial+k,final,k,r,s,p,2,memo);
			int z=answer3+function(str,initial+k,final,k,r,s,p,3,memo);
			memo[initial][status]=max(x,z);
			return memo[initial][status];
		}
		else
		{
			int answer1=0,answer2=0;
			if(str[initial]=='s')
			   answer1=r;
			if(str[initial]=='p')
			    answer2=s;
			int x=answer1+function(str,initial+k,final,k,r,s,p,1,memo);
			int y=answer2+function(str,initial+k,final,k,r,s,p,2,memo);
			//int z=answer3+function(str,initial+k,final,k,r,s,p,3,memo);
			memo[initial][status]=max(x,y);
			return memo[initial][status];
		}
	}
}
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    string str;
    cin>>str;
    int answer=0;
    int memo[n+1][4];
    int j;
    for(j=0;j<=n;j++)
    {
		for(int i=0;i<4;i++)
	    {
			memo[j][i]=-1;
		}
	}
    for(j=0;j<k;j++)
    {
		answer+=function(str,j,n-1,k,r,s,p,0,memo);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 16000
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
int a[200020];
int b;
#undef int
int main() {
	#define int long long
	int n;
	scanf("%lld", &n);
	for(int i=1;i<=n;i++) {
		scanf("%lld", &a[i]);
		a[i]-=i;
	}
	sort(a+1, a+n+1);
	b = a[(n+1)>>1];
	int ans =0;
	for(int i=1;i<=n;i++) {
		ans += abs(a[i]-b);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import sys
import math

g = 9.8

while True:
    try:
        s = raw_input()
        vd = float(s)
        #N = int(math.ceil((vd * vd / (10 * g)) + 1))
        N = int(math.ceil((vd * vd / (9.8 * 2) + 5) / 5))
        print N
    except EOFError:
        break

Measured memory_bytes: 4372
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let ans = [a+b,a-b,a*b].iter().fold(std::i32::MIN, |x,y| std::cmp::max(x,*y));
    println!("{}", ans);
}


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

int main(){
	string s;
	int k,x=0;
	cin>>s>>k;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			x++;
			continue;
		}
		if(x>=k){
			cout<<'1'<<endl;
			return 0;
		}
		else{
			cout<<s[i]<<endl;
			return 0;
		}
	}
	cout<<'1'<<endl;
	return 0;
}

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

#define N 100
#define INF 10000000

int Q[N];
int n,M[N][N];
int d[N];
int head=0,tail=0;

void bfs(int s);
void enqueue(int x);
int dequeue();

int main(void)
{
  int i,j;
  int u,v,k;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=0;
	}
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
    
      u--;
    
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
      
	  v--;
      
	  M[u][v]=1;
	}
    }
  
  bfs(0);

  return 0;
}

void bfs(int s)
{
  int i;
  int v,u;
  
  enqueue(s);
  
  for(i=0;i<n;i++)
    {
      d[i]=INF;
    }
  
  d[s]=0;
  
  while(head!=tail)
    {
      u=dequeue();
    
      for(v=0;v<n;v++)
	{
	  if(M[u][v]==0)
	    {
	      continue;
	    }
	  if(d[v]!=INF)
	    {
	      continue;
	    }
	  d[v]=d[u]+1;
      
	  enqueue(v);
	}
    }
  
  for(i=0;i<n;i++)
    {
      printf("%d ",i+1);
    
      if(d[i]==INF)
	{
	  printf("-1");
	}
      else
	{
	  printf("%d",d[i]);
	}
      putchar('\n');
    }
}


void enqueue(int x)
{
  Q[tail]=x;
  tail=(tail+1)%N;
}

int dequeue()
{
  int x=Q[head];
  
  head=(head+1)%N;
  
  return x;
}



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

int main() {
  int n;
  cin >> n;
  vector<int>ok(n);
  for (auto i=0; i<n; ++i) {
    int a,b;cin>>a>>b;
    if(a==b){
      ok[i]=1;
    }
    if(i>1 && ok[i] and ok[i-1]and ok[i-2]){
      cout<<"Yes\n";
      return 0;
    }
  }
  cout<<"No\n";
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;
vector<int> arr, tmp;
int cnt;

void print(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		cout << arr[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
}

void insert_sort(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		for (int j = i; j > 0; --j) {
			if (arr[j - 1] > arr[j])
				swap(arr[j - 1], arr[j]);
		}
		print(arr);
	}
}

void bubble_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < arr.size(); ++i) {
		for (int j = n - 1; j > i; --j) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j - 1], arr[j]);
				cnt++;
			}
		}
	}
	print(arr);
	cout << cnt << endl;
}

void select_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int mi_idx = i;
		for (int j = i; j < n; ++j) {
			if (arr[j] < arr[mi_idx])
				mi_idx = j;
		}
		cnt += (i != mi_idx);
		swap(arr[i], arr[mi_idx]);
	}
	print(arr);
	cout << cnt << endl;
}

void merge(vector<int> &arr, int a, int b, int c) {
	for (int i = a; i <= c; ++i)
		tmp[i] = arr[i];

	int i = a;
	int j = b + 1;
	while (i <= b && j <= c) {
		cnt++;
		if (tmp[i] <= tmp[j]) arr[a++] = tmp[i++];
		else arr[a++] = tmp[j++];
	}
	while (i <= b) { arr[a++] = tmp[i++]; cnt++; };
	while (j <= c) { arr[a++] = tmp[j++]; cnt++; }
}

void merge_sort(vector<int>& arr, int l, int r) {
	if (l < r) {
		int mid = l + (r - l) / 2;
		merge_sort(arr, l, mid);
		merge_sort(arr, mid+1, r);
		merge(arr, l, mid, r);
	}
}

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

	arr.assign(n, 0);
	tmp.assign(n, 0);
	cnt = 0;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	merge_sort(arr, 0, n - 1);
	print(arr);
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  int H,W;
  bool f=true;
  cin>>H>>W;
  char c[H][W];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++) cin>>c[i][j];
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int ax=j+1,ay=i-1,bx=j-1,by=i+1;
      if(c[i][j]=='#'){
        if(0<=ax&&ax<W&&0<=ay&&ay<H&&c[ay][ax]=='#') f=false;
        if(0<=bx&&bx<W&&0<=by&&by<H&&c[by][bx]=='#') f=false;
      }
    }
  }
  if(f) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
}


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

int main(void) {
  int max = 0;
  int n;
  cin >> n;
  int r = 0;
  int a;
  for(int i = 0; i < n; i++) {
    cin >> a;
    if(max < a) max = a;
    r += a;
  }
  r -= max / 2;
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
import math
from itertools import permutations

n = int(input())
coor = []
for _ in range(n):
    c = list(map(int, input().split()))
    coor.append(c)

ave = 0

for p in permutations(coor, n):
    for i in range(n-1):
        ave += math.sqrt((p[i][0] - p[i+1][0])**2 + (p[i][1] - p[i+1][1])**2)

ans = ave/math.factorial(n)

print(ans)


Measured memory_bytes: 73772
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
// https://atcoder.jp/contests/abc167/tasks/abc167_d
map<ll, ll> m;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,k;
    cin >> n >> k;
    vector<ll> v(n+1);
    for(int i = 1;i<=n;i++){
        cin >> v[i];
    }
    ll pos = 1;
    ll t = 1;
    while(m[pos] == 0){
        m[pos] = t;
        t++;
        pos =v[pos];
    }
    if(k > n){
        k -= m[pos]-1;
        ll temp = k % (t-m[pos]);
        ll curr = pos;
        while(temp){
            curr = v[curr];
            temp--;
        }
        cout << curr;
    }
    else{
        ll curr = 1;
        while(k){
            curr = v[curr];
            k--;
        }
        cout << curr;
    }
	return 0;

}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    string S; cin >> S;
    int N = S.size();
    vector<ll> val(2019, 0);
    ll fac = 1;
    ll cur = 0;
    val[cur]++;
    rep(i, N) {
      ll add = S[N-1-i] - '0';
      cur = (cur + fac * add) % 2019;
      fac = (fac * 10) % 2019;
      val[cur]++;
    }
    ll ans = 0;
    rep(i, 2019) ans += val[i] * (val[i] - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int x[m];
  for(int i=0;i<m;i++) cin>>x[i];
  sort(x,x+m);

  if(m==1 || n>=m) cout<<0<<endl;
  else
  {
  int dif[m-1];
  for(int i=0;i<m-1;i++) dif[i]=x[i+1]-x[i];
  sort(dif,dif+m-1);

  int sg=x[m-1]-x[0],i=0;
  while(n-1>0)
  {
    sg-=dif[m-2-i];
    n--;
    i++;
  }

  cout<<sg<<endl;
}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int count;
  
  for (int a=0;a <= A;a++){
    for (int b=0;b <=B;b++){
      for (int c=0;c <=C;c++){
        
        if(X == 500*a+100*b+50*c) ++count;
        
      }
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x;
  cin >> x;
  pr((x/2)*(x/2+x%2));
}

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


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = a;
    int y = c;
    while(true){
        y-=b;
        if(y<=0){
            cout << "Yes" << endl;
            break;
        }
        x-=d;
        if(x<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
K = int(input())
alist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(alist[K-1])

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys

def main():
	N, M = map(int, input().split(" "))
	
	store = []
	for i in range(N):
		tmp = input().split(" ")
		store.append([int(s) for s in tmp])
	
	store.sort()
	
	ans = 0
	for i, val in enumerate(store):
		if val[1] >= M:
			ans = ans + (val[0] * M)
			M = 0
		if val[1] < M:
			ans = ans + (val[0] * val[1])
			M = M - val[1]
		if M <= 0 :
			break
	
	print(ans)
			
if __name__ == "__main__":
	main()
	

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> ni(n + 1);
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    ++ni[l], --ni[r];
  }
  for (int i = 1; i <= n; ++i) {
    ni[i] += ni[i - 1];
    if (ni[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

ll inf=1ll<<60;

ll gcd(ll n,ll m){
	while (n!=0&&m!=0){
		if (n>m){n%=m;}
		else {m%=n;}
	}
	return n+m;
}

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	if (c%gcd(a,b)==0){
		cout<<"YES";
	}
	else {
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
static const int MAX = 200000;

pair<ll, ll> a[100009];

int main() {
    ll N, M;
    ll cnt = 0;
    cin >> N >> M;
    ll altitude[MAX];
    ll tower[MAX];
    for(int i = 0; i < N; i++)
        tower[i] = 0;
    for(int i = 0; i < N; i++)
        cin >> altitude[i];
    for(int i = 0; i < M; i++)
    {
        cin >> a[i].first;
        cin >> a[i].second;
    }
    for(int i = 0; i < M; i++)
    {
        if(altitude[a[i].first - 1] <= altitude[a[i].second - 1])
            tower[a[i].first - 1]++;
        if(altitude[a[i].first - 1] >= altitude[a[i].second - 1])
            tower[a[i].second - 1]++;
    }
    for(int i = 0; i < N; i++)
    {
        if(tower[i] == 0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6756
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = A + A
mod = 10 ** 9 + 7

count1 = 0
count2 = 0

#A1回での転倒数を求める
for i in range(N):
  for j in range(i+1, N):
    if A[i] > A[j]:
      count1 += 1 
      
#繰り返すことで生じる転倒数を求める
for i in range(2*N):
  for j in range(i+1, 2*N):
    if A2[i] > A2[j]:
      count2 += 1
      
count3 = count2 - count1 * 2

count = count3 * (K - 1) * K // 2 + count1 * K
print(count % mod)
#print(count1,count2,count3)



Measured memory_bytes: 41836
package main

import (
	"fmt"
)

func main() {
	var a, b, coin int
	fmt.Scan(&a, &b)

	if a == b {
		coin = 2 * a
	} else if a > b {
		coin = 2*a - 1
	} else {
		coin = 2*b - 1
	}
	fmt.Printf("%d", coin)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>


using namespace std;


struct node {
    long k;
    node *l, *r, *p;
};


int top = 0;
node nodes[500001];
node *t, *z;

void insert(long k)
{
    node *f = &nodes[top++];
    f->k = k;

    node *tmp = t, *p = z;
    while(tmp != z) {
        p = tmp;
        if (k <= tmp->k) {
            tmp = tmp->l;
        } else {
            tmp = tmp->r;
        }
    }

    f->p = p;
    if (p == z) {
        t = f;
    } else if (k <= p->k) {
        p->l = f;
    } else {
        p->r = f;
    }
}


void inorder(node *x)
{
    if (x->l != z)
        inorder(x->l);
    cout << " " << x->k;
    if (x->r != z)
        inorder(x->r);
}


void preorder(node *x)
{
    cout << " " << x->k;
    if (x->l != z)
        preorder(x->l);
    if (x->r != z)
        preorder(x->r);
}


void print()
{
    inorder(t);
    cout << endl;
    preorder(t);
    cout << endl;
}


node *find(long k)
{
    node *tmp = t;
    while (tmp != z && tmp->k != k) {
        if (k <= tmp->k)
            tmp = tmp->l;
        else
            tmp = tmp->r;
    }

    return tmp;
}


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

    z= &nodes[n];
    z->p = z;
    z->l = z;
    z->r = z;

    t = z;

    for (int i = 0; i < n; i++) {
        nodes[i].p = z;
        nodes[i].l = z;
        nodes[i].r = z;
    }

    for (int i = 0; i < n; i++) {
        string cmd;
        cin >> cmd;
        if (cmd[0] == 'i') {
            long k;
            cin >> k;
            insert(k);
        } else if (cmd[0] == 'p') {
            print();
        } else if (cmd[0] == 'f') {
            long k;
            cin >> k;
            if (find(k) == z)
                cout << "no" << endl;
            else
                cout << "yes" << endl;
        }
    }
}


Measured memory_bytes: 18804
//phoenix




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=0; i--)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a) sort(a,a+n);


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;



/*
ll solveDp(ll i,ll w[],ll v[],ll n,ll wt,map <ll,map <ll,ll> > &dp) {
    if(i>=n || wt<0)
        return 0;
    if(dp[wt][i])
        return dp[wt][i];
    else if(wt<w[i])
        return dp.insert(mp([wt][i]=solveDp(i+1,w,v,n,wt,dp);
    else
        return dp[wt][i]=max(solveDp(i+1,w,v,n,wt,dp),v[i]+solveDp(i+1,w,v,n,wt-w[i],dp));
}
*/


/*
void bfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    queue <ll> q;
    q.push(k);
    while(!q.empty()) {
        ll node=q.front();
        q.pop();
        cout<<node<<" ";
        vis[node-1]=true;
        fr(j,0,v[node-1].size()) {
            if(vis[v[node-1][j]-1]!=true)
                q.push(v[node-1][j]),vis[v[node-1][j]-1]=true;
        }
    }
}




void dfs(ll k,bool vis[],ll n,vector <ll> v[]) {
    cout<<k<<" ";
    vis[k-1]=true;
    fr(i,0,v[k-1].size()) {
        if(!vis[v[k-1][i]-1])
            dfs(v[k-1][i],vis,n,v);
    }
}




ll solveDp(ll i,ll a[],ll n,vector <ll> &dp) {
    if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    else {
        ll mx=-inf;
        fr(j,0,n) {
            mx=max(mx,a[i]+solveDp(i+j+2,a,n,dp));
        }
        return dp[i]=mx;
    }
}
*/



void cazz() {
    ll r;
    cin>>r;
    double res;
    res=((double)22/7)*2*r;
    cout<<res<<"\n";
    /*cin>>n>>m;
    vector <ll> v[n];
    fr(i,0,m) {
        cin>>j>>k;
        v[j-1].pb(k);
        v[k-1].pb(j);
    }
    cout<<"\n";
    fr(i,0,n) {
        cout<<i+1<<"\t";
        fr(j,0,v[i].size()) {
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
    cout<<"\n";
    cin>>k;
    bool vis[n]={};
    bfs(k,vis,n,v);
    cout<<"\n";
    bool vi[n]={};
    dfs(k,vi,n,v);*/
}




int main() {
    spdio;
	cazz();
	return 0;
}


Measured memory_bytes: 3796
def main():
    S = input()
    if len(set(S)) == 1:
        print(0)
    else:
        s2 = ''
        prev = ''
        for si in S:
            if si == prev:
                pass
            else:
                s2 += si
            prev = si
        
        print(len(s2) - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;
constexpr char nl = '\n';

int main() {
    string S;
    cin >> S;
    long long nw = 0, n = 0; 
    for (auto i : irange(0ul, S.size())) {
        if (S[i] == 'W') {
            n += i - nw;
            nw++;
        }
    }
    cout << n << nl;
}


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

int main()
{
	std::vector<std::string> day_of_week{
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};

	std::vector<int> day_num_of_month{
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};

	int month = 0;
	int day = 0;

	while (std::cin >> month >> day)
	{
		if (0 == month) { break; }

		int days_elapsed = 0;
		for (int m = 1; m < month; ++m)
		{
			days_elapsed += day_num_of_month[m - 1];
		}
		days_elapsed += day;

		std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3024
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long q = sc.nextLong();
		
		for(long z=0; z<q; z++){
			String str = sc.next();
			int[] a = new int[8];
		
			for(int i=0; i<8; i++){
				if(str.charAt(i) >= 'a'){
					a[i] = (int)str.charAt(i) - 'a' + 10;
				}
				else{
					a[i] = Integer.parseInt(str.charAt(i) + "");
				}
				//System.out.println(a[i]);
			}
		
			StringBuffer sb = new StringBuffer();
			for(int i=0; i<8; i++){
				sb.append(a[i]/8);
				if(a[i]/8>0) a[i]-=8;
				sb.append(a[i]/4);
				if(a[i]/4>0) a[i]-=4;
				sb.append(a[i]/2);
				if(a[i]/2>0) a[i]-=2;
				sb.append(a[i]/1);
			}			
		
			//System.out.println(sb);
			
			int minus=0;
			BigDecimal ans = new BigDecimal("0");
			
			if(sb.charAt(0)=='1') minus=1;
			
			for(int i=1; i<32; i++){
				if(sb.charAt(i)=='1'){
					BigDecimal tnp = new BigDecimal(Math.pow(2.0, 24-i));
					ans = ans.add( tnp );
				}
			}
			
			if(minus==1) System.out.print("-");
			System.out.print(ans);
			
			int scale = ans.scale();
			if(scale==0) System.out.print(".0");
	
			System.out.println();
		}
	
	}
}

Measured memory_bytes: 60336
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
ll n, a, b, k, com[300010], ans;
const ll mod = 998244353;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n >> a >> b >> k;
	com[0] = 1;
	for (ll i = 0; i < n; i++)
	{
		com[i + 1] = com[i] * (n - i) % mod * div(i + 1) % mod;
	}
	for (ll i = 0; i <= n; i++)
	{
		ll j = (k - a * i) / b;
		if (j <= n && j >= 0 && k == a * i + b * j)
		{
			(ans += (com[i] * com[j]) % mod) %= mod;
		}
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N,W;
	
	scanf("%d %d",&N,&W);
	
	vector<int> v(N);
	vector<int> w(N);
	vector<int> dp(10001,0);
	
	for(int i=0;i<N;i++){
		scanf("%d %d",&v[i],&w[i]);
	}
	for(int i=0;i<N;i++){
		for(int j=w[i];j<=W;j++){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	printf("%d\n",*max_element(dp.begin(),dp.begin()+W+1));
}


Measured memory_bytes: 3280
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const string YES = "Yes";
const string NO = "No";
void yn(bool ok){
  cout << (ok ? YES : NO) << endl;
}

void solve(long long K, long long X){
  yn(500*K>=X);
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long K;
  scanf("%lld",&K);
  long long X;
  scanf("%lld",&X);
  solve(K, X);
  return 0;
}


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

using namespace std;

int main() {

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

	long long x, N, K;
	cin >> N >> K;
	if (N % K < llabs((N % K) - K)) cout << N % K;
	else cout << llabs((N % K) - K);
	// if (N == K) cout << N - K;
	// else if (N < K) {
	// 	if (N < llabs(N - K)) cout << N;
	// 	else cout << llabs(N - K);
	// }
	// else if (N > K) {
	// 	if (N % K < llabs((N % K) - K)) cout << N % K;
	// 	else cout << llabs((N % K) - K);
	// }
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,m,q;
    cin>>n>>m>>q;
    VV query(q,V(4));
    rep(i,q){
        rep(j,4){
            cin>>query[i][j];
        }
    }
    V vec;
    rep(i,m-1){
        vec.push_back(1);
    }
    rep(i,n){
        vec.push_back(0);
    }
    sort(all(vec));
    ll res=0;
    do{
        ll reg=1;
        ll tempres=0;
        V temp;
        for(auto i:vec){
            if(i==0){
                temp.push_back(reg);
            }else{
                reg++;
            }
        }
        rep(i,q){
            if(temp[query[i][1]-1]-temp[query[i][0]-1]==query[i][2]){
                tempres+=query[i][3];
            }
        }
        chmax(res,tempres);
    }while(next_permutation(all(vec)));
    cout<<res<<endl;
}


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

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

use std::cmp::{max, min};
use std::collections::HashMap;

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

  let x1 = 0;
  let y1 = c[0][0];
  let y2 = c[0][1];
  let y3 = c[0][2];
  let x2 = c[1][0] - y1;
  let x3 = c[2][0] - y1;

  if y2 + x2 == c[1][1] && y2 + x3 == c[2][1] && y3 + x2 == c[1][2] && y3 + x3 == c[2][2] {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
using ll = long long;

using namespace std;

int main(){
	/*int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if(cin.eof())	break;	
		a[i]=x;
	}*/
	
	int n,t,a;
	
	cin >> n;
	
	int h[n];
	cin >> t >> a;
	rep(j, n){
		cin >> h[j];
	}
	
	int ans=0;
	
	rep(i, n){
		if(fabs(t-0.006*h[i]-a) < fabs(t-0.006*h[ans]-a)){
			
			ans = i;
		}
	}
	cout << ans+1 << endl;
	
	return 0;
}


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

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

    vector<int> kushi;
    for (int i = 0; i < in * 2; i++) {
        int k;
        cin >> k;
        kushi.push_back(k);
    }
    sort(kushi.begin(), kushi.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < in * 2; i = i + 2) {
        auto m = min(kushi.at(i), kushi.at(i + 1));
        sum += m;
    }
    cout << sum << endl;
    return 0;
}

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

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i, s in enumerate(S):
    if (i + 1) % 2 == 1 and (s not in odd):
        print("No")
        exit()
    if (i + 1) % 2 == 0 and (s not in even):
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3060
N, M = map(int, input().split())
edges = [list(map(int,input().split())) for i in range(M)]

connect_to_1 = []
connect_to_N = []
for i in range(M):
  if edges[i][0] == 1:
    connect_to_N.append(edges[i][1])
  if edges[i][1] == N:
    connect_to_1.append(edges[i][0])

if len(set(connect_to_1) & set(connect_to_N)) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 61088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
int n, m, x, y;ll z = 0, w, h, sum = 0, ans = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
	cin >> n; vector<ll> k(5, 0); string s;
	rep(i, n) {
		cin >> s;
		if (s[0] == 'M') k[0]++;
		else if (s[0] == 'A')k[1]++;
		else if (s[0] == 'R')k[2]++;
		else if (s[0] == 'C') k[3]++;
		else if (s[0] == 'H') k[4]++;
	}
	rep(i, 1 << 5) {
		int cnt = 0; sum = 1;
		rep(j, 5) {
			if (i & (1 << j)) cnt++;
		}
		if (cnt != 3) continue;
		rep(j, 5) {
			if (i & (1 << j))sum *= k[j];
		}
		ans += sum;
	}cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int maxn = 1e4 + 5;
const int MAX = 10000000;

int n;
ll a[maxn];
ll po[40];
int main()
{
    po[0]=1;
    for(int i=1;i<=32;i++)
        po[i]=po[i-1]*2;
    ll ans=0;
   cin>>n;
   for(int i=1;i<=n;i++)
    cin>>a[i];
   for(int i=1;i<=n;i++)
   {
    for(int j=32;j>=1;j--)
    {
        if(a[i]%po[j]==0)
            {
                ans+=j;
                break;
            }
    }
   }
   cout<<ans;
    return 0;
}

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

int main(){
  double W, H, area;
  int x, y, j;
  j = 0;
  cin >> W >> H >> x >> y;
  if((W==2*x)&&(H==2*y)) j = 1;
  
  area = W * H / 2.0;

  cout << area << " " << j;
  return 0;
}

Measured memory_bytes: 256
n, c, k = gets.chomp.split.map(&:to_i)
t = Array.new(n) { gets.to_i }.sort!
i = n
res = 0
while i > 0
  r = t[0...i]
  v = r.bsearch_index {|x| x >= t[i - 1] - k }
  i -= [i - v, c].min
  res += 1
end
puts res


Measured memory_bytes: 15892
#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];
    }

    long long ans = 1000;
    for (int i = 0; i < n - 1; i++)
    {
        if(a[i] < a[i + 1])ans += (a[i + 1] - a[i]) * (ans /  a[i]);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

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

    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    long long sum = 0;

    if (K - A >= 0) {
        sum += A;
    } else {
        sum += K;
    }
    K -= A;
    K -= B;
    if (K > 0) {
        if (K - C < 0) {
            sum -= K;
        } else {
            sum -= C;
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using std::max; 
const int N=1005;
long long sum1,sum2;
int a[N],ans[N],n,cnt,now,l,r,t;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (i&1) sum1+=max(a[i],0);
		else sum2+=max(a[i],0);
	}
	if (sum1==0 && sum2==0){
		int mx=1;
		for (int i=1;i<=n;i++) if (a[i]>a[mx]) mx=i;
		printf("%d\n%d\n",a[mx],n-1);
		for (int i=n;i>mx;i--) printf("%d\n",i);
		for (int i=1;i<mx;i++) printf("%d\n",1);
		return 0; 
	}
	if (sum1>sum2){
		t=1;
		printf("%lld\n",sum1);	
	} else t=0,printf("%lld\n",sum2);
	int i=n;
	for (;(i%2)!=t || a[i]<0;i--) ans[++cnt]=i;
	r=i;
	i=1;
	for (;(i%2)!=t || a[i]<0;i++) ans[++cnt]=1;
	l=i;
	for (i=l;i<=r;i+=2) 
		if (a[i]<0 && (i%2)==t) ans[++cnt]=now*2+1;
		else now++;
	for (int i=1;i<now;i++) ans[++cnt]=2;
	printf("%d\n",cnt);
	for (int i=1;i<=cnt;i++) printf("%d\n",ans[i]); 
}

Measured memory_bytes: 3772
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //next()で受け取って/を閾値で分けて配列に入れる
        String date[] = sc.next().split("/", -1);
        sc.close();
        String kekka = jud(date);
        System.out.println(kekka);
    }
    
    private static String jud(String data[]){
        int a = 0;
        String kekka = null;
        if((a = Integer.parseInt(data[0])) <= 2019){
            if(Integer.parseInt(data[1]) < 5){
                kekka = "Heisei";
            }else{
                kekka = "TBD"; 
            }
        }
        return kekka;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    long double a, b;
    cin >> a >> b;
    a *= b;
    ll x = ll(a);
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3796
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        System.out.println((a * b) % 2 == 0 ? "Even" : "Odd");
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld", &n)
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define uu first
#define vv second
#define MOD 1000000007
#define inf 1000000000
#define limit 10001000

int ar[100005][4];
int dp[100005][4];

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

    int i, j, k, n;

    while(scanf("%d", &n)==1)
    {
//        cout<<n<<endl;
        for(i=1; i<=n; i++)
        {
            for(j=0; j<3; j++)
            {
//                cout<<"i= "<<i<<" j= "<<j<<endl;
                scanf("%d", &ar[i][j]);
                dp[i][j]=ar[i][j];
            }
        }

//        cout<<"end\n";
//        memset(dp, 0, sizeof dp);

        for(i=1; i<n; i++)
        {
            if(i+1<=n)
            {
                for(j=0; j<3; j++)
                {
                    for(k=0; k<3; k++)
                    {
                        if(j==k)
                            continue;

                        dp[i+1][k]=max(dp[i+1][k], dp[i][j]+ar[i+1][k]);
                    }
                }
            }
        }

        printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
    }


    return 0;
}





Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        map<string,int> mp;
        fr(i,0,n)
        {
            string s;
            cin>>s;
            mp[s]++;
        }
        cout<<"AC x "<<mp["AC"]<<endl;
        cout<<"WA x "<<mp["WA"]<<endl;
        cout<<"TLE x "<<mp["TLE"]<<endl;
        cout<<"RE x "<<mp["RE"]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    string s;
    cin >> s;
    long long int ans = 0;
    long long int count = 0;
    for(long long int i = 0; i < s.length(); i++){
        if(s[i] == 'W'){
            ans += (i - count);
            count++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
// KOI NI YAAR SAB SAHI HOEGA  BAS  CHORRO MAT
// ENJOR KARO YAAR
// HAAR MAT MAANO
// // APNA TIME AAYEGA
// BEILIEVE IN GOD
#include<bits/stdc++.h>
using namespace std;
#define lli int
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define loopb(i,a,b) for (lli i=a;i>=b;i--)
#define pb push_back
#define mod 1000000007
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define gcd(a,b) (__gcd((a),(b)))
#define lcm(a,b)(((a)*(b))/gcd((a),(b)))
#define ma 1e18
#define bc __builtin_popcountll
#define vi vector<lli>
#define pr pair<lli,lli>
#define vp vector<pr>
#define F  first
#define S   second
#define lld  double
#define PI  3.14159265358979
#define pri  priority_queue<ll>
#define prim  priority_queue<ll,vector<ll>,greater<ll>>
#define flush  cout<<flush

const lli  N=3e3+10;
 
vector<vector<lld>> dp(N,vector<lld>(N,-1)); 
lli n;
lld a[3000];



lld solve(lli index , lli tails)
{if(index == n)
{if(tails<=n/2)
{return 1;
}
else
{return 0;
}
}
if(dp[index][tails]!=-1)
{return dp[index][tails];
}
return dp[index][tails] = (a[index] *1.0 * solve(index+1,tails)) + (1-a[index])  * 1.0 * solve(index+1,tails+1);
}

int main()
{lli num;
fast();
cin>>n;

loop(i,0,n)
{cin>>a[i];
}

cout<<fixed<<setprecision(10)<<solve(0,0)<<"\n";
}


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

int main(){
  int n;
  cin >> n;
  int color=0, c=0;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    if(color==tmp){
      c++;
      color=0;
    }
    else {
      color=tmp;
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define pb push_back
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 

using namespace std;

void test(){
	int h,w,k;
	cin>>h>>w>>k;
	string s[h];
	f(i,h)cin>>s[i];
	
	ll res = 0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			int cnt = 0;
			f(row,h){
				if(!(i&(1<<row))){
					f(col,w){
						if(!(j&(1<<col))){
							if(s[row][col]=='#')cnt++;
						}
					}	
				}	
			}
			if(cnt==k)res++;
		}
	}
	cout<<res<<"\n";
}

int main(){
	int tests=1;
//	cin>>tests;
	while(tests--){
		test();
	}
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;
typedef pair<int, int> pii;
int lst[26], frm[200010], nxt[200010][26];
char s[200010];
queue<pii> Q;
string tmp, ans;
int main() {
	scanf("%s", s);
	int l = strlen(s);
	memset(lst, -1, sizeof lst);
	for (int i = l - 1; ~i; i--)
		memcpy(nxt[i], lst, sizeof lst),
		lst[s[i] - 'a'] = i;
	int mlen = 0x3f3f3f3f;
	for (int i = 0; i < 26; i++) {
		if (lst[i] == -1) {
			ans.clear();
			ans.push_back(i + 'a');
			break;
		}
		while (!Q.empty()) Q.pop();
		memset(frm, -1, sizeof frm);
		Q.push(pii(lst[i], 1)); pii w;
		int l = -1, smlst = -1;
		while (true) {
			w = Q.front(); Q.pop();
			if (w.second + 1>= mlen) break;
			for (int i = 0; i < 26; i++)
				if (nxt[w.first][i] == -1) {
					l = w.first; smlst = i; mlen = w.second + 1;
					break;
				}
				else {
					if (~frm[nxt[w.first][i]]) continue;
					frm[nxt[w.first][i]] = w.first;
					Q.push(pii(nxt[w.first][i], w.second + 1));
				}
			if (~smlst) break;
		}
		if (smlst == -1) continue;
		tmp.clear();
		tmp.push_back(smlst + 'a');
		while (~l) {
			tmp.push_back(s[l]);
			l = frm[l];
		}
		reverse(tmp.begin(), tmp.end());
		ans = tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 21632
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0501?year=2006

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;

    while (cin >> n, n) {
        map<char, char> mp;
        for (int i = 0; i < n; ++i) {
            char x, y;
            cin >> x >> y;
            mp[x] = y;
        }

        int m;
        cin >> m;

        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            if (mp[c] != 0) {
                cout << mp[c];
            } else {
                cout << c;
            }
        }
        cout << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T 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;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, m;
	cin >> n >> m;

	/*
	// 愚直に表示するプログラムを書いてみる
	cout << "〇：表" << endl << "●：裏" << endl;
	vector<vector<bool>> cards(n, vector<bool>(m, true));
	rep(i, 0, n) {
		rep(j, 0, m) {
			repeq(si, -1, 1) {
				if (0 <= i + si && i + si < n) {
					repeq(sj, -1, 1) {
						if (0 <= j + sj && j + sj < m) {
							cards[i + si][j + sj] = !cards[i + si][j + sj];
						}
					}
				}
			}
		}
	}
	rep(i, 0, n) {
		rep(j, 0, m) {
			if (cards[i][j]) {
				cout << "〇";
			}
			else {
				cout << "●";
			}
		}
		cout << endl;
	}
	*/

	if (m < n) {
		swap(n, m);
	}
	if (n * m == 1) {
		cout << 1 << endl;
	}
	else if (n == 1) {
		cout << m - 2 << endl;
	}
	else {
		cout << n * m - (2 * n + 2 * m - 4) << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
M, D = map(int, input().split())
res = 0
for i in range(1, D + 1):
  for j in range(1, M + 1):
    if i < 10:
      continue
    n = list(str(i))
    if int(n[0]) < 2 or int(n[1]) < 2:
      continue
    if int(n[0]) * int(n[1]) == j:
      res += 1
print(res)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

int n, smax = 0;;
int A[5][110];

int main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	
	cin >> n;
	for (int i=0; i < 2; i++) {
		for (int j=0; j < n; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		int score = 0;
		for (int j = 0; j <= i; j++) {
			score += A[0][j];
		}
		for (int k = i; k < n; k++) {
			score += A[1][k];
		}
		smax = max(smax, score);
	}

	cout << smax << endl;
	

	return 0;
}

Measured memory_bytes: 256