akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll K;
  cin >> K;
  ll result = 0;
  REP(i, 1, K+1) {
    REP(j, 1, K+1) {
      REP(k, 1, K+1) {
        ll ij = gcd(i, j);
        result += gcd(ij, k);
      }
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = RArInt();
            string s = RSt();

            string ans = "";
            for (int i = 0; i < s.Length; i++)
            {
                if (i == nk[1] -1)
                {
                    ans += char.ToLower(s[i]);
                }
                else
                {
                    ans += s[i];
                }
            }
            Console.WriteLine(ans);

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int x, a, b, ab, o;
    string s;
    a = b = ab = o = 0;
    while (true) {
        cin >> x;
        cin.ignore();
        cin >> s;
        if (cin.eof()) break;
        else if (s == "A") a++;
        else if (s == "B") b++;
        else if (s == "AB") ab++;
        else if (s == "O") o++;
    }
    cout << a << endl;
    cout << b << endl;
    cout << ab << endl;
    cout << o << endl;
    return 0;
}

Measured memory_bytes: 1204
M, D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d % 10
        d //= 10
        d10 = d % 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            ans += 1
print(ans)

Measured memory_bytes: 2940
// 2015/01/05 Tazoe

#include <iostream>
#include <queue>
using namespace std;

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

	int G[100][100] = {0};

	for(int i=0; i<n; i++){
		int u, k;
		cin >> u >> k;

		for(int j=0; j<k; j++){
			int v;
			cin >> v;

			G[u-1][v-1] = 1;
		}
	}

	int d[100];
	for(int i=0; i<n; i++){
		d[i] = -1;
	}

	queue<int> Q;

	Q.push(0);
	d[0] = 0;

	while(!Q.empty()){
		int u = Q.front();

		int v = -1;
		for(int j=0; j<n; j++){
			if(G[u][j]==1 && d[j]==-1){
				v = j;
				break;
			}
		}

		if(v!=-1){
			Q.push(v);
			d[v] = d[u]+1;
		}
		else{
			Q.pop();
		}
	}

	for(int i=0; i<n; i++){
		cout << i+1 << ' ' << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1248
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int h,w;
int dx[] = {0,1,-1,0};
int dy[] = {1,0,0,-1};
string a[1000];
bool ok(int i,int j){
    return 0<= i and i < h and 0<=j and j < w and a[i][j] == '.';
}
int dist[1000][1000];
int main(){
    cin >> h >> w;
    queue<pii>q;
    memset(dist,-1,sizeof(dist));
    rep(i,h){
        cin >> a[i];
        rep(j,w){
            if(a[i][j] == '#'){
                dist[i][j] = 0;
                q.emplace(i,j);
            }
        }
    }
    int ans = 0;
    while(!q.empty()){
        auto t = q.front();
        q.pop();
        int x = t.first;
        int y = t.second;
        rep(i,4){
            int xx = x + dx[i];
            int yy = y + dy[i];
            if(!ok(xx,yy))continue;
            if(dist[xx][yy] == -1){
                dist[xx][yy] = dist[x][y] + 1;
                ans = max(ans, dist[xx][yy]);
                q.emplace(xx,yy);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;cin >> s;
    string ans;ans="AKIHABARA";
    ll i,j;i=j=0;
    while(j!=ans.size() and i!=s.size())
    {
        if(s[i]==ans[j]){i++;j++;}
        else if(ans[j]=='A'){j++;}
        else{cout << "NO";return 0;}
    }
    if(j==ans.size()-1)j++;
   // trace(i);trace(j);
    if(i==s.size() and j==ans.size())cout << "YES";else cout << "NO";
    }

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

const int DIM = 1e5 + 5;

int cnt[DIM];

int main(void) {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        
        cnt[x]++;
    }
    
    int mxm = -1;
    for (int i = 0; i <= 1e5; ++i)
        mxm = max(mxm, cnt[i] + cnt[i + 1] + cnt[i + 2]);
    
    cout << mxm;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	int a[3010];
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i] - 1;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 1000000000, MAXI = N, D = 14;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 5, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//         int a = rand()%N+1;
//         a *= flag;
      
//         flag *= -1;

//         int b = rand()%MAXI + 1, c;

//         int d = rand()%D + 1;

//         int flag2 = rand()%3, k;

//         if(flag2==0)
//         {
//         	k = rand()%d+1;
//         	c = a + k*b;
//         }
//         else if(flag2==1)
//         {
//         	k = rand()%d + 1;
//         	c = a - k*b;
//         }
//         else
//         	c = rand()%MAXI;

//         cout << a << " " << b << " " << c << " " << d;
//         cout << "\n";
//         cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005

 
// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
    int n;
    cin >> n;
    while(n)
    {
    	if(n%10==7)
    	{
    		cout << "Yes";
    		return 0;
    	}
    	n/=10;
    }

    cout << "No";

    
    return 0;
 
} 

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
  long long int x, y;
  while(cin >> x >> y) {
    if (x < y) swap(x, y);
    long long int X = x, Y = y;
    while(1) {
      x %= y;
      swap(x, y);
      if(y == 0) break;
    }
    cout << x << ' ' << X * Y / x << endl;
  }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll H, ll W, vector<string> S) {
  REP(i,H) REP(j,W) {
    if (S[i][j] == '#') continue;
    int cnt = 0;
    for (int di = -1; di <= 1; ++di) {
      for (int dj = -1; dj <= 1; ++dj) {
        const int ni = i + di, nj = j + dj;
        if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
        if (S[ni][nj] == '#') ++cnt;
      }
    }
    S[i][j] = '0' + cnt;
  }
  for (string s: S) cout << s << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll W;
	ll H;
	scanf("%lld", &H);
	vector<string> S(H-1+1);
	scanf("%lld", &W);
	for (int i = 0 ; i <= H-1 ; i++) {
	  cin >> S[i];
	}
	solve(H, W, S);
	return 0;
}


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

const int N = 5e3;

int a[N];

int main(void) {
	int n; scanf("%d", &n);
	for (int i = 1; i <= 2 * n; ++ i) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + 2 * n);
	int sum = 0;
	for (int i = 1; i <= 2 * n; i += 2) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> X;
  C=A+B+X;
  if(C>21)Out("bust");
  else Out("win");
}

Measured memory_bytes: 256
#!ruby -na
f=->n,m,a,b{a/m*n*~-n/2+(b-=m*y=(b+n*a%=m)/m
y>0?f[y,a,m,b%a]+y*=n+b/a:0)}
p f[*$F.map(&:to_i)]if$.>1

Measured memory_bytes: 14304
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,i,j,k,sum=0;
	cin>>n;
	ll a[n+1][n+1];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	}
	ll dp[1<<n]={};
	ll len=(1<<n)-1;
	for(i=0;i<=len;i++)
	{
		vector<ll> vec;
		for(j=0;j<n;j++)
		{
			if(i&(1<<j))
				vec.push_back(j+1);
		}
		sum=0;
		//cout<<vec.size()<<endl;
		for(j=0;j<vec.size();j++)
		{
			for(k=j+1;k<vec.size();k++)
				sum+=a[vec[j]][vec[k]];
		}
		dp[i]=sum;
	}
	//for(i=0;i<=len;i++)
		//cout<<dp[i]<<" ";
	for(i=1;i<=len;i++)
	{
		for(j=i;j>0;j=(j-1)&i)
			dp[i]=max(dp[i],dp[j]+dp[i^j]);
	}
	cout<<dp[len]<<endl;
}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int K;
    int A,B;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K==0){
        cout<<"OK"<<endl;
        return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////


int main(){
    int n;
    cin>>n;
    vi ans(1000000);
    arep(x,1,100)arep(y,1,100)arep(z,1,100){
        int a=x*x+y*y+z*z+x*y+x*z+y*z;
        ans[a]++;

    }
    rep(i,n){
        cout<<ans[i+1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 7060
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vector<int>(10));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> f[i][j];
    }
  }
  vector<vector<int> > p(n, vector<int>(11));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -1000000000;
  for (int i = 1; i < 1024; i++) {
    int score = 0;
    for (int j = 0; j < n; j++) {
      int open = 0;
      for (int k = 0; k < 10; k++) {
        if ((i >> k & 1) && f[j][k]) {
          open++;
        }
      }
      score += p[j][open];
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  string C;
  cin >> C;
  ll Wsum = 0;
  vl W(N + 1, 0);
  REP(i, N) {
    if (C[i] == 'W') {
      W[i + 1] = W[i] + 1;
      Wsum++;
    } else
      W[i + 1] = W[i];
  }
  ll ans = llINF;
  REP(i, N + 1) {
    ll leftW = W[i];
    ll rightW = Wsum - W[i];
    ll rightR = N - i - rightW;
    // cout << leftW << "," << rightR << endl;

    ll score = min(leftW, rightR);
    leftW -= score;
    rightR -= score;
    score += leftW + rightR;
    ans = min(ans, score);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5188
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int a,b;

	cin >> a >> b;

	cout << a*b;
}

Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			int[] AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
			int A = AB[0];
			int B = AB[1];
			int tap = 0;
			int hole = 1;
            while (true)
            {
				if (hole >= B)
					break;
				hole += A - 1;
				tap++;
            }
			Console.WriteLine(tap);
		}

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static long Lcm(long a, long b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static long Gcd(long a, long b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> data(h);
  for(int i = 0; i < h; i++){
    cin >> data.at(i);
  }
  string s = "##";
  for(int i = 0; i < w; i++){
    s += "#";
  }
  cout << s << endl;
  for(int i = 0; i < h; i++){
    cout << "#" << data.at(i) << "#" << endl;
  }
  cout << s << endl;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  string ans="";
  rep(i,s.size()){
    if(s[i]=='B'){
      if(!ans.empty())ans.pop_back();
    }else{
      ans.push_back(s[i]);
    }
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lf double
#define E complex<lf>
#define inf 0x3f3f3f3f
#define eps 1e-8
#define pa pair<int,int>
#define pb push_back
#define ms(x,y) memset(x,y,sizeof(x))
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define mod 1000000007
#define N 100010
using namespace std;
inline ll read() {
	ll x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int a[N],n;
int main() {
	n=read();
	for (int i=1; i<=n; i++) a[i]=read();
	sort(a+1,a+1+n);int x=-1;
	for (int i=n-1; i; i--) 
		if (a[i]==a[i+1]) {
			if (x==-1) x=a[i];
			else return printf("%lld",1ll*x*a[i]),0;
			i--;
		}
	puts("0");
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

const int INF = 1000000000;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> heights(N);
    rep(i, 0, N) cin >> heights[i];

    vector<int> cost(N+K, INF);
    cost[0] = 0;
    rep(from, 0, N-1)
        rep(step, 1, K+1)
        {
            int to = from + step;
            cost[to] = min(cost[to], cost[from] + abs(heights[from]-heights[to]));
        }

    cout << cost[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define int long long
int n,m,z;
vector <int> a,b,c;
string s;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    n  =(int)s.size();
    vector <int> g;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(i+1 < n && s[i] == 'B' && s[i+1] == 'C'){
            g.push_back(0);
            i += 1;
        }
        else if(s[i] == 'A')g.push_back(1);
        else {
            
            int il_1 = 0;
            for(int h : g){
                if(h == 1){
                    il_1 += 1;
                }
                else {
                    ans += il_1;
                }
            }
            g.clear();
        }
    }
    {
            int il_1 = 0;
            for(int h : g){
                if(h == 1){
                    il_1 += 1;
                }
                else {
                    ans += il_1;
                }
            }
            g.clear();
        }
    cout << ans << '\n';
}

Measured memory_bytes: 2700
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        nl "\n"
#define        End return 0
#define        gt greater<int>()
#define        ll long long int
#define        mp make_pair
#define        pb push_back
#define        mod 1000000007
#define        ull unsigned long long int
int            Max = INT_MIN;
int            Min = INT_MAX;
#define        pi acos(-1)
int i,j,f=0,x,y,z,S=0,len,n,m;
/*
bool isprime(int n)
{
  if(n<2)return false;
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    return false;
  }
  return true;
}*/

int main()
{
  MP;

scanf("%d",&n);
//ll a=pi*2*n;
printf("%.2f",pi*2*n);


  End;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

class UF
{
  public:
    vi rank, p;
    UF() {}
    UF(ll size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        REP(i, size)
        {
            init(i);
        }
    }

    void init(ll x)
    {
        p[x] = x;
        rank[x] = 0;
    }

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

    void unite(ll x, ll y)
    {
        link(root(x), root(y));
    }

    void link(ll x, ll y)
    {
        if (rank[x] > rank[y])
        {
            p[y] = x;
        }
        else
        {
            p[x] = y;
            if (rank[x] == rank[y])
            {
                rank[y]++;
            }
        }
    }

    ll root(ll x)
    {
        if (x != p[x])
        {
            p[x] = root(p[x]);
        }
        return p[x];
    }

    ll getSetNum(){
        map<ll, ll> c;
        REP(i,p.size()) {
            c[root(i)]++;
        }
        return c.size();
    }
};

int main() {
    cin>>n>>m;
    vi va(m), vb(m);
    REP(i,m) {
        cin >> va[i] >> vb[i];
        va[i]--;
        vb[i]--;
    }
    REP(i,m) {
        UF uf = UF(n);
        REP(j,m) {
            if(j!=i){
                uf.unite(va[j], vb[j]);
            }
        }
        ans += (uf.getSetNum() > 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<pair<string, pair<int, int>>> rest(N);

    for (int i = 0; i < N; i++) {
        cin >> rest[i].first >> rest[i].second.first;
        rest[i].second.first *= -1;
        rest[i].second.second = i+1;
    }

    sort(all(rest));

    for (int i = 0; i < N; i++)
        cout << rest[i].second.second << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){
    int n,k;cin>>n>>k;
    vector<ll> h(n);
    rep(i,n)cin>>h[i];
    sort(h.begin(),h.end());
    ll mn = 10000000000;
    rep(i,n-k+1){
        if(mn > h[i+k-1]-h[i]){
            mn = h[i+k-1]-h[i];
        }
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 8
#define FREE -1
#define NOFREE 1
 
int dpos[2 * N - 1],dneg[2 * N - 1];
int row[N], col[N], x[N][N];

void initialize(void);
void print_board(void);
void recursive(int);
 
int main(){
  int i,j;
	int r,c;
	int k;
   
  initialize();
 
  for( i = 0 ; i < N ; i++ ){
    for(j = 0 ; j < N ; j++ ){
      x[i][j] = 0;
    }
  }
  
  scanf("%d",&k);
 
  for( i = 0 ; i < k ; i++ ){
    scanf("%d%d",&r,&c);
    x[r][c] = 1;
  }
 
  recursive(0);
 
  return 0;
}
 
void initialize(){
  int i,j;
	
  for( i = 0 ; i < N ; i++ ) {
    row[i] = FREE;
    col[i] = FREE;
  }
 
  for( i = 0 ; i < 2 * N - 1 ; i++ ){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}
 
 
void print_board(){
  int i,j;
   
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(x[i][j]){
    if(row[i] != j) return;
      }
    }
  }
 
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] == j ) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void recursive(int i){
	  int j;
	
  if( i == N ){
    print_board();
    return;
  }
 
  for( j = 0 ; j < N ; j++ ){
    if( NOFREE == col[j] || NOFREE == dpos[i + j] || NOFREE == dneg[i - j + N - 1]) continue;
 
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOFREE;
 
    recursive(i + 1);
 
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}

Measured memory_bytes: 572
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s: String));
    
    let mut ans: i32;
    ans = 0;
    
    let list = input.split_whitespace()
        .flat_map(|x| x.chars())
        .collect::<Vec<_>>();

    for i in list {
        if i == '1' {
            ans = ans + 1;
        }
    }

    ans.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 9" => "12",
    test2: "31 32" => "63",
    test3: "1 2" => "3",
    test4: "-1 2" => "1",
    test5: "10 1" => "11",
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    long long K;
    std::cin >> K;

    int i = 0, ans = 1;

    rep(i, N) {
        if (ans * 2 < ans + K)
            ans *= 2;
        else
            ans += K;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//BY: YASH JAIN, CF: yashjain0333
#include <bits/stdc++.h>
using namespace std;
#define May_the_fork_be_with_you ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define ll long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define int long long

void solve(){
    int n; cin>>n;
  if(n>=30) cout<<"Yes\n";
  else cout<<"No\n";
}

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


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi AS (N);
	vi BS (N);
	F0R(i, N) {cin >> AS[i]; cin >> BS[i];}	
	ll total = 0;
	ll sum = 0;
	R0F(i, N) {
		ll pushes = ((AS[i] + sum) % BS[i]) ? BS[i] - ((AS[i] + sum) % BS[i]) : 0;
		sum += pushes;
	}
	print(sum);
}

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

#define fi first
#define se second 
#define pb push_back

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h,a; 
	cin>>h>>a; 
	cout<<(h+a-1)/a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N,n,d,i,xMax,xMin,yMax,yMin,ix[200],iy[200],h,w;
  while(1){
    cin >> N;
    if(N==0) break;
    ix[0]=iy[0]=0;    //location(i)=(ix,iy)
    xMax=xMin=yMax=yMin=0;
    for(i=1;i<N;i++){
      cin >> n >> d;
      if(d==0){
    ix[i]=ix[n]-1;
    iy[i]=iy[n];
    xMin=min(ix[i],xMin);
      }
      else if(d==1){
    iy[i]=iy[n]-1;
    ix[i]=ix[n];
    yMin=min(iy[i],yMin);
      }
      else if(d==2){
    ix[i]=ix[n]+1;
    iy[i]=iy[n];
    xMax=max(ix[i],xMax);
      }
      else{
    iy[i]=iy[n]+1;
    ix[i]=ix[n];
    yMax=max(iy[i],yMax);
      }
    }
    w=xMax-xMin+1;
    h=yMax-yMin+1;
    cout << w << ' ' << h << endl;
  }
  return 0;
}

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

int main() {
int N;
string S;
cin >> N >> S;
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < alpha.size() / 2; j++) {
        if (S.at(i) == alpha.at(j)) {
            S.at(i) = alpha.at(j + N);
            break;
        }
    }
}
cout << S << endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")



void solve(){
    ll n,k;
    cin>>n>>k;
    vec<ll> a(n);
    REP(i,n) cin>>a[i];
    REP(i,k){
        vec<ll> b(n+1,0);
        REP(j,n){
            ll l = max(0LL, j-a[j]);
            ll r = min(n, j+a[j]+1);
            b[l]++;
            b[r]--;
        }
        REP(j,n) b[j+1]+=b[j];
        bool flag=true;
        REP(j,n) if(b[j]!=n){ flag=false;break;}
        a=b;
        if(flag) break;
    }
    REP(i,n) cout<<a[i]<<" ";
    cout<<en;
}

int main() {
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 8008
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    int sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    cout << (H > sum ? "No" : "Yes") << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 100000


int main(){
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	long long b[N];
	long long c[4];
	f(i, N)b[i] = 0;
	int n;
	long long k,x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	z = 1;
	x = 0;
	f(i, n){
		if (a[i] == '?')x++;
	}
	f(i, 4){
		if (x >= 0){
			z = 1;
			f(j, x){
				z = z * 3;
				z = z%MOD;
			}
			c[i] = z;
		}
		else c[i] = 0;
		x--;
	}

	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == 'C')k++;
		if (a[n - i - 1] == 'B')b[n - i - 1] = k;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == 'A'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[0]);
	ans = ans%MOD;



	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == '?')k++;
		if (a[n - i - 1] == 'B')b[n - i - 1] = k;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == 'A'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[1]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == 'C')k++;
		if (a[n - i - 1] == '?')b[n - i - 1] = k;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == 'A'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[1]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == 'C')k++;
		if (a[n - i - 1] == 'B')b[n - i - 1] = k;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == '?'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[1]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == '?')b[n - i - 1] = k;
		if (a[n - i - 1] == '?')k++;

	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == 'A'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[2]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == 'B')b[n - i - 1] = k;
		if (a[n - i - 1] == '?')k++;

	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == '?'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[2]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == '?')b[n - i - 1] = k;
		if (a[n - i - 1] == 'C')k++;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == '?'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[2]);
	ans = ans%MOD;


	f(i, N)b[i] = 0;
	k = 0;
	f(i, n){
		if (a[n - i - 1] == '?')b[n - i - 1] = k;
		if (a[n - i - 1] == '?')k++;
	}
	k = 0;
	s = 0;
	f(i, n){
		if (a[n - i - 1] == '?'){
			s += k;
			s = s%MOD;
		}
		k += b[n - i - 1];
		k = k%MOD;
	}
	ans += (s*c[3]);
	ans = ans%MOD;


	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int n,m,p;
  char s[3];

  char *buf_ac = NULL;
  int  *buf_wa = NULL;
  int  sum_ac =0;
  int  sum_wa =0;
  
  
  scanf("%d %d", &n, &m);

  buf_ac = (char *)calloc(n, sizeof(char));
  buf_wa = (int *)calloc(n, sizeof(int));
  
  for (int i=0; i<m; i++){
    scanf("%d %s", &p, s);
    
    if (s[0] == 'A') {
      buf_ac[p-1] = 1;
    } else {
      if (buf_ac[p-1] == 0)
        buf_wa[p-1]++;
    }
  }
  
  
  for (int i=0; i<n; i++) {
	if (buf_ac[i]) {
		sum_ac++;
		sum_wa += buf_wa[i];
	}
  }
  
  printf("%d %d\n", sum_ac, sum_wa);
  
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#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 mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll sum=0;

void dfs(ll a,ll b){
    if(b<=0) return;
    if(b<a) swap(a,b);
    sum+=b/a*a*3;
    dfs(a,b%a);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,X;
    cin>>N>>X;
    dfs(X,N-X);
    cout1(sum)
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
S=[input() for _ in range(h)]
x=0
for i in range(2**h):
  T=[S[j] for j in range(h) if (i>>j)&1]
  for l in range(2**w):
    U=[row[m] for row in T for m in range(w) if (l>>m)&1]
    if U.count('#')==k:
      x+=1
print(x)

Measured memory_bytes: 9064