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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vii=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
struct R{
  int i;
  string s;
  int p;
};
int main(){
  vector<R> rs;
  int n;
  cin>>n;
  REP(i,n){
    string s;
    int p;
    cin>>s>>p;
    rs.push_back({i+1,s,p});
  }
  sort(rs.begin(),rs.end(),
  [](auto& a,auto& b)->bool{
    return a.s!=b.s?a.s<b.s:a.p>b.p;
  });
  for(auto& r:rs){
    cout<<r.i<<endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <algorithm>

using namespace std;

int a[300][300];
int b[300];
int c[300];
int f[300];

int main() {
    int n, m, ans = 1e9, i, j;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
            a[i][j]--;
        }
    }
    
    for (i = 0; i < m; i++) {
        int x = 0, y = 0;
        
        for (j = 0; j < m; j++) c[j] = 0;
        
        for (j = 0; j < n; j++) c[a[j][b[j]]]++;
        
        for (j = 0; j < m; j++) {
            if (c[j] > x) {
                x = c[j];
                y = j;
            }
        }
        
        ans = min(ans, x);
        
        f[y] = 1;
        
        for (j = 0; j < n; j++) {
            while (b[j] < m && f[a[j][b[j]]] == 1) b[j]++;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.math.BigInteger.*;
public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void debug(Object...os){
		System.err.println(deepToString(os));
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0)
				return;
			int[] is = new int[n+m];
			for(int i = 0; i < n; i++)
				is[i] = sc.nextInt();
			for(int i = 0; i < m; i++)
				is[i+n] = sc.nextInt();
			sort(is);
			for(int i = n + m - 1; i > 0; i--)
				is[i] -= is[i-1];
			int max = 0;
			for(int i = 0; i < n + m; i++)
				max = max(max, is[i]);
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[150]={0};
    int n=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        char a=0;
        scanf(" %c", &a);
        arr[a]+=1;
    }
    int sum=0;
    for(int i=0;i<150;i++){
        if(arr[i]!=0){
            sum+=1;
        }
    }
    if(sum==3){
        printf("Three");
    }
    else{
        printf("Four");
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int cards[52];
	rep(i, 0, 52) {
		cards[i] = 1;
	}
	rep(i, 0, n) {
		char mark;
		int number;
		cin >> mark >> number;
		switch(mark){
		case 'S': cards[number-1] = 0; break;
		case 'H': cards[number + 12] = 0; break;
		case 'C': cards[number + 25] = 0; break;
		case 'D': cards[number + 38] = 0; break;
		}
	}
	rep(i, 0, 52) {
		if (cards[i] == 1) {
			switch (i / 13) {
			case 0:cout << "S " << i + 1 << endl; break;
			case 1:cout << "H " << i-12 << endl; break;
			case 2:cout << "C " << i-25 << endl; break;
			case 3:cout << "D " << i-38 << endl; break;
			}
		}
	}

}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

int main()
{
  int n;cin>>n;
	int dp0[n+1][4][4][4];//NG
	int dp1[n+1][4][4][4];//OK
	int i,j,k,l,m;
	rep(i,n+1)rep(j,4)rep(k,4)rep(l,4)
	{
		dp0[i][j][k][l]=0;
		dp1[i][j][k][l]=0;
	}
	rep(j,4)rep(k,4)rep(l,4)
	{
		if(j==0&&k==2&&l==1||j==0&&k==1&&l==2||j==2&&k==0&&l==1)
		{
			dp0[3][j][k][l]=1;
		}
		else dp1[3][j][k][l]=1;
	}
	for(i=3;i<n;i++)
	{
		rep(j,4)rep(k,4)rep(l,4)
		{
			rep(m,4)
			{
				dp0[i+1][k][l][m]+=dp0[i][j][k][l];
				dp0[i+1][k][l][m]%=MOD;
				if(k==0&&l==2&&m==1||j==0&&l==2&&m==1||k==2&&l==0&&m==1||k==0&&l==1&&m==2||j==0&&k==2&&m==1)
				{
					dp0[i+1][k][l][m]+=dp1[i][j][k][l];
					dp0[i+1][k][l][m]%=MOD;
				}
				else
				{
					dp1[i+1][k][l][m]+=dp1[i][j][k][l];
					dp1[i+1][k][l][m]%=MOD;
				}
			}
		}
	}
	int sum=0;
	rep(j,4)rep(k,4)rep(l,4)
	{
		sum+=dp1[n][j][k][l];
		sum%=MOD;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,num[100],alice,bob,tmp;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

  for(int j=0;j<n;j++){
    for(int k=j+1;k<n;k++){
      if(num[j]<num[k]){
        tmp=num[j];
        num[j]=num[k];
        num[k]=tmp;
      }
    }
  }
    for(int l=0;l<n;l++){
      if(l%2==0) alice+=num[l];
      else bob+=num[l];
    }

    printf("%d\n",alice-bob);
    return 0;

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    string s, t; cin>>s>>t;
    t.pop_back();
    if(s==t){
        cout<<"Yes";
    }
    else
        cout<<"No";
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}





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

typedef long long int ll;

void solve()
{
    ll n;
    cin>>n;
    ll sum=0,num;
    unordered_map<ll,ll>mp;
    while(n--){
        cin>>num;
        sum+=num;
        mp[num]++;
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        ll k=mp[b];
        mp[b]-=k;
        mp[c]+=k;
        sum+=k*(c-b);
        cout<<sum<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
int n,d;
int a[15][15];
int ans;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>d;
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int nw=0;
			for(int k=0;k<d;k++){
				nw+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			int nnw=sqrt(nw);
			if(nnw*nnw!=nw)continue;
			ans++;
		}
	}
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,s=0;
    scanf("%d%d",&a,&b);
    if(b<10){a=a*10;}
    else if(b<100){a=a*100;}
    else{a=a*1000;}
    
    for(int i=1;i<a+b;i++){
        if(i*i==(a+b)){cout<<"Yes"<<endl;return 0;}
        
    }
    cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ld a, b, x;
	cin>>a>>b>>x;
	ld ang;
	if(x > a*a*b/2){
		ld d = 2*x/(a*a) - b;
		ld tt = (b - d)/a;
		ang = atan(tt);
	}else{
		ld d = 2*x/(a*b);
		ang = atan(b/d);
	}
	ang *= 180.0/acos(-1.0);
	cout<<ang<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  bool flag = true;
  int A = vec.at(0);
  int smaller = 0; 
  int bigger = 0;
  for(int i=0; i<N; i++){
    if(vec.at(i) == A){
      smaller++;
    }
    else if(vec.at(i) == A+1){
      bigger++;
    }
    else{
      flag = false;
    }
  }
  int single = 0;
  int some = 0;
  if(bigger != 0){
    single = smaller;
    some = (A+1) - smaller;
    if(some < 1){
      flag = false;
    }
    if(N < single + some*2){
      flag = false;
    }
  }
  else{
    some = A;
    if(N < single + some*2 && N != A+1){
      flag = false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=3005;
#define M 998244353
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);



    map<int, int> deep;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        deep[a[i]]++;
    }

    int tot = 0;
    for(auto i : deep)
        tot += (i.S * (i.S - 1)) / 2;
    for(int i = 0; i < n; i++){
        cout << tot - (deep[a[i]] - 1) << endl;
    }
    
    

return 0;  
}


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

int main(){
  int64_t N,sum=0,max=0;
  cin >> N;
  
  
  for(int i=0;i<N;i++){
    int64_t x;
    cin >> x;
    if(max < x){
      max = x;
    }else{
      sum += max - x;
    }
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n ;
    set<string> s;
    for(int i=0; i<n;i++) {
        string item;
        cin >> item;
        s.insert(item);
    }
    cout << s.size() << endl;
}

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

int n;
lli calc(vector<lli> a, lli b)
{
    lli s = 0;
    rep(i, n)
    {
        s += abs(a[i] - b);
    }
    return s;
}
int main()
{
    cin >> n;
    vector<lli> a(n);
    rep(i, n)
    {
        cin >> a[i];
        a[i] -= (i + 1);
    }
    lli up = 1e10;
    lli low = -1e10;
    while (up - low > 2) {
        lli mid1 = (up + 2 * low) / 3;
        lli mid2 = (up * 2 + low) / 3;
        lli v1 = calc(a, mid1);
        lli v2 = calc(a, mid2);

        // cout << up << " " << low << " " << v1 << " " << v2 << endl;
        if (v1 > v2) {
            low = mid1;
        } else if (v1 < v2) {
            up = mid2;
        } else {
            low = mid1;
            up = mid2;
        }
    }
    cout << min({calc(a, low), calc(a, low + 1), calc(a, up)}) << endl;
}


Measured memory_bytes: 6500
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <bool Directed, typename TEdge> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + 1) {}
    graph(int n, int m) : graph(n) { edges.reserve(m); }
    TEdge& operator()(int i) { return edges[i]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - 1; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
struct wedge {
    int u, v;
    ld w;
    wedge reverse() const { return {v, u, w}; }
};
ostream& operator<<(ostream& os, const wedge& e) {
    os << "(" << e.u << ", " << e.v << ", " << e.w << ")";
    return os;
}
template <bool Directed> vector<ld> sssp(graph<Directed, wedge>& g, int s) {
    vector<bool> vis(g.size() + 1, false);
    vector<ld> d(g.size() + 1, numeric_limits<ld>::infinity());
    vector<int> p(g.size() + 1);
    priority_queue<pair<ld, int>> pq;
    pq.push({d[s] = 0, s});
    while(not pq.empty()) {
        int u = pq.top().second; pq.pop();
        if(not vis[u]) {
            vis[u] = true;
            for(int i : g[u]) {
                if(not vis[g(i).v] and d[g(i).v] > d[u] + g(i).w) {
                    p[g(i).v] = i, d[g(i).v] = d[u] + g(i).w;
                    pq.push({-d[g(i).v], g(i).v});
                }
            }
        }
    }
    return d;
}
const int N = 1000;
ll x[N+3], y[N+3], r[N+3];
ld d(int i, int j) {
    ll dx = x[i] - x[j], dy = y[i] - y[j];
    return max(sqrtl(dx * dx + dy * dy) - r[i] - r[j], 0.0l);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> x[1] >> y[1] >> x[N+2] >> y[N+2];
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x[i + 1] >> y[i + 1] >> r[i + 1];
    }
    x[n+2] = x[N+2], y[n+2] = y[N+2];
    graph<0, wedge> g(n + 2);
    for(int i = 1; i <= n + 2; i++) {
        for(int j = 1; j <= n + 2; j++) {
            g.add_edge({i, j, d(i, j)});
        }
    }
    cout << fixed << setprecision(9) << sssp(g, 1)[n+2] << endl;
    return 0;
}


Measured memory_bytes: 89180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    ll s;
    cin >> s;
    cout << "0 0 1000000000 1 ";
    ll a = s / 1e9;
    if (a * 1e9 == s) {
        cout << 0 << " " << a << endl;
    } else {
        cout << 1000000000 - (s % 1000000000LL) << " " << a + 1 << endl;
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

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

	if (s==u) {
		a--;
	}
	if (t==u) {
		b--;
	}
	cout << a << " " << b;

	return 0;
}

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

using namespace std;

typedef int64_t i64;
const int NMAX = 1000;
const long double eps = 1e-9;

int N, M, L;
int P[NMAX], T[NMAX], V[NMAX];
long double answer[NMAX];
vector<long double> value[NMAX], prob[NMAX];

int getSign(long double value) {
	if (value < -eps)
		return -1;
	if (value > eps)
		return 1;
	return 0;
}

i64 repeatedPerm(int a, int b) {
	unordered_map<int, int> primeFact;
	int c = a + b;
	for (int i = 2; i <= c; ++i) {
		int currNum = i;
		for (int j = 2; j <= sqrt(currNum) + 0.5; j += 2) {
			while (currNum % j == 0) {
				++primeFact[j];
				currNum /= j;
			}
			if (j == 2)
				j = 1;
		}
		if (currNum > 1)
			++primeFact[currNum];
	}
	for (int i = 2; i <= a; ++i) {
		int currNum = i;
		for (int j = 2; j <= sqrt(currNum) + 0.5; j += 2) {
			while (currNum % j == 0) {
				--primeFact[j];
				currNum /= j;
			}
			if (j == 2)
				j = 1;
		}
		if (currNum > 1)
			--primeFact[currNum];
	}
	for (int i = 2; i <= b; ++i) {
		int currNum = i;
		for (int j = 2; j <= sqrt(currNum) + 0.5; j += 2) {
			while (currNum % j == 0) {
				--primeFact[j];
				currNum /= j;
			}
			if (j == 2)
				j = 1;
		}
		if (currNum > 1)
			--primeFact[currNum];
	}

	i64 answer = 1;
	for (auto it: primeFact) {
		int curr = it.second;
		while (curr--)
			answer *= it.first;
	}
	return answer;
}

int main() {
//	assert(freopen("debug.in", "r", stdin));
//	assert(freopen("debug.out", "w", stdout));

	int i, j, k, l;

	cin >> N >> M >> L;
	for (i = 1; i <= N; ++i)
		cin >> P[i] >> T[i] >> V[i];

	for (i = 1; i <= N; ++i) {
		long double time = L / (long double)V[i];
		for (j = 0; j <= M; ++j, time += T[i]) {
			i64 currCases = repeatedPerm(j, M - j);
			long double probability = pow(P[i] / (long double)100, j) * pow(1 - P[i] / (long double)100, M - j);
			prob[i].push_back(probability * currCases);
			value[i].push_back(time);
		}
	}

	for (i = 1; i <= N; ++i) {
		for (j = 0; j <= M; ++j) {
			long double currProb = prob[i][j];
			for (k = 1; k <= N; ++k) {
				if (i == k)
					continue;
				long double nowProb = 0;
				for (l = M; l >= 0 && value[k][l] > value[i][j]; --l)
					nowProb += prob[k][l];
				currProb *= nowProb;
			}
			answer[i] += currProb;
		}
	}

	cout << fixed << setprecision(8);
	for (i = 1; i <= N; ++i)
		cout << answer[i] << '\n';

	return 0;
}



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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            //入力した値を数値変換する
            string str = Console.ReadLine();
            string[] strArray = new string[num];
            strArray = str.Split(' ');
            int[] intArray = Array.ConvertAll(strArray, int.Parse);

            Array.Sort(intArray);
            Array.Reverse(intArray);

            int i = intArray.Length;

            int intAnswer = intArray[0] - intArray[i-1];

            Console.WriteLine(intAnswer);

        }
    }
}


Measured memory_bytes: 26784
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b; cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
        exit(0);
    }
    if (a > 0) {
        cout << "Positive\n";
        exit(0);
    }
    if ((b - a + 1) % 2)
        cout << "Negative\n";
    else
        cout << "Positive\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i + 1] == s[i]) {
            count++;
            if (s[i] == '0')
                s[i + 1] = '1';
            else
                s[i + 1] = '0';
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;


int main()

{

    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='o')
            count++;
    }
    cout<<700+(count*100)<<endl;
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  

  int mini = 1000000000;
  for(int i = 1;i <= N/2;i++) {
    int j = N - i,k = i;
    int suma = 0,sumb = 0,sum = 0;
    while(k > 0) {
      suma += k % 10;
      k /= 10;
    }

    while(j > 0) {
      sumb += j % 10;
      j /= 10;
    }
    
    sum = suma + sumb;
    mini = min(mini,sum);

  }

  cout << mini << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    set<pii> U;

    reps(i, 1, N-1) {
        int a = i;
        int b = N - a;
        if (a == b) continue;
        if (a > b) swap(a, b);
        U.emplace(a, b);
    }

    print(U.size());

    return 0;
}


Measured memory_bytes: 31488
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CSlimes {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        string S;
        in>>S;
        vc<char> res;
        for(auto& c : S){
            if(res.empty() or res.back()!=c){
                res.pb(c);
            }
        }
        out<<LEN(res)<<'\n';
    }
};


int main() {
	CSlimes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    // スペース区切りの整数の入力
    int sum[N] = {0};
    int a;

    for (int i = 0; i<N-1; i++){
        cin >> a;

        sum[a-1] += 1;
        
    }
    
    for (int i = 0; i<N; i++){
        cout << sum[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4376
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <sys/time.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef pair<int, PP> IPP;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"\
			<<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;

int main() {
	omajinai;
	ll w,h;cin>>w>>h;
	VP v;
	REP(i,w){
		int p;
		cin>>p;
		v.PB(P(p, 0));
	}
	REP(i,h){
		int p;
		cin>>p;
		v.PB(P(p, 1));
	}
	SORT(v);

	int c[] = {0,0};
	ll ans = 0;
	for(auto e:v){
		int x = e.first, f = e.second;
		ans += (ll)x * ((f ? w+1 : h+1) - c[f]);
		c[!f]++;
	}
	cout << ans;
}


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

  // 必要十分：道路の数＝＝数字の登場数
int main(){
  int n,m;cin>>n>>m;
  int a[50],b[50],c[50];
  for(int i=0;i<m;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++)c[i]=0;
  for(int i=0;i<m;i++){
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  for(int i=0;i<n;i++)cout<<c[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

from itertools import permutations
def solve():
    n = LI()
    for p in permutations(n):
        if p == (1,9,7,4):
            print("YES")
            return
    print("NO")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38640
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, t;
const ll mod = 1e9 + 7;
ll a[SIZE], pre[SIZE];
ll qpow(ll a, ll b, ll mod) { //快速幂 a ^ b % mod
	ll ans = 1;
	while (b) {
		if (b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
int main() {
	io(); cin >> n;
	map<int, int> MP;
	rep(i, 1, n) cin >> a[i], MP[a[i]]++;
	int zero = 0, f = 0;
	for (auto it : MP) {
		if (!it.first) zero = it.second;
		else if (it.second != 2) f = 1;
	}
	if (zero != 1 && zero != 0) f = 1;
	cout << (f ? 0 : qpow(2ll, n / 2, mod));
}

Measured memory_bytes: 7296
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		while (true) {
			String str = s.nextLine();
			if (str.equals("."))
				break;

			char[] c = new char[100];
			for (int i = 0; i < str.length(); i++) {
				c[i] = str.charAt(i);
				// System.out.println(c[i]);
			}

			// for (int i = 0; i<str.length(); i++) {
			// System.out.println(c[i]);
			// }

			Stack<Character> stack = new Stack<Character>();
			String ans = "yes";

			for (int count = 0; count < str.length(); count++) {
				if (c[count] == '[') {
					stack.push(']');
				} else if (c[count] == '(') {
					stack.push(')');
				} else if (c[count] == ']') {
					if (stack.empty())
						ans = "no";
					else if (stack.pop() != ']')
						ans = "no";
				} else if (c[count] == ')') {
					if (stack.empty())
						ans = "no";
					else if (stack.pop() != ')')
						ans = "no";
				}
			}

			// for (int j = 0; j < str.length() - 1; j++)
			// System.out.println(stack.pop());

			// if (stack.empty())
			// System.out.println("yes");
			// else
			// System.out.println("no");

			if (!stack.empty())
				ans = "no";
			System.out.println(ans);
		}

		s.close();
	}
}

Measured memory_bytes: 32520
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000100,mod=1000000007;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,f[maxn],s[maxn],ans;
int main(){
	n=read();
	f[0]=s[0]=1;
	FOR(i,1,n){
		f[i]=f[i-1];
		if(i>=3) f[i]=(f[i]+s[i-3])%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	FOR(i,0,n-2) ans=(ans+1ll*(i+1+1ll*(n-1)*(n-1))%mod*f[i])%mod;
	ans=(ans+1ll*(n-1)*f[n-1])%mod;
	printf("%d\n",(f[n]+ans)%mod);
}

Measured memory_bytes: 8064
N = int(input())
A = list(map(int, input().split()))

B = [0]
for i in range(N):
    B.append(B[i]+A[i])

ans = float('inf')
for i in range(1, N):
    ans = min(ans, abs((B[-1]-B[i])-B[i]))
print(ans)

Measured memory_bytes: 87120
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  std::string s; std::cin >> s;
  std::string ans;
  for(auto i=0; i<s.size(); i++) {
    if ( i % 2 == 0 ) ans += s[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
//using ll = long long;
     
int main(){
     	string str;
	cin >> str;
	map<char,int> mp;
	for(int d = 0 ; d < str.length(); d++){
		mp[str[d]]++;	
	}
	for(auto& el : mp){
		if(el.second != 1){
			cout << "no" << endl;
			return 0;
		}
	}
     
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import bisect

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a2z = set(list(map(chr, range(97, 123))))
S = rs()
if len(S) < 26:
    unused = a2z - set(S)
    print(S + sorted(list(unused))[0])
    exit()
else:
    l = [S[25]]
    for i in range(24, -1, -1):
        j = bisect.bisect_left(l, S[i])
        if j != len(l):
            answer = S[:i] + l[j]
            print(answer)
            exit()
        else:
            l.append(S[i])
            l.sort()
print(-1)
#47


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		try {
			int n = Integer.parseInt(scanner.nextLine());
			String[] str = scanner.nextLine().split(" ");
			int[] array = new int[n];
			for(int i = 0; i < n; i++) {
				array[i] = Integer.parseInt(str[i]);
			}
			System.out.println(lower(n, array));
			
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			scanner.close();
		}
		


	}
	
	public static int lower(int n, int[] columns) {
		int cnt = 0;
		int max = 0;
		for(int i = 0; i < n - 1; i++) {
			if(columns[i] >= columns[i + 1]) {
				cnt++;
			}else {
				if(max < cnt) {
					max = cnt;
				}
				cnt = 0;
			}
			if(max < cnt) {
				max = cnt;
			}
		}
		return max;
	}

}


Measured memory_bytes: 50924
<?php

// 標準入力
$N = fgets(STDIN);

// メイン処理

// 10以下は $N がすべて該当
if ($N < 10) {
    echo $N;
}
// 10 ~ 100は 1~9 のみ
if (10 <= $N && $N < 100) {
    echo 9;
}
// 100 ~ 1000は 1~9 と 100 ~ のみ
if (100 <= $N && $N < 1000) {
    echo 9 + ($N - 99);
}
// 1000 ~ 10000は 1~9 と 100 ~ 999のみ
if (1000 <= $N && $N < 10000) {
    echo 909;
}
// 10000 ~ 100000は 1~9 と 100 ~ 999 と 10000~ のみ
if (10000 <= $N && $N < 100000) {
    echo 909 +  ($N - 9999);
}

if (100000 <= $N && $N < 1000000) {
    echo 90909;
}



Measured memory_bytes: 3700
using System;
using System.Collections;
class main{
	public static void Main(){
		string[] input = Console.ReadLine().Split();
		int W = int.Parse(input[0]), H = int.Parse(input[1]), x = int.Parse(input[2]), y = int.Parse(input[3]), r = int.Parse(input[4]);
		if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
		{
			Console.WriteLine("Yes");
		}
		else Console.WriteLine("No");
	}
}

Measured memory_bytes: 9000
#include <iostream>

#define int long long
#define MOD 998244353
#define HALF 499122177

int ans[3005];

signed main() {
  int n, s;
  std::cin >> n >> s;

  ans[0] = 1;
  for(int i = 0; i < n; i++)
    ans[0] = (ans[0]*2)%MOD;

  for(int i = 0; i < n; i++) {
    int x;
    std::cin >> x;

    for(int j = s; j >= 0; j--) {
      if(j+x <= s) {
        ans[j+x] = (ans[j+x] + (ans[j]*HALF))%MOD;
      }
    }
  }

  std::cout << ans[s] << std::endl;
  return 0;
}



Measured memory_bytes: 3660
#include <cstdio>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

int main()
{
    LL N, M;
    char key[20];
    string* s_key;
    map<string, int> counter;
    scanf("%lld\n", &N);
    REP(i, N) {
        fgets(key, sizeof(key), stdin);
        s_key = new string(key);
        ++counter[*s_key];
    }
    scanf("%lld\n", &M);
    REP(i, M) {
        fgets(key, sizeof(key), stdin);
        s_key = new string(key);
        --counter[*s_key];
    }
    int result = 0;
    for (auto& x : counter) {
        if (x.second > result) {
            result = x.second;
        }
    }
    result = max(result, 0);
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    double ans = 0.0;
    REP(i, n)
    {
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x * 380000.0;
        }
    }
    printf("%.9lf\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;
ll power(ll a,ll b){
    if(a==0)return 1;
    ll res=1,curr=2;
    while(a){
        if(a&1)
        res=(res*curr)%b;
        curr=(curr*curr)%b;
        a/=2;
    }
    return res;
}
ll fun(ll num){
    if(num==0)return 0;
    ll coun,res=0;
    while(num){
        coun=__builtin_popcount(num);
        if(coun==0)break;
        res++;
        num%=coun;
    }
    return res;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;
        string s;cin>>s;
        ll sum=0;
        for(ll i=0;i<n;i++)if(s[i]=='1')sum++;
        ll curr=1,num=0;
        ll plu,neg;
        sum++;
        for(ll i=s.length()-1;i>=0;i--){
            if(s[i]=='1'){
                num=(num+curr)%sum;
            }
            curr=(curr*2)%sum;
        }
        plu=num;
        // cout<<power(4,3)<<"y";
        // for(ll i=0;i<n;i++)plu[i]=num;
        sum-=2;curr=1;num=0;
        // cout<<sum<<" ";
        for(ll i=s.length()-1;i>=0;i--){
        	if(sum==0){
        		num=0;break;
        	}
            if(s[i]=='1'){
                num=(num+curr)%sum;
            }
            curr=(curr*2)%sum;
        }
        neg=num;
        sum++;
        // ll n=s.length();
        // cout<<plu<<" "<<neg;
        ll ans;
        for(ll i=0;i<n;i++){ans=0;
            if(s[i]=='1'){
                num=neg;
                // cout<<sum-1<<" ";
                if(sum-1==0){
                num=0;cout<<"0"<<endl;continue;}
                num=(num-power(n-i-1,sum-1)+sum-1)%(sum-1);
            }
            else{
                num=plu;
                // cout<<n-i-1<<" ";
                // cout<<power(n-i-1,sum+1)<<" ";
                num=(num+power(n-i-1,sum+1)+sum+1)%(sum+1);
            }
            ans=fun(num)+1;cout<<ans<<endl;
        }


}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io

	int n, a[1010];

	cin >> n;
	bool possible = true;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 and a[i] % 5 != 0)
				possible = false;
		}
	}
	cout << (possible ? "APPROVED\n" : "DENIED\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans, cnt = 0;
	repd(i, a) {
		if (a % i == 0 && b % i == 0) {
			cnt++; 
			if (cnt == c) {
				ans = i;
			}
		}

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

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)1e5;
const int mod = (int)1e9+7;

void solve()
{
    string s, t;
    cin>>s>>t;
    int n = s.size(), ans = 0;
    f(i, 0, n) if(s[i] != t[i]) ans++;
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if(B <= A) cout << "delicious" << endl; 
    else if(A < B && B <= A+X) cout << "safe" << endl; 
    else cout << "dangerous" << endl; 
}

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

int N;
vector<vector<int>> graph(100010);
vector<int> visit(100010,-1);
int s=0;

void BFS_f(){
	queue<int> q;
	visit[0]=0;
	q.push(0);
	while(q.empty()==0){
		int f=q.front();
		q.pop();
		for(auto t:graph[f]){
			if(visit[t]==-1){
				visit[t]=visit[f]+1;
				q.push(t);
			}
		}
	}
}

void BFS_s(){
	queue<int> q;
	visit[N-1]=0;
	q.push(N-1);
	s++;
	while(q.empty()==0){
		int f=q.front();
		q.pop();
		for(auto t:graph[f]){
			if(visit[t]>visit[f]+1){
				visit[t]=visit[f]+1;
				s++;
				q.push(t);
			}
		}
	}
}

int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	BFS_f();
	BFS_s();
	
	if(s>=(N+1)/2)cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
	return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<deque>
using namespace std;

class Team {

    public:
        int id;
        int school;
        int cleared;
        int penalty;

        Team (int a, int b, int c, int d) {
            id = a;
            school = b;
            cleared = c;
            penalty = d;
        }

        friend bool operator<(const Team& lhs, const Team& rhs) {

            if (lhs.cleared != rhs.cleared) {
                return lhs.cleared < rhs.cleared;
            } else if (lhs.penalty != rhs.penalty) {
                return lhs.penalty > rhs.penalty;
            } else {
                return lhs.id > rhs.id;
            }
        }
        
};

int main() {

    int n;
    while(true) {
        cin >> n;
        if (n == 0) break;

        vector<Team> teams;
        for(int i = 0; i < n; i++) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            teams.push_back(Team(a, b, c, d));
        }
        sort(teams.begin(), teams.end());
        reverse(teams.begin(), teams.end());

        vector<int> schools;
        int selected = 0;
        for(int i = 0; i < teams.size(); i++) {
            if (selected < 10 && count(schools.begin(), schools.end(), teams[i].school) < 3) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            } else if (selected < 20 && count(schools.begin(), schools.end(), teams[i].school) < 2) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            } else if (selected < 26 && find(schools.begin(), schools.end(), teams[i].school) == schools.end() ) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            }
        }
    }
     
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
  char a[4];
  char b[4];
  int sum=0;
  scanf("%s",a);
  scanf("%s",b);
  if(a[0]==b[0])
  sum++;
  if(a[1]==b[1])
  sum++;
  if(a[2]==b[2])
  sum++;
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
/* Author: Dhruv Rastogi */
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define ll long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

string a[205];
vll adjlist[205];
int dist[205][205];
int vis[205];
int c[205];
void dfs(int node,int color){
	c[node]=color;
	vis[node]=1;
	for(int i:adjlist[node]){
		if(!vis[i]){
			dfs(i,1-color);
		}
		else if(c[node]==c[i]){
			cout<<-1<<endl;
			exit(0);
		}
	}
}

void solve(){  
	int n;
	cin>>n;
	rep(i,0,n) cin>>a[i];  
	rep(i,0,n){
		rep(j,0,n){
			if(i!=j)
			dist[i][j]=hell;
		}
	}
	rep(i,0,n){
		rep(j,0,n){
			if(a[i][j]=='1'){
				adjlist[i].pb(j);
				dist[i][j]=1;
			}
		}
	}
	dfs(0,0);
	rep(k,0,n){
		rep(i,0,n){
			rep(j,0,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=0;
	rep(i,0,n){
		rep(j,0,n){
			ans=max(ans,dist[i][j]);
		}
	}
	cout<<ans+1<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 640