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

int main() {
	int n;
	cin>>n;
	string s;
	unordered_set <string> set;
	while(n--)
	{
		cin>>s;
		set.insert(s);
	}
	unordered_set <string> :: iterator ptr;
	int count=0;
	for(ptr = set.begin();ptr != set.end();ptr++)
	count++;
	
	cout<<count;
	return 0;
}


Measured memory_bytes: 17656
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    colors = [-1] *(N+1)
    g = [[] for i in range(N+1)]
    for i in range(N-1):
        g[u[i]].append([v[i], w[i]])
        g[v[i]].append([u[i], w[i]])

    # print(g)

    from collections import deque
    d = deque()
    colors[1] = 0
    d.append(1)
    while len(d) > 0:
        # print("d:"+d)
        n = d.popleft()
        for V, W in g[n]:
            if colors[V] != -1:
                continue
            d.append(V)
            if W%2 == 0:
                colors[V] = colors[n]
            else:
                colors[V] = int(not colors[n])
    
    for i in range(1, N+1):
        print(colors[i])
            

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 47780
#include <iostream>

int main(int argc, const char * argv[]) {
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a < b && b < c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

vector<int> adj[100005];
int dp[100005];

void solve(int v) {
	if (dp[v] != 0) {
		return;
	}
	dp[v] = 1;
	for (int u : adj[v]) {
		solve(u);
		dp[v] = max(dp[v], dp[u] + 1);
	}
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		adj[x].push_back(y);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		solve(i);
		ans = max(ans, dp[i]);
	}
	printf("%d", ans - 1);
}

Measured memory_bytes: 8192
#include <stdio.h>

int main(void) {

int S ;
int h,m,s;
scanf("%d" , & S);

h = S/3600;
m = (S-h*3600)/60;
s = S-h*3600-m*60;

	printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

const long long MOD = (long long)1e9+7;

int main(){
	long long N,K;
	cin >> N >> K;
	vector<long long> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	long long ans=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A.at(i)>A.at(j))	ans++;
			ans%=MOD;
		}
	}
	long long xx=0;
	sort(A.begin(),A.end(),greater<long long>());
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(A.at(i)>A.at(j))	xx++;
			xx%=MOD;
		}
	}
	long long aa=(K*(K-1))/2;
	aa%=MOD;
	xx*=aa;
	xx%=MOD;
	ans*=K;
	ans%=MOD;
	ans+=xx;
	ans%=MOD;
	cout << ans << endl;

	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

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

string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		cout << 'x';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;

int a[200010];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; ++i){
        int an;
        cin >> an;
        a[an]++;
    }

    for(int i = 1; i <= n; ++i){
        println(a[i]);
    }
}

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

#define ll long long
#define ar array

const int mxH=18, mxN=1<<mxH, M=1e9+7;
int h, n, a[mxN/2], fl[mxN], fr[mxN];
ll ans, iv[mxN], w[mxN];

void dfs1(int u=1, int p=0) {
	if(p)
		w[u]=w[p]*u%M;
	else
		w[u]=1;
	fl[u]=fr[u]=u;
	while(fl[u]<n/2) {
		fl[u]=fl[u]*2;
		fr[u]=fr[u]*2+1;
	}
	if(u<n/2) {
		dfs1(2*u, u);
		dfs1(2*u+1, u);
	}
}

vector<ar<int, 2>> lv;

ll dfs3(int l1, int r1, int u=1, int p=0, ll fix=1) {
	if(u>=n/2||l1>=r1)
		return 0;
	ll fix2=fix*(1+M-(ll)u*p%M)%M, ans=0, s=0;
	for(int i=l1; i<r1; ++i) {
		ans=(ans+w[lv[i][0]+n/2]*w[lv[i][1]+n/2]%M*s)%M;
		s=(s+w[lv[i][0]+n/2]*w[lv[i][1]+n/2])%M;
	}
	ans=ans*fix2%M;
	int m1=l1;
	while(m1<r1&&lv[m1][0]<=fr[2*u]-n/2)
		++m1;
	ans+=dfs3(l1, m1, 2*u, u, fix*iv[2*u]%M*iv[u]%M);
	ans+=dfs3(m1, r1, 2*u+1, u, fix*iv[2*u+1]%M*iv[u]%M);
	return ans%M;
}

void dfs2(int u=1, int p=0, ll fix=1) {
	if(u>=n/2)
		return;
	ll fix2=fix*(1+M-(ll)u*p%M)%M;
	//(a[i], i) for i in [fl[u], fr[u]]-n/2
	for(int i=fl[u]-n/2; i<=fr[u]-n/2; ++i)
		lv.push_back({a[i], i});
	sort(lv.begin(), lv.end());
	ans=(ans+fix2*dfs3(0, lv.size()))%M;
	lv.clear();
	dfs2(2*u, u, fix*iv[2*u]%M*iv[u]%M);
	dfs2(2*u+1, u, fix*iv[2*u+1]%M*iv[u]%M);
}

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

	cin >> h;
	n=1<<h;
	for(int i=0; i<n/2; ++i)
		cin >> a[i], --a[i];
	iv[1]=1;
	for(int i=2; i<n; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	dfs1();
	dfs2();
	cout << ans;
}

Measured memory_bytes: 10916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	string s; cin >> s;
	int N = s.size();
	VV<int> dp(N+1,V<int>(4,-1));
	rep(i,N){
		if(i==0){
			rep1(x,3) if(x<=N) dp[x][x] = 1;
			continue;
		}
		rep1(x,3) if(dp[i][x] != -1){
			rep1(y,3) if(i+y<=N && s.substr(i-x,x) != s.substr(i,y)){
				chmax(dp[i+y][y],dp[i][x]+1);
			}
		}
	}
	cout << max({dp[N][1],dp[N][2],dp[N][3]}) << endl;
}


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

int main() {
  int N, a, ans = 1, minA=100000, maxA=0; cin >> N;
  vector<int> A(100000, 0);
  for (int i = 0; i<N; i++) {
    cin >> a;
    A[a]++;
    minA = min(minA, a);
    maxA = max(maxA, a);
  }
  for (int i = 0; i<N-2; i++) ans = max(ans, A[i]+A[i+1]+A[i+2]);
  cout << ans << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);







int main() {


    ll nn;
    string ss;
    cin>>nn>>ss;
    int ans=0;

   for(int l=0;l<nn;l++) {
       string s=ss.substr(l);
       int n=s.size();

       int ret[n];
       rep(i, n)ret[i] = 0;
       ret[0] = n;
       int i = 1, j = 0;
       while (i < n) {
           while (i + j < n && s[j] == s[i + j])
               ++j;
           ret[i] = j;
           if (j == 0) {
               ++i;
               continue;
           }
           int k = 1;
           while (i + k < n && k + ret[k] < j) {
               ret[i + k] = ret[k];
               ++k;
           }
           i += k;
           j -= k;
       }

      for(int i=1;i<n;i++){
          // cout << ret[i] <<" ";
           int left=i;
           int right=n-(i);
           int small = min(left,right);
           int k = min(small,ret[i]);
           ans=max(ans,k);
       }
     //  cout<<endl;

   }
   cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi pair<int,int>
using namespace std;
long long n,m;
string s;
int k;
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<k;i++)
	{
		if(i%2==0)
		{
			if(n%2==1)
			n--;
			m+=n/2;
			n/=2;
		}
		else
		{
			if(m%2==1)
			m--;
			n+=m/2;
			m/=2;
		}
	}
	cout<<n<<" "<<m;
	return 0;
} 

Measured memory_bytes: 256
(n, k) = [int(s) for s in input().split()]

data = [[0 for i in range(k)] for j in range(n)]

for i in range(0, k):
    d = int(input())
    a = [int(s) for s in input().split()]

    for m in a:
        data[m - 1][i] = 1

dd = []

for d in data:
    dd.append(sum(d))

ans = 0

for ddd in dd:
    if ddd == 0:
        ans += 1

print(ans)



Measured memory_bytes: 9240
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


signed main()
{
	std::cin.sync_with_stdio(false);
	std::cin.tie(0);

	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--; t--;
	vector<vector<array<int, 3>>>graph(n);
	rep(i, m) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		graph[u].push_back({ v,a,b });
		graph[v].push_back({ u,a,b });
	}

	vector<int>yen(n, -1);
	priority_queue<pair<int,int>, vector<pair<int, int>>, greater<pair<int,int>>>dijkstra;
	dijkstra.push(make_pair(0,s));
	while (!dijkstra.empty()) {
		pair<int, int> x = dijkstra.top();
		dijkstra.pop();
		if (yen[x.second] != -1)continue;
		yen[x.second] = x.first;
		for (auto y : graph[x.second]) {
			dijkstra.push(make_pair(x.first + y[1], y[0]));
		}
	}

	vector<int>snuuk(n, -1);
	dijkstra.push(make_pair(0, t));
	while (!dijkstra.empty()) {
		pair<int, int> x = dijkstra.top();
		dijkstra.pop();
		if (snuuk[x.second] != -1)continue;
		snuuk[x.second] = x.first;
		for (auto y : graph[x.second]) {
			dijkstra.push(make_pair(x.first + y[2], y[0]));
		}
	}

	int money = 1;
	rep(i, 15)money *= 10;
	vector<int>goalmoney(n, money);
	rep(i, n)goalmoney[i] -= yen[i] + snuuk[i];

	for (int i = n - 2; i >= 0; --i)goalmoney[i] = max(goalmoney[i], goalmoney[i + 1]);

	rep(i, n)cout << goalmoney[i] << endl;


	return 0;
}

Measured memory_bytes: 13936
#include <bits/stdc++.h>
using namespace std;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    string s;
    cin>>s;
    bool flag = true;
    FOR(i,0,(s.size()-1)/2) {
        if (s[i] != s[(s.size()-1)/2-1-i]) {
            flag = false;
        }
    }
    FOR(i,(s.size()+3)/2,s.size()) {
        if (s[i] != s[s.size()-1-i]) {
            flag = false;
        }
    }
    Yes(flag);

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<math.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<time.h>
#include<stdio.h>
using namespace std;
const int N=1100;

int main()
{
    int x;
    cin>>x;
    if(x>=400&&x<=599){
        cout<<8<<endl;
    }
    else if(x>=600&&x<=799){
        cout<<7<<endl;
    }
    else if(x>=800&&x<=999){
        cout<<6<<endl;
    }
    else if(x>=1000&&x<=1199){
        cout<<5<<endl;
    }
    else if(x>=1200&&x<=1399){
        cout<<4<<endl;
    }
    else if(x>=1400&&x<=1599){
        cout<<3<<endl;
    }
    else if(x>=1600&&x<=1799){
        cout<<2<<endl;
    }
    else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
using namespace std;
#include <string>
char A[55][55];
char B[55][55];
int main(void)
{
    int n,m;
    cin>> n>>m;
    for (int i=0;i<n ;i++ )
    {
        scanf("%s",A[i]);
    }
    for (int j=0;j<m ;j++ )
    {
        scanf("%s",B[j]);
    }
    bool flag ;
    bool flag2;
    for (int i =0;i<=n-m ;i++ )
    {
        for(int j=0;j<=n-m;j++)
        {
            flag = true;
            flag2 = false;
            for (int p=0;p<m ;p++ )
            {
                for (int q=0;q<m ;q++ )
                {
                    if(A[i+p][j+q]==B[p][q])
                    {
                        flag2= true;
                    }
                    else
                    {
                        flag2 = false;
                    }
                    flag= flag&& flag2;
                }
            }
            if(flag==true)
            {
                cout << "Yes"<< endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

template<class T>
struct Combination{
	vector<T> fact,factinv;
	Combination(int n) : fact(n + 1),factinv(n + 1){
		fact[0] = 1;
		for(int i = 1;i <= n;i++) fact[i] = fact[i - 1] * T(i);
		factinv[n] = ~fact[n];
		for(int i = n;i >= 1;i--) factinv[i - 1] = factinv[i] * T(i);
	}
	T nCr(int n,int r){
		if(r < 0 || n < r) return 0;
		return fact[n] * factinv[r] * factinv[n - r];
	}
};

signed main(){
	Combination<modint<MOD>> comb(100010);
	int n,d[100010],cnt[100010] = {},mad = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> d[i];
		chmax(mad,d[i]);
		cnt[d[i]]++;
		if((!i && d[i]) || (i && !d[i])){
			cout << 0 << endl;
			return 0;
		}
	}
	modint<MOD> ans = 1;
	for(int i = 1;i <= mad;i++){
		ans *= modint<MOD>(cnt[i - 1]).pow(cnt[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
N = int(input())
A = [0] * N
data = [[] for _ in range(N)]
for i in range(N):
    A[i] = int(input())
    for j in range(A[i]):
        new = list(map(int,input().split()))
        new[0] -= 1
        data[i].append(new)

m = -1
for n in range(2**N):
    nn = n
    cur = [0] * N
    for i in range(N):
        cur[i] = nn % 2
        nn = nn // 2
    s = sum(cur)
    if s <= m:
        continue
    det = 1
    for i in range(N):
        if cur[i] == 0:
            continue
        for j in range(A[i]):
            if data[i][j][1] != cur[data[i][j][0]]:
                det = 0
                break
        if det == 0:
            break
    if det == 1:
        m = s
    #print(cur,s,det)

#print(data)
print(m)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a, b, x[110000], res;
int main(void){
    // Your code here!
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 1; i < n; i++) {
        ll far = a * (x[i] - x[i - 1]);
        res += (far < b ? far : b);
    }
    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef set<int> si;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a);
#define nl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (sizeof(a) / sizeof(a[0]))
#define INF 1000000007
#define mp(a, b) make_pair(a, b)
#define FILL(a, v, b) memset(a,v,(b) * sizeof(a[0]))

template<typename T>
void print_array(T* arr, int num) {
	FOR(i, 0, num) cout << arr[i] << ' ';
	cout << nl;
}

template<typename T> 
void print_vector(vector<T> vec) {
	FOR(i,0,vec.size()) cout << vec[i] << ' ';
	cout << nl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
//	freopen("test.txt", "r", stdin);
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	FOR(i,sy,ty) cout << "U";
	FOR(i,sx,tx) cout << "R";
	FOR(i,sy,ty) cout << "D";
	FOR(i,sx,tx) cout << "L";
	cout << "L";
	FOR(i,sy,ty + 1) cout << "U";
	FOR(i,sx,tx + 1) cout << "R";
	cout << "D" << "R";
	FOR(i,sy,ty + 1) cout << "D";
	FOR(i,sx,tx + 1) cout << "L";
	cout << "U";
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    double v[51];
    int i, j, t;
    
    cin >> n;
    for(i=0; i<n; i++) cin >> v[i];
    
    for(i=0; i<n-1; i++){
        for(j=i+1; j<n; j++){
            if(v[i] > v[j]){
                t = v[i];
                v[i] = v[j];
                v[j] = t;
            }
        }
    }
    
    for(i=0; i<n-1; i++){
        v[i+1] = (v[i] + v[i+1])*0.5;
    }
    
    cout << v[n-1];
    
    return 0;
}







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

#define x first
#define y second

int magic (pair < int, int > a, pair < int, int > b) {
    return abs(a.x - b.x) + abs(a.y - b.y);
}

signed main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int h, w, d;
    cin >> h >> w >> d;
    vector < pair < int, int > > pos(h * w + 1);
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            int a;
            cin >> a;
            pos[a] = make_pair(i, j);
        }
    }
    vector < vector < int > > pref(d);
    for (int i = 1; i <= d; ++i) {
        pref[i % d].push_back(0);
        pair < int, int > prv = pos[i];
        for (int j = i + d; j <= h * w; j += d) {
            pref[i % d].push_back(pref[i % d].back() + magic(prv, pos[j]));
            prv = pos[j];
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << pref[r % d][r / d - int(r % d == 0)] - pref[r % d][l / d - int(l % d == 0)] << '\n';
    }
}


Measured memory_bytes: 6144
N,M = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(M)]
cnt = (N+1)*[0]
ids = {}

for p,y in sorted(P,key=lambda x: x[1]):
	cnt[p] += 1
	ids[y] = "%06d%06d" % (p,cnt[p])

for _,y in P:
	print(ids[y])

Measured memory_bytes: 43844
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

x = INT()
arr = make_divisors(x)
for i, j in arr:
    for a in range(-1000, 1000):
        b = a - i
        if a ** 4 + (a ** 3) * b + (a ** 2) * (b ** 2) + a * (b ** 3) + b ** 4 == j:
            print(a, b)
            exit()


Measured memory_bytes: 69308
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int ans=0;
		for(int i = 1;i<=s[0];i++) {
			for(int j = 22;j<=s[1];j++) {
				var t=j.ToString();
				if(t[0]=='1'||t[1]=='1'){continue;}
				if((t[0]-'0')*(t[1]-'0')==i){
					ans++;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main() {
    vector<char> re(6); //2*3=6マス
    for (int i = 0; i < 6;i++) {
        cin >> re.at(i);
    }
    puts(re.at(0) == re.at(5) && re.at(1) == re.at(4) && re.at(2) == re.at(3) ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int main()
{
	int n;
	cin >> n;
	vector< int > v(n);
	for(int i = 0 ; i < n ; i++){
		cin >> v[i];
		v[i]--;
	}
	int cur = 0 , cnt = 0;
	while(1){
		if(cur == 1){
			cout << cnt << endl;
			return 0;
		}
		if(cnt >= n)
			return cout << -1 , 0;
		cur = v[cur];
		cnt++;
	}
	return 0;
} 




Measured memory_bytes: 640
import static java.lang.Integer.parseInt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			for (int i = 0; i < n; i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				Quaternion qa, qb;
				qa = new Quaternion(parseInt(st.nextToken()),
						parseInt(st.nextToken()), parseInt(st.nextToken()),
						parseInt(st.nextToken()));
				qb = new Quaternion(parseInt(st.nextToken()),
						parseInt(st.nextToken()), parseInt(st.nextToken()),
						parseInt(st.nextToken()));
				System.out.println(qa.Multi(qb).toString());
			}

		}

	}
}

class Quaternion {

	int n, i, j, k;

	public Quaternion(int n, int i, int j, int k) {
		this.n = n;
		this.i = i;
		this.j = j;
		this.k = k;
	}

	public Quaternion Plus(Quaternion b) {
		return new Quaternion(n + b.n, i + b.i, j + b.j, k + b.k);
	}

	public Quaternion Multi(Quaternion b) {

		int _n, _i, _j, _k;
		_n = n * b.n - i * b.i - j * b.j - k * b.k;
		_i = n * b.i + i * b.n + j * b.k - k * b.j;
		_j = n * b.j - i * b.k + j * b.n + k * b.i;
		_k = n * b.k + i * b.j - j * b.i + k * b.n;
		return new Quaternion(_n, _i, _j, _k);
	}

	public String toString() {
		return new String(n + " " + i + " " + j + " " + k);
	}

}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 5005;



int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    //S
    //    is Sunny, Cloudy, or Rainy.

    map<string, string> q;
    q.insert({ "Sunny", "Cloudy" });
    q.insert({ "Cloudy", "Rainy" });
    q.insert({ "Rainy", "Sunny" });

    string s;
    cin >> s;
    cout << q[s] << endl;

    return 0;
}


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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    YES(C % gcd(A, B) == 0);
}



Measured memory_bytes: 256
N,K =input().split()
listA=list(map(int,input().split()))


for i in range(100001):
    if i >= int(N):
        ans=str(i)
        num=0
        for j in range(len(ans)):
            if int(ans[j]) not in listA:
                num += 1

            if num == len(ans):
                print(i)
                exit()

Measured memory_bytes: 3060
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long x;

int main(){
    scanf("%ld", &x);
    if(x % 100 > x / 100 * 5){
        printf("0\n");
    }else{
        printf("1\n");
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	String s = sc.next();
      	long count = 0;
      	long rc = 0;
      	long gc = 0;
      	long bc = 0;
      	int istack;
      
      	Map cMap = new HashMap<Character,Integer>() {
          {
        	put('R',1);
        	put('G',10);
        	put('B',100);
          }
        };    	
      
      	for(int i = 0;i < n;i++){
        	if(s.charAt(i) == 'R') rc++;
          	else if(s.charAt(i) == 'G') gc++;
          	else if(s.charAt(i) == 'B') bc++;
        }
 
      	for(int i = 0;i < n;i++){
          for(int j = i+1;j < n;j++){
            if(j+(j-i) < n){
              istack = (int)cMap.get(s.charAt(i))
                      +(int)cMap.get(s.charAt(j))
                      +(int)cMap.get(s.charAt(j+(j-i)));
              if(istack == 111) count++;
            }
          }
        }
      
      	System.out.println(rc*gc*bc-count);
	}
}


Measured memory_bytes: 38420
import heapq as hq
x,y,z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
abc = [(-(A[0]+B[0]+C[0]), 0,0,0)]
used = set((0,0,0))
while K > 0:
    K -= 1
    p,i,j,k = hq.heappop(abc)
    print(-p)
    for a,b,c in [(i+1,j,k), (i,j+1,k), (i,j,k+1)]:
        if a < x and b < y and c < z and (a,b,c) not in used:
            used.add((a,b,c))
            hq.heappush(abc, (-(A[a]+B[b]+C[c]), a,b,c))


Measured memory_bytes: 10332
using System;

namespace AOJ
{
    class ListOfTop3Hills
    {
        public static void Main(string[] args)
        {
            int[] data = new int[10];
            for (int i = 1; i < 10; i++) { data[i] = -1; }

            for (int i = 0; i < 10; i++)
            {
                int value = int.Parse(Console.ReadLine().Trim());
                int pos = i - 1;
                while (pos >= 0 && value > data[pos])
                {
                    data[pos + 1] = data[pos];
                    pos--;
                }
                data[pos + 1] = value;
            }

            for (int i = 0; i <= 2; i++) { Console.WriteLine(data[i]); }
        }
    }
}

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

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

    int N;
    cin >> N;
    vector<int> v(N);
    for (int i=0;i<N;i++) cin >> v.at(i);

    int ans = -1;
    int max = 100010;
    int pointer = 0;

    for (int t=1;t<max;t++){
        if (v.at(pointer) == 2){
            ans = t;
            break;
        }
        pointer = v.at(pointer)-1;
    }
    cout << ans << endl;
}


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

#define INF 1.1e9
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

ll m,n;
const ll MOD=1e9+7;

ll calc(ll a, ll b) {
	ll res=1;
	if(b>0) {
		res=calc(a,b/2);
		if(b%2==0) res=(res*res)%MOD;
		else res=(((res*res)%MOD)*a)%MOD;
	}
	return res;
}

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

	cin>>m>>n;
	cout<<calc(m,n)<<endl;

	return 0;
}

Measured memory_bytes: 3176
#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>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    ll a[55][55];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            scanf("%lld", &a[i][j]);
        }
    }
    const ll MAX=1e9;
    mcf_graph<int, ll> g(2*n+2);
    int s=2*n, t=2*n+1;
    for(int i=0; i<n; i++){
        g.add_edge(s, i, k, 0);
        g.add_edge(i+n, t, k, 0);
    }
    g.add_edge(s, t, n*k, MAX);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            g.add_edge(i, j+n, 1, MAX-a[i][j]);
        }
    }
    printf("%lld\n", MAX*n*k-g.flow(s, t, n*k).second);
    auto ve=g.edges();
    string str[55];
    for(int i=0; i<n; i++) for(int j=0; j<n; j++) str[i]+='.';
    for(auto e:ve){
        if(e.from<n && n<=e.to && e.to<2*n && e.flow){
            str[e.from][e.to-n]='X';
        }
    }
    for(int i=0; i<n; i++) cout<<str[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4156
#include <cstring>
#include <string>
#include <vector>

using namespace std;

#define MAXN 200005

vector<int> L[MAXN];
int v[MAXN], s[MAXN], e[MAXN], dx[MAXN], ans[MAXN];

int dfs(int cur, int parent, int p){
  v[p] = cur;
  s[cur] = p;
  ++p;

  int cur_sz = 1;

  for(int i = L[cur].size() - 1;i >= 0;--i){
    int v = L[cur][i];

    if(v != parent){
      int sz = dfs(v, cur, p);
      p += sz;
      cur_sz += sz;
    }
  }

  e[cur] = p;
  return cur_sz;
}

int main(){
  int N,Q;
  scanf("%d %d", &N,&Q);

  for(int i = 0,a,b;i < N - 1;++i){
    scanf("%d %d", &a, &b);
    --a; --b;
    L[a].push_back(b);
    L[b].push_back(a);
  }

  dfs(0, -1, 0);

  memset(dx, 0, sizeof dx);

  int p, x;

  while(Q--){
    scanf("%d %d", &p, &x);
    --p;
    dx[ s[p] ] += x;
    dx[ e[p] ] -= x;
  }

  int cur = 0;

  for(int i = 0;i < N;++i){
    cur += dx[i];
    ans[ v[i] ] = cur;
  }

  for(int i = 0;i < N;++i){
    printf("%d ", ans[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 32896
import sys
S = input()
N = len(S)

for i in range(N // 2):
    if S[i] == S[i * (-1) - 1]:
        continue
    else:
        print("No")
        sys.exit()
for i in range(N // 4):
    index = int(i * (-1) - 1 - (N-1)/2 - 1)
    if S[i] == S[index]:
        continue
    else:
        print("No")
        sys.exit()
for i in range(N // 4):
    index = int(i + (N+3)/2-1)
    if S[index] == S[i * (-1) - 1]:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define MAX_H 305
#define MAX_W 305

int H, W;
char C[MAX_H][MAX_W];

void input()
{
  cin >> H >> W;
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      cin >> C[i][j];
    }
  }
}

LL dp[MAX_H][MAX_H];
LL memo[MAX_H][MAX_W][MAX_W];

int main()
{
  input();

  for(int x = 0; x < W - 1; x++){
	   for (size_t y = 0; y <= H; y++) {
	     memo[x][y][H] = memo[x][H][y] = 0;
	   }
     for (int y1 = H-1; 0 <= y1; y1--) {
       for (int y2 = H-1; 0 <= y2; y2--) {
         memo[x][y1][y2] = memo[x][y1+1][y2+1] + (C[H-1-y1][x] == C[H-1-y2][x+1]);
       }
     }
  }

  LL ans = 0;
  for (int x = 0; x < W-1; x++) {

    for (size_t i = 0; i <= H; i++) {
      for (size_t j = 0; j <= H; j++) {
        dp[i][j] = 1145141919;
      }
    }

    dp[0][0] = 0;
    for (int y1 = 0; y1 <= H; y1++) {
      for (int y2 = 0; y2 <= H; y2++) {
        if(y1 + 1 <= H){
          dp[y1 + 1][y2] = min(dp[y1 + 1][y2], dp[y1][y2] + memo[x][y1][y2]);
        }
        if(y2 + 1 <= H){
          dp[y1][y2 + 1] = min(dp[y1][y2 + 1], dp[y1][y2] + memo[x][y1][y2]);
        }
      }
    }

    ans += dp[H][H];

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 216832
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> field(H);
  REP(h,H) {
    string s;
    cin >> s;
    field[h] = s;
  }

  REP(h,H){
    REP(w,W){
      if(field[h][w] == '.') continue;
      bool ok = false;
      REP(dir,4){
        int nh = h+dx[dir];
        int nw = w+dy[dir];
        //範囲外スキップ
        if(nh < 0 || nw < 0) continue;
        if(nh >= H || nw >= W) continue;
        //
        if(field[nh][nw] == '#'){
          ok = true;
          break;
        }
      }
      if(!ok){
        cout << "No" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 3608
#include <iostream>
#include "string.h"
#include <algorithm>
#include <vector>
#include <stdio.h>
#include "math.h"
#include <queue>
using namespace std;

int a[100010];
int b[100010];

int main() {

    int n;
    cin>>n;
    for (int i=0; i<n; i++) scanf("%d", a+i);
    sort(a, a+n);

    int l = 1;
    int r = n-1;
    deque<int> q;
    q.push_back(a[0]);
    for (int i=1; i<n; i++) {

        int x, y, z, w;
        x = abs(q.back() - a[l]);
        y = abs(q.back() - a[r]);
        z = abs(q.front() - a[l]);
        w = abs(q.front() - a[r]);

        if (x >= y && x >= z && x >= w) {
            q.push_back(a[l++]);
        }
        else if (x <= y && y >= z && y >= w) {
            q.push_back(a[r--]);
        }
        else if (x <= z && y <= z && z >= w) {
            q.push_front(a[l++]);
        }
        else {
            q.push_front(a[r--]);
        }

    }

    int i = 0;
    while (!q.empty()) {
        b[i++] = q.front();
        q.pop_front();
    }

    long long sum = 0;
    for (int i=1; i<n; i++) sum += abs(b[i] - b[i-1]);

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

long p=pow(10,9)+7;

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  int x,y;
  cin>>x>>y;
  if((2*x-y)%3!=0||(2*y-x)%3!=0||2*y<x||2*x<y){
    cout<<0;
    return 0;
  }
  int a=(2*x-y)/3,b=(2*y-x)/3;
  long sums=1,sumi=1;
  for (int i = a+1; i <= a+b; i++) {
    sums*=i;
    sums%=p;
  }
  for (int i = 2; i <= b; i++) {
    sumi*=i;
    sumi%=p;
  }
  cout<<(sums*modinv(sumi, p))%p;
  
}

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

#define maxn 100005
#define INF 0x3f3f3f3f
#define MINF 0x7fffffffffffffff
#define mod 1000000007
#define PI 3.14159365358
typedef long long ll;
using namespace std;

void slove()
{
	double n;
	cin >> n;
	cout.setf(ios::fixed);
	cout << setprecision(8) << 2 * n * PI;
}

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

	slove();

	return 0;
}

Measured memory_bytes: 3804