akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n, m,k;
    cin>>n>>m>>k;
    //ll ans;
    ll c[n+1];
    c[0]=1;
    for(ll i=1;i<=n-1;i++){
        c[i]=(c[i-1]*(n-i))%mod;
        c[i]=(c[i]*mod_pow(i,mod-2,mod))%mod;
    }
    ll ans=0;
    ll cnt=mod_pow(m-1,n-1,mod);
    for(ll i=0;i<=k;i++){
        ans=(ans+c[i]*m%mod*cnt%mod)%mod;
        cnt=(cnt*mod_pow(m-1,mod-2,mod))%mod;
    }
    if(m!=1)cout<<ans<<endl;
    else{
        if(n==1||k==n-1) cout<<1<<endl;
        else cout<<0<<endl;
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 5172
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var RL = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            var N = RL[0];
            var K = RL[1];
            var A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            var mod = 1000000007;

            var a1 = new long[N];
            var a2 = new long[N];
            for(var i = 0;i < N; i++) {
                a1[i] = A.Skip(i).Take((int)N - i).Count(x => x < A[i]);
                a2[i] = A.Count(x => x < A[i]);
            }
            var t1 = ((a1.Sum() * K)) % mod;
            var t2 = (a2.Sum() * (((K - 1) * K) / 2 % mod)) % mod;
            var ans = (t1+ t2) % mod;
            Console.Write(ans);
        }
    }
}

Measured memory_bytes: 13504
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, k;
  cin >> n >> k;
  ll count = 1;
  while(n>=k){
    n = n / k;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

ll MOD = 1e9 + 7;

int main() {
	ll n, c, sum = 0, ans = 0;
	cin >> n;
	
	FOR(i, n) {
		cin >> c;
		ans = (ans + c*sum) % MOD;
		sum = (sum + c) % MOD;
	}

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


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 510;
int n;
int c[N], s[N], f[N], ans[N];

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n - 1; ++i) {
        int j = i;
        int t = 0;
        while (j < n - 1) {
            if (t <= s[j])
                t = s[j] + c[j];
            else {
                int d = t % f[j];
                if (d)
                    t += f[j] - d;
                t += c[j];
            }
            ++j;
        }
        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = Integer.parseInt(sc.nextLine());
		int[] num = new int[count];
		int[] max = new int[count];
		int maxOperate = 0;
		for(int i = 0 ; i < count ;i++) {
			num[i] = sc.nextInt();
			max[i] = 0;
			while((num[i]%2)==0) {
				num[i] = num[i]/2;
				max[i] += 1;
			}
			if(i == 0) {
				maxOperate = max[i];
			}else if(maxOperate > max[i]) {
				maxOperate = max[i];
			}
		}
		System.out.println(maxOperate);
	}

}


Measured memory_bytes: 36084
def f(a):
    if a == [0] * 10:
        return True

    for i in range(1, 10):
        if a[i] < 3: continue
        b = list(a)
        b[i] -= 3
        if f(b):
            return True

    for i in range(3, 10):
        if a[i - 2] == 0 or a[i - 1] == 0 or a[i] == 0: continue
        b = list(a)
        for j in range(i - 2, i + 1):
            b[j] -= 1
        if f(b):
            return True
    return False

try:
    while True:
        a = [0] * 10
        for c in raw_input():
            a[int(c)] += 1
        d = []
        for i in range(1, 10):
            if a[i] == 4: continue
            b = list(a)
            b[i] += 1
            for j in range(1, 10):
                if b[j] < 2: continue
                c = list(b)
                c[j] -= 2
                if f(c):
                    d.append(str(i))
                    break
        print ' '.join(d) if d else 0
except EOFError:
    pass

Measured memory_bytes: 4284
#!/bin/bash
retuInt=0
max(){
	local re;
	if (( $1>$2 )); then
		re=$1
	else
		re=$2
	fi
	retuInt=$re
	}

read -p "" n
sum=0
max=0
input=0
i=0
until (( $i==$n ))
do
	i=$(($i+1))
	read -p "" input
	max $max $input
	max=$retuInt
	sum=$((sum+input))
done
echo $(( $sum-$max/2 ))


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

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

const long long MOD = 1000000007;

int main(){
  int n;
  string s;
  cin >> n;
  vector<string> x(n);
  rep(i,n){
    cin >> s;
    sort(s.begin(),s.end());
    x.at(i) = s;
  }
  sort(x.begin(),x.end());
  ll ans=0,a=0,l=1;
  for(int i=0;i<n-1;i++){
    if(x.at(i+1)==x.at(a) && i!=n-2){
      l++;
      continue;
    }
    else{
      if(i==n-2 && x.at(i+1)==x.at(a)) l++; 
      a=i+1;
      if(l==2) ans+=1;
      else if(l>2) ans+=l*(l-1)/2;
      l=1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);

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

	public static void solve() { 
		int n = sc.nextInt();
		
      	if(n==1)
		System.out.println("0");
      	if(n==0)
		System.out.println("1");

	}
}

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

#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)			    for(int i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh						while
#define mp						make_pair
#define le						length()
#define M						1000000007


void solve()
{
	int n;
	cin>>n;
	
	vi a(n+1);
	
	fr1(i,n)
	a[i]=0;
	
	for(int i=2;i<=n;i++)
	{
		int b;
		cin>>b;
		
		a[b]++;
	}
	
	fr1(i,n)
	{
		cout<<a[i]<<endl;
	}

}


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

Measured memory_bytes: 3964
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
sx = l.shift() * 1
sy = l.shift() * 1 
tx = l.shift() * 1 
ty = l.shift() * 1 
ans = ''
for (i=sx; i<tx; i++) {
    ans += 'R'
}
for (i=sy; i<ty; i++) {
    ans += 'U'
}
for (i=tx; i>sx; i--) {
    ans += 'L'
}
for (i=ty; i>sy; i--) {
    ans += 'D'
}
ans += 'D'
for (i=sx; i<=tx; i++) {
    ans += 'R'
}
for (i=sy; i<=ty; i++) {
    ans += 'U'
}
ans += 'L'
ans += 'U'
for (i=tx; i>=sx; i--) {
    ans += 'L'
}
for (i=ty; i>=sy; i--) {
    ans += 'D'
}
ans += 'R'
console.log(ans)

Measured memory_bytes: 7756
a=int(input())
b=[input() for i in range(a)]
d=[i.split() for i in b]

series_count=0

for di in d:
	if di[0]==di[1]:
		series_count+=1
	else:
		series_count=0

	if series_count==3:
		print("Yes")
		break

if series_count<3:
	print("No")


Measured memory_bytes: 9116
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll N, T;
	cin >> N >> T;
	vector<ll> time(N);
	for (int i = 0; i < N; i++)cin >> time[i];
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (time[i + 1] - time[i] < T)ans += time[i + 1] - time[i];
		else ans += T;
	}
	ans += T;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int time;
	if(c>=b||d<=a)
		time=0;
	else if(a>=c&&b<=d)
	{
		time=b-a;
	}
	else if(a<=c&&b>=d)
	{
		time=d-c;
	}
	else if(c<=b&&d>=b)
	{
		time=b-c;
	}
	else
	{
		time=d-a;
	}
	printf("%d",time);
	return 0;
}


Measured memory_bytes: 256
/*
   Push yourself, because no one else is going to do it for you.
*/
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long int
#define PI 2 * acos(0.0)
#define MAX 1000000000000000000
#define in(a) scanf("%d",&a);
#define out(a) printf("%d",a);
#define INF 1000000 
#define M 1000000007
#define pi 3.14159265 
using namespace std; 
int main(){ 
   fast_io
   ll n;
   cin>>n;
   long double y = 0;
   ll a[n];
   for(ll i = 0;i<n;i++) cin>>a[i];
   for(ll i = 0;i<n;i++){
      long double sum = 1.0/(long double) (a[i]);
      y += sum; 
   }
   long double h = 1.0 / y;
   cout<<fixed<<setprecision(15)<<h<<endl;
   return 0;
} 

Measured memory_bytes: 3752
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAXN = 4010;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,ans;
int sum[310][MAXN];
char s[MAXN];

char res(char a,char b) {
	if((a == 'R' && b == 'G') || (a == 'G' && b == 'R')) return 'B';
	if((a == 'B' && b == 'G') || (a == 'G' && b == 'B')) return 'R';
	if((a == 'R' && b == 'B') || (a == 'B' && b == 'R')) return 'G';
}

signed main () {
	cin >> n >> s + 1;
	for(register int i = n;i >= 1; --i) {
		sum['R'][i] = sum['R'][i + 1] + (s[i] == 'R');
		sum['G'][i] = sum['G'][i + 1] + (s[i] == 'G');
		sum['B'][i] = sum['B'][i + 1] + (s[i] == 'B');
	}
	for(register int i = 1;i <= n; ++i) {
		for(register int j = i + 1;j < n; ++j) {
			if(s[i] == s[j]) continue;
			char v = res(s[i],s[j]);
			ans += sum[v][j + 1];
			ans -= (bool)(2 * j - i <= n && s[2 * j - i] == v);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
      x = (int) (1LL * x * p.x % mod);
      return *this;
  }

  ModInt &operator/=(const ModInt &p) {
      *this *= p.inverse();
      return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
      int a = x, b = mod, u = 1, v = 0, t;
      while(b > 0) {
          t = a / b;
          swap(a -= t * b, b);
          swap(u -= t * v, v);
      }
      return ModInt(u);
  }

  ModInt pow(int64_t n) const {
      ModInt ret(1), mul(x);
      while(n > 0) {
          if(n & 1) ret *= mul;
          mul *= mul;
          n >>= 1;
      }
      return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
      return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
      int64_t t;
      is >> t;
      a = ModInt< mod >(t);
      return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;

map<ll, ll> PrimeFactor(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
        if(LLINF / i <= i) { break; }  // オーバーフロー警察
    }
    if(n != 1) { res[n] = 1; }
    return res;
}

map<int, int> pri;

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

    int N;
    cin >> N;

    for(int i = N; i >= 2; --i) {
        auto res = PrimeFactor(i);
        for(auto& p : res) {
            pri[p.first] += p.second;
        }
    }

    modint ans(1);

    for(auto& p : pri) {
        ans *= modint(p.second + 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
A = [0] + list(map(int,input().split()))
t = 1
u = 1
ans = 1
L = [0] * (N + 1)
loop = [0]
l1 = 0
l2 = 0
count = 0

while True:
  t = A[t]
  if L[t] == 1:
    l2 += 1
    L[t] += 1
    loop.append(t)
  elif L[t] == 0:
    L[t] += 1
    l1 += 1
    l2 += 1
  elif L[t] == 2:
    break
l = l2 - l1
loop[0] = loop[-1]

if K <= l1:
  while count < K:
    u = A[u]
    count += 1
  print(u)
else:
  print(loop[(K - l1) % l])

#print(l1)
#print(l2)
#print(loop)

Measured memory_bytes: 32292
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x);
#define rl(x) scanf("%lld",&x);
#define rlcfpoj(x) scanf("%I64d",&x);
#define pi(x) printf("%d",x);
#define pl(x) printf("%lld",x);
#define plcfpoj(x) printf("%I64d",x);
#define lfd() printf("\n");
#define sp() printf(" ");
vector<int> ga[2001];
int n,k;
bool vis[2001];
int u,v;
int dfs(int u,int max_dist){
	if(max_dist==0)
		return 1;
	vis[u]=true;
	int res=1;
	for(int i=0;i<ga[u].size();i++)
	{
		if(!vis[ga[u][i]])
			res+=dfs(ga[u][i],max_dist-1);
	}
	return res;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ga[u].push_back(v);
		ga[v].push_back(u);
	}
	int maxx=0;
	if(k%2==0){
		for(int i=1;i<=n;i++){
			memset(vis,0,sizeof(vis));
			int tmp=dfs(i,k/2);
			maxx=max(maxx,tmp);
		}
	}
	if(k%2==1){
		for(int i=1;i<=n;i++){
			for(int j=0;j<ga[i].size();j++){
				int l=ga[i][j];
				memset(vis,0,sizeof(vis));
				vis[i]=vis[l]=true;
				maxx=max(maxx,dfs(i,k/2)+dfs(l,k/2));
			}
		}
	}
	cout<<n-maxx<<endl;
	return 0;
}


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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b; cin>>a>>b;
    set<ll>s;
    for(ll i=2;i*i<=a;i++){
        if(a%i==0){
            while(a%i==0){
                a=a/i;
            }
            s.insert(i);
        }
    }
    if(a>1) s.insert(a);
    int ans=0;
    for(ll i=2;i*i<=b;i++){
        if(b%i==0){
            while(b%i==0){
                b=b/i;
            }
            if(s.count(i)){
                ans++;
            }
        }
    }
    if(b>1) {
        if(s.count(b)) ans++;
    }
    cout<<1+ans;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef __int128 int128;
const int mod=998244353;


map<int128,int>mp;

int solve(int128 x,int len){
	if(!len)return 1;x=x^(x>>len<<len);
	int128 y=x|((int128)1<<len);
	if(mp.count(y))return mp[y];
	int&ret=mp[y];
	ret=(((x>>(len-1))+1)*solve(x,len-1))%mod;
	for(int i=1;i<len;++i){
		int128 tmp=x>>(len-i);
		for(int j=i+i;j<=len;j+=i){
			tmp=tmp&(x>>(len-j));
			ret=(ret+(ll)solve(tmp,i)*solve(x,len-j))%mod;
		}
	}
	return ret;
}
char s[1234];int n;
int main(){
	cin>>s;n=strlen(s);
	int128 x=0;
	for(int i=0;i<n;++i)x=(x<<1)|(s[i]-'0');
	cout<<solve(x,n)<<'\n';
	return 0;
}


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

bool isP(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if (!isP(s)) ans = false;
    if (!isP(s.substr(0, s.size()/2))) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <iostream>
using namespace std;
int main()
{
	long long int a, b, yojo = 0;
	cin >> a;
	b = a;
	while (a > 0) {
		yojo += a % 10;
		a /= 10;
	}
	if (b%yojo==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().strip().split()))
dp = []
for i in range(0, n):
    dp.append(0)
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[n-1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  bool f=false;
  if(x+x==w&&y+y==h)f=true;
  cout<<(w*h)/2<<" ";
  if(f)cout<<1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,i,j,now;
long long qdh[1005],ans,sp;
vector<long long> q;
int main(){
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		cin>>qdh[i];
		qdh[i]+=qdh[i-1];
	}
	ans=0;
	for(i=0;i<n;i++)
		for(j=i+1;j<=n;j++)
			q.push_back(qdh[j]-qdh[i]);
	for(i=40;i>=0;i--)
	{
		ans+=((long long)1<<i);
		int cnt=0;
		for(j=0;j<=q.size();j++)
			if((q[j]&ans)==ans)
				cnt++;
		if(cnt<k)
			ans-=((long long)1<<i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  }
  else if (A >= 6 && A <= 12) {
    cout << B / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
	ll x, y, a, b, c;
	scanf("%lld %lld %lld %lld %lld", &x, &y, &a, &b, &c);
	ll d[a], e[b], f[c];
	for (ll i = 0; i < a; i++) scanf("%lld", &d[i]);
	for (ll i = 0; i < b; i++) scanf("%lld", &e[i]);
	for (ll i = 0; i < c; i++) scanf("%lld", &f[i]);
	sort(d, d + a); reverse(d, d + a);
	sort(e, e + b); reverse(e, e + b);
	sort(f, f + c); reverse(f, f + c);
	ll t[x + y + 1], pa = 0, pb = 0;
	fill(t, t + x + y + 1, 0);
	while (true){
		if (pa == x){
			if (pb == y){
				break;
			}else{
				t[pa + pb + 1] = t[pa + pb] + e[pb];
				pb++;
			}
		}else{
			if (pb == y){
				t[pa + pb + 1] = t[pa + pb] + d[pa];
				pa++;
			}else{
				if (d[pa] > e[pb]){
					t[pa + pb + 1] = t[pa + pb] + d[pa];
					pa++;
				}else{
					t[pa + pb + 1] = t[pa + pb] + e[pb];
					pb++;
				}
			}
		}
	}
	ll ans = -1, s = 0;
	for (ll i = 0; i <= c; i++){
		if (x + y - i < 0) break;
		ans = max(ans, s + t[x + y - i]);
		s += f[i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.File;
import java.util.*;

public class Main {

    public static StringBuilder output = new StringBuilder();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int length = in.nextInt();
        String arr[] = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.next();
        }
        Solver solver = new Solver();
        solver.solve(arr);
        System.out.println(output);
    }

}

class Solver {
    public void solve(String arr[]) {
        String a = "";
        Arrays.sort(arr);
        for (String s : arr) {
            a = a.concat(s);
        }
        Main.output.append(a);

    }
}

Measured memory_bytes: 37888
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

struct SegmentTree{
    vector <ll> tree;
    bool minst;
    int N;
    ll neutro;
    SegmentTree(vector <ll> &A, bool _minst){
        minst = _minst;
        N = A.size();
        tree.resize(4*N);
        if(minst) neutro = 1e9;
        else neutro = 0;
        build(0, 0, N-1, A);
    }
    ll merge(ll a, ll b){
        if(minst) return min(a,b);
        else return max(a,b);
    }
    void build(int n, int l, int r, vector<ll> &A){
        if(l == r){
            tree[n] = A[l];
            return;
        }
        int mid = (l+r)/2;
        build(2*n+1, l, mid, A);
        build(2*n+2, mid+1, r, A);
        tree[n] = merge(tree[2*n+1], tree[2*n+2]);
    }
    ll query(int i, int j){
        return query(0, 0, N-1, i, j);
    }
    ll query(int n, int l, int r, int i, int j){
        if(r < i || j < l) return neutro;
        if(i <= l && r <= j) return tree[n];
        int mid = (l+r)/2;
        ll a = query(2*n+1, l, mid, i, j);
        ll b = query(2*n+2, mid+1, r, i, j);
        return merge(a,b);
    }
};

ll calc(ll L, ll R){
    return max(0LL, R-L+1);
}

bool comp(pll a, pll b){
    return (a.s-a.f+1) < (b.s-b.f+1);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector <pll> nums(n);
    for(int i=0; i<n; i++){
        cin >> nums[i].f >> nums[i].s;
    }
    sort(nums.begin(), nums.end());
    vector <ll> L(n);
    vector <ll> R(n);
    for(int i=0; i<n; i++){
        L[i] = nums[i].f;
        R[i] = nums[i].s;
    }
    SegmentTree max_L(L, 0);
    SegmentTree min_R(R, 1);
    ll L1, R1, L2, R2;
    ll ans = 0;
    for(int i=0; i<n-1; i++){
        L1 = max_L.query(0, i);
        R1 = min_R.query(0, i);
        L2 = max_L.query(i+1,n-1);
        R2 = min_R.query(i+1,n-1);
        ans = max(ans, calc(L1,R1)+calc(L2,R2));
    }

    sort(nums.begin(), nums.end(), comp);
    for(int i=0; i<n; i++){
        L[i] = nums[i].f;
        R[i] = nums[i].s;
    }
    SegmentTree max2_L(L, 0);
    SegmentTree min2_R(R, 1);
    for(int i=0; i<n-1; i++){
        L1 = max2_L.query(0, i);
        R1 = min2_R.query(0, i);
        L2 = max2_L.query(i+1, n-1);
        R2 = min2_R.query(i+1, n-1);
        ans = max(ans, calc(L1,R1)+calc(L2,R2));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 15956
#include<bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int> T;
int main(){
    int n,C;
    cin>>n>>C;
    int s[n],t[n],c[n];
    T p[n];
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i]>>c[i];
        p[i]={c[i],s[i],t[i]};
    }
    sort(p,p+n);
    int imos[100002]={};
    for(int i=0;i<n-1;i++){
        imos[get<1>(p[i])]++;
        if(get<0>(p[i])==get<0>(p[i+1]) && get<2>(p[i])==get<1>(p[i+1]))imos[get<2>(p[i])]--;
        else imos[get<2>(p[i])+1]--;
    }
    imos[get<1>(p[n-1])]++,imos[get<2>(p[n-1])+1]--;
    int wa[100002];
    wa[0]=imos[0];
    int m=0;
    for(int i=1;i<100002;i++){
        wa[i]=wa[i-1]+imos[i];
        m=max(m,wa[i]);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 6792
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main(){
    int a;
    cin>>a;

    if(a==3)cout<<"YES";
    else if(a==5)cout<<"YES";
    else if(a==7)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

const ll modulo = 1000000007;
const ll sizek = 1000000;
ll len;
vector<ll> dpfact(3 * sizek + 10, 0);

ll modpow(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }
    if (b % 2 == 0)
    {
        ll r = modpow(a, b/2);
        return r * r % modulo;
    }
    else
    {
        return modpow(a, b-1) * a % modulo;
    }
}

ll modinv(ll n)
{
    return modpow(n, modulo-2);
}

ll modfact(ll n)
{
    dpfact[0] = 1;
    if (dpfact.at(n) == 0)
    {
        ll r = modfact(n-1);
        dpfact[n] = n * r % modulo;
    }
    return dpfact.at(n);
}

// n C (len-1)
ll modcomb(ll n)
{
    return (modfact(n) * modinv(modfact(len - 1)) % modulo) * modinv(modfact(n - len + 1)) % modulo;
}

int main()
{
    ll k;
    string s;
    cin >> k >> s;
    len = s.length();
    ll res = 0;
    rep(m, k+1)
    {
        res = (res + (modpow(25, k-m) * modpow(26, m) % modulo) * modcomb(k-m+len-1) % modulo) % modulo;
    }
    cout << res << endl;
}

Measured memory_bytes: 58756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i > (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define IN(x) cin >> x
#define DE(x) cerr << (x) << " "
#define BR cerr << "\n"
#define OUT(x) cout << (x) << endl
#define FIX cout << fixed << setprecision(10)

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 1;

int main(void){
  ll K;
  IN(K);
  if (K % 7 == 0) K /= 7;
  ll d = 1;
  while(d % K != 0) {
    d = d % K;
    d *= 10;
    d += 1;
    ret++;
    if (ret > 10000000) {
      ret = -1;
      break;
    }
  }

  OUT(ret);

}


Measured memory_bytes: 3628
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)
for _ in range(m):
    x,y,c = map(int,input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Measured memory_bytes: 24764
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

int PRECISION = 10;

double eat(vector<int>& sushis){

    int size = sushis.size();
    vector<vector<vector<double> > > records = vector<vector<vector<double> > >(size+1, vector<vector<double> >(size+1, vector<double>(size+1, 0)));

    vector<int> count = vector<int>(4, 0);
    for(int i = 0; i < size;i++)
        count[sushis[i]]++;

    double* p_ans = &records[count[1]][count[2]][count[3]];

    for(int three_num = 0; three_num <= count[3]; three_num++){
        for(int two_num = 0; two_num <= size; two_num++){
            for(int one_num = 0; one_num <= size; one_num++){
                int zero_num = size - (one_num + two_num + three_num);
                if(zero_num < 0)
                    continue;

                if(zero_num == size){
                    continue;
                }
                 
                double sum = 0;
                //chose a dish w/ 2 pieces
                if(two_num)
                    sum += (records[one_num+1][two_num-1][three_num]+1)*((double)two_num/size); 
                //chose a dish w/ 3 pieces
                if(three_num)
                    sum += (records[one_num][two_num+1][three_num-1]+1)*((double)three_num/size);
                //chose a dish w/ 1 pieces
                if(one_num){
                    sum += (records[one_num-1][two_num][three_num]+1)*((double)one_num/size);
                }
                //chose a dish w/ 0 pieces
                //records[one_num][two_num][three_num]*((double)zero_num/size)
                sum += (double)zero_num/size;
                records[one_num][two_num][three_num] = sum / (1-(double)zero_num/size);  
            }
        }
    }

    return *p_ans;
}

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

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

    double expected_num = eat(sushis);

    cout << setprecision(PRECISION) << expected_num << "\n";

    return 0;
}


Measured memory_bytes: 216832
s = list(input())
l = len(s) - 1
ans = 0
for i in range(2**l):
    op = [""] * l
    res = ""
    for j in range(l):
        if (i>>j) & 1:
            op[j] = "+"
    
    for n, k in zip(s, op+[""]):
        if len(k) != 0:
            res += n + k
        else:
            res += n
    ans += eval(res)

print(ans)

Measured memory_bytes: 3188
# coding:utf-8

import sys


input = sys.stdin.readline


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


# ---
class UnionFind:
    __slots__ = ['nodes', 'weight']

    def __init__(self, size: int) -> None:
        self.nodes = [-1] * size  # ノードの値が負の場合ルートを表し、値は木のランクを表す
        self.weight = [0] * size  # ノードx -> ルート(ノードx)への重みを表す

    # 検索
    def find(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            parent = self.find(self.nodes[x])
            self.weight[x] += self.weight[self.nodes[x]]
            self.nodes[x] = parent
            return parent

    # 併合
    # def unite(self, x: int, y: int, w: int) -> bool:
    #     root_x = self.find(x)
    #     root_y = self.find(y)
    #     if root_x == root_y:
    #         return False
    #     else:
    #         rank_x = -self.nodes[root_x]
    #         rank_y = -self.nodes[root_y]
    #         if rank_x < rank_y:
    #             self.nodes[root_x] = root_y
    #             self.weight[root_x] = w - self.weight[y] - self.weight[x]
    #         else:
    #             self.nodes[root_y] = root_x
    #             self.weight[root_y] = w - self.weight[x] - self.weight[y]
    #
    #             if rank_x == rank_y:
    #                 self.nodes[root_x] += -1
    #
    #         return True

    # xとyのルートが等しい時: 入力された重みwが正しいかどうかを判定
    # xとyのルートが異なる時: xとyを併合する
    # True: 併合，False: 何もしない，ValueError: 入力された重みに矛盾がある
    def relate(self, x: int, y: int, w: int) -> bool:
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            # 入力された重みwに矛盾がないか判定
            if self.weight[x] - self.weight[y] == w:
                return False
            raise ValueError
        else:
            rank_x = -self.nodes[root_x]
            rank_y = -self.nodes[root_y]
            if rank_x < rank_y:
                self.nodes[root_x] = root_y
                self.weight[root_x] = w + self.weight[y] - self.weight[x]
            else:
                self.nodes[root_y] = root_x
                self.weight[root_y] = -w + self.weight[x] - self.weight[y]

                if rank_x == rank_y:
                    self.nodes[root_x] += -1
            return True

    # UnionFind木の一覧を返す
    # def get_tree(self) -> dict:
    #     tree = {}
    #     for i, node in enumerate(self.nodes):
    #         if node < 0:
    #             if i not in tree.keys():
    #                 tree[i] = []
    #         else:
    #             if self.find(node) in tree.keys():
    #                 tree[self.find(node)].append(i)
    #             else:
    #                 tree[self.find(node)] = [i]
    # 
    #     return tree


N, M = inpl()
uf = UnionFind(N)
relate = uf.relate
try:
    for i in range(M):
        l, r, d = inpl()
        relate(l - 1, r - 1, d)
    else:
        print('Yes')
except ValueError:
    print('No')


Measured memory_bytes: 9376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
    Scanner sc = new Scanner(System.in);
    long l0=2;
    long l1=1;
    long l=0;
    long n = sc.nextLong();
        for (int i = 0; i < n+1; i++) {
            if (i<2) {
                if (i==0) {
                    l=l0;
                }else{
                    l=l1;
                }
            }else{
                l=l0+l1;
                l0=l1;
                l1=l;
            }
        }
        System.out.println(l);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  string s;
  cin >> s;
  if(s == "ABC") {
    cout << "ARC";
  } else {
    cout << "ABC";
  }
}

Measured memory_bytes: 3596
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll k,s;
  cin>>k>>s;
  ll ans=0;
  rep(x,k+1) rep(y,k+1) if(0<=s-x-y && s-x-y<=k) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] res = new int[N + 1];
		for (int x = 1; x <= N; x++) {
			if (x * x > N) {
				break;
			}
			for (int y = 1; y <= x; y++) {
				if (x * x + y * y + x * y > N) {
					break;
				}
				for (int z = 1; z <= y; z++) {
					int tmpRes = x * x + y * y + z * z + x * y + y * z + z * x;
					if (tmpRes > N) {
						break;
					}
					if (tmpRes < N + 1) {
						if (x != y && y != z && z != x) {
							res[tmpRes] += 6;
						} else if (x == y && y == z && z == x) {
							res[tmpRes] += 1;
						} else {
							res[tmpRes] += 3;
						}
					}
				}
			}
		}
		for (int i = 1; i < res.length; i++) {
			System.out.println(res[i]);

		}
	}
}

Measured memory_bytes: 38868
#include <iostream>
#include <set>

using namespace std;

#define MAX_N 200000
int A[MAX_N];
multiset<int> inverted;

int invert(int x) {
    int inv{1};
    while (inv <= x) inv <<= 1;
    return inv - x;
}

int main() {
    int N; scanf("%d", &N);
    for (int i{}; i < N; ++i) scanf("%d", &A[i]);
    sort(A, A + N);

    int count{};
    for (int i{N-1}; i >= 0; --i) {
        const auto& found = inverted.find(A[i]);
        if (found != inverted.end()) {
            inverted.erase(found);
            ++count;
        } else {
            inverted.insert(invert(A[i]));
        }
    }

    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 10368
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll a(n), b(n);
  vll c(n);
  for(ll i = 0; i < n; i++) cin >> a[i];
  for(ll i = 0; i < n; i++) cin >> b[i];
  for(ll i = 1; i <= n; i++) c[i-1] = i;
  ll x1, x2;  
  ll pass = 1;
  do {
  	if(a == c) x1 = pass;
  	if(c == b) x2 = pass;
  	pass++;
  } while(next_permutation(all(c)));
  cout << abs(x2 - x1) << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
n, m = list(map(int, input().split()))

redball = [0]*n
redball[0] = 1
ball_cnt = [1]*n

for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1

    if ball_cnt[x] == 1 and redball[x] == 1:
        redball[x] = 0
        redball[y] = 1

    if ball_cnt[x] > 1 and redball[x] == 1:
        redball[y] = 1

    ball_cnt[x] -= 1
    ball_cnt[y] += 1

print(redball.count(1))


Measured memory_bytes: 10304
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

answer = []
# Bがマイナス
[*0..64].each do |a|
  [*-64..-1].each do |b|
    if a ** 5 - b ** 5 == X
      answer = [a, b]
    end
  end
end

# Bがプラス
[*0..120].each do |a|
  [*0..120].each do |b|
    if a ** 5 - b ** 5 == X
      answer = [a, b]
    end
  end
end

puts "#{answer[0]} #{answer[1]}"


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

int main()
{
	string S;
	cin >> S;

	if (S == "SUN")
		cout << "7\n";
	else if (S == "MON")
		cout << "6\n";
	else if (S == "TUE")
		cout << "5\n";
	else if (S == "WED")
		cout << "4\n";
	else if (S == "THU")
		cout << "3\n";
	else if (S == "FRI")
		cout << "2\n";
	else if (S == "SAT")
		cout << "1\n";
						
	return 0;
}


Measured memory_bytes: 256
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    string s;
    cin >> s;
    int ans = 0, pv = 0;
    for (int i = 0; i < sz(s); ++i) {
        pv += s[i]-'0';
        ans = max(ans, pv-1 + (sz(s)-i-1) * 9);
    }
    cout << max(pv, ans);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
static unsigned int inf = 1e9+7;
int main(){
    int n;
    int a[20];
    int b[20];
    int c[20];
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    for(int i = 0;i < n-1;i++){
        cin >> c[i];
    }
    int sum = 0;
    int old = 0;
    for(int i = 0; i < n; i++){
        int index = a[i]-1;
        sum+=b[index];
        if(i >= 1 && old+1 == index){
            sum += c[old];
        }
        old = index;
    }
    cout << sum << endl;
    return 0;

}

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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m = map(int, input().split())
abl = []
for _ in range(m):
    a,b = map(int, input().split())
    abl.append((a,b))

uf = UnionFind(n)
ans_r = []
curr_ans_minus = 0
for ab in reversed(abl):
    a,b = ab
    if not uf.same(a-1,b-1): 
        a_size = uf.size(a-1)
        b_size = uf.size(b-1)
        curr_ans_minus += (a_size+b_size)*(a_size+b_size-1)//2
        curr_ans_minus -= (a_size*(a_size-1)//2 + b_size*(b_size-1)//2)
        uf.union(a-1,b-1)
    ans_r.append(curr_ans_minus)


all_sum = n*(n-1)//2
for v in reversed(ans_r[:-1]):
    print(all_sum-v)
print(all_sum)


Measured memory_bytes: 24504
#include<iostream>
using namespace std;
int main(){
	int a[201];
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	int c=0;
	for(;;){
		for(int j=0;j<N-1;j++){
			if(a[j]%2==0){
				a[j]=a[j]/2;
			}
			else{
				cout<<c;
				return 0;
			}
		}
		if(a[N-1]%2==0){
			c+=1;
			a[N-1]=a[N-1]/2;
		}
		else{
			cout<<c;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	long long int n, a, b, c, d, e, f;
	cin >> n >> a >> b;
	c = a + b;
	d = n % c;
	e = n / c;
	if (d > a) {
		e = e + 1;
		f = e * a;
		cout << f;
	}
	else {
		f = e * a;
		f = f + d;
		cout << f;
	}
}

Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)
val A = sc.nextInt()
val B = sc.nextInt()

fun main(args: Array<String>) {
    (A..B).map { if (judge(it)) 1 else 0 }.sum().run(::println)
}

fun judge(n: Int): Boolean {
    val s = n.toString()
    for (i in 0 until s.length / 2) {
        if (s[i] != s[s.length - 1 - i]) {
            return false
        }
    }
    return true
}


Measured memory_bytes: 38640