akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
char s[101010];
int n,suma[101010],sumb[101010],lasa[3],lasb[3]/*,nxta[101010],nxtb[101010]*/;
ll dp[101010];
vector<int> e[101010];
signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=0;
	for (int i=1;i<n;i++){
		if (s[i]==s[i+1]){
			flag=1;break;
		}
	}
	if (!flag){
		puts("1");return 0;
	}
	for (int i=1;i<=n;i++){
		suma[i]=suma[i-1],sumb[i]=sumb[i-1];
		if (s[i]=='a') suma[i]++;
		else sumb[i]++;
	}
	memset(lasa,-1,sizeof lasa);
	memset(lasb,-1,sizeof lasb);
	int i;
	for (i=n;~i;i--){
		int aa=(2+i+suma[i])%3,bb=(2+i+sumb[i])%3;
		if (~lasa[aa]) e[lasa[aa]].push_back(i);
		if (~lasb[bb]) e[lasb[bb]].push_back(i);
		lasa[(i+suma[i])%3]=i,lasb[(i+sumb[i])%3]=i;
	}
	dp[0]=1;
	for (i=1;i<=n;i++){
		for (int j:e[i]) dp[i]=(dp[i]+dp[j])%ljc;
	}
	ll _=0;
	for (i=1;i<=n;i++){
		if (!((n+suma[n]-(suma[i]+i)%3)%3)) _=(_+dp[i])%ljc;
	}
	cout<<_;
	return 0;
}



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

long long n, k, anssize = 0;
vector<long long> a, ans, memo;
map<long long, vector<long long> > mp;

void solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    mp[a[i]].push_back(i);
  }
  solve();
  for(int i = 0; i < ans.size(); ++i) {
    if(i != 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

void solve() {
  memo.resize(n);
  for(auto now : mp) {
    int nowsize = now.second.size();
    for(int i = 0; i < nowsize; ++i)
      memo[now.second[i]] = now.second[(i + 1) % nowsize];
  }
  long long allsize = 0, nowi = 0;
  while(1) {
    allsize +=
        1 + memo[nowi] - nowi + n * (memo[nowi] <= nowi);
    nowi = (memo[nowi] + 1) % n;
    if(nowi == 0) break;
  }
  k *= n;
  k %= allsize;
  while(k > 0) {
    if(1 + memo[nowi] - nowi + n * (memo[nowi] <= nowi) > k)
      break;
    k -= 1 + memo[nowi] - nowi + n * (memo[nowi] <= nowi);
    nowi = (memo[nowi] + 1) % n;
  }
  stack<long long> st;
  set<long long> ch;
  for(int i = 0; i < k; ++i) {
    if(ch.find(a[nowi]) == ch.end()) {
      st.push(a[nowi]);
      ch.insert(a[nowi]);
    }
    else {
      while(1) {
        long long tp = st.top();
        st.pop();
        ch.erase(tp);
        if(a[nowi] == tp) break;
      }
    }
    nowi = (nowi + 1) % n;
  }
  while(!st.empty()) {
    ans.push_back(st.top());
    st.pop();
  }
  reverse(ans.begin(), ans.end());
}

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

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> vec(N);
    for(int i = 0;i < N;i++)
        cin >> vec.at(i);
    sort(vec.begin(),vec.end());

    for(int i = 0;i < N;i++)
        X -= vec.at(i);

    int a = X/vec.at(0);

    cout << N + a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int i, sum[1000], a, MAX;
   for(i = 1; i <= 100; i++){
      sum[i] = 0;
   }
   while(scanf("%d", &a) != EOF){
      sum[a]++;
   }
   MAX = 0;
   for(i = 1; i <= 100; i++){
      if(sum[i] > MAX){
         MAX = sum[i];
      }
   }
   for(i = 1; i <= 100; i++){
      if(sum[i] == MAX){
         printf("%d\n", i);
      }
   }
   return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <string>
using namespace std;
void func() {
    string s;
    cin  >> s;
    int ans = 0;
    for (auto ch: s){
        ans += ch == '+' ? 1 : -1;
    }
    cout << ans << endl;
}

int main() {
    func();
    return 0;
}

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

int N, M, Q, ans;
int a[50], b[50], c[50], d[50];
int A[10];

void dfs(int depth, int now) {
  if (depth == N) {
    int tmp = 0;
    rep(i, Q) {
      if (A[b[i] - 1] - A[a[i] - 1] == c[i]) tmp += d[i];
    }
    ans = max(tmp, ans);
    return;
  }

  for (int i = now; i <= M; i++) {
    A[depth] = i;
    dfs(depth + 1, i);
  }
}

int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  A[0] = 1;
  dfs(1, 1);
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x;
    if (n>=b)
    {
        x = b-1;
    }
    else{
        x = n;
    }
    cout<<(floor(a*x/b)-floor(x/b)*a)<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif



    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> 

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

ss = {}

for i in range(1,n+1):
  s, p = input().split()
  p = int(p)
  if s in ss:
  	ss[s][p] = i
  else:
    ss[s] = {}
    ss[s][p] = i

for city in sorted(ss.keys()):
  for poi in sorted(ss[city].keys(),reverse=True):
    print(ss[city][poi])

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

int N;

int main(){
    int buf;
    cin >>N;
    map<int, int> stu;
    for(int i = 1; i<= N; i++){
        cin >> buf;
        stu[buf] = i;
    }
    for(int i = 1; i<= N; i++){
        cout << stu[i] << ' ';
    }
    cout << endl;

}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
const int N=100+10;
int n, b[N], c[N], p[N], vis[N], s=0;
inline void update( int x, int k )
{
	for ( int i=x; i<=n; i+=i&(-i) )
	  c[i]+=k;
}
inline int query( int x )
{
	int z=0;
	for ( int i=x; i>=1; i-=i&(-i) )
	  z+=c[i];
	return z;
}
int main()
{
	scanf( "%d", &n );
	for ( int i=1; i<=n; i++ )
	  scanf( "%d", &b[i] );
	for ( int i=1; i<=n; i++ )
	  for ( int j=n; j>=1; j-- )
	  {
	  	  if ( vis[j] ) continue; 
	      if ( j-query(j)==b[j] ) 
	      {
	      	  ++s;
	      	  p[n-i+1]=b[j];
	      	  vis[j]=1;
	      	  update( j, 1 );
	      	  break;
	      }
	  }
	if ( s<n ) { printf( "-1"); return 0; }
	for ( int i=1; i<=n; i++ )
	  printf( "%d\n", p[i] );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=3000;
int a[N],M,inv[N];
int rev(int x,int m=M){
    if(x==1)return 1;
    return (1-rev(m%x,x)*m)/x+m;
}
vector<int> mul(vector<int> p,int l){
    int n=p.size();
    p.pb(0);
    vector<int> res(n+1);
    res[0]=(-l*p[0])%M;
    for(int i=1;i<=n;++i)res[i]=(p[i-1]-p[i]*l)%M;
    forn(i,n+1)if(res[i]<0)res[i]+=M;
    return res;
}
vector<int> del(vector<int> b,int l){
    if(!l){b.erase(b.begin());return b;}
    l=M-l;
    int n=b.size()-1;
    vector<int> p(n);
    p[0]=(b[0]*inv[l])%M;
    for(int i=1;i<n;++i)p[i]=((b[i]-p[i-1])*inv[l])%M;
    forn(i,n)if(p[i]<0)p[i]+=M;
    return p;
}
int32_t main(){
    cin>>M;
    forn(i,M)cin>>a[i];
    vector<int> s={0,1};//x+0
    for(int i=1;i<M;++i){s=mul(s,i);inv[i]=rev(i);}
    vector<int> fun(M);
    forn(i,M){
        vector<int> cur=del(s,i);
        int bottom=1;
        forn(j,M)if(i^j)(bottom*=i-j)%=M;
        if(bottom<0)bottom+=M;
        int zhopa=(a[i]*inv[bottom])%M;
        forn(j,M)(fun[j]+=zhopa*cur[j])%=M;
    }
    for(int&i:fun)if(i<0)i+=M;
    for(int i:fun)cout<<i<<' ';
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 384
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                var right = numsS.Length;
                var left = 0;
                var mid = numsS.Length / 2;

                while (left < right)
                {
                    if (numsT[i] < numsS[mid])
                    {
                        right = mid;
                        mid = (right - left) / 2 + left;
                    }
                    else if (numsT[i] > numsS[mid])
                    {
                        left = mid + 1;
                        mid = (right - left) / 2 + left;
                    }
                    else
                    {
                        ans++;
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 18136
n = int(input())
x = list(map(int, input().split()))
ans = 10 ** 6 + 1
for i in range(1, 101):
    s = 0
    for j in range(n):
        s += (x[j] - i) * (x[j] - i)
    ans = min(ans, s)
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
  if i == n-1 and a[i] == n:
    ans += 1
  elif a[i] == i+1:
    ans += 1
    a[i], a[i+1] = a[i+1], a[i]
print(ans)

Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;


//素因数分解
map<ll,ll> prime_factor(ll n) {
  map<ll,ll> res;
  for(int i=2;i*i<=n;i++) {
    while(n%i==0) {
      res[i]++;
      n/=i;
    }
  }
  if(n!=1) {
    res[n]=1;
  }
  return res;
}

//繰り返し自乗法
ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

//階乗
vector<ll> tfact(1e7+1,-1);
ll fact(ll n) {
  if(tfact[n]<0) {
    if(n==0) {
      tfact[n]=1;
    }
    else {
      tfact[n]=fact(n-1)*n%mod;
    }
  }
  return tfact[n];
}

//nCk
ll comb(ll n, ll k) {
  return fact(n)*mpow(fact(k),mod-2)%mod*mpow(fact(n-k),mod-2)%mod;
}

int main() {
  ll n,m;
  cin >> n >> m;
  map<ll,ll> prime=prime_factor(m);
  ll ans=1;
  for(auto p:prime) {
    ans=ans*comb(p.second+n-1,n-1)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 81536
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){

    int n; cin >> n;
    int aary[n];
    int bary[n];
    int cary[n-1];
    rep(i,n) cin >> aary[i];
    rep(i,n) cin >> bary[i];
    rep(i,n-1) cin >> cary[i];

    int ans = 0;
    rep(i,n) ans += bary[i];

    rep(i,n-1)
    {
        if (aary[i]+1 == aary[i+1])
        {
            ans += cary[aary[i]-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); }

//?????????????????£?????°??????
Graph reverse(const Graph &g) {
	Graph rg(g.size());
	for (auto &es : g)
		for (auto &e : es)
			rg[e.d].emplace_back(e.d, e.s, e.w);
	return rg;
}

//?????£?????????????§£
//ret[u] = u ????±??????????????????£??????????????????????????????
vector<int> kosaraju(const Graph &g) {
	int n = g.size();
	Graph rg = reverse(g);
	vector<int> cc(n, -1);
	vector<int> post;
	function<void(int, int)> dfs_cc = [&](int u, int cc_id) {
		if (cc[u] != -1)return;
		cc[u] = cc_id;
		for (auto &e : g[u])
			dfs_cc(e.d, cc_id);
		post.emplace_back(u);
	};
	int count_cc = 0;
	for (int u = 0; u < n; u++)
		if (cc[u] == -1)
			dfs_cc(u, count_cc++);
	vector<int> scc(n, -1);
	function<void(int, int, int)> dfs_scc = [&](int u, int scc_id, int cc_id) {
		if (scc[u] != -1)return;
		if (cc[u] != cc_id)return;
		scc[u] = scc_id;
		for (auto &e : rg[u])
			dfs_scc(e.d, scc_id, cc_id);
	};
	int count_scc = 0;
	reverse(post.begin(), post.end());
	for (auto &u : post)
		if (scc[u] == -1)
			dfs_scc(u, count_scc++, cc[u]);
	return scc;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	Graph g(N);
	rep(i, 0, M) {
		int s, t; cin >> s >> t;
		add_arc(g, s, t);
	}
	vector<int> scc = kosaraju(g);
	int Q; cin >> Q;
	rep(i, 0, Q) {
		int u, v; cin >> u >> v;
		dump(u, v);
		cout << (scc[u] == scc[v]) << endl;
	}
	return 0;
}

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


int main() {
  char ch;
  cin >> ch;
  
   if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
     cout << "vowel" << endl;
   }
   else {
     cout << "consonant" << endl;
   }
   
}

Measured memory_bytes: 256
var a : array[1..110] of longint;
    n, i : longint;
    ok : boolean;

begin
    readln(n);
    ok := true;
    for i := 1 to n do
    begin
        read(a[i]);
        if (a[i] mod 2 = 0) and (a[i] mod 3 <> 0) and (a[i] mod 5 <> 0) then
        begin
            ok := false;
            break;
        end;
    end;
    if ok then writeln('APPROVED')
    else writeln('DENIED');
end.

Measured memory_bytes: 128
N=int(input())

ab=[]
cd=[]

for i in range(N):
    e,f=map(int,input().split())
    tmp=[e,e,f]
    ab.append(tmp)

for i in range(N):
    e,f=map(int,input().split())
    tmp=[e,e,f]
    cd.append(tmp)

ab.sort()
cd.sort()

#ab.reverse()
#cd.reverse()

ans=0

for i in range(N):
    L=len(ab)
    mi=1000000
    num=-1
    for j in range(L):
        if ab[j][1]<cd[i][1] and ab[j][2]<cd[i][2]:
            tmp=abs(ab[j][2]-cd[i][2])
            if tmp<mi:
                mi=tmp
                num=j
    if not num<0:
        del ab[num]
        ans+=1


print(ans)

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

int main(){
  int N;
  cin >> N;
  int sum=0,l=0,r=0;
  for(int i=0;i<N;i++){
    cin >> l >> r;
    sum += (r-l+1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
int N,d;
vi NV;
int main() {
    cin>>N;
    vector<vi> memo(10,vi(10,0));
    for (int i = 1; i < N+1; i++){
        string s=to_string(i);
        int l=(int)s[0]-(int)'0';
        int r=(int)s[s.size()-1]-(int)'0';
        memo[l][r]++;
    }
    int ans=0;
    for (int i = 1; i < 10; i++){
        for (int j = 1; j < 10; j++){
            ans+=memo[i][j]*memo[j][i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(void){
    string s;int k;cin>>s>>k;
    int n=s.size();
    rep(i,s.size()-1){
        if('z'-s[i]+1<=k && s[i]!='a'){
            k-='z'-s[i]+1;s[i]='a';
        }
    }
    k%=26;
    if('z'-s[n-1]+1<=k){
        k-='z'-s[n-1]+1;s[n-1]='a';
        s[n-1]+=k;
    }
    else s[n-1]+=k;
    cout<<s<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
struct P{
	double x,y;
	double abs()
	{
		return hypot(x,y);
	}
	P operator+(P b)
	{
		return{x+b.x,y+b.y};
	}
	P operator-(P b)
	{
		return{x-b.x,y-b.y};
	}
};
P div(P a,P b)
{
	return{a.x/a.abs()+b.x/b.abs(),a.y/a.abs()+b.y/b.abs()};
}
double theta(P a,P b)
{
	double ret=atan2(b.y,b.x)-atan2(a.y,a.x);
	ret=abs(ret);
	if(ret>M_PI)ret=2*M_PI-ret;
	return ret;
}
P take(P a,P b,double x)
{
	P q=div(a,b);
	double t=theta(a,b);
	double k=x/q.abs()/sin(t/2);
	return{q.x*k,q.y*k};
}
double cross(P a,P b){return a.x*b.y-a.y*b.x;}
bool in(P a,P b,P c,P p)
{
	return cross(p-a,b-a)*cross(p-a,c-a)<=0
		&&cross(p-b,c-b)*cross(p-b,a-b)<=0
		&&cross(p-c,a-c)*cross(p-c,b-c)<=0;
}
double dis(P p,P a,P b)
{
	double t=theta(b-a,p-a);
	return sin(t)*(p-a).abs();
}
bool check(P a,P b,P c,double x)
{
	P ab=take(a-c,b-c,x)+c,bc=take(b-a,c-a,x)+a,ca=take(c-b,a-b,x)+b;
	if(!in(a,b,c,ab)||!in(a,b,c,bc)||!in(a,b,c,ca))return false;
	if(dis(ab,a,b)<x||dis(bc,b,c)<x||dis(ca,c,a)<x)return false;
	return (ab-bc).abs()>=2*x||(bc-ca).abs()>=2*x||(ca-ab).abs()>=2*x;
}
main()
{
	P a,b,c;
	cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
	double L=0,R=1e3;
	for(int i=0;i<100;i++)
	{
		double M=(L+R)/2;
		if(check(a,b,c,M))L=M;
		else R=M;
	}
	cout<<fixed<<setprecision(15)<<L<<endl;
}

Measured memory_bytes: 512
N = int(input())
A = [int(i) for i in input().split()]
f = [False]*8
c = 0
for a in A:
    if a < 400:
        f[0] = True
    elif a < 800:
        f[1] = True
    elif a < 1200:
        f[2] = True
    elif a < 1600:
        f[3] = True
    elif a < 2000:
        f[4] = True
    elif a < 2400:
        f[5] = True
    elif a < 2800:
        f[6] = True
    elif a < 3200:
        f[7] = True
    else:
        c += 1
print(max(f.count(True), 1), f.count(True)+c)


Measured memory_bytes: 38256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[i] + l[j] > l[k]:
                if l[i] != l[j] != l[k]:
                    ans += 1

print(ans)

Measured memory_bytes: 9184
#include"stdio.h"
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int f[n+1][2];
    for(int i=0;i<n+1;i++)
        for(int j=0;j<2;j++)
            f[i][j]=0;
    int a[m],b[m];
    for(int i=0;i<m;i++)
        scanf("%d %d",&a[i],&b[i]);

    for(int i=0;i<m;i++){
        if(a[i]==1) f[b[i]][0]=1;
        if(b[i]==n) f[a[i]][1]=1;
    }
    
    for(int i=0;i<n+1;i++)
        if(f[i+1][0]==1&&f[i+1][1]==1){
            printf("POSSIBLE\n");
            return 0;
        }

    printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 4752
import math
import os
import sys
# from fractions import gcd
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def main():
    a, b, x = list(map(int, input().split()))
    area = x / a
    h = area / a
    remain = b - h
    if h >= b / 2:
        print(math.degrees(math.atan2(remain, a / 2)))
    else:
        a_dash = (2 * area) / b
        print(math.degrees(math.atan2(b, a_dash)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38504
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

vector<vector<int>> N(200001, vector<int> (0));
vector<int> count(200001);
int n;

void Tree_make(int u, int v) {
    N[u].push_back(v);
    N[v].push_back(u);
}

void counter_assign(int u, long w, int p) {
    count[u] = count[u] + w;

    for ( int i = 0; i < N[u].size(); i++ ) {
        int v = N[u][i];
        if ( v == p ) continue;
        counter_assign(v, count[u], u);
    }
}

int main() {
    int u, v, q;
    int w;

    scanf("%d %d", &n, &q);
    for ( int i = 0; i < n - 1; i++ ) {
        scanf("%d %d", &u, &v);
        Tree_make(u, v);
    }

    for ( int i = 0; i < n; i++ ) {
        count[i] = 0;
    }

    for ( int i = 0; i < q; i++ ) {
        scanf("%d %d", &u, &w);
        count[u] = count[u] + w;
    }

    counter_assign(1, 0, 0);

    for ( int i = 1; i < n + 1; i++ ) {
        printf("%d ", count[i]);
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    int a,b,c; cin >> a >> b >> c;
    
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2, 1,15,2,2,5,4,1,4,1,51},i,b,c,d,n;
    scanf("%d",&n);
    printf("%d",a[n]);
    return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.string;
 
void main() {
    string ans = "WA";
    char[] s = readln.strip.dup;
 
    if (s[0] == 'A') {
        ulong c = 0;
        foreach(i, e; s[0..$ - 1]) {
            if (e == 'C' && i > 1) {
                c = i;
                break;
            }
        }
        if (c > 1) {
            ans = "AC";
            foreach(i, e; s) {
                if (i == 0 || i == c)
                    continue;
                if (e < 97 || e > 122) {
                    ans = "WA";
                    break;
                }
            }
        }
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

bool IsNotPrime[100000 + 1] = { true, true, };
int tree[400000], input[100001];

int init(int node, int st, int ed)
{
	if (st == ed) return tree[node] = input[st];
	return tree[node] = init(node * 2, st, (st + ed) / 2) + init(node * 2 + 1, (st + ed) / 2 + 1, ed);
}

int sum(int node, int st, int ed, int left, int right)
{
	if (st > right || ed < left) return 0;
	if (st >= left && ed <= right) return tree[node];
	return sum(node * 2, st, (st + ed) / 2, left, right) + sum(node * 2 + 1, (st + ed) / 2 + 1, ed, left, right);
}

int main()
{
	for (int i = 2; i < 100000 + 1; i++)
	{
		if (!IsNotPrime[i])
		{
			for (long long j = (long long)i*i; j < 100000 + 1; j += i) IsNotPrime[j] = true;
		}
	}
	for (int i = 1; i <= 100000; i++)
	{
		if (i % 2 == 1)
		{
			if (!IsNotPrime[i] && !IsNotPrime[(i + 1) / 2]) input[i] = 1;
		}
	}
	init(1, 1, 100000);
	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", sum(1, 1, 100000, l, r));
	}
	return 0;
}

Measured memory_bytes: 2048
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.size = [1]*n


    def find_root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find_root(self.par[x])
            return self.par[x]
    

    def merge(self, x, y):
        x, y = self.find_root(x), self.find_root(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


    def issame(self, x, y):
        return self.find_root(x) == self.find_root(y)


    def get_size(self, x):
        x = self.find_root(x)
        return self.size[x]

ans = 0
data = []
for i in range(M):
    a, b = [int(_) for _ in stdin.readline().rstrip().split()]
    a, b = a-1, b-1
    data.append((a, b))

for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i == j:
            continue
        uf.merge(data[j][0], data[j][1])
    flag = False
    for j in range(N):
        if not uf.issame(0, j):
            flag = True
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int i;
		for(i=0;n!=1;++i){
			if(n%2) n=n*3+1;
			else n/=2;
		}
		cout<<i<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W, N;
  cin >> H >> W >> N;
  vector<ll> a(N);
  vector<pair<ll, ll>> colors(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    colors[i] = {a[i], i + 1};
  }
  vector<vector<ll>> MAP(H, vector<ll>(W, -1));
  queue<pair<ll, ll>> q;
  q.push({0, 0});
  int cur_color_id = 0, cur_color_cnt = 0;
  for (int i = 0; i < H; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < W; j++) {
        if (cur_color_cnt == colors[cur_color_id].first) {
          cur_color_id++;
          cur_color_cnt = 0;
          if (cur_color_cnt == colors.size()) break;
        }
        MAP[i][j] = colors[cur_color_id].second;
        cur_color_cnt++;
      }
    } else {
      for (int j = W - 1; j >= 0; j--) {
        if (cur_color_cnt == colors[cur_color_id].first) {
          cur_color_id++;
          cur_color_cnt = 0;
          if (cur_color_cnt == colors.size()) break;
        }
        MAP[i][j] = colors[cur_color_id].second;
        cur_color_cnt++;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << MAP[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3796
N,K = map(int,input().rstrip().split(' '))

count = 0
flag = 0

for i in range(N):
    flag = 0
    for j in range(K):
        if i + j < N:
            pass
        else:
            flag = 1

    if flag == 0:
        count += 1
    else:
        break

print(count)

Measured memory_bytes: 2940
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    let mut a = 0;
    for k in 1..=n {
        a += (n / k) * (n / k + 1) / 2 * k;
    }
    println!("{}", a);
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    string S;
    cin >> S;
    int N = S.size();

    bool a = 1, b = 1, c = 1;
    for(int i = 0; i < N; i++){
        a &= (S[i] == S[N-i-1]);
    }
    for(int i = 0; i < N/2; i++){
        //cout << N/2 - i - 1<< " ";
        b &= (S[i] == S[N/2 - i - 1]);
    }
    for(int i = N/2 +1; i < N; i++){
        //cout << N - i + N/2 << " ";
        c &= (S[i] == S[N - i + N/2]);
    }

   // cout << endl;

    Cout(Yes(a & b & c));
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var h, w, num int
	fmt.Scan(&h, &w)
	a := make([]string, h)
	ans := make([]string, h)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			num = 0
			if string(a[i][j]) == "#" {
				ans[i] += "#"
				continue
			}
			if i-1 >= 0 && j-1 >= 0 && string(a[i-1][j-1]) == "#" {
				num++
			}
			if i-1 >= 0 && string(a[i-1][j]) == "#" {
				num++
			}
			if i-1 >= 0 && j+1 < w && string(a[i-1][j+1]) == "#" {
				num++
			}
			if j-1 >= 0 && string(a[i][j-1]) == "#" {
				num++
			}
			if j+1 < w && string(a[i][j+1]) == "#" {
				num++
			}
			if i+1 < h && j-1 >= 0 && string(a[i+1][j-1]) == "#" {
				num++
			}
			if i+1 < h && string(a[i+1][j]) == "#" {
				num++
			}
			if i+1 < h && j+1 < w && string(a[i+1][j+1]) == "#" {
				num++
			}
			ans[i] += strconv.Itoa(num)
		}
	}
	for i := range ans {
		fmt.Println(ans[i])
	}
}


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

namespace ABC085D {
    class Program {
        static void Main(string[] args) {
            int[] NHInput = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();//2つ以上のスペース区切り入力の取得
            int N = NHInput[0];
            int H = NHInput[1];
            int shakeMax = 0;
            long[] thrs = new long[N];
            int answer = 0;
            for (int i = 0; i < N; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                int sha = input[0];
                int thr = input[1];
                thrs[i] = thr;
                if (sha > shakeMax) {
                    shakeMax = sha;
                }
            }
            for (int i = 0; i < N; i++) {
                if (thrs[i] < shakeMax) {
                    thrs[i] = shakeMax;
                }
            }
            long throwSum = thrs.Sum();
            if (throwSum >= H) {
                Array.Sort(thrs);
                Array.Reverse(thrs);
                int num = 0;
                while (H > 0) {
                    H -= (int)thrs[num];
                    num++;
                    answer++;
                }
            } else {
                H -= (int)throwSum;
                answer += N;
                answer += (H + shakeMax - 1) / shakeMax;
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 16192
<?php
$s = trim(fgets(STDIN));
$arr = str_split($s);

$count = 0;
$max = 0;

for($i=0; $i<count($arr); $i++){
    if($arr[$i] == 'A' || $arr[$i] == 'C' || $arr[$i] == 'G' || $arr[$i] == 'T'){
        $count++;
    }else{
        $count = 0;
    }
    $max = max($max, $count);
}
echo $max;
?>

Measured memory_bytes: 4728
import sys
input=sys.stdin.readline

# 頂点数 v のグラフ d の頂点 i から頂点 j への最短路を求める
def warchall_floyd(d, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
def main():
    H,_ = map(int, input().split())
    C = []
    A = []
    for _ in range(10):
        C.append(list(map(int, input().split())))
    for _ in range(H):
        A.append(list(map(int, input().split())))
    
    warchall_floyd(C, 10)

    ans = 0
    for a in A:
        for x in a:
            if x != -1:
                ans += C[x][1]
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
	int A,B;
  cin>>A>>B;
  bool flag=true;
  for(int i=10;i<=1250;i++){
    if(25*A<=2*i&&2*i<25*(A+1)&&10*B<=i&&i<10*(B+1)){
      cout<<i<<endl;
      flag=false;
      break;
    }
  }
  if(flag==true) cout<<-1<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		HashMap<Long, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
			if (map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i])+1);
			} else {
				map.put(a[i], 1);
			}
		}
		long[] m = new long[n];
        Arrays.fill(m, 0);
		int j = 0;
		for (long i : map.keySet()) {
			if (map.get(i) >= 4) {
				m[j] = m[j+1] = i;
				j += 2;
			} else if (map.get(i) >= 2) {
				m[j] = i;
				j++;
			}
		}
		Arrays.sort(m);
		System.out.println(m[n-1]*m[n-2]);
	}
}


Measured memory_bytes: 65440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int a;
    string b;
    cin >> a >> b;
    if (a >= b.size())cout << b << endl;
    else {
        for (int i = 0; i < a; i++) {
            cout << b.at(i);
        }
        cout << "..." << endl;
    }

}

Measured memory_bytes: 3632
fn main() {
    let mut v:Vec<u32> = read_vec();
    v.sort();
    v.dedup();
    println!("{}", v.len());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll treasure[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n);
	vector<pair<ll, ll>>res;
	rep(i, n) {
		cin >> a[i] >> b[i];
		res.push_back(make_pair(a[i] + b[i], i));
	}
	sort(res.rbegin(), res.rend());
	ll ans = 0;
	rep(i, n) {
		ll target = res[i].second;
		if (i % 2 == 0) {
			ans += a[target];
		}
		else {
			ans -= b[target];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
using namespace std;
void make_set(int *parent, int v) {
    parent[v] = v;
}
int find_set(int *parent, int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent,parent[v]);
}
void union_sets(int *parent, int a, int b) {
    a = find_set(parent,a);
    b = find_set(parent,b);
    if (a != b)
        parent[b] = a;
}
void dfs(vector<int> *G, int v, vector<bool> &visited, int *parent) {
    visited[v] = true;
    for (int u : G[v]) {
        if (!visited[u]) {
            union_sets(parent,v,u);
            dfs(G,u,visited,parent);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int N, K, L, x, y;
    cin >> N;
    vector<int> pq[N], rs[N];
    int parent1[N], parent2[N];
    for (int i = 0; i < N; i++) {
        make_set(parent1,i);
        make_set(parent2,i);
    }
    for (cin >> K >> L; K; K--) {
        cin >> x >> y;
        pq[--x].push_back(--y);
        pq[y].push_back(x);
    }
    vector<bool> visited(N);
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            dfs(pq,i,visited,parent1);
        }
    }
    while (L--) {
        cin >> x >> y;
        rs[--x].push_back(--y);
        rs[y].push_back(x);
    }
    visited = vector<bool>(N);
    for (int i = 0; i < N; i++) {
        if (!visited[i]) {
            dfs(rs,i,visited,parent2);
        }
    }
    map<pair<int,int>,int> counter;
    for (int i = 0; i < N; counter[make_pair(find_set(parent1,i),find_set(parent2,i))]++, i++);
    for (int i = 0; i < N; i++) {
        cout << counter[make_pair(find_set(parent1,i),find_set(parent2,i))] << ' ';
    }
}

Measured memory_bytes: 27776
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [i64; n],
        m: usize,
        k: usize,
        a: [usize1; m]
    }
    let mut p: Vec<usize> = (0..n - 1).collect();
    for &i in &a {
        let t = p[i];
        p[i] = p[i - 1];
        p[i - 1] = t;
    }
    let mut b = 1;
    let mut ds = vec![];
    for i in 0..n - 1 {
        ds.push(v[i + 1] - v[i]);
    }
    while b <= k {
        if b & k != 0 {
            let mut ds2 = vec![0; n - 1];
            for i in 0..n - 1 {
                ds2[i] = ds[p[i]];
            }
            ds = ds2;
        }
        let mut p2 = vec![0; n - 1];
        for i in 0..n - 1 {
            p2[i] = p[p[i]];
        }
        p = p2;
        b <<= 1;
    }
    let mut s = v[0];
    println!("{}", s);
    for i in 0..n - 1 {
        s += ds[i];
        println!("{}", s);
    }
}


Measured memory_bytes: 11892
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int M = sc.nextInt();
        char[][] a = new char[N][];
        char[][] b = new char[M][];
        for (int i = 0; i < N; i++) {
            a[i] = sc.next().toCharArray();
        }
        for (int i = 0; i < M; i++) {
            b[i] = sc.next().toCharArray();
        }
        for (int sy = 0; sy <= N - M; sy++) {
            for (int sx = 0; sx <= N - M; sx++) {
                boolean ok = true;
                for (int y = 0; y < M; y++) {
                    for (int x = 0; x < M; x++) {
                        if(a[sy+y][sx+x]!=b[y][x]){
                            ok = false;
                        }
                    }
                }
                if(ok){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;


int main() {
	long long a;

	string b;
	
	cin >> a >> b;

	int bb = 100*(b[0]-'0') + 10*(b[2]-'0') + (b[3]-'0');
	
	long long ans = a * bb;

	cout << ans/100 << endl;

	return 0;

}


Measured memory_bytes: 3600
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
H,W = map(int,readline().split())
grid = ''
grid += '#'* (W+2)
for _ in range(H):
    grid += '#' + readline().decode().rstrip() + '#'
grid += '#'*(W+2)
L = len(grid)
INF = float('inf')

def bfs(start):
    dist = [-INF] * L
    q = [start]
    dist[start] = 0
    while q:
        qq = []
        for x,dx in itertools.product(q,[1,-1,W+2,-W-2]):
            y = x+dx
            if dist[y] != -INF or grid[y] == '#':
                continue
            dist[y] = dist[x] + 1
            qq.append(y)
        q = qq
    return max(dist) 

ans = 0
for i in range(L):
    if grid[i] == '.':
        start = i
        max_dist = bfs(start)
        ans = max(ans,max_dist)
print(ans)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, w;
    cin >> n >> w;

    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;

    vector<vector<long long>> dp(n + 1, vector<long long>(100010, 0x3f3f3f3f));
    dp[0][0] = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < 100010; j++){
            if (j - a[i - 1].second >= 0){
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - a[i - 1].second] + a[i - 1].first);
            }
            else
                dp[i][j] = dp[i - 1][j];

            if (dp[i][j] <= w)
                ans = max(ans, j);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 83172
import java.util.*;
public class Main {

	private static final int m = 0;
	public static void main(String[] args) {
 Scanner sc=new Scanner(System.in);
 int a=sc.nextInt();
 int b=sc.nextInt();
 if(a==b) {
 	System.out.println("Draw");
 }else
 if(a==1) {
 	System.out.println("Alice");
 }else if(b==1) {
 	System.out.println("Bob");
 }else {
 	if(a>b) {
 		System.out.println("Alice");
 	}else  {
 		System.out.println("Bob");
 	}
 }
		
		
	}
}

Measured memory_bytes: 35644
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	ll r = 0;
	int c = 0;
	for (int i = 0; i < s.size(); i++)if (s[i] == 'W')r += i - c, c++;
	printf("%lld\n", r);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll long long
#define Graph vector<vector<long long>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define inf 5000000321
#define mod107 1000000007;

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

ll dp[200][200000] = {0};

int main(){
  ll N,W;
  cin >> N >> W;
  vector<ll> w(N),v(N);
  for(int i = 0;i < N;i++){
    cin >> w[i] >> v[i];
  }
  for(int i = 0;i < N;i++){
      for(int sum_w = 0;sum_w <= W;sum_w++){
          if(sum_w - w[i] >= 0){
              chmax(dp[i+1][sum_w],dp[i][sum_w - w[i]] + v[i]);
          }
          chmax(dp[i+1][sum_w],dp[i][sum_w]);
      }
  }  
  cout << dp[N][W] << endl;
}


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

using namespace std;

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

    string s;
    cin >> s;
    int m, d;
    m = (s[5] - '0') * 10 + (s[6] - '0');
    d = (s[8] - '0') * 10 + (s[9] - '0');

    if (m > 4)
        return cout << "TBD", 0;
    if (d > 30)
        return cout << "TBD", 0;
    cout << "Heisei\n";

    return 0;
}

Measured memory_bytes: 256