akhauriyash/Code-Regression huggingface dataset:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

def solve(n):
    ret = {i:[] for i in range(n+1)}
    X=int(n**(1/2) +0.5)+1
    Y=int(n**(1/2) +0.5)+1 
    Z=int(n**(1/2) +0.5)+1
    for x in range(1,X):
        for y in range(1,Y):
            d = x**2+y**2+x*y
            for z in range(1,Z):
                if n < d+z**2 + y*z + z*x:
                    continue
                ret[d+z**2 + y*z + z*x].append((x,y,z))
    return ret

ret = solve(N)
for i in range(1,N+1):
    print(len(set(ret[i])))

Measured memory_bytes: 93748
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var S = ReadLine();
            var ans = 0;
            for(var i=0;i<S.Length/2;i++)
            {
                if (S[i] != S[S.Length - i - 1]) ans++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 17404
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void) {

	string haiku;

	cin >> haiku;

	haiku[5] = ' ';
	haiku[13] = ' ';

	
	cout << haiku << endl;
	return 0;
	



}

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

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

  int pre = -999;
  for(int i = 0;i < n;i++){
    if(pre <= a[i]-1){
      pre = a[i]-1;
    }
    else if(pre <= a[i]){
      pre = a[i];
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second

using namespace :: std;

const ll maxn=3e5+500;
const ll mod=1e9+7;
const ll inf=1e9+500;

ll a[maxn];

ll sag(ll a){
	return a/2+(a%2);
}


int main(){
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	ll k,n;
	cin>>k>>n;
	if(k%2==0){
		cout<<k/2<<' ';
		for(ll i=1;i<n;i++){
			cout<<k<<' ';
		}
		return 0;
	}
	if(n==1){
		cout<<sag(k);
		return 0;
	}
	if(k==1){
		for(ll i=0;i<sag(n);i++){
			cout<<"1 ";
		}
		return 0;
	}
	ll oi=sag(k);
	for(ll i=0;i<n;i++){
		a[i]=oi;
	}
	for(ll i=0;i<n/2  ;i++){
		for(ll j=n-1;j>=0;j--){
			if(a[j]!=0){
				a[j]--;
				if(a[j]==0){
					for(j++;j<n;j++){
						a[j]=0;
					}
				}
				else{
					for(j++;j<n;j++){
						a[j]=k;
					}	
				}
				break;
			}
		}
	}
	for(ll i=0;i<n;i++){
		if(a[i]==0){
			return 0;
		}
		cout<<a[i]<<' ';
	}


}



Measured memory_bytes: 3456
from math import sqrt


def route(a, b):
    return(sqrt((p[a-1][0]-p[b-1][0])**2+(p[a-1][1]-p[b-1][1])**2))


n = int(input())
p = list()
for i in range(n):
    p.append(tuple(map(int, input().split())))

sum = int()
cnt = int()
for i in range(1, n):
    for j in range(i+1, n+1):
        #print(i, j)
        sum+=route(i,j)
        cnt+=1

sum*=n-1
print(sum/cnt)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var (
		S string
		K int
	)
	fmt.Scan(&S, &K)
	for i := 0; i < K && i < len(S); i++ {
		if S[i] >= '2' {
			fmt.Println(string(S[i]))
			return
		}
	}
	fmt.Println(1)
}


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

#include <vector>
using namespace std;

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

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

typedef long long ll;

struct Edge {
    int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
    int k = 1;
    rep(i, g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u == p) continue;
        if (k == c) ++k;
        ans[ei] = k;
        ++k;
        dfs(u, ans[ei], v);
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int>(n - 1);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(Edge{b, i});
        g[b].push_back(Edge{a, i});
    }

    dfs(0);
    int mx = 0;
    rep(i, n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i, n - 1) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
using namespace std;
typedef long long llong;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A <= 5) cout << 0;
	else if (6 <= A && A <= 12) cout << B / 2;
	else cout << B;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define scan(n)     scanf("%lld", &n);
#define print(n)    printf("%lld\n", n);
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        100005
#define LOG         19
#define mod         1000000007
using namespace std;
// good approach
// yes


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,k,j;
    scan(n);
    scan(k);
    ll a[n],dp[n];
    for(ll i=0;i<n;i++){
        scan(a[i]);        
    }
    for(i=0;i<n;i++){
        dp[i]=MAX;
    }
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=0;j<=k;j++){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
                // cout<<i<<" "<<i-j<<endl;
            }
        }
    }
    // for(i=0;i<n;i++){
    //     cout<<dp[i]<<" ";
    // }
    cout<<dp[n-1];
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll N;
	cin >> N;
	vector<ll> x(1e6 + 10, 0);
	ll tmp = N;
	for(ll i = 2; i * i < N; i++) {
		while(tmp % i == 0) {
			x.at(i)++;
			tmp /= i;
		}
	}
	ll ans = 0;
	if(tmp != 1) ans++;
	for(int i = 0; i < x.size(); i++) {
		ll base = 1;
		while(base <= x[i]) {
			x[i] -= base;
			base++;
			ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 11176
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const ll mod = 1000000007;
ll dp[105][10];
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  dp[0][1] = 1LL;
  auto lok = [&](int bm, int j) {
    if(j == 1) return false;
    if(!(bm & (1 << (j - 2)))) return false;
    return true;
  };
  auto rok = [&](int bm, int j) {
    bool res = true;
    if(j == w) return false;
    if(!(bm & (1 << (j - 1)))) return false;
    return true;
  };
  auto cok = [&](int bm, int j) {
    bool res = true;
    if(j != 1)
      if(bm & (1 << (j - 2))) return false;
    if(j != w)
      if(bm & (1 << (j - 1))) return false;
    return true;
  };

  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      rep(bm, (1 << (w - 1))) {
        bool ok = true;
        rep(k, w - 2) if(3 == ((bm >> k) & 3) % 4) ok =
          false;
        if(!ok) continue;
        if(lok(bm, j))
          dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
        if(rok(bm, j))
          dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % mod;
        if(cok(bm, j))
          dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
      }
    }
  }
  cout << dp[h][k] << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      k:usize,
      a:usize,b:usize
   }

   for i in a..=b {
      if i % k == 0 {
         println!("OK");
         return;
      }
   }
   println!("NG");
}


Measured memory_bytes: 2140
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
    int n, m; cin>>n>>m;
    unionfind uf(n);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans=1;
    for(int i=0; i<n; i++) ans=max(ans, uf.size(i));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll x[N],y[N],a[N];
    rep(0,i,N)cin>>x[i]>>y[i];
    double sum=0,sumN=0;
    rep(0,i,N)a[i]=i+1;
    do{
        rep(0,i,N-1){
            sum+=1.0*(sqrt((x[a[i+1]-1]-x[a[i]-1])*(x[a[i+1]-1]-x[a[i]-1])+(y[a[i+1]-1]-y[a[i]-1])*(y[a[i+1]-1]-y[a[i]-1])));
        }
        ++sumN;
    }while(next_permutation(a,a+N));
    cout<<fixed<<setprecision(10)<<1.0*sum/sumN<<endl;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            while (true)
            {
                if (a[i] % 2 == 0) { a[i] /= 2; count++; }
                else break;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13792
n = int(input())
for i in range(1 , n+1):
	if "3" in str(i):
		print(" {}".format(i), end="")
	else:
		if i % 3 == 0:
			print(" {}".format(i), end="")
		else:
			if i % 10 == 3:
				print(" {}".format(i), end="")
print()



Measured memory_bytes: 5872
#include <stdio.h>

int main(void){
    int n;
    char s[100];
    int i,cnt=0,pre=0;
    int d[100];//d[i]はsの最初i文字に含まれる(の個数-)の個数
    int x;//x=min(d[0],d[1],...d[n];
    //d[s]=0かつx=0となれば良い
    scanf("%d %s",&n,s);
    for(i=0;i<n;i++){
        if(s[i]=='(')cnt++;
        if(s[i]==')'){
            if(cnt!=0)cnt--;
            else pre++;
        }
    }
    for(i=0;i<pre;i++){
        printf("(");
    }
    printf("%s",s);
    for(i=0;i<cnt;i++)printf(")");
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
k = int(input())
s = list(str(input()))
if len(s) <= k:
    ans = ""
    for i in range(len(s)):
        ans += s[i]
    print(ans)
else:
    ans = ""
    for i in range(k):
        ans += s[i]
    ans += "..."
    print(ans)

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

const int N = 1000 * 100 + 10;
int a[N], b[N], n, par[N * 2], sz[N * 2];

int get_par(int root) {
	return par[root] == root? root: par[root] = get_par(par[root]);
}

void Union(int v, int u) {
	v = get_par(v), u = get_par(u);
	if (v == u)
		return;
	if (sz[u] > sz[v])
		swap(v, u);
	sz[v] += sz[u];
	par[u] = v;
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], a[n] ^= a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i], b[n] ^= b[i];
	map<int, int> cnt;
	for (int i = 0; i <= n; i++)
		cnt[a[i]]++;
	for (int i = 0; i < n; i++) {
		cnt[b[i]]--;
		if (cnt[b[i]] < 0)
			return cout << "-1\n", 0;
	}
	vector<int> vec;
	for (int i = 0; i < n; i++)
		if (a[i] != b[i])
			vec.push_back(a[i]), vec.push_back(b[i]), ans++;
	vec.push_back(a[n]), vec.push_back(b[n]);
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	int s = (int)(vec.size());
	for (int i = 0; i < s; i++)
		par[i] = i, sz[i] = 1;
	for (int i = 0; i <= n; i++) 
		if (a[i] != b[i]) {
			a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			b[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			Union(a[i], b[i]);
		}
	for (int i = 0; i < s; i++)
		if (get_par(i) == i)
			ans++;
	cout << ans - 1 << '\n';
	return 0;
}


Measured memory_bytes: 10528
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef pair<int, int> P;
const int MAXN = 200010;

int n, k, l;

class UnionFind {
  vector<int> size_;
  vector<int> parent_;
  public:
  UnionFind(int n) {
    size_.reserve(n);
    parent_.reserve(n);
    for (int i=0;i<n;i++) {
      size_.push_back(1);
      parent_.push_back(i);
    }
  }

  int getSize(int x) {
    return size_[x];
  }

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

  int find(int x) {
    if (x == parent_[x]) {
      return x;
    }
    return parent_[x] = find(parent_[x]);
  }

  void _union(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return;
    }
    if (size_[x] < size_[y]) {
      parent_[x] = y;
      size_[y] += size_[x];
    } else if (size_[x] >= size_[y]) {
      parent_[y] = x;
      size_[x] += size_[y];
    }
  }
};

UnionFind road(MAXN), rail(MAXN), all(MAXN);

void solve() {
  map<P, int> m;
  for (int i=0;i<n;i++) {
    m[P(road.find(i), rail.find(i))] += 1;
  }
  for (int i=0;i<n;i++) {
    cout << m[P(road.find(i), rail.find(i))] << " ";
  }
  cout << endl;
}

int main() {
  cin >> n >> k >> l;
  int x, y;
  for (int i=0;i<k;i++) {
    cin >> x >> y;
    road._union(--x, --y);
  }
  for (int i=0;i<l;i++) {
    cin >> x >> y;
    rail._union(--x, --y);
  }
  solve();
}


Measured memory_bytes: 16768
#include <iostream>
#include <vector>
using namespace std;
#define INF 1LL<<60
template<class T> inline bool chmin(T& a, T b) { if( a > b ){ a=b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if( a < b ){ a=b; return 1; } return 0; }

int main() {
    // INPUT
    long long N=0, W=0;
    cin >> N >> W;
    vector<vector<long long>> product(N, vector<long long>(2, 0));
    long long max_value = 0;
    for(int i=0; i<N; i++) {
        cin >> product[i][0] >> product[i][1];
        max_value += product[i][1];
    }

    // SOURCE
    vector<vector<long long>> dp_value(N, vector<long long>(max_value+1, INF));
    dp_value[0][0] = 0;
    for(int j=1; j<=product[0][1]; j++) dp_value[0][j] = product[0][0];
    for(int i=1; i<N; i++) {
        for(int j=0; j<max_value+1; j++) {
            long long tmp_value = j + product[i][1];
            if( max_value >= tmp_value ) { 
                chmin(dp_value[i][tmp_value], dp_value[i-1][j] + product[i][0]);
            }
            chmin(dp_value[i][j], dp_value[i-1][j]);
        }
    }
    long long ans = 0;
    for(int i=1; i<max_value+1; i++) {
        if( dp_value[N-1][i] <= W ) {
            if( ans < i ) ans = i;
        }
    }

    // OUTPUT
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define bt(i) (1LL<<(i))
typedef long long ll;
using namespace std;
ll two[61];
ll MOD=1e9+7;
int main()
{
	fio;
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif;
	two[0]=1;
	for(int i=1;i<61;i++)two[i]=two[i-1]*2%MOD;
    //for(int i=0;i<61;i++)cout<<two[i]<<" ";
    //cout<<endl;
    int n;
	cin>>n;
	vector<ll>v(n);
	for(int i=0;i<n;i++)cin>>v[i];

	ll ans=0;
	for(int k=0;k<60;k++){
		ll one=0,zero=0;
		for(int i=0;i<n;i++){
			if(bt(k)&v[i])one++;
			else zero++;
		}
		//cout<<zero<<" "<<one<<" "<<two[k]<<endl;
		ans+=two[k]*(one*zero%MOD);
		//cout<<"ans = "<<ans<<endl;
		ans%=MOD;

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


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

ll n;
ll w[110];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n;
	rep(i, 0, n) cin >> w[i];
	ll p = 0, q = 0;
	ll ans = INF;
	rep(i, 0, n) q += w[i];
	rep(i,0,n-1){
		p += w[i];
		q -= w[i];
		ans = min(ans, abs(p - q));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		float b = float.Parse(input[0]);
		float c = float.Parse(input[1]);
		// 文字列の入力
		//出力
		Console.WriteLine(b/c);
	}
}

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if(a+b==c||a+c==b||b+c==a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l == r)
  {
    cout << "Balanced";
    return;
  }
  cout << (l < r ? "Right" : "Left");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
set<int> s;
int main()
{
	ios::sync_with_stdio(false);
    int n,a;
    n=read();
    for(register int i=1;i<=n;i++)
    {
    	a=read();
        if(s.find(a)==s.end()) s.insert(a);
        else s.erase(s.find(a));
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 4992
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n=int(input())
l=make_divisors(n)
print(len(str(l[len(l)//2])))

Measured memory_bytes: 3060
//
// Created by yamunaku on 2019/12/01.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CYESA cout<<"Yay!"<<endl
#define CNOA cout<<":("<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    ll t1, t2;
    ll a1, b1, a2, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll x1 = a1 * t1 - b1 * t1;
    ll x2 = a2 * t2 - b2 * t2;
    if(x1 + x2 == 0){
        cout << "infinity" << endl;
        return 0;
    }
    if((x1 / abs(x1)) * (x2 / abs(x2)) > 0){
        cout << 0 << endl;
        return 0;
    }
    if(abs(x1) > abs(x2)){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ans = abs(x1) / (abs(x2) - abs(x1)) * 2;
    if(abs(x1) % (abs(x2) - abs(x1)) == 0) ans--;
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, k = gets.split.map(&:to_i)

$uf = (0..n).to_a

def root(i)
  return i if $uf[i]==i
  return i if $uf[i]<0
  $uf[i] = root($uf[i])
  return $uf[i]
end

def same(i, j)
  return root(i) == root(j)
end

def group(i)
  x = root(i)
  g = $uf[x]
  return -g if g<0
  return 0
end

def set_group(i, g)
  x = root(i)
  $uf[x] = -g
end

def unite(i, j)
  x, y = root(i), root(j)
  g, h = $uf[x], $uf[y]
  if g<0
    $uf[y] = x
  else
    $uf[x] = y
  end
end

(1..k).each{|i|
  r, a, b = gets.split.map(&:to_i)
  if r==1
    ga, gb = group(a), group(b)
    if ga>0 and gb>0 and ga!=gb
      puts i
      exit
    else
      unite(a, b)
    end
  elsif r==2
    g = group(a)
    if g==0
      set_group(a, b)
    elsif g>0 && g!=b
      puts i
      exit
    end
  end
}
puts 0


Measured memory_bytes: 9800
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <complex>

using namespace std;

typedef complex<double> xy_t;
char c;
double x, y;
xy_t P[20];
const int MAX = 10000000;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

int main(void){

	
	int k = 0;
	while(cin >> x >> c >> y){
		P[k] = xy_t(x, y);
		k++;
	}

	
	double ans = 0;

	for(int i = 1; i < k - 1; i++){
			ans += abs(0.5 * cross_product(xy_t (P[i] - P[0]), xy_t (P[i + 1] - P[0])));
	}


	printf("%.6f\n", ans);
	
    return 0;
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
int n;
string s;

int main() {
	run();
	cin >> n;
	cin >> s;
	int ans = 1;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1])
			ans++;

	}
	cout << ans;
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans = 10**1000
for i in make_divisors(n):
    ans = min(ans, max(len(str(n//i)), len(str(i))))
print(ans)

Measured memory_bytes: 3060
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n=ii()
    p = li()
    cnt = 0
    for i in range(1,n+1):
        if i!=p[i-1]:
            cnt+=1
    if cnt<=2:
        print('YES')
    else:
        print('NO')



main()




Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r,c;
	while (cin >> r >> c){
		if (!(r | c)) break;
		for (int i=0;i<r;i++){
			for (int j=0;j<c;j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sum = 0;
		for (int x = a; x <= b; x++) {
			if (c % x == 0) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 26148
#include<stdio.h>

int main(void){
    int n, l, x = 0, ans = 0;

    scanf("%d %d", &n, &l);

    if (l < 0 && -l >= n) {
        x = 1;
    }

    for (int i = 0; i < n; i++) {
        ans +=  l + i;
    }

    if (l >= 0) {
        ans = ans - l;
    }
    else if (l < 0 && x == 1) {
        ans = ans - (l + n - 1);
    }

    printf("%d", ans);

}

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

using namespace std;

int main() {

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

	int n, m;
	cin >> n >> m;
	vector<int> integers, next;
	if (n == 1) integers.push_back(0);
	for (int i = (int) pow(10, n - 1); i < pow(10, n); ++i) 
		integers.push_back(i);
	int s;
	char c;
	for (int i = 0; i < m; ++i) {
		cin >> s >> c;
		for (int j = 0; j < integers.size(); ++j) {
			if (to_string(integers[j])[s - 1] == c) {
				next.push_back(integers[j]);
			}
		}
		integers.clear();
		for (int j = 0; j < next.size(); ++j) {
			integers.push_back(next[j]);
		}
		next.clear();
	}
	if (integers.size() == 0) {
		cout << -1 << '\n';
		return 0;
	}
	sort(integers.begin(), integers.end());
	cout << integers[0] << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
 
int main(){
    string s, t;
    cin >> s >> t;

    ll dp[s.size()+1][t.size()+1] = {};
    rep(i, s.size()+1)rep(j, t.size()+1)dp[i][j] = 0;
 
    rep(i, s.size())rep(j, t.size()){
        if(t[j] == s[i])dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
        else {
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]); 
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]); 
        }
    }

    string ans = "";
    ll i = s.size();
    ll j = t.size();

    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j])--i;
        else if(dp[i][j] == dp[i][j-1])--j;
        else{
            ans = s[i-1] + ans;
            --i, --j;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 70656
let w = read_line() ;;
let t =
  let rec f(s) =
    let a = read_line() |> (fun x -> (^) x " ") in
    if a = "END_OF_TEXT " then s
    else f (s ^ String.lowercase a)
  in
  f("") ;;

let tl = Str.split (Str.regexp " ") t;;

let () =
  let f x xs = List.fold_left (fun e y -> if x = y then (e + 1) else e) 0 xs in
  Printf.printf "%d\n" (f w tl);;


Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main()
{
  long long h,n,sum=0;
  cin>>h>>n;
  long long a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>=h)
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  else
  {
    cout<<"No"<<endl;
    return 0;
  }
}

Measured memory_bytes: 1024
H, N = map(int, input().split())
# mahous = [(a, b) for a, b in list(map(int, input().split()))]

mahous = []
for i in range(N):
    a, b = map(int, input().split())
    mahous.append((a, b))

dp = [float("inf")] * (H + 1)
dp[0] = 0

for h in range(1, H + 1):
    for n in range(N):
        a, b = mahous[n]
        tairyoku = max(0, h - a)
        # if h - a >= 0:
        dp[h] = min(dp[h], dp[tairyoku] + b)
    # print(dp)

print(dp[H])

Measured memory_bytes: 44612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 and i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main{
  static int H,W,h,w,ans;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    H = sc.nextInt();
    W = sc.nextInt();
    h = sc.nextInt();
    w = sc.nextInt();
    ans = H*W-H*w-W*h+w*h;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>


using namespace std;

int main(){
    long n;
    cin >> n;
    long c[11][11];
    //初期化
    for(int j=0;j<10;j++){
    for(int i=0;i<10;i++){
        c[j][i]=0;
    }
    }
    
    for(long i=1;i<=n;i++){
        string p=to_string(i);
        int lead=p[0]-'0';
        int last=p[p.size()-1]-'0';
        c[lead][last]++;
    }
    long ans=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            ans+=c[i][j]*c[j][i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, d;
    cin >> n >> d;
    cout << (n - 1) * 127 + (n % 2 == 1 ? d : 127 - d) << '\n';
}

bool multitest = true;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3652
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

string s ;
bool seen [ 26 ] ;
string res = "" ;

bool chk ( string t ) {
	bool mark [ 26 ] ;
	memset ( mark , 0 , sizeof mark ) ;
	for ( auto x : t ) {
		if ( mark [ x - 'a' ] ) return 0 ;
		mark [ x - 'a' ] = 1 ;
	}
	return 1 ; 
}

bool kam ( string s , string t ) {
	for ( int i = 0 ; i < min ( ( int ) s . size ( ) , ( int ) t . size ( ) ) ; ++ i ) {
		if ( s [ i ] < t [ i ] ) return 1 ;
		if ( t [ i ] < s [ i ] ) return 0 ; 
	}
	return ( int ) s . size ( ) < ( int ) t . size ( ) ; 
}/*

void inc ( string &t ) {
	while ( 1 ) {
		if ( t . empty ( ) ) break ;
		char save = t . back ( ) ;
		t . pop_back ( ) ;
		if ( kam ( s , t ) ) ;
		else  {
			t += save ;
			break ; 
		}
	}
}
*/
void update ( string chi ) {
	//if ( !kam ( s , chi ) ) return  ; 
	if ( !chk ( chi ) )
		return ;
	//	inc ( chi ) ; 
	if ( res . empty ( ) ) res = chi ;
	if ( kam ( chi , res ) )
		res = chi ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s ;
	if ( ( int ) s . size ( ) < 26 ) {
		for ( auto x : s )
			seen [ x - 'a' ] = 1 ;
		for ( int c = 0 ; c < 26 ; ++ c ) {
			if ( !seen [ c ] ) {
				cout << s << ( char ) ( c + 'a' ) << endl ;
				return 0 ; 
			}
		}
		return 0 ; 
	}
	else {
		int n = ( int ) s . size ( ) ; 
		for ( int i = n - 1 ; ~i ; --i ) {
			for ( int c = ( int ) ( s [ i ] - 'a' ) + 1 ; c < 26 ; ++ c ) { 
				string cur = "" ;
				for ( int j = 0 ; j < i ; ++ j )
					cur += s [ j ] ;
				cur += ( char ) ( c + 'a' ) ;
				if ( c >= 0 && c < 26 ) 
					update ( cur ) ;
			}
			seen [ s [ i ] - 'a' ] = 1 ; 
		}
	}
	/*
	for ( int c = 0 ; c < 26 ; ++ c ) {
		string cur = "" ;
		cur += s ;
		cur += ( char ) ( c + 'a' ) ; 
		update ( cur ) ; 
	}
	s . pop_back ( ) ;
	int n = ( int ) s . size ( ) ; 
	for ( int i = 0 ; i < n ; ++ i ) {
		for ( int c = 0 ; c < 26 ; ++ c ) {
			char save = s [ i ] ;
			string cur = "" ; 
			s [ i ] = ( char ) ( c + 'a' ) ;
			cur = s ;
			s [ i ] = save ; 
			update ( cur ) ; 
		}
	}
	for ( int i = 0 ; i < n ; ++ i ) {
		string pre = "" , suf = "" ; 
		for ( int c = 0 ; c < 26 ; ++ c ) {
			pre = "" , suf = "" ;
			for ( int j = 0 ; j < i ; ++ j )
				pre += s [ j ] ;
			for ( int j = i ; j < n ; ++ j )
				suf += s [ j ] ; 
			pre += ( char ) ( c + 'a' ) ;
			pre += suf ;
			update ( pre ) ; 
		}
	}
	*/
	if ( res . empty ( ) ) res = "-1" ; 
	cout << res << '\n' ; 
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	if a * b % 2 != 0 {
		fmt.Println("Yes")
	} else if a * b * 2 % 2 != 0 {
		fmt.Println("Yes")
	} else if a * b * 3 % 2 != 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 512
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    input! {
        n: usize,
        s: chars
    };
    assert!(s.len() == 2*n);

    let mut t = vec![0i64; 2*n];
    let mut f = 0;
    let mut isok = true;
    for i in 0..2*n {
        if s[i] == 'B' {
            if f % 2 == 0 {
                f += 1;
            } else {
                f -= 1;
                t[i] = 1;
            }
        } else {
            if f % 2 == 0 {
                f -= 1;
                t[i] = 1;
            } else {
                f += 1;
            }
        }
        if f < 0 {
            isok = false;
        }
    }
    if f != 0 {
        isok = false;
    }
    if isok {
        let mut ans = 1i64;
        let mut w = 0i64;
        for i in (0..2*n).rev() {
            if t[i] == 1 {
                w += 1;
            } else {
                ans *= w;
                ans %= MOD;
                w -= 1;
            }
        }
        for i in 1..n+1 {
            ans *= i as i64;
            ans %= MOD;
        }
        println!("{}", ans);
    } else {
        println!("0");
    }
}


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

#define int long long int 


int32_t main()
{
    int n;
    cin>>n;
    string str;
    cin>>str;
    int w,e;
    w=e=0;
    for(int i=1;i<str.size();i++)
    {
        if(str[i]=='E')
        e++;
    }
     int ans=INT_MAX;
     for(int i=0;i<n;i++)
     {
         ans=min(ans,w+e);
         if(i==n-1)
         break;
         if(str[i]=='W')w++;
         if(str[i+1]=='E')e--;
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 3904
n, k = [int(i) for i in input().split()]
cnt = n
cnt_ = [0] * n
for _ in range(k):
  d = int(input())
  a = [int(i) for i in input().split()]
  for j in a:
    if cnt_[j - 1] == 0:
      cnt -= 1
      cnt_[j - 1] = 1
print(cnt)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,m;

int main(){
	cin>>n>>m;
  ll tot=m*1900+(n-m)*100;
  cout<<tot*pow(2,m)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#include<cfenv>
#include<cmath>
#define MAX_N pow(10,6)
#define MAX_M pow(10,6)
#define INF pow(10,6)
#define REP(i,n) for(long long i=0;i<n;i++)
typedef long long ll;
using namespace std;
vector<ll>h(MAX_N);
vector<bool>seen(MAX_N);
vector<vector<ll>>miti(MAX_N,vector<ll>(2));
using Graph = vector<vector<int>>;
Graph G(MAX_N);
ll ans=0;

int main(){
    ll n,m;
    cin>>n>>m;
    REP(i,n){
        cin>>h[i];
    }
    REP(i,m){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        G[b].push_back(a);
        G[a].push_back(b);
    }

    bool aaa=true;
    REP(i,n){
        aaa=true;
        for (auto next_v : G[i]) { 
            
            if(h[i]>h[next_v]){

            }else{
                aaa=false;
                break;
            }
        }
        if(aaa){
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 92224
import sys
sys.setrecursionlimit(10**7)
 
n=int(input())
l=[list(input()) for i in range(n)]
connection=[[] for i in range(n)]
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      connection[i].append(j)
 
colors = [0]*n
def dfs(v,color):
    colors[v] = color
    for to in connection[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True
 
def is_bipartite():
    return dfs(0,1)
if is_bipartite()==0:
  print(-1)
  sys.exit()
 
 
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 or visitct!=n:
    ct+=1
    for i in range(len(next)):
      distance[next[i]]=ct
      visited[next[i]]=1
      visitct+=1
      for j in range(len(connection[next[i]])):
        if visited[connection[next[i]][j]]==-1:
          next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

ans=[]
for i in range(n):
  ans.append(max(bfs(i)))
print(max(ans)+1)

Measured memory_bytes: 45248
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> 
using namespace std;
#define ll long long
int main() 
{
    ll n, judge = 0;
    cin >> n;
    vector<ll> d(n), e(n), equal(n, 0);
    for(ll i = 0; i < n; i++) {
        cin >> d.at(i) >> e.at(i);
        if(d.at(i) == e.at(i)) {
            equal.at(i) = 1;
        }
    }

    for(ll i = 0; i < n - 2; i++) {
        if(((equal.at(i) == 1) && (equal.at(i + 1) == 1)) && (equal.at(i + 2) == 1)) {
            judge = 1;
        }
    }

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

Measured memory_bytes: 3632
n = int(input())
A = list(map(int, input().split()))
B = A[::-1]
S = [0] * n
S[0] = A[0]
T = [0] * n
T[0] = B[0]
ans = float('inf')
for i in range(1, n):
    S[i] = S[i - 1] + A[i]
    T[i] = T[i - 1] + B[i]
T = T[::-1]
ans = 2020202020 + 1
for i in range(n):
    diff = abs(S[i] - T[i] - A[i])
    ans = min(ans, diff)
print(ans)

Measured memory_bytes: 34028
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  vector<ll> A(n);
  for (auto& _a : A) cin >> _a;
  ll ans = 0;
  for (ll b = 0; b < 62; ++b) {
    ll n1 = 0;
    for (ll i = 0; i < n; ++i) {
      ll n0 = i - n1;
      if (A[i] >> b & 1) {
        ans += (n0 * ((1LL << b) % mod))%mod;
        ++n1;
      } else {
        ans += (n1 * ((1LL << b) % mod))%mod;
      }
      ans %= mod;
    }
  }
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 5516
import numpy as np
import bisect

N, K = map(int, input().split())
x_np = np.array(list(map(int, input().split())))

idx0 = bisect.bisect_left(x_np, 0)
right_cost = x_np[idx0:]
right_cost = np.append(np.zeros(1), right_cost)


if idx0 > 0:
    left_cost = np.zeros(1)
    left_cost = np.append(left_cost, -x_np[idx0-1::-1])

    res = 10**16
    iter_s = max(0, K - (N-idx0))
    iter_e = min(K, idx0)

    if iter_s == 0:
        res = min(res, right_cost[K])
    if iter_e == K:
        res = min(res, left_cost[K])

    for i in range(max(1, iter_s), min(K, iter_e+1)):
        res = min(res, left_cost[i]*2 + right_cost[K-i], left_cost[i] + right_cost[K-i]*2)

    print(int(res))
else:
    print(int(right_cost[K]))



Measured memory_bytes: 23072
S = input()
N = len(S)
S_1 = S[0:int((N - 1 ) / 2)]
S_2 = S[int((N + 3 ) / 2 -1):N]
if S == S[::-1] and S_1 == S_1[::-1] and S_2 == S_2[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
// Abu Hurayra (HurayraIIT)
// IIT, Jahangirnagar University

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long LL;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio(0);  cin.tie(0);
#define sz(a) int((a).size())
#define space " "
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define pi acos(-1.0)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define MOD 1000000007
#define PRECISION(x) cout << fixed << setprecision(x);
#define rep(i,a,n) for(int ( i ) = ( a ) ;( i ) <( n );( i )++)

LL dig ( LL n )
{
    LL cnt = 0 ;
    while(n)
    {
        cnt+=n%10;
        n /= 10 ;
    }
    return cnt ;
}
int main()
{
    fast_io
    
    LL n ;
    cin>> n ;
    if(n%dig(n)==0) cout << "Yes\n";
    else cout << "No\n";

    
    
    return 0;
}


 

Measured memory_bytes: 3584