akhauriyash/Code-Regression huggingface dataset:
h,w = map(int,input().split())
s = []
point = [[0 for j in range(0,w+2)] for i in range(0,h+2)]
ans = []
for _ in range(h):
    S = input()
    s.append(S)
for i in range(0,h+2):
    point[i][0] = 1
    point[i][w+1] = 1
for i in range(0,w+2):
    point[0][i] = 1
    point[h+1][i] = 1

def haba(y,x):
    point[y][x] = 1
    q = []
    q.append((y,x,s[y-1][x-1]))
    while len(q) > 0:
        (y,x,ss) = q.pop(0)
        nextPoint = [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]
        for ny,nx in nextPoint:
            if point[ny][nx] != 0:
                continue
            if ss == "#" and s[ny-1][nx-1] == ".":
                ans[-1][0] += 1
                point[ny][nx] = 1
                q.append((ny,nx,s[ny-1][nx-1]))
            if ss == "." and s[ny-1][nx-1] == "#":
                ans[-1][1] += 1
                point[ny][nx] = 1
                q.append((ny,nx,s[ny-1][nx-1]))
for i in range(1,h+1):
    for j in range(1,w+1):
        if point[i][j] == 1:
            continue
        if s[i-1][j-1] == ".":
            ans.append([1,0])
        else:
            ans.append([0,1])
        haba(i,j)
sum = 0
for i,j in ans:
    sum += i*j
print(sum)


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

void dfs(int node, auto& g, auto& dp, auto& preff, auto& suff, auto& f) {
    dp[node] = 1;

    vector<int> sons;

    for (int v : g[node]) {
        if (v == f[node])
            continue;
        f[v] = node;
        dfs(v, g, dp, preff, suff, f);
        sons.push_back(v);
    }

    int k = sons.size();

    for (int i = 0; i < k; i += 1) {
        dp[node] = 1LL * dp[node] * (dp[sons[i]] + 1) % MOD;
        preff[node].push_back(dp[node]);
    }
    
    dp[node] = 1;

    for (int i = k - 1; i >= 0; i -= 1) {
        dp[node] = 1LL * dp[node] * (dp[sons[i]] + 1) % MOD;
        suff[node].push_back(dp[node]);
    }

    reverse(suff[node].begin(), suff[node].end());
}

void dfs2(int node, auto& g, auto& dp, auto& preff, auto& suff, auto& f, auto& sol, int up) {
    sol[node] = dp[node];
    vector<int> sons;

    for (int v : g[node]) {
        if (v == f[node])
            continue;
        sons.push_back(v);
    }

    int k = sons.size();
    for (int i = 0; i < k; i += 1) {
        int left_coef = (i - 1 >= 0 ? preff[node][i - 1] : 1);
        int right_coef = (i + 1 < k ? suff[node][i + 1] : 1);
        
        dp[node] = 1LL * left_coef * right_coef % MOD;
        dp[node] = 1LL * dp[node] * up % MOD;
        dp[sons[i]] = 1LL * dp[sons[i]] * (dp[node] + 1) % MOD;
        dfs2(sons[i], g, dp, preff, suff, f, sol, dp[node] + 1);
    }   
    
    dp[node] = 1;
    for (int i = 0; i < k; i += 1)
        dp[node] = 1LL * dp[node] * (dp[sons[i]] + 1) % MOD;

    if (f[node] >= 0)
        dp[f[node]] = 1LL * dp[f[node]] * (dp[node] + 1) % MOD;
}

int main() {
    int n, m; cin >> n >> m;
    MOD = m;
    vector<vector<int>> g(n);

    for (int i = 0; i < n - 1; i += 1) {
        int x, y; cin >> x >> y;
        x -= 1, y -= 1;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    
    vector<int> dp(n, 0);
    vector<vector<int>> preff(n), suff(n);
    vector<int> f(n, -1);

    dfs(0, g, dp, preff, suff, f);

    vector<int> sol(n, 0);

    dfs2(0, g, dp, preff, suff, f, sol, 1);

    for (int i = 0; i < n; i += 1)
        cout << sol[i] << "\n";
}

Measured memory_bytes: 33664
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		// get a integer
		int A = sc.nextInt();
		// get two integers separated with half-width break
		int B = sc.nextInt();

		if ((B % A) == 0)
			System.out.println(A+B);
		else 
			System.out.println(B-A);
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  bool ok = true;
  rep(i, n) {
    if(n % 2 && a[i] != (i + 1) / 2 * 2)
      ok = false;
    else if(n % 2 == 0 && a[i] != i / 2 * 2 + 1)
      ok = false;
  }
  mint ans = 0;
  if(ok) ans = mint(2).pow(n / 2);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;

void solve(int _t){
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, 0, n) cin >> a[i];
	bool dp[N] = {0};
	rep(i, 0, n) dp[a[i]] = 1;
	dp[0] = 0;
	for(int x = 1; x <= k; x++){
		rep(j, 0, n){
			if(x > a[j])
				dp[x] |= !dp[x-a[j]];
		}
	}
	if(dp[k])
		cout<<"First"<<endl;
	else 
		cout<<"Second"<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}

Measured memory_bytes: 3852
n = int(input())
A = list(map(int,input().split()))

S,cnt,res1 = 0,0,0
for a in A:
	S += a
	cnt += 1
	if cnt%2 == 1 and S <= 0:
		res1 += abs(S-1)
		S = 1
	elif cnt%2 == 0 and S >= 0:
		res1 += S+1
		S = -1

S,cnt,res2 = 0,0,0
for a in A:
	S += a
	cnt += 1
	if cnt%2 == 1 and S >= 0:
		res2 += S+1
		S = -1
	elif cnt%2 == 0 and S <= 0:
		res2 += abs(S-1)
		S = 1

print(min(res1,res2))

Measured memory_bytes: 14468
n,m,x = map(int,input().split())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append([tmp[0], tmp[1:]])
res = 10 ** 100
for i in range(1 << n):
    mon = 0
    recog = [0] * m
    for j in range(n):
        if i & (1 << j):
            a,b = l[j]
            mon += a
            for k in range(m):
                recog[k] += b[k]
    if all(i >= x for i in recog):
        res = min(res, mon)
if res == 10 ** 100:
    res = -1
print(res)

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
void solution()
{
    string st;
    int n;
    int res=0;
    cin>>st;
    n=st.size();
    for(int i=1;i<n;i++)
    {
        if(st[i-1]!=st[i])
        {
            res++;
        }
    }
    cout<<res<<endl;
}
int main()
{
    solution();
    return 0;
}


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

int main()
{
  int K,N ;
  cin>>K>>N ;
  vector<int>A(N) ;
  for(int i=0;i<N;i++) cin>>A.at(i) ;
  
  int min=1e9 ;
  for(int i=0;i<N;i++){
    int len_clockwise=0 ;  //時計回りの長さ
    int len_C_clockwise=0 ;  //反時計回りの長さ
    if(i==N-1) len_clockwise=A.at(N-1)-A.at(0) ;
    else len_clockwise=A.at(i)+K-A.at(i+1) ;
    if(i==0) len_C_clockwise=A.at(0)+K-A.at(1) ; 
    else  len_C_clockwise=K-A.at(i)+A.at(i-1) ;
    if(min>(len_clockwise>len_C_clockwise?len_C_clockwise:len_clockwise)){
      min=(len_clockwise>len_C_clockwise?len_C_clockwise:len_clockwise) ;
    }    
  }
  
  cout<<min<<endl ;
  
  return 0 ;
}

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

using namespace std;  


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

bool f=true;
if(s[0]!='A')f=false;
int k=-1;
for(int i=2;i<s.length()-1;++i){
if(s[i]=='C')k=i;
}
if(k==-1)f=false;
for(int i=1;i<s.length();++i){
if(isupper(s[i])&&i!=k){
f=false;
}

}

if(f)cout<<"AC"<<endl;
else{cout<<"WA"<<endl;}


 return 0; 
}


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

int main() {
    int N;
    int ans = 0;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a.at(i);
    rep(i,N) {
        while (a.at(i) > 0) {
            if (a.at(i) % 2 == 0) {
                ++ans;
                a.at(i) /= 2;
            } else break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <stdio.h>

using namespace std;


int main(){
	int count[10001],tmp,num=3;
	for(int i=0;i<10001;i++)count[i]=0;

	for(int i=0;i<10;i++){
		scanf("%d",&tmp);
		count[tmp]++;
	}

	for(int i=10000;i>=0&&num>0;i--){
		if(count[i]>0){
			for(int k=0;k<count[i]&&num>0;k++){
				printf("%d\n",i);
				num--;
			}
		}
	}

    return 0;
}

Measured memory_bytes: 2740
#include <iostream>
#include <vector>

int main() {
	std::vector<char> vec(3);
	std::cin >> vec[0] >> vec[1] >> vec[2];

	int num = 0;
	for (auto&& elm : vec) {
		if (elm == '1') {
			++num;
		}
	}

	std::cout << num << std::endl;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
struct
{
    int p, y;
} a[N];
vector<pair<int, int>> v[N];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
        scanf("%d%d", &a[i].p, &a[i].y);
    for (int i = 0; i < m; i++)
        v[a[i].p].push_back({a[i].y, i});
    for (int i = 1; i <= n; i++)
        sort(v[i].begin(), v[i].end());
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < v[i].size(); j++)
            a[v[i][j].second].y = j + 1;
    for (int i = 0; i < m; i++)
        printf("%06d%06d\n", a[i].p, a[i].y);
    return 0;
}

Measured memory_bytes: 7808
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
void FAIL() {
	printf("-1");
	exit(0);
}
ll ans,tot,suf[N];
int A[N],n;
int main() {
	rd(n);
	for(int i=0;i<=n;++i) rd(A[i]);
	for(int i=n;i>=0;--i) suf[i]=suf[i+1]+A[i];
	ll cur=1;
	for(int i=0;i<=n;++i) {
		if(cur<A[i]) FAIL();
		ans+=cur;
		cur-=A[i],cur=min(cur*2,suf[i+1]);
	}
	printf("%lld",ans);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(i,30){
        vll A(n), B(n);
        ll T = 1<<i;
        rep(j,n) A[j]=a[j]%(2*T);
        rep(j,n) B[j]=b[j]%(2*T);
        sort(all(B));
        int cnt=0;
        rep(j,n){
            cnt -= lower_bound(all(B), T-A[j])-B.begin();
            cnt += lower_bound(all(B), T*2-A[j])-B.begin();
            cnt -= lower_bound(all(B), T*3-A[j])-B.begin();
            cnt += lower_bound(all(B), T*4-A[j])-B.begin();
        }
        if (cnt&1) ans|=1<<i;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6572
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
// End Template IO/Utility
int solve(){
	char ch;
	cin>>ch;
	cout<<((ch>='A' && ch<='Z')?'A':'a');
	return 0;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    
    if(a>=3200){
      System.out.println(s);
    }else{
      System.out.println("red");
    }
    
    
    
    
  }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define x first
#define y second
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
const ll m=1e9+7;
const ll N=1e6;
bool prime[N];
vector<int> p;
void sieve(int n)
{
	fill(prime, prime+n, true);
	for(int i=2;i<n;i++)
	{
		if(prime[i])p.pb(i);
		for(int j=0;j<p.size() and i*p[j]<n;j++)
		{
			prime[i*p[j]]=false;
			if(i%p[j]==0)break;
		}
	}
}
ll col(ll n)
{
	ll res=0;
	while(n>1)
	{
		if(n&1)
		n=3*n+1;
		else n=n>>1;
		res++;
		
	}
	return res;
}
ll modp(ll a, ll b)
{
	if(b==0)return 1;
	ll u=modp(a, b>>1);
	u=(u*u)%m;
	if(b&1)
	return (u*a)%m;
	return u;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1];
    memset(dp, 0, sizeof dp);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            if(s[i]==t[j])
                dp[i+1][j+1]=dp[i][j]+1;
            else
                dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
    }
    int len=dp[n][m];
    string ans="";
    for(int i=n-1,j=m-1;i>=0 and j>=0 and len>=0;)
    {	
        if(s[i]==t[j]){ans+=s[i];i--,j--;if(ans.length()==len)break;}
        else if(dp[i+1][j]>dp[i][j+1])j--;
        else i--;
		
    }
  	reverse(ans.begin(),ans.end());
    cout<<ans;




}

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

using namespace std;

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

  string S;
  cin >> S;

  if (S[K-1] == 'A') {
    S[K-1] = 'a';
  }
  else if ( S[K-1] == 'B'){
    S[K-1] = 'b';
  }
  else {
    S[K-1] = 'c';
  }
 
 cout << S << endl;
 return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double m_ang = m * 6.0;
  double h_ang = h * 30.0 + (m/60) * 30.0;
  double angle = abs(h_ang-m_ang);
  if (angle > 180.0)
  {
      angle = 360 - angle;
  }
//   cout << angle << endl;

  double cos_angle = 0;
  if (angle == 90) cos_angle = 0;
  else cos_angle = cos(M_PI/180.0*angle);
//   cout << cos_angle << endl;

  double ans = a*a + b*b - 2*a*b*cos_angle;
//   cout << ans << 2*a*b*cos_angle << endl;
  ans = sqrt(ans);
  cout << setprecision(10) << ans << endl;
  return 0;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
int n, k, a[111], ans;
int main(){
    n = read(), k = read();
    for (int i = 1; i <= k; ++i){
        int d = read();
        for (int j = 1; j <= d; j++){
            int l = read();
            a[l]++;
        }
    }
    for (int i = 1; i <= n; i++){
        if (!a[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}
//g++ B.cpp -o B.exe -lm -Wall -O2 -std=c++11

Measured memory_bytes: 3748
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
     int n , m;
    int arr[N];
int main()
{

    cin >> n >> m;
    for(int i = 0 ; i < n ; i++){
        scanf("%d" , &arr[i]);
    }
    sort(arr , arr + n);
    long long int sum = 0;
    for(int i = 0 ; i < n - m ; i++)
        sum += arr[i];
    cout << sum << endl;
    return 0;
}


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

int main(){
	int n,x;
	cin>>n>>x;
	int a[200];
	lp(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	lp(i,n){
		if(a[i]<=x){
			x-=a[i];
			ans++;
		}
		else break;
	}
	if(ans==n&&x!=0) ans--;
	cout<<ans<<endl;
  	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 3e5;
int dp[N][3];

signed main() {
    accell();
    int n, k;
    int r, s, p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string a;
    cin >> a;
    for (int i = 0; i < a.size(); ++i) {
        if (i - k < 0) {
            if (a[i] == 's') {
                dp[i][0] = r;
            }
            if (a[i] == 'p') {
                dp[i][1] = s;
            }
            if (a[i] == 'r') {
                dp[i][2] = p;
            }
        }
        if (i - k >= 0) {
            if (a[i] == 's') {
                dp[i][0] = max(dp[i - k][1], dp[i - k][2]) + r;
                dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
                dp[i][2] = max(dp[i - k][0], dp[i - k][1]);
            }
            if (a[i] == 'p') {
                dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
                dp[i][2] = max(dp[i - k][0], dp[i - k][1]);
                dp[i][1] = max(dp[i - k][0], dp[i - k][2]) + s;
            }
            if (a[i] == 'r') {
                dp[i][2] = max(dp[i - k][0], dp[i - k][1]) + p;
                dp[i][1] = max(dp[i - k][0], dp[i - k][2]);
                dp[i][0] = max(dp[i - k][1], dp[i - k][2]);
            }
        }
    }
    int res = 0;
    for (int i = n - 1; i >= max(n - k, 0LL); --i) {
        res += max(max(dp[i][1], dp[i][0]), dp[i][2]);
        // cout << max(max(dp[i][1], dp[i][0]), dp[i][2]) << ' ';
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 4560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] k = new int[M];
        int[] p = new int[M];
        int[][] s = new int[M][];
        for(int i=0; i<M; i++) {
            k[i] = Integer.parseInt(sc.next());
            int[] S = new int[k[i]];
            for(int j=0; j<k[i]; j++) {
                S[j] = Integer.parseInt(sc.next());
            }
            s[i] = S;
        }
        
        int ans = 0;
        for(int i=0; i<M; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        for(int i=0; i<Math.pow(2, N); i++) {
            int[] swit = new int[N]; 
            boolean hantei = true;
            for(int j=0; j<N; j++) {
                if((1&i>>j) == 1) {
                    swit[j] += 1;
                }else {
                    swit[j] += 0;
                }
            }
            
            for(int x=0; x<M; x++) {
                int count = 0;
                for(int y=0; y<k[x]; y++) {
                    if(swit[s[x][y]-1] == 1) {
                        count++;
                    }
                }
                if(count % 2 != p[x]) {
                    hantei = false;
                }
            }
            
            
            if(hantei) ans++;
        }
        System.out.println(ans);
        
    }
}


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

using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> city(N,0);
  for(int i=0;i<M;++i){
    int a,b;
    cin>>a>>b;
    city[a-1]++;
    city[b-1]++;
  }

  for(auto c:city) cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long Q = sc.nextLong();
        long H = sc.nextLong();
        long S = sc.nextLong();
        long D = sc.nextLong();
        long N = sc.nextLong();
        sc.close();
        
        long min = Math.min(Math.min(4*Q, 2*H), S);

        if(2*min <= D){
            System.out.println(min*N);
        } else {
            System.out.println(D*(N/2) + min*(N%2));
        }

    }
}

Measured memory_bytes: 22996
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>
using namespace std;

#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

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

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

int main()
{
    // #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    string str;
    cin>>str;
    int i = 0, n = str.size(), mx = 0;
    while(i<n) {
        int count = 0;
        if(str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T') {
            while(i<n && (str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T')) {
                count++; i++;
            }
            mx = max(count, mx);
        }
        else i++;
    }
    cout<<mx;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;
int main()
{
	ll k,n;
	cin>>k>>n;
	std::vector<ll> v(n);
	std::map<ll, ll> mp;
	for (ll i = 0; i < n; ++i)
	{
		cin>>v[i];
		mp[v[i]] = i;
	}
	ll x=k,y=k;
	if(mp.find(k) == mp.end()){
		cout<<k<<endl;
		return 0;
	}
	ll a = 0;
	for (ll i = 1; ; )
	{
		// if(a == 2){
		// 	i++;
		// 	a=0;
		// }
		// if(i % 2){
			x = x - i;
			//i--;
		// }else{
			y = y + i;
			//i--;
		// }
			i++;
		//cout<<x<<" "<<y<<endl;
		if(mp.find(x) == mp.end()){
			cout<<x<<endl;
			break;
		}else if(mp.find(y) == mp.end()){
			cout<<y<<endl;
			break;
		}
		x = k;
		y = k;
		// a++;			
	}
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int ta[22],tb[22];
vector<int> v1[55];
int ts[2][22];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s=INF;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>ta[i];
		ta[i]--;
	}
	for(i=0;i<n;i++){
		cin>>tb[i];
		tb[i]--;
	}
	for(i=0;i<(1<<n);i++){
		for(j=0;j<50;j++)v1[j].clear();
		for(j=0;j<n;j++){
			if(i&(1<<j))a=ta[j];
			else a=tb[j];
			v1[a].push_back(j);
		}
		a=0;
		int eve=0;
		int p=1,q=0;
		for(j=0;j<50;j++){
			eve=(a+v1[j].size())/2-a/2;
			c=0;
			for(k=0;k<v1[j].size();k++){
				b=v1[j][k];
				if((i&(1<<b))==0)b++;
				if(b%2==1){
					c++;
					ts[0][p]=v1[j][k];
					ts[1][v1[j][k]]=p;
					p+=2;
				}else{
					ts[0][q]=v1[j][k];
					ts[1][v1[j][k]]=q;
					q+=2;
				}
			}
			a+=v1[j].size();
			if(eve!=c)break;
		}
		//cout<<i<<" "<<j<<endl;
		if(j<50)continue;
		b=0;
		for(j=0;j<n;j++){
			a=ts[0][j];
			for(k=0;k<a;k++){
				if(ts[1][k]<j)continue;
				b++;
			}
		}
		s=min(s,b);
	}
	if(s==INF)s=-1;
	cout<<s<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  cout << "ABC" << n/100 << (n%100)/10 << n%10 << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 100005;
int a[N], cnt[N];

int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
        sum += a[i];
    }
    int q;
    scanf("%d", &q);
    while (q--) {
        int x, y;
        scanf("%d %d", &x, &y);
        cnt[y] += cnt[x];
        sum -= (ll)cnt[x] * x;
        sum += (ll)cnt[x] * y;
        cnt[x] = 0;
        printf("%lld\n", sum);
    }
	return 0;
}


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

int main(){
  long N,H;
  cin >> N >> H;
  long a[N],b[N];
  for(int i=0;i<N;++i){
    cin >> a[i] >> b[i];
  }
  sort(a,a+N,greater<int>());
  sort(b,b+N,greater<int>());
  long sum=0,cnt=0;
  int max=a[0];
  for(int i=0;max<b[i];++i){
    sum+=b[i];
    ++cnt;
    if(sum>=H) break;
  }
  if(sum<H){
    cnt+=(int)ceil((double)(H-sum)/max);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
def turn(n):
    if n=='0':
        return '1'
    else:
        return '0'
    
s = input()
n = len(s)
s = list(s)
count = 0
for i in range(n-1):
    if s[i]==s[i+1]:
        s[i+1] = turn(s[i+1])
        count += 1
print(count)

Measured memory_bytes: 49648
#include<bits/stdc++.h>
#define inf 1000000000
#define N 2009
using namespace std;

int n,cnt,f[N],g[N]; char a[N],b[N];
struct node{ int x,y; }c[N];
bool cmp(node u,node v){ return u.x<v.x; }
int calc(int x,int y,int u,int v){
	return x+y+min(y+abs(x-u),x+abs(y-v));
}
int main(){
	scanf("%s%s",a,b); n=strlen(a);
	int i,j,x;
	for (i=0; i<n; i++) if (b[i]=='1') break;
	if (i>=n){
		for (i=0; i<n; i++) if (a[i]=='1') break;
		puts(i<n?"-1":"0"); return 0;
	}
	int ans=inf;
	for (i=n-1; i>=0; i--) if (b[i]=='1'){ f[n-1]=n-1-i; break; }
	for (i=0; i+1<n; i++) f[i]=(b[i]=='1'?0:f[(i-1+n)%n]+1);
	for (i=0; i<n; i++) if (b[i]=='1'){ g[0]=i; break; }
	for (i=n-1; i; i--){
		g[i]=(b[i]=='1'?0:g[(i+1)%n]+1);
	}
	for (i=0; i<n; i++){
		for (j=cnt=0; j<n; j++) if (a[j]!=b[(i+j)%n])
			c[++cnt]=(node){f[j],g[j]};
		sort(c+1,c+cnt+1,cmp);
		for (j=cnt,x=0; j>=0; j--){
			ans=min(ans,cnt+calc(x,c[j].x,i,(n-i)%n));
			x=max(x,c[j].y);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int ab,bc,ca;

int gcm(int a1,int b1,int c1){
    int a=a1,b=b1,c=c1,tmp;
    while(a%b!=0){
        tmp=a%b;
        a=b;
        b=tmp;
    }
    ab=b;
    a=a1;b=b1;
    while(b%c!=0){
        tmp=b%c;
        b=c;
        c=tmp;
    }
    bc=c;
    b=b1;c=c1;
    while(c%a!=0){
        tmp=c%a;
        c=a;
        a=tmp;
    }
    ca=a;
    return 0;
}

int main(void){
    int k,ans=0;
    scanf("%d",&k);
    for(int i=1;i<=k;i++){
        for(int i2=1;i2<=k;i2++){
            for(int i3=1;i3<=k;i3++){
                ab=i;bc=i2;ca=i3;
                while(!(ab==bc && bc==ca)){
                    gcm(ab,bc,ca);
                }
                ans+=ab;
            }
        }
    }
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 1732
#include <bits/stdc++.h> 
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	char c;
	cin>>c;
	if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout<<"vowel\n";
	else cout<<"consonant\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
	stringstream ss;
    // 入力
    int N,A,B;
    cin>>N>>A>>B;
    int max=min(A,B);
    int min=A-(N-B);
    if(min<0) min=0;
    cout<<max<<" "<<min<<endl;
    return 0;
}

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

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for w in range(1, W):
  if a[0][w] != '#':
    dp[0][w] = dp[0][w - 1]

for h in range(1, H):
  if a[h][0] != '#':
    dp[h][0] = dp[h - 1][0]
  for w in range(1, W):
    if a[h][w] != '#':
      dp[h][w] = (dp[h][w - 1] + dp[h - 1][w]) % 1000000007

print(dp[H - 1][W - 1])


Measured memory_bytes: 43616
//C
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int H, W, K, ans;
char c[7][7], tmp[7][7];

int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
			tmp[i][j] = c[i][j];
		}
	}
	for (int i = 0; i < (1 << H); i++) {
		for (int j = 0; j < (1 << W); j++) {
			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					tmp[k][l] = c[k][l];
				}
			}
			for (int k = 0; k < H; k++) {
				if ((i & (1 << k)) > 0) {
					for (int l = 0; l < W; l++) {
						tmp[k][l] = '.';
					}
				}
			}
			for (int k = 0; k < W; k++) {
				if ((j & (1 << k)) > 0) {
					for (int l = 0; l < H; l++) {
						tmp[l][k] = '.';
					}
				}
			}
			int cnt = 0;
			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					cnt += (tmp[k][l] == '#');
				}
			}
			if (cnt == K) ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    ll i = 1;
    ll cnt = 1;
    while(i < n){
        cnt++;
        i += cnt;
    }
    dump(cnt);
    ll tab = cnt*(cnt+1)/2-n;
    repr(j, 1, cnt+1){
        if(j != tab) cout << j << endl;
    }
    return 0;
}

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



int main() 
{
  ll H1,H2,M1,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  cout<<(H2-H1)*60+(M2-M1)-K<<endl;
  return 0;
}


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

int main() {
  string c;
  cin >> c;
  
  if ( c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }   
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;
const int mod=1e9+7;
typedef long long ll;

ll cnt(int a){
    ll ans=1;
    for(int i=a;i>=1;i--){
        ans*=i;
        ans%=mod;
    }
    return ans;
}

int main(){
    int a,b;
    ios::sync_with_stdio(false);
    while(cin>>a>>b){
        if(abs(a-b)>1)cout<<0<<endl;
        else if(a==b){
            cout<<cnt(a)*cnt(a)*2%mod<<endl;
        }
        else{
            cout<<cnt(a)*cnt(b)%mod<<endl;
        }
    }
    return 0;
}


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

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

fn main() {
    let N: usize = read();
    let As: Vec<u64> = (0..N).map(|_|read::<u64>()).collect();
    let As: &[u64] = As.as_slice();

    let mut s: u64 = 0;
    let M: u64 = u64::pow(10, 9) + 7;
    for k in 0..60 {
        let mut d1: u64 = 0;
        for i in 0..N {
            d1 += 1 & (As[i] >> k);
        }
        d1 = d1 * ((N as u64)-d1);

        s += (u64::pow(2,k) % M) * (d1 % M);
        s = s % M;
    }
    println!("{}", s);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int fpow(int b,int e)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2);
	if(e%2) return b*tmp*tmp;
	else return tmp*tmp;
}

int fpowm(int b,int e,int mod)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2)%mod;
	if(e%2) return b*tmp%mod*tmp%mod;
	else return tmp*tmp%mod;
}

bool cmp(string a,string b,int s)
{
	For(i,0,sz(a)-1)
	{
		if(a[i]!=b[(s+i)%sz(b)]) return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string a,b;
	cin>>a>>b;
	For(i,0,sz(a))
	{
		if(cmp(a,b,i))
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}








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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x,t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t << "\n";
    return 0;
}


Measured memory_bytes: 3652
while True:

    N = int(input())

    if N == 0:
        break

    a = list(input().split())

    l = 0
    r = 0

    las = 0
    ans = 0

    for i in a:

        if i == "lu":
            l += 1
        elif i == "ld":
            l -= 1
        elif i == "ru":
            r += 1
        else:
            r -= 1

        if l == r and l != las:
            ans += 1
            las = l

    print (ans)



Measured memory_bytes: 5608
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())

int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;

//contemp
typedef pair<int,int> P;
P   f(int x){
    int a = x%10;
    int b = 0;
    while(x){
        b = x;
        x /=10;
    }
    return P(a,b);
}
int main(){ 
    int n;
    cin >> n;
    map<P,int> mp;
    for(int i=1; i<=n; i++){
        P a = f(i);
        mp[a] ++;
    }
    int ans = 0;

    for(int i = 1;i<=n;i++){
        P a = f(i);
        P b = make_pair(a.second,a.first);
        ans += mp[b];
    }
    cout << ans <<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#define rep(i,j,n) for(i=j;i<(n);i++)

using namespace std;

int main(){
    int k,s,p=0,i,j;
    cin>>k>>s;
    rep(i,0,k+1){
        rep(j,0,k+1){
            if((s-i-j>=0)&&(s-i-j<=k)){
                p++;
            }
        }
    }
    cout<<p<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void solve();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int q=1;//cin>>q;
    while(q--){
        solve();
    }
    return 0;
}
void solve(){ 
   string s;cin>>s;
   int p=0;
   vector<int>v;
   for(int i=0;i<s.length();i++)
   {
      if(s[i]=='R')
        p++;
       else
       {
          v.push_back(p);
          p=0;
       }
   }
   v.push_back(p);
   sort(v.begin(),v.end());
   cout<<v[v.size()-1];
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,cnt = 1,ans = 0;
    cin >> n;
    vector<string> s(n);
    rep0(i, n){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    rep0(i, n - 1){
        if (s[i] == s[i + 1]) {
            ans += cnt;
            ++cnt;
        }else{
            cnt = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
# ABC072
# C
# Together
import itertools

n = int(input())
a = [int(i) for i in input().split()]

a.sort()
gr = itertools.groupby(a)
hoge_list = [0]*100001
ans = 0

for key, group in gr:
    hoge_list[key] = len(list(group))

for i in range(1,100000,1):
    _tmp = hoge_list[i-1] + hoge_list[i] + hoge_list[i+1]
    if ans < _tmp:
        ans = _tmp

print(ans)
    

Measured memory_bytes: 13744
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,k=mii()

p=b-a

if k%2==1:
    print(p)
else:
    print(-1*p)

Measured memory_bytes: 63340
#include <iostream>

using namespace std;

int main() {
    int j = 0;
    double b = 0.0;

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        double x;
        string t;
        cin >> x >> t;
        if (t == "JPY") j += (int) x;
        else b += x;
    }

    cout <<  j + 380000.0 * b << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x1 := getNextFloat64(scanner)
	y1 := getNextFloat64(scanner)
	x2 := getNextFloat64(scanner)
	y2 := getNextFloat64(scanner)

	v := complex(x2-x1, y2-y1)
	_, th := cmplx.Polar(v)
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		x := getNextFloat64(scanner) - x1
		y := getNextFloat64(scanner) - y1
		vv := rotate(complex(x, y), -th)
		ans := rotate(complex(real(vv), 0), th)
		fmt.Fprintln(writer, fmt.Sprintf("%.10f %.10f", real(ans)+x1, imag(ans)+y1))
	}
}

func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}



Measured memory_bytes: 1300