akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  	std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
	int n;
  cin>>n;
  int a[n],b[n];
  int res=0;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) res+=max(a[i]-b[i],0);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
 
int main(){
  long long n,ans=1;cin>>n;
  REP(i,n){
    ans*=i+1;
    ans=ans%((long long)(1e9+7));
  }
  cout<<ans;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
 
 
void main() {
    int[] a = readints();
    a.sort();
    int k = readint();
    foreach(i; 0..k) a[2] *= 2;
    writeln(a.sum);
}


Measured memory_bytes: 256
n = int(input())

inf = n + 100
dp = [inf] * (n+1)
dp[0] = 0
for i in range(n):
    if i <= n-1:
        dp[i+1] = min(dp[i+1], dp[i] + 1)

    cnt6 = 6
    while True:
        if i + cnt6 <= n:
            dp[i + cnt6] = min(dp[i + cnt6], dp[i] + 1)
            cnt6 *= 6
        else:
            break

    cnt9 = 9
    while True:
        if i + cnt9 <= n:
            dp[i + cnt9] = min(dp[i + cnt9], dp[i] + 1)
            cnt9 *= 9
        else:
            break

print(dp[n])

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W  && H != 0 && W != 0)
	{
		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3084
#%%
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

b = 0
count = 0

for i in range(N):
    if i != N-1:
        if x - b >= a[i] :
            count += 1
        else:
            break
    else:
        if x - b == a[i] :
            count += 1
        
    b += a[i]

print(count)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String answer = "Heisei";
        int year, month, day;
        year = Integer.parseInt(s.substring(0,4));
        month =  Integer.parseInt(s.substring(5,7));
        
        if(year > 2019) answer = "TBD";
        if(year == 2019 && month >= 5) answer = "TBD";

        System.out.println(answer);
    }
}

Measured memory_bytes: 22100
def resolve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    ans = []
    sta = 0
    end = K
    while end < N:
        # print(sta, end)
        if A[end] > A[sta]:
            print('Yes')
        else:
            print('No')
        sta += 1
        end += 1
    return
resolve()

Measured memory_bytes: 31668
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,a[224514],m1=0,m2=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>m1)
		{
			m2=m1;
			m1=a[i];
		}
		else if(a[i]>m2)
		{
			m2=a[i];
		}
	}
	for(int i=0;i<n;i++)cout<<(a[i]==m1?m2:m1)<<endl;
	return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <iostream>
#include <cstdio>
#define rint register int
#define N 1000005
using namespace std;
const int Mod = 998244353;

int n, m;
int fac[N], inv[N], ifac[N];

inline int C(int x, int y) {
    return x < 0 || y < 0 ? 0 : 1ll * fac[x + y] * ifac[x] % Mod * ifac[y] % Mod;
}

int main() {
#ifdef whyqx
    freopen("yesorno.in", "r", stdin);
    freopen("yesorno.out", "w", stdout);
#endif
    cin >> n >> m;
    if (n < m) swap(n, m);
    fac[0] = inv[1] = ifac[0] = 1;
    for (rint i = 1; i <= n << 1; ++i)
        fac[i] = 1ll * fac[i - 1] * i % Mod;
    for (rint i = 2; i <= n << 1; ++i)
        inv[i] = 1ll * inv[Mod % i] * (Mod - Mod / i) % Mod;
    for (rint i = 1; i <= n << 1; ++i)
        ifac[i] = 1ll * ifac[i - 1] * inv[i] % Mod;
    long long ans = 0;
    for (rint i = 1; i <= m; ++i)
        (ans += 1ll * C(n - i, m - i) * C(i, i) % Mod) %= Mod;
    ans = 1ll * ans * fac[n] % Mod * fac[m] % Mod * ifac[n + m]  % Mod * inv[2] % Mod;
    cout << (ans + n) % Mod;
    return 0;
}


Measured memory_bytes: 11904
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    
    static ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
    static ArrayList<Long> ans = new ArrayList<>();
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        for(int i = 0; i < 10; i++){
            ArrayList<Integer> tmp = new ArrayList<>();
            if(i - 1 >= 0) tmp.add(i-1);
            tmp.add(i);
            if(i + 1 < 10) tmp.add(i+1);
            adj.add(tmp);
        }
        for(int i = 1; i < 10; i++){
            String s = String.valueOf(i);
            dfs(s);
        }
        Collections.sort(ans);
        //System.out.println(ans);
        System.out.println(ans.get(k-1));
    }
    
    public static void dfs(String s){
        ans.add(Long.valueOf(s));
        if(s.length() == 10) return;
        int ind = Character.getNumericValue(s.charAt(s.length()-1));
        for(int i : adj.get(ind)){
            dfs(s+i);
        }
        return;
    }
}

Measured memory_bytes: 53020
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

const int MAX = 610000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a){
    return modpow(a, MOD - 2);
}

int main() {
    ll N;
    cin >> N;
    ll ten = 1, eight = 1, nine = 1;
    rep(i, N){
        ten *= 10;
        ten %= MOD;
        eight *= 8;
        eight %= MOD;
        nine *= 9;
        nine %= MOD;
    }
    nine = nine*2 % MOD;
    ll ans = (ten-nine) % MOD;
    ans = (ans + eight) % MOD;
    ans = (ans+MOD) % MOD;
    cout << ans;
}


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

using namespace std;

void solve(int step, int n, int maxx, string s) {
	if (step == n) cout << s << "\n";
	else {
		string ss;
		for (int i = 0; i <= maxx + ((step == 0) ? 0 : 1); i++) {
			ss = s + (char)('a' + i);
			solve(step + 1, n, max(maxx, i), ss);
		}
	}
}

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

	int n, i, j, k;
	cin >> n;
	solve(0, n, 0, "");


	return 0;
}


Measured memory_bytes: 1536
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, x) = input_tuple();
    let l_vec = input_vec();
    let mut d = 0;
    let mut count = 1;
    for l in l_vec {
        d += l;
        if d <= x {
            count += 1;
        }
    }
    println!("{}", count);

}


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

using namespace std;
typedef long long ll;

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x, y) cerr<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define debug2(x, y, z) cerr<<(#x)<<" " <<(#y)<<" " <<(#z)<<" is " << (x) <<" "<< (y) <<" "<<(z) << endl
#define watch(x) cerr<<(#x)<<" is " << (x) << endl

int main() {
    ll n,q=0;
    string s;
    map<string, ll> mp;
    set<string> v;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        mp[s]++;
        if (mp[s] > q) {
            q = mp[s];
        }
        v.insert(s);
    }
    for (auto i:v) {
        if (mp[i] == q) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 34560
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;
const ll V_MAX = 114514;
const ll E_MAX = 224514;
ll par[V_MAX];//oya
ll rnk[V_MAX];//hukasa

struct edge{ ll u,v,cost;};
edge es[E_MAX];
ll V,E;

void init(ll n){
  rep(i,n){
    par[i] = i;
    rnk[i] = 0;
  }
}

ll find(ll x){
  if(par[x] == x){
    return x;
  }
  else{
    return par[x] = find(par[x]);
  }
}

void unite(ll x,ll y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }
  else{
    par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(ll x , ll y){
  return find(x) == find(y);
}


bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}

ll kruskal(){
  sort(es,es+E,comp);
  init(V);
  ll res = 0;
  rep(i,E){
    edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  cin >> V;
  P x[100100],y[100100];
  rep(i,V){
    cin >> x[i].first >> y[i].first;
    x[i].second = i;
    y[i].second = i;
  }
  sort(x,x+V);
  sort(y,y+V);
  rep(i,V){
    cerr << x[i].first << " " << x[i].second << endl;
  }
  rep(i,V){
    cerr << y[i].first << " " << y[i].second << endl;
  }
  rep(i,V-1){
    P a = x[i];
    P b = x[i+1];
    edge tmp;
    tmp.u = a.second;
    tmp.v = b.second;
    tmp.cost = (b.first - a.first);
    es[i] = tmp;
  }
  rep(i,V-1){
    P a = y[i];
    P b = y[i+1];
    edge tmp;
    tmp.u = a.second;
    tmp.v = b.second;
    tmp.cost = (b.first - a.first);
    es[i+V-1] = tmp;
  }
  rep(i,(V-1)*2){
    cerr << es[i].u << " " << es[i].v << " " << es[i].cost << endl;
  }
  E = (V-1)*2;
  ll ans = kruskal();
  cout << ans << endl;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int disum(int n){
	int sum=0;

	while(n){

		sum+=n%10;
		n/=10;





	}
	return sum;




}
int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
  	bool flag= false;
  	cin>>n;




  	int maxC = n/4 + 1;
  	int maxD = n/7 +1;

  	for (int i = 0; i < maxC; ++i)
  	{
  		/* code */
  		for (int j = 0; j < maxD; ++j)
  		{
  			/* code */
  			if((4*i+7*j)==n)
  				flag=true;
  		}
  	}

  	if(flag)
  		cout<<"Yes"<<endl;
  	else
  		cout<<"No"<<endl;


}



Measured memory_bytes: 3592
#include<stdio.h>

int main (){
    char a[15];
    int n,k,i,j;
    char z;
    scanf("%d %s %d",&n,&a,&k);
    
    
    z = a[k-1]; // こいつ
    
  for(i = 0;i < n;i++){
    if(a[i] !=  z){
        a[i] = '*';
    }
  }
    
   for(j = 0;j < n;j++){
    printf("%c",a[j]);
   }
        return 0;
  
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MAXN 200005
#define reg register
#define inl inline
using namespace std;
int n,a[MAXN],ans;
inl bool Check(reg int mid)
{
	for(reg int i=0;i<n;i++)
	{
		if((a[n-i]<mid && a[n-i-1]<mid) || (a[n+i]<mid && a[n+i+1]<mid)) return 0;
		if((a[n-i]>=mid && a[n-i-1]>=mid) || (a[n+i]>=mid && a[n+i+1]>=mid)) return 1;
	}
	return a[n*2-1]>=mid;
}
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<=n*2-1;i++) scanf("%d",&a[i]);
	reg int l=1,r=n*2-1;
	while(l<=r)
	{
		reg int mid=l+r>>1;
		if(Check(mid))
		{
			l=mid+1;
			ans=mid;
		}
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
int n,s[maxn];
long long ans;
int main(){
	n = read();
	for(int i = 1; i <= n; i++)
		s[i] = read();
	for(int i = 1; i <= n; i++)
	{
		ans += s[i] / 2;
		if((s[i] & 1) && s[i + 1])
		{
			++ans;
			--s[i + 1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
N = int(input())
X = list(map(int, input().split())) 

Xmax = max(X)
Xmin = min(X)

dis = []

for i in range(Xmax - Xmin + 1):
    tmp =  list(map(lambda x: (x - Xmin - i)**2, X))
    dis.append(sum(tmp))
    
print(min(dis))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main(){
    int n,m; cin>>n>>m;
    if(n<m){
        for(int i=0;i<m;i++) cout<<n;
    }
    else 
    for(int i=0;i<n;i++) cout<<m;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

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

char board[1002][1002];
int dist[1002][1002];


int main() {
  int H,W;
  cin >> H >> W;

  memset(board,'#',sizeof(board));
  memset(dist,-1,sizeof(dist));

  queue<pair<int,int>> que;
  reps(i,H){
    reps(j,W){
    cin >> board[i][j];
      if(board[i][j]=='#'){
    	 que.push(make_pair(i,j));
       dist[i][j]=0;
      }
    }
  }


  while(!que.empty()){
    auto p= que.front();
      que.pop();
      rep(i,4){
        int y = p.first + dy[i];
        int x = p.second + dx[i];
        if(dist[y][x] != -1)  continue;
        if(board[y][x]== '#')continue;
        dist[y][x]=dist[p.first][p.second]+1;
        board[y][x]='#';
        que.push(make_pair(y,x));
      }
    }

    int ans=-1;
    reps(i,H){
      reps(j,W){
        ans=max(ans,dist[i][j]);
      }
    }
  cout <<  ans<< endl;
}

Measured memory_bytes: 13328
import sys
s=int(input())
a=[s]
i=1
while True:
  if s%2==1:
    s=s*3+1
    i=i+1
  else:
    s=s//2
    i=i+1
  if s in a :
    print(i)
    sys.exit()
  a.append(s)


Measured memory_bytes: 2940
/* ***********************************************
Author        :yang12138
Created Time  :2017/9/5 12:22:04
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=1e5+10;

int cnt[N];

void solve(){
	int n;
	scanf("%d",&n);

	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		cnt[x]++;
	}

	int ans=cnt[0]+cnt[1];
	for(int i=1;i<N-1;i++){
		ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	}
	printf("%d\n",ans);
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int NG[501],OK[501];
int N;
ll mo;
vector<vector<int>> V;

ll from[505],to[505];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>mo;
	MINUS(NG);
	MINUS(OK);
	
	FOR(i,2*N) {
		FOR(j,2*N) {
			if(i*i+j*j<=4*N*N) {
				if(i*i+j*j>=N*N) OK[i]=j;
				else NG[i]=j;
			}
		}
		OK[i]++;
		NG[i]++;
		if(NG[i]>0) V.push_back({NG[i],OK[i],i});
		else V.push_back({OK[i],0,i});
	}
	sort(ALL(V));
	
	ll ret=0;
	FOR(i,N+1) {
		ZERO(from);
		from[0]=1;
		int num=0;
		FOR(j,2*N) {
			x=V[j][2];
			ZERO(to);
			
			FOR(y,i+1) if(from[y]) {
				
				int ok=num-y;
				if(NG[x]==0) {
					(to[y]+=from[y]*max(0,V[j][0]-(j-ok)))%=mo;
				}
				else {
					// ok
					(to[y]+=from[y]*(OK[x]-N-i-ok))%=mo;
					// ng
					(to[y+1]+=from[y]*max(0,V[j][0]-(j-ok)))%=mo;
				}
			}
			
			
			swap(from,to);
			if(NG[x]) num++;
		}
		
		if(i%2) ret+=mo-from[i];
		else ret+=from[i];
	}
	
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  ll a;
  string sb;
  cin >> a >> sb;
  ll b = (sb.at(0) - '0') * 100 + (sb.at(2) - '0') * 10 + (sb.at(3) - '0') * 1;

  ll ans = (a * b) / 100;
  cout << ans << endl;
}

Measured memory_bytes: 3580
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n:usize, m:usize,
        mut l:[i32; m]
    }
    l.sort();
    let mut g: Vec<i32> = Vec::new();
    for i in 0..m-1 {
        g.push(l[i+1] - l[i])
    } 
    g.sort();
    println!("{}", if m <= n {0} else {g[..m-n].iter().sum::<i32>()})
}


Measured memory_bytes: 3704
#include<iostream>

using namespace std;

long long dp[128][21] = {0};

int main (void){

	int N;
	int field[128];
	int ans;
	cin >> N;
	for(int i=0;i<N-1;i++){
		cin >> field[i];
	}
	cin >> ans;
	dp[0][field[0]] = 1;
	for(int i=0;i<N-1;i++){
		for(int j=0;j<21;j++){
			if(dp[i][j]!=0){
				if(j+field[i+1]<=20){
					dp[i+1][j+field[i+1]]+=dp[i][j];
				}
				if(j-field[i+1]>=0){
					dp[i+1][j-field[i+1]]+=dp[i][j];
				}
			}
		}
	}

	cout << dp[N-2][ans] << endl;

	return 0;
}

Measured memory_bytes: 1172
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    // 制約から, h, n, w <= 3500を探索することになる
    val (h, n, w) = (for {
      h <- 1L to 3500L
      n <- 1L to 3500L
      top = N * h * n
      bottom = 4L * h * n - N * n - N * h
      if bottom > 0
      if top % bottom == 0
      w = top / bottom
    } yield (h, n, w)).head

    println(s"$h $n $w")
  }

}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << " ";
	}
	return s;
}

void solve(){
    ll n,k;cin>>n>>k;
    vec a(n);rep(i,n)cin>>a[i];

    map<ll,ll> mp;
    rep(i,n)mp[a[i]]++;
    vec b;
    for(auto p:mp)b.push_back(p.second);
    sort(all(b));
    ll ans=0;
    cerr<<b<<endl;
    rep(i,(ll)mp.size()-k)ans+=b[i];
    cout<<ans<<endl;
}

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


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

int main(){
	int n;
	double d,x,ans=0;
	cin>>n>>d>>x;
	for(int i=1;i<=n;i++)
		ans+=1.0/(i+1);
	cout<<fixed<<setprecision(19)<<ans*(n+1)*(d+x*(2*n-1)/2)<<endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7
 
def nCmMOD(A,B,Mod):
    num,den=1,1
    for i in range(B):
        num*=(A-i)
        den*=(i+1)
        num%=Mod
        den%=Mod
    return (num*pow(den,Mod-2,Mod))%Mod
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
 
ans=1
F=factorization(M)
for i in range(len(F)):
    f=F[i][1]
    ans*=nCmMOD(f+N-1,N-1,mod)
    ans%=mod
 
if M==1:
    print(1)
else:
    print(ans)

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var a = l[0]; var b = l[1]; var c = l[2];
        var aa = a; var ab = b; var ac = c;
        Func<long, long, long, long[]> solve = (ai, bi, ci) =>
        {
            var s = ai;
            var k = bi;
            ai = bi / 2 + ci / 2;
            bi = s / 2 + ci / 2;
            ci = s / 2 + k / 2;
            return new long[] { ai, bi, ci };
        };
        var res = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
        {
            var f = solve(a, b, c);
            a = f[0]; b = f[1]; c = f[2];
            res++;
            if (a == b && b == c)
            {
                Console.WriteLine("-1");
                return;
            } 
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 100002

using namespace std;

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

int main() {
  int N, T, A[MAX_N];
  cin >> N >> T;
  int m = INT_INF, max_diff = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    m = min(m, A[i]);
    if (A[i] - m == max_diff) {
      ans++;
    } else if (A[i] - m > max_diff) {
      ans = 1;
      max_diff = A[i] - m;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {

    int A, B;
    float T;
    cin >> A >> B >> T;

    int i=0;
    while(true){
        if(A*i > T + 0.5) break;
        i++;
    }

    cout << (i-1) * B << endl;
}


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

int main()
{
	int n, count = 0, i = 0;
	cin >> n;
	if (n % 3 == 0) {
		count = n / 3;
	}
	else {
		while (n >= 6) {
			n -= 3;
			count++;
			if (i == 0) {
				count++;
				i++;
			}
		}
	}
	cout << count;
	return 0;
}

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

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		Deque<Point> dq = new ArrayDeque<Point>();
		boolean[] judge = new boolean[k];
		Arrays.fill(judge, true);
		Point now = new Point(1,1);
		dq.add(now);
		while(!dq.isEmpty()){
			Point z = dq.removeFirst();
			if(!judge[(z.x)]){
				continue;
			}
			judge[(z.x)] = false;
			if(z.x == 0){
				System.out.println(z.y);
				break;
			}
			if(judge[(z.x*10)%k]){
				dq.addFirst(new Point((z.x*10)%k, z.y));
			}
			if(judge[(z.x+1)%k]){
				dq.addLast(new Point((z.x+1)%k, z.y+1));
			}
		}
	}
}

class Point{
	int x;
	int y;
	Point(int x, int y){
		this.x = x;
		this.y = y;
	}
}


Measured memory_bytes: 26452
#include <iostream>

typedef struct {
	int time;
	char name[10];
} process;

const int q_size = 100000;
process queues[q_size];

using namespace std;

int head = 0;
int tail = 0;

bool isEmpty()
{
	if (head == tail)
		return true;
	return false;
}

bool isFull()
{
	if (head == ((tail + 1) % q_size))
		return true;
	return false;
}

void Enqueue(process p)
{
	if (isFull()) {
		cout << "Queues is full." << endl;
		//exit(EXIT_FAILURE);
	}
	if (tail == q_size)
		tail = 0;
	queues[tail++] = p;
}

process Dequeue()
{
	if (isEmpty()) {
		cout << "No process." << endl;
		//exit(EXIT_FAILURE);
	}
	if (head + 1 == q_size) {
		process p = queues[head];
		head = 0;
		return p;
	}
		
	return queues[head++];
}

int main(void)
{
	int n, q;
	process p;

	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		cin >> p.name >> p.time;
		Enqueue(p);
	}
	int time = 0;
	while (n > 0) {
		p = Dequeue();
		if (p.time - q > 0) {
			p.time -= q;
			Enqueue(p);
			time += q;
		}
		else {
			time += p.time;
			cout << p.name << " " << time << endl;
			n--;
		}
	}

	return 0;
}

Measured memory_bytes: 4556
import java.util.*;
import java.util.ArrayList;

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


Measured memory_bytes: 26192
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
    if (a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

int64_t lcm(int64_t a, int64_t b)
{
    return a * b / gcd(a, b);
}

void solve() {
    int64_t a, b;
    cin >> a >> b;
    int64_t result = lcm(a, b);
    cout << result << endl;
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a[3],cnt[4] = {0};
    
    while(cin >> a[0]){
        cin >> a[1] >> a[2];
        
        sort(a,a+3);
        
        if(a[0] + a[1] > a[2])
            if(a[1] + a[2] > a[0])
                if(a[0] + a[2] > a[1])cnt[0]++;
                else break;
            else break;
        else break;
        
        if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]) cnt[1]++;
        else if(a[0]*a[0]+a[1]*a[1] < a[2]*a[2])cnt[3]++;
        else if(a[0]*a[0]+a[1]*a[1] > a[2]*a[2])cnt[2]++;
        
    }
    
    cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << " " << cnt[3] << endl;
    return 0;
}


Measured memory_bytes: 3160
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
        int[] ans = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
        Array.Sort(ans);
        Console.WriteLine(ans[0]+ans[1] == ans[2] ? "Yes" : "No");
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 10000000000000000
typedef long long ll;

int main() {
    
    ll N, T;
    cin >> N >> T;
    
    ll sum=0, pre=0, nxt;
    rep(i,N){
        cin>>nxt;
        sum += min(T,nxt-pre);
        pre = nxt;
    }
    cout1(sum+T);
}

Measured memory_bytes: 256
k, n = map(int,input().split())
a = list(map(int,input().split()))
max = -100
for i in range(1,len(a)):
    if abs(a[i-1]-a[i]) > max:
        max = abs(a[i-1]-a[i])
if abs(a[0]+abs(k-a[len(a)-1])) > max:
    max = abs(a[0]+abs(k-a[len(a)-1]))
print(k-max)


Measured memory_bytes: 26444
#include <iostream>
#include <numeric>
using namespace std;
int main(void){
    // Your code here!
    int k;
    cin >> k;
    int sum = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                int x = gcd(i, j);
                sum += gcd(x, l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	string s;
	cin>>s;

	if(s[0]=='S'){
		cout<<"Cloudy"<<endl;
	}else if(s[0]=='C'){
		cout<<"Rainy"<<endl;
	}else{
		cout<<"Sunny"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int h;
    int w;
    for(int i = 0; i < 300; i++){
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if((i + j) % 2 == 0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << "" << endl;
        }
        cout << "" << endl;
    }
}


Measured memory_bytes: 3076
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7;
int n, col[maxn];
vector<int> g[maxn], path;
bool dfs(int v, int p = -1) {
	bool ip = v == n;
	for(auto i : g[v]) if(i != p) {
		ip |= dfs(i, v);
	}

	if(ip) path.pb(v);
	return ip;
}
int count(int v, int p = 0) {
	int cnt = 1;
	for(auto i : g[v]) if(i != p && (col[v] == col[i] || col[i] == 0)) {
		if(col[i] ==0) col[i] == col[v];
		cnt += count(i, v);
	}
	return cnt;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	dfs(1);
	reverse(all(path));
	for(int i = 0; i < (path.size()+1)/2; i++) {
		col[path[i]] = 1;
	}
	for(int i = (path.size()+1)/2; i < path.size(); i++) {
		col[path[i]] = 2;
	}
	cout << (count(n) >= count(1) ? "Snuke" : "Fennec") << '\n';
	return 0;
}


Measured memory_bytes: 13688
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 3300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
ll n,m;
ll dp[N];
bool bo[N];

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

rep(i,0,m)
{
   ll x;
   cin>>x;
   bo[x]=true;
}
dp[0]=1;
if(bo[1]==false)
dp[1]=1;
if(bo[2]==false)
dp[2]=dp[1]+dp[0];
rep(i,3,n+1)
{
	if(bo[i]==false)
	dp[i]=(((dp[i-1]%mod+dp[i-2]%mod)+mod)%mod);
	else
	dp[i]=0;
}
cout<<dp[n];
}

Measured memory_bytes: 2432
import sys
import math

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b, c, d = inintm()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(b - (b//c + b//d) + b//lcm(c,d) - ((a-1) - ((a-1)//c + (a-1)//d) + (a-1)//lcm(c,d)))


Measured memory_bytes: 62276
N = int(input())
S = []
if N == 0:
    print('0')
    exit()
while N != 1:
    if N % (-2) == -1:
        S.append(1)
        N = (N - 1) // -2
    else:
        S.append(0)
        N = N // -2
S.append(1)
ans = ''
for s in S[::-1]:
    ans += str(s)
print(ans)

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1), b(m + 1);
	rep(i,n + 1) {
		if (i == 0) {
			a[i] = 0;
			continue;
		}
		ll tmp;
		cin >> tmp;
		a[i] = a[i - 1] + tmp;
	}
	rep(i,m + 1) {
		if (i == 0) {
			b[i] = 0;
			continue;
		}
		ll tmp;
		cin >> tmp;
		b[i] = b[i - 1] + tmp;
	}

	int ans = 0;
	int j = m;
	rep(i,n + 1) {
		if (a[i] > k) continue;
		while (b[j] > k - a[i]) j--;
		ans = max(i + j, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;string s,t;
	cin>>n>>s>>t;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(s.substr(n-i,i)==t.substr(0,i))  cnt=max(cnt,i); 
	}
	cout<<2*n-cnt<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <set>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    ll k, n;
    cin >> n >> k;
    vector<vector<ll>> td(n, vector<ll>(3, 0));
    REP(i, n) {
        cin >> td[i][0] >> td[i][1];
        td[i][2] = 0;
    }

    sort(ALL_OF(td), [](vector<ll> &a, vector<ll>& b) -> bool {
        return a[1] > b[1];
    });

    vector<bool> m(n+1, false);
    ll bonus = 1;
    ll ans = 0;
    REP(i, n) {
        if (!m[td[i][0]]) {
            m[td[i][0]] = true;
            td[i][2] = bonus;
            bonus += 2;
        }
        if (i < k) ans += td[i][1] + td[i][2];
    }
    
    int l = k, r = k-1;
    ll cand = ans;
    while (true) {
        for (l--; l >= 0; l--) if (td[l][2] == 0) break;
        for (r++; r < n; r++) if (td[r][2] != 0) break;
        if (l < 0 || r >= n) break;
        cand += td[r][1] + td[r][2] - td[l][1];
        chmax(ans, cand);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 5888
#include <stdio.h>
int n, d, x;
char s[200001];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')d++;
	}
	for (int i = 0; i < d; i++) {
		if (s[i] == 'W')x++;
	}
	printf("%d\n", x);
}

Measured memory_bytes: 1924
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS = 1000000001;
	SINT8 S[300001];

	cin >> N;
	cin >> S;

	vector<SINT32> WDATA(N);
	vector<SINT32> EDATA(N);

	if (S[0] == 'W') {
		WDATA[0] = 1;
	} else {
		EDATA[0] = 1;
	}
	
	for (SINT32 i = 1; i < N; i++) {
		WDATA[i] = WDATA[i-1];
		EDATA[i] = EDATA[i-1];
		if (S[i] == 'W') {
			WDATA[i] += 1;
		} else {
			EDATA[i] += 1;
		}
	}

	for (SINT32 i = 0; i < N; i++) {
		if (i == 0) {
			ANS = MIN(ANS, EDATA[N-1]-EDATA[0]);
		} else if ( i == N - 1) {
			ANS = MIN(ANS,WDATA[N-2]);
		} else {
			ANS = MIN(ANS,(EDATA[N-1] - EDATA[i]) + (WDATA[i-1]));
		}
	}


	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

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

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

    int n;
    cin >> n;
    long long cur = 0, ans = 0;

    while (n--) {
        int x;
        cin >> x;
        cur += x;
        if (!x || !n)
            ans += cur / 2, cur = 0;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3664
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

// 約数列挙
vector< ll > divisor(ll n) {
	vector< ll > ret;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret), greater<ll>());
	return (ret);
}
ll K[2][200001];

int main() {
	string S;
	cin >> S;
	ll N = S.size();

	K[0][0] = 0;
	K[1][0] = 0;
	K[0][1] = -1;
	K[1][1] = 1;

	for (ll i = 2; i <= N; i++) {
		//2
		if (i >= 4 && S.substr(i - 1, 2) != S.substr(i - 3, 2)) {
			K[0][i] = max(K[0][i - 2] + 1, K[1][i - 2] + 1);
		}
		else {
			K[0][i] = K[1][i - 2] + 1;
		}

		// 1
		if (S[i - 1] != S[i - 2]) {
			K[1][i] = max(K[0][i - 1] + 1, K[1][i - 1] + 1);
		}
		else {
			K[1][i] = K[0][i - 1] + 1;
		}
	}
	// for (int i = 0; i <= N; i++) { cout << K[0][i] << " "; }cout << endl;
	// for (int i = 0; i <= N; i++) { cout << K[1][i] << " "; }cout << endl;

	cout << max(K[0][N], K[1][N]) << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
S = input()
i = 0
cnt = 0
while i+1 < len(S):
  if bool == 1:
    Si = S[i:(i+2)]
  else:
    Si = S[i]
  bool = 0
  if S[i+1] == Si:
    cnt += 1
    i += 2
    bool = 1
  else:
    i += 1
print(len(S)-cnt)


Measured memory_bytes: 3500
import math

ii = lambda:int(input())
li = lambda:list(map(int,input().split()))
lix = lambda x:list(li() for _ in range(x))
##########
def main(n):
    res = n+1
    ran = math.floor(math.sqrt(n))
    for x in range(1,ran+1):
        y,mod = divmod(n,x)
        if mod == 0:
            res = min(res, calc(x,y))
    return res

def calc(x,y):
    return x + y - 2

n = ii()
print(main(n))

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

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

    vector<int> h(n+2,0);
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }

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

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

int main(){
    int N, M, a[100010], b[100010];
    long long c[100010];
    cin >> N >> M;
    a[0] = -1;
    a[M+1] = N + 1;

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

    for(int i = 0; i <= M; i++){
        b[i] = a[i+1] - a[i] - 1;
    }

    sort(b, b + M+1, greater<long long>());
    c[0] = 0;
    c[1] = 1;

    for(int i = 2; i <= b[0]; i++){
        c[i] = (c[i-1] + c[i-2]) % 1000000007;
    }

    long long count = 1;

    for(int i = 0; i <= M; i++){
        count *= c[b[i]];
        count %= 1000000007;
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    int mod = 7 + (int) 1e9 ;
    FOR(i,k,n+2){
        ans += ((n - i + 1) * i + 1)% mod;
        ans = ans % mod;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int gcd2(int a,int b){
    int t;
    while(b){
        t =a%b;
        a=b;
        b=t;
    }
    return a;
}
int gcd3(int a,int b,int c)
{
    if(a==b&&b==c)
        return a;
    else if(a==b)
        return gcd2(a,c);
    else if(a==c)
        return gcd2(a,b);
    else if(b==c)
        return gcd2(a,b);
    else
        return gcd2(gcd2(a,b),c);
}
int main()
{
    int k;
    int sum = 0;
    cin >> k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum+=gcd3(i,j,l);
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<int> edge(n, INF);
  rep(i, m){
  	int a, b;cin>>a>>b;--a;--b;
    edge[a]=min(edge[a], b);
  }
  vector<int> minr(n, INF);
  for(int i=n-1;i>=0;i--){
  	if(i==n-1)minr[i]=edge[i];
    else minr[i]=min(minr[i+1], edge[i]);
  }
  rep(i, n-1){
    if(edge[i]>=minr[i+1])edge[i]=INF;
  }
  int ans=0;
  int pos=-1;
  rep(i, n){
  	if(edge[i]==INF)continue;
    if(i<=pos)continue;
    pos=edge[i]-1;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}



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

int n, a[100005];

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++) scanf("%d", a+i);
	if (n == 2)
	{
		printf("Yes\n");
		return 0;
	}
	bool all_eq = true;
	for (int i = 1;i < n;i++) if (a[i] != a[i-1]) all_eq = false;
	int k = 0, z = 10000000;
	for (int i = 0;i < n;i++) k = max(k, a[i]), z = min(z, a[i]);
	if (k-z > 1)
	{
		printf("No\n");
		return 0;
	}
	if (all_eq)
	{
		if (a[0] == n-1 || a[0] <= n/2)
			printf("Yes\n");
		else
			printf("No\n");
	} else
	{
		int cnt = 0;
		for (int i = 0;i < n;i++) if (a[i] != k) cnt++;
		if (cnt+(n-cnt)/2 >= k && cnt <= z)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    map<int,int> h;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        h[temp]++;
    }
    int count=0;
    for(auto t:h)
    {
        if(t.first<=t.second)
            count+=t.second-t.first;
        else
            count+=t.second;
    }
    cout<<count;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4736