akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);
const int MAX_N = 21;
int a[MAX_N][MAX_N];
ll dp[MAX_N+1][1 << MAX_N];

int main2() {
  CLR(dp, 0);
  int N = nextInt();
  REP(i, N) REP(j, N) a[i][j] = nextInt();

  dp[0][0] = 1;
  REP(i, N) {
    for (int bit = 0; bit < (1 << N); bit++) {
      const ll base = dp[i][bit];
      if (base == 0) continue;
      REP(j, N) {
        if (bit >> j & 1) continue;
        if (a[i][j] == 0) continue;
        const int nb = bit | (1 << j);
        dp[i+1][nb] += base;
        if (dp[i+1][nb] >= MOD)
          dp[i+1][nb] -= MOD;

      }
    }
  }
  ll ans = dp[N][(1 << N) - 1];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 360704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a<b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a == b) {
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	vector<bool> a(n,0);
	char c; int r=0;
	REP(i,n){
		cin >> c;
		if(c=='R'){
			a[i]=1;
			r++;
		}
	}
	int w=0;
	int ans=min(n-r,r);
	REP(i,n){
		if(!a[i])
			w++;
		else
			r--;
		ans=min(ans,min(w,r)+abs(w-r));
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int cou;

void merge(vector<int> &v, int left, int mid, int right){
//    cou++;
//    cout << left <<":"<<mid<<":"<<right<<endl;
    vector<int> lvc, rvc;
//    lvc.assign(v.begin()+left,v.begin()+mid-1);
//    rvc.assign(v.begin()+mid,v.begin()+right-1);
    for(int i=0;i<mid-left;i++)lvc.push_back(v[left+i]);
    for(int i=0;i<right-mid;i++)rvc.push_back(v[mid+i]);
//    for(int i=0;i<lvc.size();i++)cout << lvc[i]<<(i!=lvc.size()-1?" ":"\n");
    lvc.pb(INT_MAX);
    rvc.pb(INT_MAX);
    int lloc, rloc;
    lloc = rloc = 0;
    for(int k = left; k < right; k++){
        cou++;
        if(lvc[lloc]<=rvc[rloc]){
//            cout << lvc[lloc]<<endl;
            v[k]=lvc[lloc];
            lloc++;
        }else{
            v[k]=rvc[rloc];
            rloc++;
        }
    }
//    for(int i=left;i<right;i++)cout << v[i]<<(i!=right-1?" ":"\n");
}

void merge_sort(vector<int> &v,int left,int right){
//    cou++;
    if(right-left>1){
        int mid = (right + left) / 2;
        merge_sort(v, left, mid);
        merge_sort(v, mid, right);
        merge(v, left, mid, right);
    }
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n);
    REP(i,n)cin >> s[i];
    merge_sort(s,0,n);

    REP(i,n)cout << s[i] << (i!=n-1?" ":"\n");
    cout << cou << endl;
}



Measured memory_bytes: 7368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int f(int n){
    if(n%2) return 3*n+1;
    else return n/2;
}
int main(){
    int n;
    cin >> n;
    int m = 0;
    int ans = 0;
    rep(i,n){
        int p;
        cin >> p;
        if(m < p) m = p;
        ans += p;
    }
    cout << ans - m/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import time
t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res

D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx

p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = T2
    p = p2
else:
    p = p1

i = D-1
next = -1
while time.time()-t1 < 1.9:
    temp = T[i]
    for j in range(1, 27):
        T[i] = j
        newp = calc(T)
        if p < newp:
            p = newp
            temp = j
    T[i] = temp
            
    i += next
    if i == -1:
        i = D-1

for t in T:
    print(t)

Measured memory_bytes: 69628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vecll = vector<long long>;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
    ll n, m;
    cin >> n;
    vecll a(n), b, result;
    for (auto &x : a)
        cin >> x;

    cin >> m;
    b.resize(m);
    for (auto &y : b)
        cin >> y;

    set_union(all(a), all(b), inserter(result, end(result)));

    for (auto &z : result)
        cout << z << endl;
}


Measured memory_bytes: 10208
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=1e7+5;
int n,a;
int Fac[N],Inv[N],Iv[N];
int calc(int a,int b,int c){
	return (LL)Fac[a+b+c]*a%mod*Iv[a+b]%mod;
}
int Comb(int n,int m){
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	n=read(),a=read();
	Fac[0]=1;
	For(i,1,n)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	For(i,1,n)
		Iv[i]=(LL)Inv[i]*Fac[i-1]%mod;
	int ans=0;
	For(i,1,a+1)
		For(j,0,i-1){
			int A=i-1-j,C=max(a-i,0),B=n-a;
			int v=(LL)calc(A,B,C)*Comb(i-1,j)%mod;
			if (j&1)
				Del(ans,v);
			else
				Add(ans,v);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 120812
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define M 10000000000LL
#define fore(i,a,b) for(int i=a,to=b;i<to;++i)
using namespace std;

typedef long long ll;

ll sq(ll x){
	ll s=0,e=1<<20;
	while(e-s>1){
		ll m=(s+e)/2;
		if((m-1)*(m-1)<x)s=m;
		else e=m;
	}
	if(s*s==x)return s;
	return -1;
}

bool isp[2222];
vector<int> ps;
ll s[100005];
int n,r;

vector<pair<ll,int> > f;

map<ll,ll> inv;
map<ll,int> c;

int main(){
	memset(isp,true,sizeof(isp));
	for(int i=2;i<2200;++i){
		if(isp[i]){
			ps.pb(i);
			for(int j=i*i;j<2200;j+=i)isp[j]=false;
		}
	}
	scanf("%d",&n);
	fore(i,0,n)scanf("%lld",s+i);
	fore(i,0,n){
		bool can=true;
		f.clear();
		ll m=s[i];
		for(int j=0;m>1&&j<ps.size();++j){
			int q=0;
			while(m%ps[j]==0){
				m/=ps[j];
				q++;
			}
			if(q%3)f.pb(mp(ps[j],q%3));
		}
		if(m<100000){
			f.pb(mp(m,1));
		}
		else {
			ll k=sq(m);
			if(k>0)f.pb(mp(k,2));
			else can=false;
		}
		if(can){
			ll k=1,m=1;
			for(int j=f.size()-1;k>0&&j>=0;--j){
				k*=f[j].fst;m*=f[j].fst;
				if(k>M){k=-1;break;}
				if(f[j].snd==2){
					k*=f[j].fst;
					if(k>M)k=-1;
				}
				else {
					m*=f[j].fst;
				}
			}
			if(k>0){
				c[m]++;
				inv[m]=k;
				inv[k]=m;
			}
			else r++;
		}
		else r++;
	}
	if(c.count(1)){
		r++;
		c.erase(1);
	}
	for(map<ll,int>::iterator it=c.begin();it!=c.end();++it){
		if(it->snd>c[inv[it->fst]]||(it->snd==c[inv[it->fst]]&&it->fst<inv[it->fst]))
			r+=it->snd;
	}
	printf("%d\n",r);
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<string> v(n);
	for (auto& x : v)
		cin >> x;
	vector<int> cnt(26, 1000000000);
	for (auto x : v)
	{
		vector<int> c(26);
		for (auto y : x)
			c[y - 'a']++;
		for (int i = 0; i < 26; ++i)
			cnt[i] = min(cnt[i], c[i]);
	}
	string ans;
	for (int i = 0; i < 26; ++i)
		for (int j = 0; j < cnt[i]; ++j)
			ans.push_back(i + 'a');
	cout << ans << endl;

}


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

namespace ABC047A {
	class Program {
		static void Main(string[] args) {
			float a, b, c, d;
			string[] input = Console.ReadLine().Split(' ');
			a = int.Parse(input[0]);
			b = int.Parse(input[1]);
			c = int.Parse(input[2]);
			d = (a + b + c) / 2;

			if (a == d || b == d || c == d) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 2648
package main

import (
	"fmt"
)

func main() {
	var i1 string
	var i int
	var cnt int
	fmt.Scan(&i1)

	for i = 0; i < len(i1)-1; i++ {
		s := string(i1[i])
		ns := string(i1[i+1])
		if s == ns {
			if ns == "0" {
				i1 = replaceAtIndex(i1, '1', i+1)
				cnt++
			}
			if ns == "1" {
				i1= replaceAtIndex(i1, '0', i+1)
				cnt++
			}
		}
	}
	fmt.Print(cnt)
}

func replaceAtIndex(str string, replacement rune, index int) string {
	return str[:index] + string(replacement) + str[index+1:]
}

Measured memory_bytes: 8580
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> P;
    for(int i = 0; i < N; ++i ){
        int x;
        cin >> x ;
        P.push_back(x);
    }

    int result = 1;
    int min = *P.begin();
    for(vector<int>::iterator itr_i = P.begin()+1; itr_i != P.end(); ++itr_i ){
        if(min > *itr_i){
            min = *itr_i;
            result += 1;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1400
// King's Inspection

#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    int n;
    int now=0;
    int k[102];
    int ansNum;
    char station[102];
    char ans[102];
    string alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //vector<char> ans;
    
    while(1) {
      // Input
        cin>>n;
        if(n == 0) {
            break;
        }
        for(int i=0; i<n; i++) {
            cin>>k[i];
        }
        cin.ignore();
        ansNum = 0;

	// Output
	now = 0;
        for(int i=0; i<102; i++) {
            scanf("%c", &station[i]);
            if(station[i] == '\n') {
                break;
            }
            ansNum++;

	    int tmp;
	    tmp = alpha.find(station[i]);
	    ans[i] = alpha[(tmp-k[now]+52)%52];
	    now++;
            if(now == n) {
                now = 0;
            }
        }

        for(int i=0; i<ansNum; i++) {
            cout<<ans[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,mod=1000000007,dp[3002][3002],pas,dp2[3002][3002],dp3[3002][3002];
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    cin>>s;
    dp3[1][1]=dp2[1][1]=dp[1][1]=1;
    for(b=2; b<=a; b++){
        for(c=1; c<=b; c++){
            if(s[b-2]=='>'){
                dp[b][c]+=dp2[b-1][c];
            }else{
                if(c-1<1) continue;
                dp[b][c]+=dp3[b-1][c-1];
            }
            dp[b][c]%=mod;
        }
        for(c=1; c<=b; c++){
            dp3[b][c]=dp[b][c]+dp3[b][c-1];
            dp3[b][c]%=mod;
        }
        for(c=b; c>=1; c--){
            dp2[b][c]=dp[b][c]+dp2[b][c+1];
            dp2[b][c]%=mod;
        }
    }
    for(b=1; b<=a; b++){
        pas+=dp[a][b];
        pas%=mod;
    }
    cout<<pas;
    return 0;
}


Measured memory_bytes: 209792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    vector<int> vec(3);
    cin >> vec.at(0);
    cin >> vec.at(1);
    cin >> vec.at(2);
    sort(begin(vec),end(vec));
    vector <int> veccmp{5,5,7};
    if(vec == veccmp)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int n,x;
signed main(){
	n=read(),x=read();
	printf("%lld",3*(n-gcd(n,x)));
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, K, x1, y1, x2, y2;
    cin >> H >> W >> K >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;
    vector<string> pond(H);
    for (int i=0; i<H; ++i) cin >> pond[i];

    vector<vector<ll>> dis(H, vector<ll>(W, LINF));
    vector<vector<vector<int>>> dm(H, vector<vector<int>>(W, vector<int>(4)));
    dis[x1][y1] = 0;
    priority_queue<tuple<ll, ll, int, int>, vector<tuple<ll, ll, int, int>>, greater<tuple<ll, ll, int, int>>> que;
    ll cnt = 0;
    que.push(make_tuple(0, cnt++, x1, y1));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        ll d = get<0>(p);
        int x = get<2>(p), y = get<3>(p);
        if (d > dis[x][y]) continue;
        for (int i=0; i<4; ++i) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W || pond[nx][ny] == '@') continue;
            int m = dm[x][y][i];
            dm[x][y][i] = 0;
            if (m > 0) {
                if (d < dis[nx][ny]) {
                    dis[nx][ny] = d;
                    dm[nx][ny] = {0, 0, 0, 0};
                    dm[nx][ny][i] = m-1;
                    que.push(make_tuple(dis[nx][ny], cnt++, nx, ny));
                } else if (d == dis[nx][ny]) {
                    dm[nx][ny][i] = m-1;
                }
            } else {
                if (d + 1 < dis[nx][ny]) {
                    dis[nx][ny] = d + 1;
                    dm[nx][ny] = {0, 0, 0, 0};
                    dm[nx][ny][i] = K-1;
                    que.push(make_tuple(dis[nx][ny], cnt++, nx, ny));
                } else if (d + 1 == dis[nx][ny]) {
                    dm[nx][ny][i] = K-1;
                }
            }
        }
    }
    cout << (dis[x2][y2] == LINF ? -1 : dis[x2][y2]) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 121280
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

constexpr int Nmax = 200000;

int main()
{
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    bitset<Nmax> st(0);
    REP(i, N) if (s[i] == 'B') st.set(i);

    int now = 0;
    bool inv = false;
    REP(_, K)
    {
        if (st[now] ^ inv)
        {
            now++, inv = !inv;
            if (now == N) now = 0;
        }
        else st[now] = !st[now];
    }
    REP(i, N) printf("%c", st[(i + now) % N] ^ inv ? 'B' : 'A');
    printf("\n");
}


Measured memory_bytes: 916
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

struct dsu {
    vector<int> parent;
    vector<int> size;
    int components = 0;
 
    dsu(int n = -1) {
        if (n >= 0)
            init(n);
    }
    void init(int n) {
        parent.resize(n + 1);
        size.assign(n + 1, 1);
        components = n;
        for (int i = 0; i <= n; i++)
            parent[i] = i;
    }
    int get(int x) {
        return x == parent[x] ? x : parent[x] = get(parent[x]);
    }
    bool unite(int x, int y) {
        x = get(x);
        y = get(y);
        if (x == y) return false;
        if (size[x] < size[y])
            swap(x, y);
        parent[y] = x;
        size[x] += size[y];
        components--;
        return true;
    }
};
 
void solve(){
	int n , m ;
	cin >> n >> m ;
	dsu d(n) ;
	forn(i,m){
		int x , y ;
		cin >> x >> y ;
		--x , --y ;
		d.unite(x, y) ;
	}	
	int mx = 0 ;
	forn(i,n) mx = max(mx, d.size[i]) ;
	cout << mx << endl ;
}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 6344
def solve():
    P.sort(reverse = True)
    M.sort()
    P.append(-1)
    M.append(1) # add endpoint
    p, m = [], []
    while len(p) + len(m) < k:
        if P[len(p)] < -M[len(m)]:
            m.append(M[len(m)])
        else:
            p.append(P[len(p)])
    if len(m)%2 == 0: return p + m

    exist_p = len(p) > 0
    exist_m = len(m) > 0
    remain_P = len(P) - 1 > len(p)
    remain_M = len(M) - 1 > len(m)
    if exist_p & exist_m & remain_P & remain_M:
        if abs(p[-1] * P[len(p)]) < abs(m[-1] * M[len(m)]):
            p.pop()
            m.append(M[len(m)])
        else:
            m.pop()
            p.append(P[len(p)])
    elif exist_m & remain_P:
        m.pop()
        p.append(P[len(p)])
    elif exist_p & remain_M:
        p.pop()
        m.append(M[len(m)])
    else:
        M.pop() # del endpoint
        m = sorted(M, reverse = True)[:k]
    return p + m

n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 32404
Scanf.scanf "%d %d" (fun h w ->
    let rec loop i acc =
        let rec loop2 j acc =
            if j = w then acc else
            let acc = Scanf.scanf " %s" (fun s ->
                if s = "snuke" then Printf.sprintf "%c%d" "ABCDEFGHIJKLMNOPQRSTUVWXYZ".[j] i else acc)
            in
            loop2 (j + 1) acc
        in
        if i > h then acc else loop (i + 1) (loop2 0 acc)
    in
    print_endline @@ loop 1 ""
)

Measured memory_bytes: 2432
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll m = 1e9+7;
const ll N = 1e4+1;
vll k;
ll d;
ll nk;
ll dp[N][2][110];

ll go(ll x , ll small, ll sumi)
{
	if(x == nk)
	{
		return (sumi%d == 0) ? 1 : 0 ;
	}

	ll &ans = dp[x][small][sumi];
	if(ans != -1)
		return ans;
	ans = 0;

	if(small)
	{
		for(ll i = 0 ; i<=9 ; ++i)
		{
			ans += go(x+1 , small , (sumi+i)%d);
			ans %= m;
		}
	}
	else
	{
		for(ll i = 0 ; i<k[x] ; ++i)
		{
			ans += go(x+1 , small^1 , (sumi+i)%d);
			ans %=m;
		}

		ans += go(x+1 , small , (sumi+k[x])%d);
		ans%=m;

	}
	return (ans+m)%m;

}

signed main()
{

	fast;
	memset(dp , -1 , sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;

	for(auto c: s)
	{
		ll a = c - '0';
		k.pb(a);
	}

	nk = k.size();

	cin >> d;

	cout<<(go(0 , 0 , 0) - 1 + m)%m<<endl;




////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n;
    cin >> n;
    vector<LL> a(n);

    rep(i,n) cin >> a[i];

    double k = 0;
    LL ans = 1;
    SORT(a);

    rep(i,n) {
      if(ans * a[i] > 1000000000000000000 || (ans * a[i] < ans && a[i] != 0)) {
        cout << -1 << endl;
        return 0;
      } else {
        ans *= a[i];
      }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6436
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
a, b, c, k = inpl()
if k%2==0:
    ans = (a-b)
else:
    ans = (b-a)
    
if abs(ans) > 10**18:
    print("Unfair")
else:
    print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int s;
    cin >> s;
    int s1=s/100;
    int s2=s-s1*100;
    string ans;
    if (s1>0 && s1<13 && s2>0 && s2<13) ans="AMBIGUOUS";
    else if (s2>0 && s2<13) ans="YYMM";
    else if (s1>0 && s1<13) ans="MMYY";
    else ans="NA";
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;


int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    
    long long ans=1000000000;
    for(int i=0;i<200001;i++){
        long long pay=i*2*c+max(0,x-i)*a+max(0,y-i)*b;
        ans=min(ans,pay);
    }
    cout<<ans<<endl;
}

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

int A, B, C;
set<int> divs;
int main(){
    scanf("%d%d%d", &A, &B, &C);
    int tmpA=A;
    for(int i=0; i<B; i++){
        divs.insert(A%B);
        A+=tmpA;
    }
    if(divs.count(C)) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc087/tasks/abc087_b

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int X;
    cin >> X;

    int sum = 0;
    REP(i, A+1) {
        REP(j, B+1) {
            REP(k, C+1) {
                if (500*i + 100*j + 50*k == X) sum++;
            }
        }
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 384
input = gets.chomp
n = input.to_i
ans = 0
(1..input.length).each do |num_digits|
  %w[3 5 7].repeated_permutation(num_digits) do |s|
    next unless %w[3 5 7].all? { |x| s.include?(x) }

    ans += 1 if s.join.to_i <= n
  end
end
puts ans

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

int main() {
    int a, b;
    string op;
    for(int i; ; i++){
    cin >> a >> op >> b;
    if(op=="?") break;
    if(op=="+") cout << a+b << endl;
    if(op=="-") cout << a-b << endl;
    if(op=="*") cout << a*b << endl;
    if(op=="/") cout << a/b << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string str;
	std::cin >> str;
	std::cout << (str == "AAA" || str == "BBB" ? "No" : "Yes") << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

int main() {
  int x,y;
  cin >> x >> y;
  
  if ( (y-2*x)<0 || (4*x-y)<0 ) {
    cout << "No";
  }else if ( (y-2*x)%2==0 && (4*x-y)%2==0 ) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  return 0;
}


Measured memory_bytes: 3636
# 2019-11-14 20:54:46(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    # ある１地点を経由してそれ以外の全てにいくのが最も多く
    # これは (n - 1) * (n - 2) // 2　通り
    # kがこれより大きいときには存在せず、それ以下の時は理論上存在する
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        sys.exit()

    all_uv = list(itertools.combinations(range(1, n+1), 2))

    m = n * (n - 1) // 2 - k
    print(m)
    # 1を中央として考えて、最低限1以外のn-1個の頂点は1とつながっている状態である必要がある
    for u, v in all_uv[:m]: # kの制約から、iの最大値は最小で(n-1)-1まで
        print(u, v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define fto(i,j,h)   for (int i=j; i<=h; i++)
#define fdto(i,j,h)  for (int i=j; i>=h; i--)
#define ANH BAI2
#define maxn 2009
#define ll long long
using namespace std;

int n, a[maxn], Max = -1e9;
ll L[maxn], R[maxn], mod = 1000000007, k, BIT[maxn];
void update(int t){
    for (int j = t; j <= Max; j += j&(-j))   BIT[j]++;
}
int Get(int t){
    int s = 0;
    for (int j = t-1; j > 0; j -= j&(-j))      s += BIT[j];
    return s;
}
int main()
{
    //freopen("ANH.inp", "r", stdin);
    //freopen("ANH.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    fto(i,1,n)   {cin >> a[i];    Max = max(Max, a[i]);}
    fdto(i,n,1){
        L[i] = Get(a[i]);
        update(a[i]);
    }
    fto(i,1,n)    R[i] = Get(a[i]);
    //fto(i,1,n)   cout << L[i] << " " << R[i] << '\n';
    ll res = 0;
    fto(i,1,n){
       ll tg = (ll)(k-1)*k;
       tg = tg/2;      tg = tg%mod;
       res = (res + ((ll)L[i]*k)%mod + ((ll)R[i]*tg)%mod) % mod;
    }
    cout << res;
}


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

using namespace std;

const int dm[] = {-1, 0, 1, 0}, dn[] = {0, -1, 0, 1};
int h, w, count;
vector< vector<int> > field, finished;

bool valid(int m, int n) {
    return 0 <= m && m < h && 0 <= n && n < w && field[m][n] == 1;
}

void dfs(int m, int n) {
    finished[m][n] = 1;
    count++;

    for(int i = 0; i < 4; i++) {
        if(valid(m + dm[i], n + dn[i]) && !finished[m + dm[i]][n + dn[i]]) {
            dfs(m + dm[i], n + dn[i]);
        }
    }
}

int main() {
    while(1) {
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        field.resize(h); finished.resize(h);
        int m, n;
        for (int i = 0; i < h; i++) {
            string input;
            cin >> input;

            field[i].resize(w); finished[i].resize(w);

            for (int j = 0; j < w; j++) {
                finished[i][j] = 0;

                if(input[j] == '@') {
                    m = i;
                    n = j;
                }
                if(input[j] == '#') {
                    field[i][j] = 0;
                } else {
                    field[i][j] = 1;
                }
            }
        }

        count = 0;
        dfs(m, n);

        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1256
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> cnt(n);
	for(int i = 0; i < 2 * m; ++i){
		int t;
		scanf("%d", &t);
		++cnt[t - 1];
	}
	for(int c : cnt){ printf("%d\n", c); }
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d,x;
	cin>>n>>d>>x;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<=d;j+=a[i]){
			x++;
		}
	}
	cout<<x<<endl;
}

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

using namespace std;
using lint = long long;

#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)

constexpr double Pi = 3.141592653589793;

template<class T> inline istream& operator>>(istream& is, vector<T>& v) { for (auto& e : v) is >> e; return is; }

lint n;
double l, ans_x, ans_y;
int main() {
	cin >> n >> l;

	vector<double>t(n);
	cin >> t;

	rep(i, n - 1) {
		repn(j, i + 1, n) {
			const lint cnt1 = j - i - 1, cnt2 = n - cnt1 - 2;
			const double mid = (t[i] + t[j]) / l * Pi;

			ans_x += (cnt2 - cnt1) * cos(mid);
			ans_y += (cnt2 - cnt1) * sin(mid);
		}
	}

	const double div = (double)(n) * (n - 1) * (n - 2) / 6;

	ans_x /= div;
	ans_y /= div;

	printf("%.15lf %.15lf\n", ans_x, ans_y);
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll A,B,M;
    cin >> A >> B >> M;
    ll a[A],b[B],x[M],y[M],c[M];
    
    ll ans = 0,memo = LINF;
    rep(i,0,A){
        cin >> a[i];
        memo = min(memo,a[i]);
    }
    ans += memo;
    rep(i,0,B){
        cin >> b[i];
        memo = min(memo,b[i]);
    }
    ans += memo;

    rep(i,0,M){
        cin >> x[i] >> y[i] >> c[i];
        ans = min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7516
#include <bits/stdc++.h>
using namespace std;
double p[3000];
double dp[3000][3000];

int main() 
{
    int n;
    cin >> n;
    
    for(int i=0;i<n;i++) cin >>p[i];
    
    dp[0][0] = 1.00;
    
    for(int i=1;i<=n;i++) dp[i][0] = (dp[i-1][0]*(1-p[i-1]));
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = (p[i-1]*dp[i-1][j-1]) + ((1-p[i-1])*dp[i-1][j]);
        }
    }
    
    double ans = 0.00;
    
    //for(int i=1;i<=n;i++) cout<<dp[i][i]<<endl;
    cout.precision(10);
    
    for(int i=0;i<=n;i++){
        if(i>n-i) ans+=dp[n][i];
    }
    
    cout<<ans<<endl;
	return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  string c;
  cin >> c;

  ll ans = INF;

  ll cnt = 0;
  rep(i, n) {
    if (c[i] == 'R')
      cnt++;
  }
  chmin(ans, cnt);

  cnt = 0;
  rep(i, n) {
    if (c[i] == 'W')
      cnt++;
  }
  chmin(ans, cnt);

  cnt = 0;

  ll lidx = 0;
  ll ridx = n - 1;

  while (lidx < ridx && c[lidx] != 'W') {
    lidx++;
  }
  while (lidx < ridx && c[ridx] != 'R') {
    ridx--;
  }

  while (lidx < ridx) {
    lidx++;
    ridx--;
    cnt++;

    while (lidx < ridx && c[lidx] != 'W') {
      lidx++;
    }
    while (lidx < ridx && c[ridx] != 'R') {
      ridx--;
    }
  }

  chmin(ans, cnt);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3688
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//ARC004
		//https://arc004.contest.atcoder.jp/tasks/arc004_1
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int ans = 0;
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] X = new int[M];
		for(int i=0; i<M; i++){
			X[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(X);
		int[] diff = new int[M-1];
		for(int i=0; i<M-1; i++){
			diff[i] = X[i+1] - X[i];
		}
		Arrays.sort(diff);
		if(N>=M){
			ans = 0;
		}else{
			for(int i=0; i<M-N; i++){
				ans += diff[i];
			}
		}
		System.out.println(ans);
		
	}
	
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
//#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 405;
const int P = 1e9 + 7;
int n;
int dp[MAX][MAX][MAX/3][2];

void add(int &a, int b){
  a += b;
  if(a >= P)
    a -= P;
}
void mnu(int &a,int b){
  a = a * 1ll * b % P;
}
int a[MAX],b[MAX],gda[MAX],gdb[MAX];

int licz(int i, int j,int k, bool kt){
  if(k < 0 || i > n || j > n)return 0;
  if(i == n && j == n && k == 0)return 1;
  int &res = dp[i][j][k][kt];
  if(res != -1){
    return res;
  }
  res = 0;
  if(i < n && gdb[a[i]] < j){
    res = licz(i+1, j, k, kt);
    return res;
  }
  if(j < n && gda[b[j]] < i){
    res = licz(i, j+1, k, kt);
    return res;
  }
  if(kt == 0)add(res, licz(i+1, j, k-1, 0) * 1ll * k % P);
  if(a[i] != b[j]){
    add(res, licz(i, j+1, k-1, 1) * 1ll * k % P);
    add(res, licz(i+1, j+1, k+1, 0));
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
//   R(i,n)a[i] = i;
//   R(i,n)b[i] = i;
  R(i,n){
    cin >> a[i];
    a[i]--;
    gda[a[i]] = i;
  }
  R(i,n){
    cin >> b[i];
    b[i]--;
    gdb[b[i]] = i;
  };
  R(i,n+1)R(j,n+1)R(k,(n/3)+1)R(kt,2)dp[i][j][k][kt] = -1;
  int res = licz(0,0,0,0);
  R(i,n/3){
    mnu(res, 3 * i + 1);
    mnu(res, 3 * i + 2);
  }
  cout << res << "\n";
}


Measured memory_bytes: 172288
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[1000];
signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) cin >> a[i];
	sort(a, a+n);
	cout << a[n-1] - a[0] << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;


void solve(){
	
	string s; cin>>s;
	
	if(s[s.size()-1]=='s'){
		s=s+"es";
	}
	else{
		s=s+'s';
	}
	
	cout<<s<<"\n";
	
	return;
}




int main() {
	
	
	

   int t=1; //cin>>t;
   
   while(t--){
   	solve();
   }
    
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define D(a) cout<<#a<<": ";for(auto i:a)cout<<i<<' ';cout<<endl;
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> A(N); for (int& a : A) cin >> a;
    int ans = 0;
    for (int i = 1; i < A.size(); i++) {
        if (A[i-1] == A[i]) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio,std.string,std.conv,std.algorithm;
void main(){
	auto arr = readln().chomp().split();
	int[] arr2;
	arr2 = [to!int(arr[0]),to!int(arr[1]),to!int(arr[2]),to!int(arr[3]),to!int(arr[4])];
	sort!("a > b")(arr2);
	writeln( arr2[0]," ",arr2[1]," ",arr2[2]," ",arr2[3]," ",arr2[4] );
}

Measured memory_bytes: 1060
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()
    pre = A[0]
    res = 0
    for a in A:
        res += max(0, pre - a)
        pre = max(a, pre)
    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 93820
def d():
    N,W = map(int, input().split())
    nupList = (map(int, input().split()) for _ in range(N))
    dp = [0] * (W + 1)

    for w, v in nupList:
        for j in range(W, w - 1, -1 ):
            DP = dp[j - w] + v
            if dp[j] < DP:
                dp[j] = DP

    return max(dp)

print(d())

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if (u == s) {
    printf("%d %d\n", a - 1, b);
  } else {
    printf("%d %d\n", a, b - 1);
  }

  return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, k = map(int, input().split())
    r = min(k, a)
    k -= a
    if k > 0:
        k -= b
        if k > 0:
            r -= k
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1
n = int(input())
A = list(map(int, input().split()))
i = partition(A, 0, n - 1)
print(*A[:i], '[{}]'.format(A[i]), *A[i + 1:])


Measured memory_bytes: 16388
#include <iostream>
using namespace std;
int memo[100001];

int rec(int n){
    if(n == 0) return 0;
    if(memo[n] != -1) return memo[n];
    
    int ret = n;
    for(int i = 1; i <= n; i*=6) ret = min(ret, rec(n - i) + 1);
    for(int j = 1; j <= n; j*=9) ret = min(ret, rec(n- j) + 1);
    return memo[n] = ret;
}

int main(void){
    // Your code here!
    int N;
    cin >> N;
    for(int i = 0; i <=  100000; i++) memo[i] = -1;
    cout << rec(N) << endl;
}


Measured memory_bytes: 3712