akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String s[]) {
        Scanner sc = new Scanner(System.in);
        String str = "";
        if (sc.hasNextLine())
            str = sc.nextLine();
        if (str.charAt(str.length() - 1) == 's')
            str += "es";
        else
            str += 's';
        System.out.println(str);
    }
}


Measured memory_bytes: 27000
#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() {

  ll n, m;
  cin >> n >> m;
  ll ans = n % m;
  ans = min(ans, m - ans);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
map<int, int> m;
int n;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    m[a]++;
  }
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    if(!m[a]--){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 9600
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;


import java.util.HashSet;
import java.util.Collections;


public class Main{
    static Scanner sc=new Scanner(System.in);
    static int a=sc.nextInt();
    static int b=sc.nextInt();
    
    public static void main(String[] args){
        int c=b-a;
        int sum=0;
        for(int i=1;i<c;i++){
            sum+=i;
        } 
        System.out.println(sum-a);
        

        
            

        
        

    }
    
        
        
    }


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  bool flag=true;
  long long count=0;
  while(flag){
    if(A%2!=0||B%2!=0||C%2!=0){
      flag=false;
      break;
    }
    if(A==B&&B==C){
      count=-1;
      flag=false;
      break;
    }
    long long AA=A;
    long long BB=B;
    long long CC=C;
    A=BB/2+CC/2;
    B=AA/2+CC/2;
    C=BB/2+AA/2;
    count++;
  }
  cout<<count<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

vector<vector<int> > dp;

int main(){

    string s;
    cin >> s;
    int n = s.size();
    dp.assign(n+1, vector<int>(2, 0));
    dp[0][0] = 1;
    rep(i, n){
        if(s[i] == '0') {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
        }
        else
            dp[i+1][1] = (dp[i][0]+dp[i][1])%MOD;

        if(s[i] == '0')
            (dp[i+1][1] += 2*dp[i][1]%MOD) %= MOD;

        else{
            (dp[i+1][0] += 2*dp[i][0]%MOD) %= MOD;
            (dp[i+1][1] += 2*dp[i][1]%MOD) %= MOD;
        }
    }
    ppp((dp[n][0]+dp[n][1])%MOD);
    return 0;
}


Measured memory_bytes: 5840
#include <iostream>

using namespace std;

int haming(string s1, string s2){
  int n=0;
  for (int i = 0; i < s1.size(); i++){
    if (s1[i] != s2[i]) n++;
  }
  return n;
}

int main(){
  string S;
  string S1, S2;
  cin >> S;
  for (int i = 0; i < S.size(); i++){
    S1.append(1, '0' + i%2);
    S2.append(1, '0' + (i+1)%2);
  }

  printf("%d\n", min(haming(S, S1), haming(S, S2)));
  
}


Measured memory_bytes: 4284
//A
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    rep(i,5){
        int x;cin>>x;
        if(x==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(){
    int  W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H) {
      printf("Yes\n");
    } else { 
      printf("No\n");
    }
    return 0;
}      


Measured memory_bytes: 2104
from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()

    # print(guusuu, len(guusuu))
    # print(kisuu, len(kisuu))
    
    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            # n=4, `4 4 4 4`
            # print('----------')
            print(guusuu[0][1])
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()

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

int main(){
  char X, Y;
  cin >> X >> Y;

  if (X == 'A') X = 10;
  if (X == 'B') X = 11;
  if (X == 'C') X = 12;
  if (X == 'D') X = 13;
  if (X == 'E') X = 14;
  if (X == 'F') X = 15;

  if (Y == 'A') Y = 10;
  if (Y == 'B') Y = 11;
  if (Y == 'C') Y = 12;
  if (Y == 'D') Y = 13;
  if (Y == 'E') Y = 14;
  if (Y == 'F') Y = 15;

  if (X < Y){
    cout << "<";
  }else if(X > Y){
    cout << ">";
  }else{
    cout  << "=";
  }
}


Measured memory_bytes: 256
#include <iostream>
 
int main(){
    u_int a, b;
     
    while(std::cin >> a >> b){
        u_int n = a + b;
        u_int count = 1;
        
        while(n / 10 != 0){
            n /= 10;
            ++count;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int n;
int u,v;
vector<int> ga[200100];
int vis[200100];
int mx[4];
int cnt[4];
int cz[3];
int res[200100];
void bipartite(int u,int co){//二分图染色 
	vis[u]=co;
	cz[co]++;
	for(int v:ga[u]){
		if(!vis[v]){
			bipartite(v,3-co);
		}
	}
}
void asgn(int vert,vector<int> ve){//把ve内容分配给vert，按序分配 
	for(int i=0;i<ve.size();i++){
		if(mx[ve[i]]<cnt[ve[i]]){
			res[vert]=3*mx[ve[i]]+ve[i];
			mx[ve[i]]++;
			return;
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	} 
	bipartite(1,1);
	cnt[3]=n/3;
	cnt[1]=n/3;
	cnt[2]=n/3;
	if(n%3==1){
		cnt[1]++;
	}
	if(n%3==2){
		cnt[1]++;
		cnt[2]++;
	}
	if(cz[1]>cz[2]){
		swap(cz[1],cz[2]);
		for(int i=1;i<=n;i++){
			if(vis[i]==1)
				vis[i]=2;
			else
				vis[i]=1;
		}
	}
	if(cz[1]<=cnt[3]){
		for(int i=1;i<=n;i++){
			if(vis[i]==1)
				asgn(i,{3});
			else
				asgn(i,{1,2,3});
		} 
	}
	else{
		for(int i=1;i<=n;i++){
			if(vis[i]==1){
				asgn(i,{1,3});
			}
			else{
				asgn(i,{2,3});
			}
		} 
	}
	for(int i=1;i<=n;i++)
		cout<<res[i]<<' ';
	cout<<endl;
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    map<int,int>c;
    int n;cin>>n;
    rep(i,n){
        int a;cin>>a;c[a]++;
    }

    int ans=0;
    for(auto &p:c){
        if(p.fi<=p.se)ans+=p.se-p.fi;
        else ans+=p.se;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6272
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
          int count=0;
          int a=sc.nextInt();
          int b=sc.nextInt();
          int c=sc.nextInt();
        for(int i=a;i<=b;i++){
            if(c%i==0){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main()
{
    int n, m, a[25][25], b[25], c, cnt=0;
    cin>>n>>m>>c;
    for(int i=0; i<m; i++) cin>>b[i];
    for(int i=0; i<n; i++)
    {
        int sum=0;
        for(int j=0; j<m; j++)
        {
            cin>>a[i][j];
            sum+=(a[i][j]*b[j]);
        }
        if((sum+c)>0) cnt++;

    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
s = input()

a = int(s[0:2])
b = int(s[2:4])

aa= ''
bb= ''

if (12>= a >0):
    aa = 'M'

if (12>= b >0):
    bb = 'M'

if (aa == 'M' and bb == 'M'):
    print('AMBIGUOUS')

if (aa == 'M' and bb != 'M'):
    print('MMYY')

if (aa != 'M' and bb == 'M'):
    print('YYMM')

if (aa != 'M' and bb != 'M'):
    print('NA')

Measured memory_bytes: 38256
#include <stdio.h>
void buildMaxHeap(int*);
void maxHeapify(int*, int);
int H;
int main(){
  int i,A[500001];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  buildMaxHeap(A);
  for(i=1;i<=H;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;
}
void buildMaxHeap(int* A){
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(A, i);
}
void maxHeapify(int*A, int i){
  int l,r,largest,B;
  l=2*i;
  r=2*i+1;
  if(l <=H && A[l]>A[i])
    largest=l;
  else largest = i;
  if(r<=H && A[r]>A[largest])
    largest=r;

  if(largest!=i){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;
    maxHeapify(A, largest);
  }
}



Measured memory_bytes: 3680
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        n: usize,
        v: [usize; n], // v_1 v_2 ... v_n
    }

    let mut ans = 0;
    for i in 0..n {
        if (i+1) % 2 == 1 && v[i] % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}",ans)
}


Measured memory_bytes: 2100
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int l;
	cin >> l;
	int r;
	for (r = 0; (1 << r) <= l; ++r) {
		;
	}
	--r;
	vector<int> a, b, c;
	for (int i = 0; i < r; ++i) {
		a.push_back(i + 1);
		a.push_back(i + 1);
		b.push_back(i + 2);
		b.push_back(i + 2);
		c.push_back(0);
		c.push_back(1 << i);
	}
	for (int t = r; t >= 0; --t) {
		if ((l - (1 << t)) >= (1 << r)) {
			a.push_back(t + 1);
			b.push_back(r + 1);
			c.push_back(l - (1 << t));
			l -= 1 << t;
		}
	}
	cout << (r + 1) << " " << a.size() << endl;
	for (int i = 0; i < (int)a.size(); ++i) {
		cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
input=lambda :sys.stdin.readline().rstrip()

H,W=map(int,input().split())
S=""
for i in range(H):
    S+=input()
S=Counter(S)
c=0
b=0
a=0

for i in S:

    z=S[i]
    c+=z-z%4
    z%=4
    b+=z-z%2
    z%=2
    a+=z
C=(H-H%2)*(W-W%2)
c-=C
if c<0:
    print("No")
    exit()
b+=c
b-=(H*W//2*2-C)
if b!=0:
    print("No")
    exit()
if a-H*W%2!=0:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 5332
from functools import reduce

# 入力
s = input()
x, y = map(int, input().split())

C = [len(fs) for fs in s.split('T')]


# 動的計画法により、各軸について到達可能な座標の集合を求め、目標の座標に到達可能か判定
def f(cs, t):
    return t in reduce(
        lambda acc, c: {i + c for i in acc} | {i - c for i in acc},
        cs,
        {0}
    )


ans = (
    'Yes' if f(C[2::2], x - C[0]) and f(C[1::2], y) else
    'No'
)
# 出力
print(ans)


Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;

long long n,g,w[105],v[105],dp[100005],maxim,rasp;

int main()
{
    cin>>n>>g;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=min(g,maxim);j>=1;j--)
        {
            if(dp[j]&&j+w[i]<=g)
            {
                dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
                maxim=max(maxim,j+w[i]);
                rasp=max(rasp,dp[j+w[i]]);
            }
        }
        dp[w[i]]=max(v[i],dp[w[i]]);
        rasp=max(rasp,dp[w[i]]);
        maxim=max(maxim,w[i]);
    }
    cout<<rasp;
}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(void)
{
	int a[5];
	int r,i;
	
	while(1)
	{
		scanf("%d",&a[0]);
		if(a[0]==0)
		{
			break;
		}
		
		for(i=1;i<5;i++)
		{
			scanf("%d",&a[i]);
		}
		
		r=1;
		for(i=0;i<5;i++)
		{
			a[i]+=2;
			r*=a[i];
		}
		
		if((r%3==0)&&(r%4==0)&&(r%5==0))
		{
			//グーもチョキもパーも
			for(i=0;i<5;i++)
			{
				a[i]=3;
			}
		}
		else if((r%3==0)&&(r%4==0))
		{
			//グーとチョキ
			for(i=0;i<5;i++)
			{
				if(a[i]==3)
				{
					a[i]=1;
				}
				else
				{
					a[i]=2;
				}
			}
		}
		else if((r%4==0)&&(r%5==0))
		{
			//チョキとパー
			for(i=0;i<5;i++)
			{
				if(a[i]==4)
				{
					a[i]=1;
				}
				else
				{
					a[i]=2;
				}
			}
		}
		else if((r%5==0)&&(r%3==0))
		{
			//パーとグー
			for(i=0;i<5;i++)
			{
				if(a[i]==5)
				{
					a[i]=1;
				}
				else
				{
					a[i]=2;
				}
			}
		}
		else
		{
			//みんな同じ
			for(i=0;i<5;i++)
			{
				a[i]=3;
			}
		}
		
		for(i=0;i<5;i++)
		{
			printf("%d\n",a[i]);
		}
	}
	
	return 0;
}

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

def hash(a, b, c, d, f, start, end):
    i = start + 1
    while i < end:
        if f[i] in "+^*":
            i += 1
            if f[i] == "a":
                tmp1 = a
            elif f[i] == "b":
                tmp1 = b
            elif f[i] == "c":
                tmp1 = c
            elif f[i] == "d":
                tmp1 = d
            elif f[i] == "[":
                i, tmp1 = hash(a,b,c,d,f,i,end)
            i += 1
            if f[i] == "a":
                tmp2 = a
            elif f[i] == "b":
                tmp2 = b
            elif f[i] == "c":
                tmp2 = c
            elif f[i] == "d":
                tmp2 = d
            elif f[i] == "[":
                i, tmp2 = hash(a,b,c,d,f,i,end)
            if f[start+1] == "+":
                return i+1, tmp1 | tmp2
            elif f[start+1] == "^":
                return i+1, tmp1 ^ tmp2
            elif f[start+1] == "*":
                return i+1, tmp1 & tmp2


def main():
    while True:
        s = input().strip()
        if s[0] == ".":
            break
        p = input().strip()
        a = int(p[0])
        b = int(p[1])
        c = int(p[2])
        d = int(p[3])
        if s[0] in "abcd":
            if s[0] == 'a':
                print(a, 1000)
            elif s[0] == 'b':
                print(b, 1000)
            elif s[0] == 'c':
                print(c, 1000)
            elif s[0] == 'd':
                print(d, 1000)
            #print(int(p['s[0]' - 'a']), 1)
            continue
        _,ans1 = hash(a,b,c,d,s,0,len(s))
        count = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        _, x = hash(a,b,c,d,s,0,len(s))
                        if x == ans1:
                            count += 1
        print(ans1, count)

if __name__ == "__main__":
    main()



Measured memory_bytes: 5628
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int N,M;
char flag[51][51];
int Wcnt[51];
int Rcnt[51];
int	Bcnt[51];

int minfunc(int n,int color){
	if(n == N-1){
		if(color == 0) return 10000;
		else return 0;
	}

	if(color == 0){
		return min(Bcnt[n]+Rcnt[n]+minfunc(n+1,color),
				Wcnt[n]+Rcnt[n]+minfunc(n+1,color+1));
	} else if(color == 1) {
		return min(Wcnt[n]+Rcnt[n]+minfunc(n+1,color),
				Wcnt[n]+Bcnt[n]+minfunc(n+1,color+1));
	} else {
		return Wcnt[n]+Bcnt[n]+minfunc(n+1,color);
	}
}

int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		Wcnt[i] = 0;
		Rcnt[i] = 0;
		Bcnt[i] = 0;
		for(int j=0;j<M;j++){
			cin >> flag[i][j];
			if(flag[i][j] == 'W') Wcnt[i]++;
			if(flag[i][j] == 'B') Bcnt[i]++;
			if(flag[i][j] == 'R') Rcnt[i]++;
		}
	}
	cout << Rcnt[0]+Bcnt[0]+minfunc(1,0)+Wcnt[N-1]+Bcnt[N-1] << endl;
}


Measured memory_bytes: 3100
[n, a, b] = [int(i) for i in input().split()]
mod = 1000000007

def factorial(n,m):
    #0〜(2 * 10 ^ 5)!のリスト
    f = [1,1]
    for i in range(2,n+1):
        f.append(f[-1]*i % m)
    #modにおける逆元のリスト
    g = [1]
    for i in range(n):
        g.append(pow(f[i+1],m-2,m))
    return f,g

f, g = factorial(2*10**5+1,mod)

div_a = g[a]
for i in range(1,a+1):
    div_a *= n - i + 1
    div_a %= mod


div_b = g[b]
for i in range(1,b+1):
    div_b *= n - i + 1
    div_b %= mod


mx = pow(2, n, mod)
mx += mod*3
print((mx - 1 - div_a - div_b)%mod)


Measured memory_bytes: 54564
N, M = map(int, input().split())
E = [[] for _ in range(N)]
dp = {}

for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

S = 1
G = (1 << N) - 1


def is_visited(v: int, path: int):
    return path & (1 << v)


def visit(v: int, path: int):
    return path ^ (1 << v)


def count(u: int, path: int):
    if path == G:
        return 1

    k = (u, path)
    if k in dp:
        return dp[k]

    s = sum(
        count(v, visit(v, path))
        for v in E[u]
        if not is_visited(v, path)
    )
    dp[k] = s
    return s


print(count(0, S))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string tmp = s;
  bool flag;
  int cnt;
  int mi = 9999999;
  for(char c='a'; c<='z'; c++){
    tmp = s;
    cnt = 0;
    while(true){
      flag = true;
      for(int i=0; i<tmp.size(); i++){
        if(tmp.at(i) != c){
          flag = false;
          break;
        }
      }
      if(flag == true){
        break;
      }
      for(int i=0; i<tmp.size()-1; i++){
        if(tmp.at(i+1) == c){
          tmp.at(i) = c;
        }
      }
      tmp.pop_back();
      cnt++;
    }
    mi = min(mi,cnt);
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
H = []
for _ in range(N):
    H.append(int(input()))

H.sort()

reslist = []

for i in range(N):
        j = i + K - 1

        if j >= N:
                break

        df = H[j] - H[i]
        reslist.append(df)

res =min(reslist)
print(res)

Measured memory_bytes: 11208
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = [list(input()) for _ in range(n)]
    b = [list(input()) for _ in range(m)]

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            is_exist = True

            # See:
            # https://beta.atcoder.jp/contests/abc054/submissions/1103264
            for dx in range(m):
                if a[i + dx][j:j + m] != b[dx]:
                    is_exist = False
                    break

            if is_exist:
                print('Yes')
                exit()

    print('No')


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vvll v(200005,vll(0));
vll A(200005);
vll B(200005);
void dfs(ll p,ll a){
  A[p]+=A[a]+B[p];
  for(ll i=0;i<v[p].sz;i++){
    if(a!=v[p][i]){
      dfs(v[p][i],p);
    }
    if(v[p][i]==0&&v[p][i+1]==0)break;
  }
}

int main(){
  ll n,q;
  cin>>n>>q;
  FOR(i,0,n-1){
    ll a,b;
    cin>>a>>b;
    v[a].pb(b);
    v[b].pb(a);
  }
  //FOR(i,1,4)co(v[i][0]<<" "<<v[i][1]<<" "<<v[i][2]);
  FOR(i,0,q){
    ll p,x;
    cin>>p>>x;
    B[p]+=x;
  }
  dfs(1,0);
  FOR(i,1,n+1){
    co(A[i]);
  }
}
  
  

Measured memory_bytes: 25856
#include <stdio.h>
#include <algorithm>
using namespace std;

int a[3];

int main(){
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    sort(a, a+3);
    int x = (a[2]*10) + a[1]+a[0];
    printf("%d\n", x);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "F"
const ll base=1000000007;
int n;
ll it[4000001];
ll lz[4000001];
void update(int i, int l, int r, int u, int v, ll x){
    if(l>v||r<u) return;
    if(u<=l&&v>=r){
        it[i]=(it[i]+x)%base;
        lz[i]=(lz[i]+x)%base;
    }
    else{
        int m=(l+r)/2;
        it[2*i]=(it[2*i]+lz[i])%base;
        lz[2*i]=(lz[2*i]+lz[i])%base;
        it[2*i+1]=(it[2*i+1]+lz[i])%base;
        lz[2*i+1]=(lz[2*i+1]+lz[i])%base;
        lz[i]=0;
        update(2*i, l, m, u, v, x);
        update(2*i+1, m+1, r, u, v, x);
        it[i]=(it[2*i]+it[2*i+1])%base;
    }
}
ll get(int i, int l, int r, int u, int v){
    if(l>v||r<u) return 0;
    if(u<=l&&v>=r) return it[i];
    else{
        int m=(l+r)/2;
        it[2*i]=(it[2*i]+lz[i])%base;
        lz[2*i]=(lz[2*i]+lz[i])%base;
        it[2*i+1]=(it[2*i+1]+lz[i])%base;
        lz[2*i+1]=(lz[2*i+1]+lz[i])%base;
        lz[i]=0;
        return get(2*i, l, m, u, v)+get(2*i+1, m+1, r, u, v);
    }
}
ll ans=0;
ll f[1000001];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    f[0]=1;
    FFOR(i, 0, n){
        if(i) f[i]=get(1, 1, n, i, i);
        if(i+3<=n) update(1, 1, n, i+3, n, f[i]);
        update(1, 1, n, i+1, i+1, f[i]);
    }
    ll sq=n-1;
    sq=(sq*sq)%base;
    ll ans=(f[n-1]*n)%base;
    DFOR(i, n-2, 0){
        ans=(ans+f[i]*sq)%base;
        ans=(ans+f[i]*(max(n-max(n-i-1, 2)+1, 0)))%base;
    }
    ans=(ans+base)%base;
    writeln(ans);
}

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

using namespace std;

#define MAX_V 100000

int V;
vector <int> graph[MAX_V];
bool vis[MAX_V];
vector <int> mlist;
int indeg[MAX_V];

void topologicalsort() {
  memset(indeg, 0, sizeof(indeg));
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      int p = graph[i][j];
      indeg[p]++;    
    }
  }

  for (int i = 0; i < V; i++) {
    if (indeg[i] == 0 && !vis[i]) {
      queue<int> que;
      que.push(i);
      mlist.push_back(i);
      vis[i] = true;
      while (!que.empty()) {
	int p = que.front(); que.pop();

	for (int j = 0; j < graph[p].size(); j++) {
	  int np = graph[p][j];
	  indeg[np]--;
	  if (vis[np]) continue;
	  if (indeg[np] == 0) {
	    vis[np] = true;
	    que.push(np);
	    mlist.push_back(np);
	  }
	}
      }
    }
  }
}

int main() {
  int E;
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    graph[s].push_back(t);
  }
  topologicalsort();

  for (int i = 0; i < mlist.size(); i++) {
    cout << mlist[i] << endl;
  }
}

Measured memory_bytes: 6272
/**
 * author  : UshanGhosh
 * created : 2020-09-20 20:34:20
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (int)1e9+7
#define    inf     (long long)1e18
#define    endl    '\n'

long long bigmod(long long a, long long b, long long M){
    if(b==0) return 1%M;
    ll x = bigmod(a,b/2,M);
    x=(x*x)%M;
    if(b%2==1) x=(x*a)%M;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    ll ans = bigmod(10,n,mod);
    ll pans = 2*bigmod(9,n,mod);
    pans -= bigmod(8,n,mod);
    pans += mod;
    pans %= mod;
    ans -= pans;
    ans += mod;
    ans %= mod;
    cout<<ans<<"\n";
}

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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 

struct p {
    ll a,b;
};

bool operator<(p &p1, p &p2) {
    return (p1.a + p1.b < p2.a + p2.b);
}

vector<p> v;

int main() {
    ios_base::sync_with_stdio(false);
    ll n,a,b;
    ll aa=0,bb=0;
    v.clear();
    cin >> n;
    rep(i,n) {
        cin >> a >> b;
        v.push_back(p{a,b});
    }
    sort(v.begin(),v.end());
    if (n%2) a=1;
    else a=0;
    rrep(i,n) {
        if (i%2==a) bb+=v[i].b;
        else aa+=v[i].a;
    }
    aa-=bb;
    cout << aa << '\n';
    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 2420
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=0
if n%2==1:
    ans=0
else:
    for i in range(40):
        ans+=(n//(2*5**(i+1)))
print(ans)


Measured memory_bytes: 38384
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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; }
ll n, k;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k;
    ll temp=k%50;
    ll temp1=k/50;
    cout<<50<<"\n";
    ll j=0;
    vector<ll> a(50);
    for(int i=temp;i<50;i++){
        a[i]=j+temp1;
        j++;
    }
    for(int i=0;i<temp;i++){
        a[i]=j+temp1+1;
        j++;
    }
    rep(i,50){
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin >> O >> E;
  if(O.size() == E.size()){
    for(int i = 0; i < O.size(); i++){
      cout << O[i] << E[i];
    }
  }
  else{
    for(int i = 0; i < O.size()-1; i++){
      cout << O[i] << E[i];
    }
    cout << O[O.size()-1];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;
ll modsize;

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(modsize + 5);
vector<ll> inv(modsize + 5);
vector<ll> facinv(modsize + 5);

void modcalc() {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0) return 0;
	if (n == 0 && k == 0) return 1;
	return modcomb(n + k - 1, k);
}

template<class T>
class segtree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	segtree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
	T operator[](int i) {
		return data[i + n - 1];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc();

	int ans = 0;
	int n, k;
	cin >> n >> k;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { //No MLE!
		Scanner input = new Scanner(System.in);
		int N = input.nextInt(); 
		long[][] dp;
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
		}
		if (N%2==0) {
			dp = new long[N/2][2];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					if (i==0&&j==0) {
						dp[i][j] = arr[i*2+j];
					}
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i>0){
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+1];
						dp[i][j] = Math.max(dp[i][j], curNum+Math.max(dp[i-1][j-1],dp[i-1][j]));
					}else if (i==0) {
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+1]);
					}	
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 2; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][1]);
		}
		else {
			dp = new long[N/2][3];
			for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					if (j==0&&i==0) dp[i][j] = dp[i][j] = arr[0];
					else if (j==0) {
						dp[i][j] = dp[i-1][j]+arr[i*2];
					}
					else if (i==0){
						dp[i][j] = Math.max(dp[i][j-1],arr[i*2+j]);
					}else if (i>0) {
						dp[i][j] = dp[i][j-1];
						long curNum = arr[i*2+j];
						dp[i][j] = Math.max(dp[i][j], dp[i-1][j]+curNum);
					}
				}
			}
			/*for (int i = 0; i < N/2; i++) {
				for (int j = 0; j < 3; j++) {
					System.out.print(dp[i][j]+" ");
				}
				System.out.print("\n");
			}*/
			System.out.println(dp[N/2-1][2]);
		}
	}
}

Measured memory_bytes: 54676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll m[n];
  for(ll i=0;i<n;i++){
    cin>>m[i];
  }
  ll d=0;
  bool f=true;
  for(ll i=1073741824;i>=1;i/=2){
    if(f) d+=i;
    else d-=i;
    ll c=0;
    for(ll i=0;i<n;i++){
      c+=(max((ll)0,m[i]-b*d)%(a-b)==0?max((ll)0,m[i]-b*d)/(a-b):max((ll)0,m[i]-b*d)/(a-b)+1);
    }
    if(c>d) f=true;
    else f=false;
  }
  if(f)
    cout<<d+1;
  else
    cout<<d;
}
    

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

int main() {
  int N;
  cin >> N;
  
  int a;
  vector<int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    cin >> a;
    A.emplace_back(a);
  }
  
  int min_vital = INF;
  for (int i = 0; i < N; i++) {
    min_vital = min(A[i], min_vital);
  }

  while (true) {
    int prev_min_vital = min_vital;
    for (int i = 0; i < N; i++) {
      int vital = A[i] % min_vital;
      if(vital > 0) { A[i] = vital; min_vital = vital; break; }
    }
    if (prev_min_vital == min_vital) break;
  }
  cout << min_vital << endl;
  
  return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define N 100016

int a[N];
vi adj[N];

void dfs(int u)
{
    for (int v : adj[u]) {
        dfs(v);
        cout << a[u] << ' ' << a[v] << '\n';
        a[u] -= a[v];
    }
}

int main()
{
    canhazfast();

    int n, p, ans = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a+n);
    p = lower_bound(a, a+n, 0)-a;
    p = max(p, 1);
    p = min(p, n-1);
    adj[n-1].pb(0);
    ans = a[n-1]-a[0];
    for (int i = 1; i < n-1; ++i) {
        if (i < p) adj[n-1].pb(i), ans -= a[i];
        else adj[0].pb(i), ans += a[i];
    }
    cout << ans << '\n';
    dfs(n-1);

    return 0;
}


Measured memory_bytes: 5112
//  MONSTER >_<
#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define dbg(x) cout<<#x<<": "<<x<<endl
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mo 1000000007
#define inf 1e18
#define eps 0.0000000001
#define stp setprecision(20)
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace std;
//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

#define N  int(2e5)+10

int main()
{    SPEED;

       ll s;cin>>s;
       ll tmp = ceil(sqrt(s));//dbg(tmp);
       
       ll diff = tmp*tmp-s;
       cout<<"0 0 "<<diff<<" "<<tmp<<" "<<tmp<<" "<<1;
}



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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, K;
  map<int, ll> cnt;

  cin >> N >> K;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  REP(i, 1, 100000 + 1) {
    K -= cnt[i];
    if (K <= 0) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define debug 0
#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 N;
  vector<int> VA;
  cin >> N;
  map<int, int> m;
  VA.resize(N);
  rep(i, N) {
    int A;
    cin >> A;
    VA.at(i) = A;
    if (m.count(A)) {
      m.at(A)++;
    } else {
      m.insert(make_pair(A, 1));
    }
  }
  ll way = 0;
  for (pair<int, int> mc : m) {
    int m_num = mc.second;
    if (m_num > 1) {
      way += (ll)m_num * (m_num - 1) / 2;
    }
  }
  rep(i, N) {
    int group_num = m.at(VA.at(i));
    if (group_num > 1) {
      cout << way - (group_num - 1) * group_num / 2 +
                  (group_num - 2) * (group_num - 1) / 2
           << endl;
    } else {
      cout << way << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8320
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest083-B
#  https://atcoder.jp/contests/abc083/tasks/abc083_b

def sumKeta(number):
	number2Str = str(number)
	numberLength=len(number2Str)
	thisNumberSum = 0
	ketaRange = range(0,numberLength,1)
	for i in ketaRange:
		thisNumberKeta = int(number2Str[i])
		thisNumberSum = thisNumberKeta + thisNumberSum

	return thisNumberSum


def  sumRangeCalcRange(limitNumber,fromNumber,toNumber):
	sumValue = 0
	valueRange = range(0,limitNumber+1,1)
	for nowNumber in valueRange:
		thisSum = sumKeta(nowNumber)
		if (fromNumber <= thisSum and thisSum <= toNumber):
			sumValue = sumValue + nowNumber
	answer = sumValue
	return answer


if __name__ == '__main__':
	n,a,b = map(int,input().strip().split(' '))
	solution=sumRangeCalcRange(n,a,b)
	print(solution)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vec a(n+1);
    rep(i,n) cin>>a[i+1];
    vec b(n*(n+1)/2);
    rep(i,n) a[i+1]+=a[i];
    int cnt=0;
    rep(i,n){
        for(int j=i+1;j<n+1;j++){
            b[cnt]=a[j]-a[i];
            cnt++;
        }
    }
    ll ans=0;
    for(int i=45;i>=0;i--){
        vec kari(0);
        int cn=0;
        rep(j,b.size()){
            if((1LL<<i)&(b[j])){
                kari.pb(b[j]);
                cn++;
            }
        }
        if(cn>=k){
            b=kari;
            ans+=(1LL<<i);
            // cout<<(1LL<<i)<<endl;
        }
        // for(auto x:b) cout<<x<<" ";cout<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9976
#include <iostream>
#include <stdio.h>
#include <cctype>
int main(){
    char ch,a,b;
    while(1){
        scanf("%c",&ch);
        if(isupper(ch)){
            a = tolower(ch);
            std::cout <<a;
        }else
        if(islower(ch)){
            b = toupper(ch);
            std::cout << b;
        }else{
            std::cout <<ch;
        }
        if(ch == '\n')break;
    }
}

Measured memory_bytes: 3072