akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s[]{"Sunny","Cloudy","Rainy"};
	string t;cin>>t;
	rep(i,3){
		if(s[i]==t){
			cout<<s[(i+1)%3]<<endl;
			return 0;
		}
	}	
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int a, b, c, k; 
  cin >> a >> b >> c >> k;

  int ans = 0;
  while (a >= b) {
    b *= 2;
    ans++;
  }
  while (b >= c) {
    c *= 2;
    ans++;
  }

  cout << (ans <= k ? "Yes" : "No") << endl;
  return 0; 
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {
	int data[101][101] = {};
	int r, c;
	int i, j;
	
	scanf("%d %d", &r, &c);
	
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &data[i][j]);
			data[r][j] += data[i][j];
			data[i][c] += data[i][j];
			data[r][c] += data[i][j];
		}
	}
	
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++)
			printf("%s%d", j ? " " : "", data[i][j]);
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 660
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = 0LL;
	
	if( (b - a) % 2LL == 0 ) {
		ans = (b - a) / 2LL;
	} else {
		ans = min(a - 1LL, n - b) + 1LL + (b - a - 1LL) / 2LL;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    int ans=1e7;
    for(int i=0; i<n; i++)
        cin >> w[i];
    for(int t=0; t<n; t++)
    {
        int s1=0,s2=0;
        for(int i=0; i<n; i++)
        {
            if(i<=t)
                s1+=w[i];
            else
                s2+=w[i];
        }
        ans=min(ans,abs(s1-s2));
    }
    cout << ans << endl;
    return 0;
}


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


int main(){

  int H = 0 , W = 0  ;

 


  while (1){


 cin >> H >> W ;
   
 if ( H == 0 && W ==0 ) break;

  for ( int h = 0; h < H ; h++){
    for ( int w = 0; w < W ; w++){
      cout << "#" ;
      
    }
    
    cout << endl ;
  
  }
  cout << "\n"; 

}

  return 0;

}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

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

    map<int,int> ma,mb;
    REP(i,n/2){
        int a,b;
        cin >> a >> b;
        ma[a]++;
        mb[b]++;
    }

    int a1(0),a2(0);
    int b1(0),b2(0);

    for(auto s:ma){
        if(ma[a1] <  s.second){
            a2 = a1;
            a1 = s.first;
        }
        else if(ma[a2] < s.second){
            a2 = s.first;
        }
    }
    
    for(auto s:mb){
        if(mb[b1] <  s.second){
            b2 = b1;
            b1 = s.first;
        }
        else if(mb[b2] < s.second){
            b2 = s.first;
        }
    }
    if(a1 != b1){
        cout << n - ma[a1] - mb[b1] << endl;
    }else{
        cout << n - max(ma[a1]+mb[b2],ma[a2]+mb[b1]) << endl;
    }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
using namespace std;
const int INF = 1e18;
const int MOD = 1000000007;

using Graph = vector<vector<int>>;
Graph G;
int wage[100];

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int A[n + 1], B[n];
    rep(i, n + 1) cin >> A[i];
    rep(i, n) cin >> B[i];

    int before = 0;
    rep(i, n + 1) before += A[i];

    int left = 0;
    int right = 0;
    for (int i = 0; i < n; i++)
    {
        left = min(A[i], B[i]);
        A[i] -= left;
        B[i] -= left;
        right = min(A[i + 1], B[i]);
        A[i + 1] -= right;
        B[i] -= right;
    }

    int after = 0;
    rep(i, n + 1) after += A[i];

    cout << before - after << endl;
}

signed main()
{
    solve();
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))

for x in a:
    if x == a[n-1]:
        print(x)
    else:
        print(x, end=' ')

for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    for x in a:
        if x == a[n-1]:
            print(x)
        else:
            print(x, end=' ')



Measured memory_bytes: 5976
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc074_a.cpp
 * time   : Wed Apr 29 00:39:46 2020
 * quest  : A - Bichrome Cells
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  cout << (n * n) - a << "\n";
  return 0;
}


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

int main(){
    int n, i;
    vector<int> a(20), b(20), c(20);
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> a.at(i);
    }for(i = 0;i < n;i++){
        cin >> b.at(i);
    }for(i = 0;i < n-1;i++){
        cin >> c.at(i);
    }

    int memo = -1;
    int ans = 0;
    for(i = 0;i < n;i++){
        ans += b.at(a.at(i)-1);
        if(memo+1 == a.at(i)) ans += c.at(memo-1);
        memo = a.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[20]:


sx,sy,tx,ty = map(int, input().split())


# In[26]:


ans = []
X = sx; Y = sy
for x in range(sx+1,tx+1):
    ans.append("R")
X = x
for y in range(sy+1,ty+1):
    ans.append("U")
Y = y
for x in reversed(range(sx,tx)):
    ans.append("L")
X = x
for y in reversed(range(sy,ty)):
    ans.append("D")
Y = y
Y -= 1
ans.append("D")
for x in range(sx+1,tx+2):
    ans.append("R")
X = x
for y in range(sy,ty+1):
    ans.append("U")
Y = y
X -= 1
ans.append("L")
Y += 1
ans.append("U")
for x in reversed(range(sx-1,tx)):
    ans.append("L")
X = x
for y in reversed(range(sy,ty+1)):
    ans.append("D")
Y = y
X += 1
ans.append("R")
print("".join(ans))


# In[ ]:






Measured memory_bytes: 68908
n = int(input().strip())
a = [input().strip() for _ in range(n)]
dic = {}
for elem in a:
    if dic.get(elem):
        if dic[elem] == 0:
            dic[elem] = 1
        else:
            dic[elem] = 0
    else:
        dic[elem] = 1
print(len(list(filter(lambda x: x == 1, dic.values()))))


Measured memory_bytes: 66644
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int X;
	std::cin >> X;

	for (int i = 0; i <= 100000/100; ++i) {
		int r = X - i * 100;
		if (r >= 0 && r <= i * 5) {
			std::cout << "1\n";
			return 0;
		}
	}
	std::cout << "0\n";
}


Measured memory_bytes: 256
S=input()
Q=int(input())
import sys
from collections import deque
d=deque()
for _ in S:
  d.append(_)
flag=False

for _ in range(Q):
  s = list(sys.stdin.readline())
  if s[0]=="1":
    if flag:
      flag=False
    else:
      flag=True
  else:
    if s[2]=="1":
      if flag:
        d.append(s[4])
      else:
        d.appendleft(s[4])
    else:
      if flag:
        d.appendleft(s[4])
      else:
        d.append(s[4])
      
if flag:
  d.reverse()
  
print("".join(d))

Measured memory_bytes: 8564
s,T=*$<.map(&:chomp)
is_rep=false
(s.size-T.size+1).times.to_a.reverse.each{|i|
  flag=true
  T.size.times{|j|
    unless s[i+j]=='?' || s[i+j]==T[j]
      flag=false;break
    end
  }
  if flag
    s[i,T.size]=T;is_rep=true;break
  end
}
puts is_rep ? s.gsub(/\?/,"a"): :UNRESTORABLE

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

int sum(int x){
    int a=0;
    while(x){
        a+=x%10;
        x/=10;
    }
    return a;
}

int main(){
    int a,n,m;
    cin>>a>>n>>m;

    int ans=0;
    for(int i=1;pow(i,n)<=m;i++){
        int x=pow(i,n);
        if(i==sum(x)+a) ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3244
#include<cstdio>
#include<set>
int main(){
  int n;
  scanf("%d", &n);
  std::multiset<int> ms;
  for(int i = 0; i < n; ++i){
    int a;
    scanf("%d", &a);
    ms.insert(a);
  }
  int x = *ms.begin(), y = *ms.rbegin();
  for(int i = 0; i < n; ++i){
    int z = x ^ y;
    auto itr = ms.find(z);
    if(itr == ms.end()){
      puts("No");
      return 0;
    }
    ms.erase(itr);
    x = y;
    y = z;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    ll l, r;
    cin >> l >> r;
    ll mi = INF;
    if (r - l == 1)
    {
        cout << (l * r) % 2019 << endl;
    }
    else if ((r / 2019 - (l - 1) / 2019) > 0)
    {
        cout << 0 << endl;
    }
    else
    {
        for (ll i = (l % 2019); i < (r % 2019); i++)
        {
            for (ll j = i + 1; j <= (r % 2019); j++)
            {
                mi = min(mi, (i * j) % 2019);
            }
        }
        cout << mi << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int N,m;
    cin >> N;
    m = N;
    vector<int> a;
    int Max = 0;
    while(N--){
        int x;
        scanf("%d",&x);
        
        //if(find(a.begin(),a.end(),x) == a.end() || (Max < x)){
            a.push_back(x);
            //Max = max(x,Max);
        //}else{
            //a.erase(find(a.begin(),a.end(),x));
        //}
        
    }
    sort(a.begin(),a.end());
    for(int i = 0; i<a.end()-a.begin()-1;i++){
        if(a[i] == a[i+1]){
            a.erase(a.begin()+i);
            a.erase(a.begin()+i);
            i--;
            m -= 2;
        }
        
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define N 200005
#define M 4000005
#define L(__) (__ << 1)
#define R(__) (L(__)|1)
using namespace std;
int n,m,x[N],wx[N],wy[N],head[N],nxt[M],num[M],a[N],ax[N],ay[N],nx[N],ny[N],dfn[N],low[N],dfs_clock,scc_cnt,scc[N],st[N],top;
void link(int x,int y){ num[++m]=y,nxt[m]=head[x],head[x]=m;}
bool cmp(int p,int q){ return x[p]<x[q];}
int Z(int x){ return x>n ? x-n : x+n;}
void B(int t,int l,int r)
{
	int mid=(l+r)>>1;
	if(l==r){
		link(t+2*n,Z(a[l]));
		link(a[l],t+10*n);
		return ;
	  }
	B(L(t),l,mid);
	B(R(t),mid+1,r);
	link(t+2*n,L(t)+2*n);
	link(t+2*n,R(t)+2*n);
	link(L(t)+10*n,t+10*n);
	link(R(t)+10*n,t+10*n);
}
void C(int t,int l,int r,int l1,int r1,int x)
{
	int mid=(l+r)>>1;
	if(l>r1 || r<l1) return ;
	if(l>=l1&&r<=r1){
		link(x,t+2*n);
		link(t+10*n,Z(x));
		return ;
	  }
	C(L(t),l,mid,l1,r1,x);
	C(R(t),mid+1,r,l1,r1,x);
}
void Tarjan(int t)
{
	int i; st[++top]=t;
	dfn[t]=low[t]=++dfs_clock;
	for(i=head[t];i;i=nxt[i])
		if(!dfn[num[i]]) Tarjan(num[i]),low[t]=min(low[t],low[num[i]]);
		else if(!scc[num[i]]) low[t]=min(low[t],dfn[num[i]]);
	if(dfn[t]==low[t]){
		++scc_cnt;
		while(1){
			scc[st[top]]=scc_cnt;
			if(st[top--]==t) break;
		  }
	  }
}
bool chk(int d)
{
	int i,l,r,p; m=0;
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	memset(scc,0,sizeof(scc));
	memset(head,0,sizeof(head));
	B(1,1,2*n);
	for(i=1;i<=2*n;i++){
		l=lower_bound(wx+1,wx+n+1,x[i]-d+1)-wx;
		r=upper_bound(wx+1,wx+n+1,x[i]+d-1)-wx-1;
		p=nx[i>n ? i-n : i];
		if(p>=l&&p<=r){
			if(l<p) C(1,1,2*n,l,p-1,i);
			if(p<r) C(1,1,2*n,p+1,r,i);
		  }
		else C(1,1,2*n,l,r,i);
		l=lower_bound(wy+1,wy+n+1,x[i]-d+1)-wy+n;
		r=upper_bound(wy+1,wy+n+1,x[i]+d-1)-wy-1+n;
		p=ny[i<=n ? i+n : i]+n;
		if(p>=l&&p<=r){
			if(l<p) C(1,1,2*n,l,p-1,i);
			if(p<r) C(1,1,2*n,p+1,r,i);
		  }
		else C(1,1,2*n,l,r,i);
	  }
	dfs_clock=top=scc_cnt=0;
	for(i=1;i<=18*n;i++)
		if(!dfn[i]) Tarjan(i);
	for(i=1;i<=n;i++)
		if(scc[i]==scc[i+n]) return 0;
	return 1;
}
int main()
{
	int i,l,r,mid;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d %d",&x[i],&x[i+n]),wx[i]=x[i],wy[i]=x[i+n],ax[i]=i,ay[i]=i+n;
	sort(ax+1,ax+n+1,cmp);
	sort(ay+1,ay+n+1,cmp);
	sort(wx+1,wx+n+1);
	sort(wy+1,wy+n+1);
	for(i=1;i<=n;i++) a[i]=ax[i],a[i+n]=ay[i];
	for(i=1;i<=n;i++) nx[ax[i]]=i,ny[ay[i]]=i;
	r=(int)(1e9),l=0;
	while(r-l>1){
		mid=(l+r)>>1;
		if(chk(mid)) l=mid;
		else r=mid;
	  }
	cout<<l;
	return 0;
}


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

int main() {

	int N;
  double sum;
 
	cin>>N;
	 vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);}
  
  sort(A.begin(),A.end());
  sum = A.at(0);
  for(int i=1; i<N; i++){
    sum+=A.at(i);sum/=2;}
  
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    long k;
    cin >> n >> k;
    set<int> st;
    map<int,long> mp;
    int a,b;
    rep(i,n){
        cin >> a >> b;
        st.insert(a);
        mp[a]+=b;
    }
    long ans;
    for(auto itr = st.begin();itr!=st.end();itr++){
        k-=mp[*itr];
        if(k<=0){
            ans = *itr;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7168
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int a, b;
	cin >> a >> b;
	cout << LL(ceil((LD) (b - 1) / (a - 1)) + 0.5) << "\n";

    return 0;
}


Measured memory_bytes: 256
/*
 * FileName:     C_fix_2
 * CreatedDate:  2020-04-10 19:27:07 +0900
 * LastModified: 2020-04-10 21:24:24 +0900
 */

#include <stdio.h>
#include <string.h>
long int dp[100001][4];
long int max(long int s,long int t){
    if(s<t){return t;}
    return s;
}
long int vacation(int i,int condition,int a[],int b[],int c[],int n){
    if(dp[i][condition]>=0){
        return dp[i][condition];
    }
    long int res;
    if(i==n){
        return 0;
    }
    if(condition==0){
        res=max(vacation(i+1,1,a,b,c,n)+(long int)a[i],vacation(i+1,2,a,b,c,n)+(long int)a[i]);
    }
    else if(condition==1){
        res=max(vacation(i+1,0,a,b,c,n)+(long int)b[i],vacation(i+1,2,a,b,c,n)+(long int)b[i]);
    }
    else{
        res=max(vacation(i+1,0,a,b,c,n)+(long int)c[i],vacation(i+1,1,a,b,c,n)+(long int)c[i]);
    }
    return dp[i][condition]=res;
}
void solve(int n,int a[],int b[],int c[]){
    memset(dp,-1,sizeof(dp));
/*    for(int i=0;i<3;i++){
        dp[n][i]=0;
    }*/
    long int tmp=0;
    for(int condition=0;condition<3;condition++){
        if(tmp<vacation(0,condition,a,b,c,n)){
            tmp=vacation(0,condition,a,b,c,n);
        }
    }
    printf("%ld\n",tmp);
}
int main(void){
    long int n;
    scanf("%ld",&n);
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    solve(n,a,b,c);
    return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  cin >> N >> D>> X;
  
  int sum = 0;
  for(int i = 0;i < N ; i ++){
    int A;
    cin >> A;
    sum += (D-1)/A + 1;
  }
  cout << sum + X << endl;
  
  return 0; 
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
  	string s;
    cin >> s;
    if (s == "Y"){
    cout << "Four" << endl;
    break;
    }
    if(s == "P" || s == "W" || s == "G"){
     if(i == N - 1){
     cout << "Three" << endl;
     }
     }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

struct point {
	double x, y;
	point() { x = y = 0.0; }
	point(double x, double y) : x(x), y(y) {}
};

double dist(point p1, point p2) {
	return hypot(fabs(p1.x - p2.x), fabs(p1.y - p2.y));
}

int main() {
    while(true) {
        int x1,y1,x2,y2,x3,y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        if (x1 == 0 && x2 == 0 && x3 == 0 && y1 == 0 && y2 == 0 && y3 == 0) break;

        point ap = point(x1,y1);
        point bp = point(x2,y2);
        point cp = point(x3,y3);

        // side opposite vertex point
        double a = dist(bp,cp);
        double b = dist(ap,cp);
        double c = dist(ap,bp);

        // herons rule
        double s = (a+b+c)/2;
        double triangleArea = sqrt(s*(s-a)*(s-b)*(s-c));
        
        // Inradius
        double r = triangleArea/s;

        // Incenter of triangle
        point ip = point((a*ap.x + b*bp.x + c*cp.x)/(a+b+c), (a*ap.y + b*bp.y + c*cp.y)/(a+b+c));

        // distance from incenter to each vertex
        double d = dist(ip,ap);
        double e = dist(ip,bp);
        double f = dist(ip,cp);

        // Malfatti's radius formula
        double r1 = r/(2*(s-a)) * (s+d-r-e-f);
        double r2 = r/(2*(s-b)) * (s+e-r-d-f);
        double r3 = r/(2*(s-c)) * (s+f-r-d-e);

        printf("%.6f %.6f %.6f\n", r1, r2, r3);
    }
    
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    ll n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    
    ll w[n] = {};
    rep(i,1,n){
	w[i] = w[i-1];
	if(s[i-1] == 'A' && s[i] == 'C')w[i]++;
    }

    // rep(i,0,n)PS(w[i]);

    rep(i,0,q){
	ll l,r;
	cin >> l >> r;
	if(l == 1)P(w[r-1]);
	else P(w[r-1] - w[l-1]);
    }
    return  0;
}


Measured memory_bytes: 1792
// ARC088-D
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   string s;
   cin >> s;
   int n = s.size();
   int ans = n;
   for (int i = 1; i < n; i++) {
      if (s[i] != s[i-1]) {
         ans = min(ans, max(i, n-i));
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define maxn 5000005
#define inf 2000000000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
const double PI = acos(-1);
using namespace std;

string s,t,ls; int n,m;
int hs[maxn]; int fmul[maxn];
int base = 31;
int Hash (int l, int r){
	int val = hs[r]-hs[l-1]*fmul[r-l+1];
	val%=mod; val=(val+mod)%mod;
	return val;
}
bool ok (int x){
	string lt; int i,j;
	if (m*x > ls.size()) return false;
	for (i=1;i<=x;i++){
		lt+=t;
	}
	int hlt=0;
	for (i=0;i<lt.size();i++){
		hlt=hlt*base+lt[i]-96; hlt%=mod;
	}
	for (i=0;i<=ls.size()-lt.size();i++){
		int val = Hash(i,i+lt.size()-1);
		if (val==hlt) return true;
	}
	return false;
}
int binsTnum(int lo,int hi){
	int daps=0;
	while (lo<=hi){
		int mid=(lo+hi)/2;
		if (ok(mid)){
			daps=max(daps,mid);
			lo=mid+1;
		}
		else hi=mid-1;
	}
	return daps;
}

main(){
	ios::sync_with_stdio(false); cin.tie(0); srand(time(NULL));
	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);
	//freopen(".inp","r",stdin); freopen(".out","w",stdout);
	cin>>s>>t; n=s.size(); m=t.size();
	int i,j,k;
	ls = s+s+s;
	while (ls.size()<=t.size()) ls+=s;
	fmul[0]=1; for(i=1;i<maxn;i++) fmul[i]=(fmul[i-1]*base)%mod;
	
	hs[0]=ls[0]-96;
	for (i=1;i<ls.size();i++){
		hs[i]=hs[i-1]*base+ls[i]-96;
		hs[i]%=mod;
	}
	int ans1= binsTnum(1,ls.size());
	ls=ls+ls;
	hs[0]=ls[0]-96;
	for (i=1;i<ls.size();i++){
		hs[i]=hs[i-1]*base+ls[i]-96;
		hs[i]%=mod;
	}
	int ans2=binsTnum(1,ls.size());
	//cout<<ans1<<' '<<ans2<<'\n';
	if (ans1==ans2){
		cout<<ans1; return 0;
	}
	else{
		cout<<-1; return 0;
	}
	
	
}

Measured memory_bytes: 75072
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   string s;
   cin >> n >> s;
   FOR(i, 0, s.length())
   {
      s[i] = 'A' + (s[i] - 'A' + n) % 26;
   }
   cout << s << endl;
   return 0;
}


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

using namespace std;

typedef pair<int,int> ii;

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

    map<ii,int> coloring;
    vector<ii> edges = vector<ii>(N-1, ii());
    vector<int> adj_list[N+1];
    for (int i = 0; i < N-1; i++) {
        int ai, bi;
        cin >> ai >> bi;

        adj_list[ai].push_back(bi);
        adj_list[bi].push_back(ai);
        edges[i] = ii(ai,bi);
    }

    int K = 0;
    for (int i = 0; i < N; i++) {
        K = max(K, int(adj_list[i].size()));
    }

    queue<ii> q;
    q.push(ii(1,-1));

    bool seen[N+1];
    memset(seen, false, sizeof seen);
    seen[1] = true;
    while(!q.empty()) {
        ii u = q.front();
        q.pop();

        bool unused[K+1];
        memset(unused, true, sizeof unused);

        unused[u.second] = false;
        for (int v : adj_list[u.first]) {
            if (seen[v]) continue;

            int color;
            for (int i = 0; i < K; i++) {
                if (unused[i]) {
                    color = i;
                    break;
                }
            }

            unused[color] = false;
            coloring.insert(pair<ii,int>(ii(u.first,v),color));
            q.push(ii(v,color));
        }

        seen[u.first] = true;
    }

    cout << K << endl;
    for (int i = 0; i < N-1; i++) {
        ii e = edges[i];
        if (coloring.find(e) != coloring.end()) {
            cout << coloring[e]+1 << endl;
        } else {
            cout << coloring[ii(e.second,e.first)]+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 13184
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	A, B := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		A[i], B[i] = ReadInt(), ReadInt()
	}

	max := 0
	for i := 0; i < N; i++ {
		if K&A[i] == A[i] {
			max += B[i]
		}
	}

	for i := 0; 1<<i <= K; i++ {
		if K>>i&1 == 0 {
			continue
		}
		mask := K - 1<<i
		mask |= 1<<i - 1
		sum := 0
		for j := 0; j < N; j++ {
			if mask&A[j] == A[j] {
				sum += B[j]
			}
		}
		if sum > max {
			max = sum
		}
	}
	fmt.Println(max)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6296
#include<bits/stdc++.h>
using namespace std;
int a;
int main(){
    cin>>a;
    if(((a-a%100)/100!=7)&&((a%100-a%10)/10!=7)&&((a%10)!=7)){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
      if (data.at(i).at(j) == '.') {
        data.at(i).at(j) = '0';
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == '#') {
        for (int x = i-1; x <= i+1; x++) {
          if (x >= 0 && x < H) {
            for (int y = j-1; y <= j+1; y++) {
              if (y >= 0 && y < W) {
                if (data.at(x).at(y) != '#') {
                  data.at(x).at(y)++;
                }
              }
            }
          }
        }  
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << data.at(i).at(j);
      if (j == W - 1) {
      cout << endl;
      }
    }    
  }
}

Measured memory_bytes: 3572
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define LIMIT 10000000

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

int n;
bool isprime[10000000] = {0};

int solve()
{
	int res = 0;
	
	FOR(i, 2, n)
	{
		if( isprime[i])
		{
			for(int j = i; j+i <= n; j++)
			{
				if( isprime[j] && (i+j == n))
					res++;
			}
		}
	}
	
	return res;
}

void init()
{
	FOR(i, 2, LIMIT)
	{
		isprime[i] = true;
	}
	
	FOR(i, 2, LIMIT)
	{
		if(isprime[i])
		{
			for(int j = 2; i*j < LIMIT; j++)
			{
				isprime[i*j] = false;
			}
		}
	}
	
	return;
}

int main()
{
	init();
	
	while(cin >> n, n)
	{
		cout << solve() << endl;
	}
	
	return 0;
}

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


int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  int ans = 0;
  for(int i = 0;i < (N / 2); i++){
    char T1,T2;
    
    T1 = S.at(i);
    T2 = S.at(N - i - 1);
    if(T1 != T2) ans++;
  }
  
  cout << ans << endl;
  
  return 0; 
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int bi[62][200000];

int main(){
    int n;
    ll k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)  cin >> bi[0][i], bi[0][i]--;
    for(int s = 1; s < 62; s++){
        for(int i = 0; i < n; i++){
            bi[s][i] = bi[s-1][bi[s-1][i]];
        }
    }
    int pos = 0;
    for(int s = 0; s < 62; s++){
        if(k>>s&1)  pos = bi[s][pos];
    }
    cout << pos+1 << endl;
    return 0;
}

Measured memory_bytes: 52068
# パティシエの赤木さんは、「お菓子の素」という粉のみを材料として
# N 種類のドーナツを作ることができます。
# これらのドーナツはドーナツ 1、ドーナツ 2、...、ドーナツ N と呼ばれます。
# ドーナツ i (1≤i≤N) を 1 個作るには、お菓子の素 mi グラムを消費する必要があります。
# なお、0.5 個など整数でない個数のドーナツを作ることはできません。
# いま、赤木さんはお菓子の素を X グラム持っています。
# これを使って、今夜のパーティーに向けて可能な限り
# たくさんのドーナツを作ることにしました。
# ただし、来客の味の好みは様々なので、次の条件を守ることにしました。
# N 種類のドーナツそれぞれを少なくとも 1 個は作る。
# このとき、最大で何個のドーナツを作ることができるでしょうか？
# お菓子の素を使い切る必要はありません。
# また、この問題の制約のもとでは、条件を守ることは必ず可能です。

input_line_1 = gets.chomp.split
n = input_line_1[0].to_i
x = input_line_1[1].to_i

count = n
remain_ingredients = x

m = Array.new
n.times do
  input_line = gets.to_i
  remain_ingredients -= input_line
  m << input_line
end

min = m.min

loop do
  if remain_ingredients < min
    break
  else
    remain_ingredients -= min
    count += 1
  end
end

puts count


Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        if(a == 0L) {
            System.out.println(xor(b));
            return;
        }
        
        long za = xor(a - 1L);
        long zb = xor(b);
        long ans = za ^ zb;
        System.out.println(ans);
    }
    
    static long xor(long x) {
        if(x % 2L == 1L) {
            long q1 = (x + 1L) / 2L;
            return q1 % 2L;
        }
        
        if(x == 0L) return 0L;
        
        return xor(x - 1L) ^ x;
    }
}


Measured memory_bytes: 23892
#import<regex>
#define l(x)std::lower_bound(B,B+*a,x-A)
int a[2<<18],B[1<<18],s,A,i=1,j,L;main(){for(;~scanf("%d",a+A++););for(;i<1<<29;i*=2){for(;j++<*a;)B[j-1]=a[j+*a]%(i*2);for(std::sort(B,B+*a);--j;s^=(a[j]&i?*a-L:L)%2*i)A=a[j]%i,L=l(i*2)-l(i);}printf("%d",s);}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A;
  string result="YES";
  vector<bool> boolean(1000000000,false);
  cin >> N;
  for(int i = 0;i < N;i++){
  	cin >> A;
    if(boolean.at(A-1)){
    	result = "NO";
          break;
    }else{
    	boolean.at(A-1) = true;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 122368
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

const int MOD = pow(10,9) + 7;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}



long long power(long long a, long long b){
    ///// 繰り返し２乗法で a^b を求める。
    long long res = 1;
    while (b > 0){
        if (b&1) res = (res*a) %MOD; //// bの２進数表示で最低桁が1なら、結果にかける
        a = ( a * a )%MOD;
        b = b >> 1; //// ビットシフトで、見る桁を変える。
    }
    return res;
}


int main() {
  
    int N = in();
    
    vector<int> A;
    
    for(auto i = 0; i<N; i++){
        A.push_back(in()); ///左右の差の絶対値
    }
    
    sort(A.begin(),A.end(),greater<int>());
    
    int pre = N+1;
    for(auto a = A.begin(); a!= A.end(); a++){
        
        if (*a != pre -2){  //正しく減少
            cout << 0 << endl;
            return 0;
        }

        if(*a == 0){
            break;
        }

        auto nex = a;
        nex++;
        
        if (*a != *nex){
            cout << 0 << endl;   //２つづつのペアになっている。
            return 0;
        }
        
        pre = *a;
        a++;
        
        if (a == A.end()){
            break;
        }
        
    }
    
    long long nf = N/2;
    
    cout << power(2,nf) << endl;

    
    
    
    return 0;
    
}


Measured memory_bytes: 892
#include<stdio.h>
typedef long long int ll;

ll MIN(ll a, ll b){return a>b?b:a;}

int main(void){
    ll n,m;
    scanf("%lld%lld", &n,&m);

    ll ans;
    ans =  MIN(n,m/2);
    ans += (m-2*ans)/4;

    printf("%lld\n", ans);

    return 0;
}

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

using namespace std;

int a, b;

int main () {
  cin >> a >> b;
  if (b == 1) {cout << 0 << endl; return 0;}
  int ans = 0;
  b -= a;
  ans = 1;
  while (b > 0) {
    b -= a-1;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string s,a;
	cin >> s >> a;
	for (int z=0;z<n;z++){
		cout << s[z] << a[z];
	}
 }

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

ll gcd(ll a, ll b){
    if(b == 0)return a;
    return gcd(b,a%b);
}

int main() { 
  int n;
  cin >> n;
  ll res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll g = gcd(i, j);
        g = gcd(g, k);
        res += g;
      }
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300000;

int n, kmp[N], T; char s[N];
ll l, r, num[N][30];

ll fib(ll len, int c){
    if(len <= n) return num[len][c];
    if(len <= n * 2) return num[n][c] + num[len-n][c];
    ll f1 = num[n][c], f2 = num[n][c] + num[T][c], l1 = n, l2 = n + T;
    // 1 : S, 2 : ST;
    while(len > l1 + l2){
        ll tmp = f2;
        f2 += f1; f1 = tmp;
        tmp = l2;
        l2 += l1; l1 = tmp;
        //2 --> 1 + 2; 1 --> 2
        //exp: STSST --> STSSTSTS; STS --> STSST 
    }
    return f2 + fib(len - l2, c);
}

ll calc(ll len, int c){ // 计算前 len 位 c 出现的次数
    if(len <= n) return num[len][c];
    if(n % T == 0){ // 形如 TTT TTT 的字符串
        ll ret = 1ll * (len-n) / T * num[T][c] + num[n][c]; // T 出现了(len-n)/T次, n出现了1次
        len -= n; len %= T;
        return ret + num[len][c];
    }
    return fib(len, c);
}

int main(){
    scanf("%s%lld%lld", s+1, &l, &r);
    n = strlen(s+1) / 2;
    kmp[0] = kmp[1] = 0; int p = 0;
    for(int i=2; i<=n; i++){
        while(p && s[i] != s[p+1]) p = kmp[p];
        kmp[i] = (s[i] == s[p+1]) ? ++p : p;
    }

    for(int i=1; i<=n; i++){
        for(int j=0; j< 26; j++)
            num[i][j] = num[i-1][j];
        num[i][s[i] - 'a'] ++;
    } // num[i][j] : 第i位和之前字符j出现的次数
    T = n - kmp[n]; // T:最长的等于一个前缀的后缀的起始位置的前一位 
    //printf("%d\n", T);
    for(int i=0; i< 26; i++)
        printf("%lld%c", calc(r, i) - calc(l-1, i), (i == 25) ? 10 : 32);
    //printf("%d\n", calc(5, 1));

    return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	int n, m, k, a, ret;
	ret = 0;
	int ms[31] = {0};
	
	cin >> n >> m;
	
	
	
	rep(i, n){
		cin >> k;
		rep(i, k){
			cin >> a;
			ms[a]++;
		}
	}
	
	rep(i,m + 1){
		if( ms[i] == n){
			ret++;
		}
	}
	
	cout << ret;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,s=1;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {  
      if(i<0)
            s*=-1;
      if(i==0)
      {
          cout<<"Zero"<<endl;
          return 0;
      } 
    }
    if(s>0)
        cout<<"Positive"<<endl;
    if(s<0)
        cout<<"Negative"<<endl;
    if(s==0)
        cout<<"Zero"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b, c, d;

	cin >> a;

	b = a / 3600; //h?????¨???

	int hs, s;

	hs = 3600 * b;
	
	a = a - hs;

	c = a / 60;  //m?????¨???

	s = c * 60;

	d = a - s;  //s?????¨???

	cout << b << ":" << c << ":" << d <<endl;


	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  int i = 0;
  while (a > 0 && c > 0) {
    if (i % 2 == 0)
      c -= b;
    else
      a -= d;
    i++;
  }

  cout << (a > c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i,N){
        if((i + 1) % 3 != 0 && (i + 1) % 5 != 0){
            ans += i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1]-a[0]<<endl;
}


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

int main(void){
    long n;
    cin >> n;
    vector<long> v(n);
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        v[i] = t-(i+1);
    }
    sort(v.begin(), v.end());
    long ans = 0;
    for(long i=0; i<n; i++){
        ans += labs(v[i]-v[n/2]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var l = double.Parse(Console.ReadLine());
        Console.WriteLine(Pow(l / 3, 3));
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(k,n) for(int i=k;i<(n);i++)
#define REP(n) for(int i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
 
#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))
 
#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))
 
#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}
 
#define acm accumulate
#define SUM(v) accumulate(all(v),0l)
 
 
int main() {
  long long n;
  cin>>n;
  long long k=n-1;
  for(long long i=2;i<=sqrt(n);i++){
    if(n%i==0){
      k=min(k,i+n/i-2);
    }
  }
  cout<<k;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            args=new string[3];
            args[0] = console.ReadLine();
                 args[1] = args[0].Count()==26?((char)(25 - args[0].Skip(1).Zip(args[0],(a,b)=>a-b).Reverse().TakeWhile(i=>i<0).Count())).ToString():"";
            console.WriteLine(args[0].Count()==26?((args[1][0]==0)?"-1":(string.Join("",args[0].Take(args[1][0]).Select((v,i)=>i==args[1][0]-1?args[0].Last(c=>c>args[0][args[1][0]-1]):v)))):(args[0] +(char)('a'+ args[0].OrderBy(c=>c).Where((c,i)=>c-i=='a').Count())));
        }
    }
}

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

int main() {

	ll n; cin >> n;
	string s; cin >> s;
	/*ll w_cnt = 0;
	ll r_cnt = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'W') w_cnt++;
		else r_cnt++;
	}
	ll diff = abs(r_cnt - w_cnt);
	if (diff != 0) {
		bool w_large;
		ll index;
		if (w_cnt < r_cnt) {
			w_large = false;
			index = n - 1;
		}
		else if (r_cnt < w_cnt) {
			w_large = true;
			index = 0;
		}
		ll cnt = diff / 2;		
		if (w_large) {
			while (0 < cnt) {
				if (s[index] == 'W') {
					s[index] = 'R';
					cnt--;
				}
				index++;
			}
		}
		else {
			while (0 < cnt) {
				if (s[index] == 'R') {
					s[index] = 'W';
					cnt--;
				}
				index--;
			}
		}
	}*/
	ll left_w = 0;
	ll right_r = n - 1;
	ll ans = 0;
	while (true) {
		while (true) {
			if (s[left_w] == 'W') {
				break;
			}
			else {
				left_w++;
				if (left_w == n) {
					break;
				}
			}
		}
		while (true) {
			if (s[right_r] == 'R') {
				break;
			}
			else {
				right_r--;
				if (right_r == -1) {
					break;
				}
			}
		}
		if (left_w == n || right_r == -1) {
			break;
		}
		if (right_r < left_w) {
			break;
		}
		swap(s[left_w], s[right_r]);
		ans++;
		left_w++;
		right_r--;
		if (left_w == n || right_r == -1) {
			break;
		}
		if (right_r < left_w) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3736
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	cin >> S;

	auto pos = S.find( "hi" );
	while( pos != string::npos ) {
		S.erase( pos, 2 );
		pos = S.find( "hi", pos );
	}

	cout << (S.empty() ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()

	if n == 1 {
		fmt.Println("Hello World")
	} else {
		a, b := getInt(), getInt()
		fmt.Println(a + b)
	}
}


Measured memory_bytes: 640