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

template <typename T>
class weighted_quick_find {
	using pid = pair<int, T>;
	vector<pair<int, T>> data;
	vector<vector<int>> all;
public:
	weighted_quick_find(int n) : data(n), all(n, vector<int>(1)) {
		for (int i = 0; i < n; i++) {
			data[i].first = i;
			all[i][0] = i;
		}
	}
	void unite(int a, int b, T d) {
		if (same(a, b)) return;
		d += data[a].second - data[b].second;
		a = data[a].first;
		b = data[b].first;
		if (all[a].size() < all[b].size()) swap(a, b), d = -d;
		for (auto& id : all[b]) {
			data[id].first = a;
			data[id].second += d;
			all[a].push_back(id);
		}
	}
	bool same(int a, int b) const {
		return data[a].first == data[b].first;
	}
	T dist(int a, int b) const {
		return data[b].second - data[a].second;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	weighted_quick_find<int> wqf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			int z;
			cin >> z;
			wqf.unite(x, y, z);
		}
		else if (wqf.same(x, y)) {
			printf("%d\n", wqf.dist(x, y));
		}
		else {
			puts("?");
		}
	}
	return 0;
}



Measured memory_bytes: 10256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;
static const int INF = (1<<29);
int main(){
  vector <int> v;
  int yen,time=0;
  int T[100001];
  v.push_back(1);
  v.push_back(0);
  for(int i=1;  pow(9,i) <= 100000 ;i++){
    v.push_back(pow(9,i));
  }

  for(int i=1;  pow(6,i) <= 100000; i++ ){
    v.push_back(pow(6,i));
  }

  sort(v.begin(), v.end());

  cin >> yen;

  for(int i = 0; i <= 100000;i++) T[i] = INF;
  T[0] = 0;
  for(int i = 1; i < v.size(); i++){
    for(int j = 0; j + v[i] <= yen; j++){
      T[j+v[i]] = min(T[j+v[i]],T[j]+1);
      //cout << "T[" << j+v[i] << "] = " << T[j+v[i]] << endl;
    }
  }
  cout << T[yen] << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i ++){
        cin >> d.at(i);
    }
    sort (d.begin(), d.end());
    int ans = N;
    for (int i = 0; i < N - 1; i ++){
        if (d.at(i) == d.at(i + 1)){
            ans --;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int a , b;
 
int main()
{
    cin >> a >> b;
 
    if (a == b){
 
        cout << "a == b" << endl;
    }
    else if (a > b){
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a < b" << endl;
     }
return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>

int max(int a,int b){
  if(a>b){
    return a;
  }
  else
    return b;
}

int main(){
  int i,j,k;
  int A,B,AB,nA,nB;
  scanf("%d %d %d %d %d",&A,&B,&AB,&nA,&nB);
  long ans=1000000000000000;
  long tmp;
  
  for(i=0;i<=100000;i++){
    tmp= i*2*AB + max(nA-i,0)*A + max(nB-i,0)*B;
    if(tmp < ans)
      ans = tmp;
  }
  
  printf("%ld\n",ans);
  return 0;
}
    


Measured memory_bytes: 128
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
    int n, i, j, done, count = 0;
    int A[N];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

    done = 1;
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n - 1 - i; j++)
        {
            if (A[j] > A[j + 1])
            {
                A[j] = A[j + 1] ^ A[j];
                A[j + 1] = A[j + 1] ^ A[j];
                A[j] = A[j + 1] ^ A[j];
                done = 0;
                count++;
            }
        }
        if(done == 1)
            break;
    }
    
    trace(A, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    long long n, ans;
    cin >> n;

    ans = n - 1;
    for(long long i=2; i*i<=n; i++){
       if(n%i == 0){
          long long ans_tmp;
          ans_tmp = i + n/i -2;
          ans = min(ans, ans_tmp);
       }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100000;
int A[MAX],n;
int partition(int p,int r){
  int x = A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }

  int q = partition(0,n-1);
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    if (i==q) cout<<"[";
    cout<<A[i];
    if(i==q) cout<<"]";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3372
#include <iostream>

using namespace std;

int main() {
    int n, *t, *x, *y, i;
    bool can = true;
    cin >> n;
    t = new int[n+1];
    x = new int[n+1];
    y = new int[n+1];
    for (i = 1; i <= n; i++)
        cin >> t[i] >> x[i] >> y[i];
    t[0] = x[0] = y[0] = 0;
    
    for (i = 0; i < n; i++) {
        int dx = abs(x[i+1] - x[i]);
        int dy = abs(y[i+1] - y[i]);
        int dt = t[i+1] - t[i];

        if (dx + dy > dt || (dx + dy - dt) % 2 != 0)
            can = false;
    }

    if (can)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int N, A, B, C, X;
int x;

inline int hash(int& x){ return x = (A * x + B) % C; }

int main()
{
  while(cin >> N >> A >> B >> C >> X, N){
    vi Y(N);
    int ptr = 0;
    rep(i, N){
      cin >> x;
      Y[i] = x;
    }

    int res = -1;
    erep(i, 0, 10000){
      if(Y[ptr] == X) ptr += 1;
      if(ptr >= N){
        res = i;
        break;
      }
      hash(X);
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());
        sc.close();

    }

}


Measured memory_bytes: 76952
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    vector<int> d(n);
    d[0] = 1;
    q.push(0);
    while(!q.empty()){
        int now = q.front();q.pop();
        for(auto next:g[now]){
            if(d[next])continue;
            d[next] = (d[now] == 1?2:1);
            q.push(next);
        }
    }
    vector<int>ans(n);
    vector<int> used(n+1);
    int iti = 0, ni = 0,zero = n/3;
    rep(i,n)(d[i]==1?iti++:ni++);
    int p = 1,x = 1;
    if(iti <= zero){
        // d[i] == 1 は全て 3*xで置き換える
        // d[i] == 2 は全て適当な数値を埋める
        rep(i,n){
            if(d[i] == 1){
                ans[i] = 3*p;
                used[3*p] = 1;
                p++;
            }
        }
        rep(i,n){
            if(d[i]==2){
                if(used[x]==0)ans[i] = x;
                else {
                    while(used[x])x++;
                }
                ans[i] = x;
                used[x] = 1;
                x++;
            }
        }
    }else if(ni <= zero){
        // d[i]== 2 は全て 3*xで置き換える
        // d[i]== 1 は全て適当な数値を埋める
        rep(i,n){
            if(d[i] == 2){
                ans[i] = 3*p;
                used[3*p] = 1;
                p++;
            }
        }
        int x = 1;
        rep(i,n){
            if(d[i]==1){
                if(used[x]==0){
                    ans[i] = x;
                    x++;
                }else{
                    while(used[x])x++;
                    ans[i] = x;
                    used[x] = 1;
                    x++;
                }
            }
        }
    }else{
        // d[i] == 2 は 2で埋める (mod3)
        // d[i] == 1 は 1で埋める (mod3)
        // 埋められなかった点は全て0で埋める
        int zeronum = 0,ninum = 0,itinum = 0;
        rep(i,n){
            if(d[i] == 2){
                if(2 + (3*ninum) <=n){
                    ans[i] = 2 + 3*ninum;
                    ninum++;
                }else{
                    ans[i] = 3 + 3*zeronum;
                    zeronum++;
                }
            }else if(d[i] == 1){
                if( 1 + (3*itinum) <=n){
                    ans[i] = 1 + 3*itinum;
                    itinum++;
                }else{
                    ans[i] = 3 + 3*zeronum;
                    zeronum++;
                }
            }
        }
    }
    rep(i,n)cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 16112
#!/usr/bin/env python
# coding: utf-8

# In[12]:


N = int(input())
a = list(map(int, input().split()))


# In[13]:


ans = 0
for i in range(len(a)):
    if i+1 == a[a[i]-1]:
        ans += 1
print(ans//2)


# In[ ]:






Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);

    std::vector<std::string> result;

    while (first < str.size()) {
        std::string subStr(str, first, last - first);

        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == std::string::npos) {
            last = str.size();
        }
    }

    return result;
}
int main()
{
    string s;
    cin >> s;
    char del = '/';
    int i = 0;
    for(auto substr : split(s, del))
    {
        if(i == 0)
        {
            if(atoi(substr.c_str()) < 2019)
            {
                cout << "Heisei" << endl;
                return 0;
            }
        }
        else if (i == 1)
        {
            if(atoi(substr.c_str()) <= 4)
            {
                cout << "Heisei" << endl;
                return 0;
            }
        }
        i++;
    }
    cout << "TBD" << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    int k, i = 0;
    cin >> k >> s;
    for (char c : s) {
        if (i++ == k) {
            cout << "...";
            break;
        }
        cout << c;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

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

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,mod-2); }

inline int eval(ii a,int x){
	return a.x*x+a.y;
}
deque<ii> dq;
bool del(ii a){
	if(dq.size()<=1) return 0;
	int n=dq.size();
	ii b1=dq[n-2],b2=dq[n-1];
	return (a.y-b1.y)*(b2.x-a.x) > (b1.x-a.x)*(a.y-b2.y); 
}

signed main(){
	IOS
	int n,c;cin>>n>>c;
	int x;cin>>x;
	dq.pb({-2*x,x*x});
	vi DP(n);
	DP[0]=0;
	for(int i=1;i<n;i++){
		cin>>x;
		while(dq.size()>1 && eval(dq[0],x)>eval(dq[1],x))
			dq.pop_front();
		DP[i]=eval(dq[0],x)+x*x+c;
		ii here={-2*x,x*x+DP[i]};
		while(del(here))
			dq.pop_back();
		dq.push_back(here);
		// for(auto p:dq) cout<<"("<<p.x<<","<<p.y<<") ";
		// cout<<"\n";
		// cout<<"dp "<<DP[i]<<"\n";
	}
	cout<<DP.back();

}


Measured memory_bytes: 4096
import sys
import copy
import bisect
import numpy as np
N,K = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
res = 0
fact = [0]*(N+1)
ifact = [0]*(N+1)
inv = [0]*(N+1)
p=10**9+7

def combination(n,fact,ifact):
    fact[0] = 1
    fact[1] = 1
    ifact[0] = 1
    ifact[1] = 1
    inv[1] = 1
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%p
        inv[i] = p - inv[p%i]*(p//i)%p
        ifact[i] = (ifact[i-1]*inv[i])%p
def op(n,k,fact,ifact):
    if k<0 or k>n or n<0:
        return 0
    return int(fact[n]*ifact[k]*ifact[n-k])%(10**9+7)

combination(N,fact,ifact)
for i in range(N):
    res += (a[i]*op(i,K-1,fact,ifact))%p
#a = list(-np.array(a))
a = [-elem for elem in a]
a = sorted(a)
for i in range(N):
    res += (a[i]*op(i,K-1,fact,ifact))%p
print(res%p)


Measured memory_bytes: 31992
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	int res=0;
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='R')
			res++;
		else
		{
			ans=max(ans,res);
			res=0;
		}
	}
	ans=max(ans,res);
	cout<<ans<<endl;
}
signed main()
{
	int t=1; 
	while(t--)
		solve();
	return 0;
}



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

typedef long long ll;



int N;
double x[100005], dx[100005];
ll M, K;
int a[100005];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i];
	cin >> M >> K;
	for (int i = 0; i < M; i++) cin >> a[i], a[i]--;

	for (int i = 0; i < N - 1; i++) dx[i] = x[i + 1] - x[i];
	vector<int> m(N - 1), m_(N - 1), ans(N - 1);
	for (int i = 0; i < N - 1; i++) m[i] = ans[i] = i;
	for (int i = 0; i < M; i++) swap(m[a[i] - 1], m[a[i]]);
	for (ll i = 0; (1LL << i) <= K; i++) {
		if ((K >> i) & 1) {
			for (int j = 0; j < N - 1; j++) ans[j] = m[ans[j]];
		}
		for (int j = 0; j < N - 1; j++) m_[j] = m[m[j]];
		swap(m_, m);
	}
	double pos = x[0];
	for (int i = 0; i < N; i++) {
		printf("%.10f\n", pos);
		if (i < N - 1) pos += dx[ans[i]];
	}
	return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N, ac, wa, tle, re;
    string a;
    cin >> N;
    
    ac = wa = tle = re =0;
    
    for(int i = 0; i < N; ++i)
    {
        cin >> a;
        if(a == "AC")
        {
            ++ac;
        }
        else if(a == "TLE")
        {
            ++tle;
        }
        else if (a == "WA")
        {
            ++wa;
        }
        else if(a == "RE")
        {
            ++re;
        }
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  ll n,m,d; cin >> n >> m >> d;
  precout();

  if(d == 0) {
    ld ans = (ld)(n * (m - 1)) / (ld)(n * n);
    cout << ans << endl;
  } else {
    ld ans = (ld)((n - d) * 2 * (m - 1)) / (ld)(n * n);
    cout << ans << endl;
  }
}

// (1,d + 1), (2, d + 2), ((n - d), d + (n - d))


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int ans=0;
string s="CODEFESTIVAL2016",t;

int main(){
	cin>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define X 1000010
ll lo(ll x){
	ll res=0;
	while(x%2==0){
		x/=2;
		res++;
	}
	return res;
}
ll n,a[X],b[X];
bool solve(){
	n--;
	ll rui=0;
	ll ans=b[0];
	for(int i=1;i<=n;i++){
		rui+=lo(n+1-i)-lo(i);
		if(rui==0)ans+=b[i];
		//cerr<<i<<":"<<rui<<endl;
	}
	ans%=2;
	return ans;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>n;
	string s;
	cin>>s;
	rep(i,n){
		a[i]=s[i]-'0';
	}
	n--;
	rep(i,n){
		b[i]=abs(a[i]-a[i+1]);
	}
	bool th1=0;
	rep(i,n)if(b[i]==1)th1=1;
	ll k=1;
	if(th1==0){
		k=2;
		rep(i,n)b[i]/=2;
	}
	ll fans=solve()*k;
	cout<<fans<<endl;
}


Measured memory_bytes: 17052
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long int64;

int n, m, p;
int64 f[5555], t[5555], v[5555], d[5555];

void go() {
  for (int i = 0; i < m; i++) {
    int64 ff = f[i], tt = t[i], vv = v[i];
    if (d[ff] + vv > d[tt]) {
      d[tt] = d[ff] + vv;
    }
  }
}

int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 0; i < m; i++) {
    int ff, tt, vv;
    scanf("%d%d%d", &ff, &tt, &vv);
    f[i] = ff;
    t[i] = tt;
    v[i] = vv - p;
  }
  for (int i = 0; i <= n; i++) {
    d[i] = -1E18;
  }
  d[1] = 0;
  for (int i = 0; i < n * 10; i++) {
    go();
  }

  int64 maybe_ans = d[n];

  for (int i = 0; i < n * 10; i++) {
    go();
  }

  if (d[n] > maybe_ans) {
    cout << -1 << endl;
  } else {
    if (d[n] < 0) {
      d[n] = 0;
    }
    cout << d[n] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

  typedef struct{
    char s[10];
    int t;
  } process;

int main(){

  int n,q,i,sum=0,c=0;
  process p[100000];
  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s%d",p[i].s,&p[i].t);
    if(p[i].t<=q){
      sum+=p[i].t;
      p[i].t=0;
      printf("%s %d\n",p[i].s,sum);
      c++;
    }
    else if(p[i].t>q){
      sum+=q;
      p[i].t-=q;
    }
  }
  while(c!=n){
  for(i=0;i<n;i++){
    if(p[i].t==0)continue;
    if(p[i].t<=q){
      sum+=p[i].t;
      p[i].t=0;
      printf("%s %d\n",p[i].s,sum);
      c++;
    }
    else if(p[i].t>q){
      sum+=q;
      p[i].t-=q;
	}
  }
  }
  return 0;
}



Measured memory_bytes: 2496
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i <= n[0]; i++)
        {
            int _10000 = i * 10000;
            int without_10000 = n[1] - _10000;
            for (int j = 0; j <= n[0] - i; j++)
            {
                if (n[1] == i * 10000 + j * 5000 + (n[0] - i - j) * 1000)
                {
                    Console.WriteLine(i + " " + j + " " + (n[0] - i - j) + " ");
                    Console.ReadLine();
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
<?php
fscanf(STDIN, '%d', $min);
if ($min === 2) {
    echo $min . "\n";
    exit;
} elseif ($min % 2 === 0) {
    $min++;
}

$max = 100003;

$count = 0;
$tmp = 1;
$max = intval($max);

$str = str_repeat('01', $max/2+1);
$loopmax = ceil(sqrt($max));

for ($i=3; $i <= $loopmax; $i+=2) {
    if ($str[$i] === '0') {
        continue;
    }
    $loop = 2;
    $now = $i * 2;
    while ($now <= $max) {
        $str[$now] = '0';
        $loop++;
        $now = $i * $loop;
    }
}

$prime_count = 1;
$prime_numbers = [];
for ($i=3; $i <= $max; $i+=2) {
    if ($str[$i] === '1' && $i >= $min) {
        $prime_count++;
        $prime_numbers[] = $i;
    }
}

echo min($prime_numbers) . "\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int a, b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    scanf("%d/%d/%d", &a, &b, &c);
    if (b > 4) cout << "TBD";
    else cout << "Heisei";
    return 0;
}

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

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


int main()
{
    long long X, K, D;
    cin >> X >> K >> D;

    long long n = llabs(X)/D;
    if(n < K){
        X = abs(X);
        if(n%2 == K%2) cout << X%D << endl;
        else cout << llabs(X%D-D) << endl;
    }else{
        if(X <= 0) cout << llabs(X+K*D) << endl;
        if(X >  0) cout << X-K*D << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] arr = new int[n];
		scan.nextLine();
		
		for (int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
		}
		
		for(int i=n-1; i>=0; i--) {
			System.out.print(arr[i]);
			if(i!=0) {
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}








Measured memory_bytes: 26116
#include<bits/stdc++.h>
using namespace std;
int N = 100 + 5;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=b-a+1;i<b+a;i++){
		cout<<i<<" ";
	}
//	int n,m;
//	cin>>n>>m;
//	int a[N],len=0;
//	int p=m-n+1;
//	for(int i=0;i<n*2-1;i++){
//		a[len++]=p++;
//		cout<<a[i]<<" ";
//	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define int long long
#define iter set<int>::iterator
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+5;
const int mod=1e9+7;

main ()
{
    ios;
    int a;
    string s;
    cin>>a>>s;
    if (a<3200)cout<<"red"<<endl;
    else cout<<s<<endl;
}


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

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int n;
    double d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        double ans = pow(x * x + y * y, 0.5);
        if (ans <= (double)d) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL


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

  int n, x, t;
  cin >> n >> x >> t;
  cout << (((n-1)/x) + 1) * t << endl;
}


Measured memory_bytes: 3648
#!/usr/bin/python3

n = int(input())
a = tuple(map(int, input().split()))

ms = [ [0 for i in range(3)] for j in range(n) ]

ms[0][0] = 0
ms[0][1] = 0
ms[0][2] = a[0]

ms[1][0] = 0
ms[1][1] = max(a[0], a[1])

for i in range(2, n):
    if i % 2 == 1:
        ms[i][0] = max(ms[i - 1][1], ms[i - 2][0] + a[i])
        ms[i][1] = max(ms[i - 1][2], ms[i - 2][1] + a[i])
    else:
        ms[i][0] = ms[i - 1][0]
        ms[i][1] = max(ms[i - 1][1], ms[i - 2][1] + a[i])
        ms[i][2] = ms[i - 2][2] + a[i]


print(ms[n - 1][1])


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    while(1){
    cin >> n >> m;
    if(n==0||m==0)break;
    int base[100005]={};
    rep(i,0,n){
        rep(j,0,m){
            int t;cin >> t;
            base[j] |= t<<i;
        }
    }
    int ans=0;
    rep(bit,0,(1<<n)){
        int res=0;
        rep(j,0,m){
            int bits=base[j]^bit;
            int bitss=__builtin_popcount(bits);
            res+=max(bitss,n-bitss);
            //cout << res << endl;
        }
        ans=max(ans,res);
    }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3904
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  ll N=in<ll>(),M=in<ll>();
  vector<pair<ll,ll>> AB;
  REP(i,N){
    ll k=in(),v=in();
    AB.emplace_back(k,v);
  }
  sort(ALL(AB));

  ll num=0;
  ll sum=0;
  for(auto itr=AB.begin();itr!=AB.end();++itr){
    ll v=itr->first,n=itr->second;
    sum+=v*n;
    num+=n;
    if(num>M){
      sum -= (num-M)*v;
      break;
    }
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;

int main(void)
{
    double a, b, x, s;
    cin >> a >> b >> x;
    s = x / a;
    if (a * b * 0.5 < s)
    {
        printf("%.10f\n", atan(2 * (a * b - s) / (a * a)) * 180 / M_PI);
    }
    else
    {
        printf("%.10f\n", atan((b * b) / (2 * s)) * 180 / M_PI);
    }
}


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

const int MAX = 100005;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    COMinit();
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    rep(i, n) {
      ans += A[i] * COM(i, k-1);
      ans -= A[i] * COM(n-i-1, k-1);
      if (ans < 0) ans += MOD;
      ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	if( s[2] == s[3] and s[4] == s[5] ) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int ans = 0, n = s.size();
	rep(i,n / 2){
		if(s.at(i) != s.at(n - 1 - i)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = sum(B)
for i in range(len(A)-1):
    if A[i] + 1 == A[i+1]:
        ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 9200
import sys

s = list(map(str, input()))

ans = 0
while s:
	if s[0] == s[-1]:
		s.pop(0)
		try:
			s.pop()
		except IndexError:
			break
	elif s[0] == 'x':
		ans += 1
		s.pop(0)
	elif s[-1] == 'x':
		ans += 1
		s.pop()
	else:
		print(-1)
		sys.exit()

print(ans)

Measured memory_bytes: 4212
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        # x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        # prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for x0, y0, h0 in XYH[0:]:
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            if h0 == 0:
                continue
            break
        for xi, yi, hi in XYH[0:]:
            if max(prob_H - abs(xi-cx) - abs(yi-cy),0) == hi:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        print(cx,cy,prob_H)
        quit()


Measured memory_bytes: 3188
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def get_rank(L):
    D = {x:i for i,x in enumerate(sorted(L))}
    return [D[x] for x in L]
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = [b for a, b in sorted([(s*m+t, i) for i, (s, t) in enumerate(Z)])]
        A = get_rank([s*m+t for s, t in Z])
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

Measured memory_bytes: 131284
#include<bits/stdc++.h>
using namespace std;
queue<long long>q;
int main(){
    int K;
    cin >> K;
    for (int i=1; i<10; i++){
        q.push(i);
    }
    while (K--){
        long long x = q.front();
        q.pop();
        if (K==0){
            cout << x << endl;
            return 0;
        }
        if (x % 10 != 0){
            q.push(10*x+x%10-1);
        }
        q.push(10*x+x%10);
        if (x % 10 != 9){
            q.push(10*x+x%10+1);
        }
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n, m; cin >> n >> m;
    priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        que.push(a);
    }
    for (int i = 0; i < m; i++) {
        int price = que.top();
        que.pop();
        que.push(price/2);
    }
    ll ans = 0;
    while (que.size() != 0) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<iostream>

using namespace std;

int main()
{
    long long A,B;
    char op;
    cin >> A >> op >> B;
    if(op == '+')
    {
        cout<<A+B<<endl;
    }
    else if(op == '-')
    {
        cout<<A-B<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, nextInt())
	}
	return
}

func min(num1, num2 int) int {
	if num1 < num2 {
		return num1
	}
	return num2
}

func max(num1, num2 int) int {
	if num1 < num2 {
		return num2
	}
	return num1
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	sumNumber := 0
	secondNumber := 0
	B := scanNums(N - 1)
	sumNumber += B[0]
	for i := 0; i < N-2; i++ {
		secondNumber = min(B[i], B[i+1])
		sumNumber += secondNumber
	}

	sumNumber += B[N-2]

	fmt.Println(sumNumber)
}


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

ll h, w, k;

int main() {
	cin>>h>>w>>k;
	char a[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cin>>a[i][j];
		}
	}
	char temp[h][w];
	ll ans=0;
	for (int i=0; i<(1<<h); i++) {
		for (int j=0; j<(1<<w); j++) {
			for (int m=0; m<h; m++) {
				for (int n=0; n<w; n++) {
					temp[m][n]=a[m][n];
				}
			}
			for (int m=0; m<h; m++) {
				if ((i&(1<<m))>0) {
					for (int n=0; n<w; n++) {
						temp[m][n]='.';
					}
				}
			}
			for (int m=0; m<w; m++) {
				if ((j&(1<<m))>0) {
					for (int n=0; n<h; n++) {
						temp[n][m]='.';
					}
				}
			}
			ll item=0;
			for (int m=0; m<h; m++) {
				for (int n=0; n<w; n++) {
					if (temp[m][n]=='#') item++;
				}
			}
			if (item==k) ans++;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=45;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}char s[MAXN][MAXN];
int n;ll f[MAXN][MAXN][MAXN],g[MAXN][MAXN][MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),n<<=1;
	Rep(i,1,n)scanf("%s",s[i]+1);
	Rep(i,1,n-1){f[i][i][i]=1;Rep(j,i+1,n)if(s[i][j]=='1')g[i][i][j]=1;}
	for(int i=3;i<n;i+=2){
		Rep(j,1,n-i){
			int k=i+j-1;
			for(int l=j;l<=k;l+=2)for(int r=k;r>l;r-=2){
				ll s=0;Rep(t,r,k)s+=g[j][l][t]*f[r][k][t];
				Rep(t,l+1,r-1)f[j][k][t]+=f[l+1][r-1][t]*s;
			}
			Rep(t1,j+1,k-1)Rep(t2,k+1,n)if(s[t1][t2]=='1')g[j][k][t2]+=f[j][k][t1];
		}
	}ll ans=0;Rep(i,1,n-1)if(s[i][n]=='1')ans+=f[1][n-1][i];
	cout<<ans<<"\n";
	return 0;
}




Measured memory_bytes: 4608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 300000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N;
int A[MAX_N + 1];
int B[MAX_N + 1];

void solve()
{
  int M = 0;
  // 1-indexed
  for (int i = N; i >= 1; i--) {
    int bb = 0;
    // i 以上で i の倍数のボールの個数がどうなっていたか
    for (int j = i + i; j <= N; j += i) {
      bb += B[j];
    }
    // 制約チェック
    // ボールがすでに A[i] の制約を満たしているなら
    if (bb % 2 == A[i]) {
      // ボールを加えない
      B[i] = 0;
    }
    else {
      // ボールを加える
      B[i] = 1;
      M++;
    }
  }
  int idx = 0;
  // search last 1
  for (int i = 1; i <= N; i++) {
    if (B[i] == 1) idx = i;
  }
  cout << M << endl;
  for (int i = 1; i <= idx; i++) {
    if (B[i] == 1) cout << i << (i == idx ? "\n" : " ");
  }
}

int main(void)
{
  cin >> N;
  // 1-indexed
  REP(i, N) cin >> A[i + 1];
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

vector<ll>path[101010];
ll flg[101010][2];
ll A, B, C;
ll A_cnt, B_cnt;

int main(){

    ll N, M;
    cin >> N >> M;
    rep(i, M){
        ll x, y;
        cin >> x >> y;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    rep1(i, N){
        if(flg[i][0] || flg[i][1])continue;
        if(path[i].empty()){
            C++;
            continue;
        }
        flg[i][0] = 1;
        queue<P>Q;
        Q.push(P(i, 0));
        while(!Q.empty()){
            ll idx = Q.front().first;
            ll v = Q.front().second;
            Q.pop();
            rep(j, path[idx].size()){
                ll to = path[idx][j];
                if(flg[to][v ^ 1])continue;
                flg[to][v ^ 1] = 1;
                Q.push(P(to, v ^ 1));
            }
        }
        if(flg[i][1])B++;
        else A++;
    }
    rep1(i, N){
        if(flg[i][0] && flg[i][1])A_cnt++;
        else if(flg[i][0] || flg[i][1])B_cnt++;
    }

    cout << B * B + 2 * A * B + 2 * A * A + 2 * B_cnt * C + 2 * A_cnt * C + C * C << endl;

    return 0;
}

Measured memory_bytes: 11776
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


D, N = na()
print(N * 100**D if N != 100 else 101 * 100**D)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<fixed<<setprecision(9)<<W*H/2<<endl;
  if(x==W/2&&y==H/2){cout<<1<<endl;}
  else{cout<<0<<endl;}
  return 0;  
}

Measured memory_bytes: 3768
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
inline int mal(int x,int y){
  return x*y;
}
int main(void){
  FOR(i,1,10)FOR(j,1,10){
    printf("%dx%d=%d\n",i,j,mal(i,j));
  }
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
const ll mod=1000000007LL;

#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << endl,err(++it, args...);
}

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

	map<int,int> f;

	rep(i,2,n+1){
		int cur=i;
		for(int p=2;p*p<=cur;++p){
			if(cur%p) continue;
			int idx=0;
			while(cur%p==0) cur/=p,idx++;
			f[p]+=idx;
		}
		if(cur!=1) f[cur]++;
	}

	ll ans=1LL;
	for(auto &it:f){
		ans=1LL*ans*(it.second+1LL)%mod;
		//error(it.first,it.second);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384