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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  string s; cin >> s;
  int ans = 0;
  if(s == "MON")  ans = 6;
  else if(s == "TUE") ans = 5;
  else if(s == "WED") ans = 4;
  else if(s == "THU") ans = 3;
  else if(s == "FRI") ans = 2;
  else if(s == "SAT") ans = 1;
  else if(s == "SUN") ans = 7;
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[4];
int main(){
	scanf("%s",in);
	if(in[1]=='B')printf("ARC\n");
	else printf("ABC\n");
}

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

int main(){
  int A,B,C,K; //1,0,-1,枚数
  int ans;
  
  cin >> A >> B >> C >> K;
  
  if(A>=K){
  	ans = K;
  }else{
  	ans = A;
    K -= A;
    if(B>=K){
    }else{
    	K -= B;
      	ans -= K;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
def si(p):
  if p == 0:
    return "-"
  else:
    return "+"
N = int(input())
X = [N // 1000, (N % 1000) // 100, (N % 100) // 10, N % 10]
f = 0
for i in range(2):
  for j in range(2):
    for k in range(2):
      x = X[0] + (2 * i - 1) * X[1] + (2 * j - 1) * X[2] + (2 * k - 1) * X[3]
      if x == 7:
        print(str(X[0]) + si(i) + str(X[1]) + si(j) + str(X[2]) + si(k) + str(X[3]) + "=7")
        f = 1
        break
    if f == 1:
      break
  if f == 1:
    break

Measured memory_bytes: 61924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,N,cnt=0;
  string s;
  queue<int> a;
  queue<string> b;
  cin>>n>>q;
  for(int i=0;i<n;i++){
    cin>>s>>N;
    a.push(N);
    b.push(s);
  }
  while(!a.empty()){
    if(a.front()-q > 0){
      cnt+=q;
      a.push(a.front()-q);
      a.pop();
      b.push(b.front());
      b.pop();
    }else{
      cnt+=a.front();
      cout<<b.front()<<" "<<cnt<<endl;
      a.pop();
      b.pop();
    }
  }
  return 0;
}



Measured memory_bytes: 6032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		for(int i = 1 ; i <= Math.sqrt(n) + 1 ; i++) {
			if(i * i > n)
				break;
			max = i * i;
		}

		sc.close();
		System.out.println(max);

	}
}



Measured memory_bytes: 35800
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef unsigned long long ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 1e12;
    const int i_INF = 2147483647;
     
    int main() {
      int a,b;
      cin>>a>>b;
      if((b%a)!=0)cout<<b-a<<endl;
      else cout<<b+a<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;

	const int MAX = 3005;
	ll N;
	double probs[MAX];
	double dp[MAX][MAX], vis[MAX][MAX];
	
	double prob(ll pos, ll heads) {
		if(heads<0) {
			return 0.0;
		}

		if(pos == 0) {
			return (heads == 0);
		}

		if(vis[pos][heads]) {
			return dp[pos][heads];
		}
		vis[pos][heads] = 1;
		return dp[pos][heads] = prob(pos-1,heads-1)*probs[pos] + prob(pos-1,heads)*(1.0 -probs[pos]);

	}
	int main()
	{	
		std::ios::sync_with_stdio(false);
		
		memset(dp,0.0,sizeof(dp));
		cin>>N;

		for(ll i=1; i<=N; i++) {
			cin>>probs[i];
		}
		double tot = 0;
		for(ll i=(N+1)/2; i<=N; i++) {
			
			
				tot = tot + prob(N,i);
			
		}

		cout<<setprecision(10)<<tot<<endl;
		return 0;
	}


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

inline void read(int &a)
{
    a=0;int c=getchar();
    while(c>'9'||c<'0') c=getchar();
    while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();
}

int n,P;

int main()
{
	read(n);read(P);
	cout<<(n*3+P)/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string b; cin >> b;
    if(b[0]==b[2]) pr("Yes");
    else pr("No");
}



Measured memory_bytes: 256
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String o="";
        long x=sc.nextLong();
        x=x%10;
        if(x==2||x==4||x==5||x==7||x==9)o="hon";
      	else if(x==3)o="bon";
      else o="pon";
      System.out.println(o);
    }
    
}

Measured memory_bytes: 35788
#include <stdlib.h>
#include <stdio.h>
int main(void){
  int x;
  int uresisa=0;
 
  scanf("%d",&x);
  uresisa=x/500*1000;
  x=x-x/500*500;
  uresisa=uresisa+x/5*5;
  printf("%d",uresisa);
  return 0;
}


Measured memory_bytes: 1732
K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.reverse()
span = []
for i in range(len(A)):
  if i + 1 > len(A) - 1:
    span.append(K - A[0] + A[-1])
    continue
  span.append(A[i] - A[i + 1])
print(sum(span) - max(span))


Measured memory_bytes: 24908
import sys
def input(): return sys.stdin.readline().strip()


def main():
    h1, m1, h2, m2, k = map(int, input().split())
    wake = (h2 - h1) * 60 + m2 - m1
    print(max(0, wake - k))



if __name__ == "__main__":
    main()


Measured memory_bytes: 61644
#include <stdio.h>

int main(){

  int i,num,a,b,c,d,j,k;
  int mat1[222][333]={0};
  int mat2[222][333]={0};
  int mat3[222][333]={0};
  int mat4[222][333]={0};

  scanf("%d",&num);

 for(i=0;i<num;i++){
   scanf("%d%d%d%d",&a,&b,&c,&d);
 if(a==1)
     mat1[b-1][c-1]+=d;
 if(a==2)
     mat2[b-1][c-1]+=d;
 if(a==3)
     mat3[b-1][c-1]+=d;
 if(a==4)
     mat4[b-1][c-1]+=d;
 }





   for(j=0;j<3;j++){
     for(k=0;k<10;k++){

       printf("%2d",mat1[j][k]);
     }
     printf("\n");
}
     printf("####################\n");
   


 for(j=0;j<3;j++){
     for(k=0;k<10;k++){

       printf("%2d",mat2[j][k]);
     }
     printf("\n");
   }
 printf("####################\n");

  
 for(j=0;j<3;j++){
     for(k=0;k<10;k++){

       printf("%2d",mat3[j][k]);
     }
     printf("\n");
}
     printf("####################\n");
   
   for(j=0;j<3;j++){
     for(k=0;k<10;k++){

       printf("%2d",mat4[j][k]);
     }
     printf("\n");
   }




 return 0;
}

Measured memory_bytes: 1780
#include<stdio.h>
int max(int a, int b, int c);
int main(void){
    int A,B;
    scanf("%d %d", &A, &B);
    printf("%d\n",max((A+B),(A-B),(A*B)));
    return 0;
}

int max(int a, int b, int c){
    int max = a;
    if(max < b) max = b;
    if(max < c) max = c;
    return max;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int num;
    scanf("%d", &num);
    if(num%10==2||num%10==4||num%10==5||num%10==7||num%10==9){
        printf("hon");
    }else if(num%10==0||num%10==1||num%10==6||num%10==8){
        printf("pon");
    }else{
        printf("bon");
    }
    return 0;
}

Measured memory_bytes: 1732
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int a, b;
  	cin >> a >> b;
	if(b%a ==0) cout << a+b << endl;
	else cout << b-a << endl;  	
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main()
{
    // cout << fixed << setprecision(5);
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    string t;
    rep(i, Q)
    {
        int ty;
        cin >> ty;
        if (ty == 1)
        {
            swap(S, t);
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                t += c;
            }
            else
            {
                S += c;
            }
        }
    }
    reverse(t.begin(), t.end());
    t += S;
    cout << t << endl;

    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
const int N=25005,P=1e9+7;
int n,k,m,a[N],f[N][405],g[N][405],lst[405],fac[405];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r;} 
int main()
{
	scanf("%d%d%d",&n,&k,&m);
	int l=0,mx=0,ans=1ll*(n-m+1)*pw(k,n-m)%P;
	for(int i=1;i<=m;i++)scanf("%d",&a[i]),l=min(l+1,i-lst[a[i]]),lst[a[i]]=i,mx=max(mx,l);
	for(int i=fac[0]=1;i<=k;i++)fac[i]=1ll*fac[i-1]*i%P;
	if(mx==k){printf("%d\n",ans);return 0;}
	if(mx==m)
	{
		f[0][0]=1;
		for(int i=1;i<=n;i++)for(int j=k-1,s1=0,s2=0;j>=1;j--)
		{
			s1=(s1+f[i-1][j])%P;s2=(s2+g[i-1][j])%P;
			f[i][j]=(s1+1ll*f[i-1][j-1]*(k-j+1))%P;
			g[i][j]=(s2+1ll*g[i-1][j-1]*(k-j+1))%P;
			if(j>=m)g[i][j]=(g[i][j]+f[i][j])%P;
		}
		int res=0;for(int i=1;i<k;i++)res=(res+g[n][i])%P;
		res=1ll*res*fac[k-m]%P*pw(fac[k],P-2)%P;
		printf("%d\n",(ans+P-res)%P);
		return 0;
	}
	int u=0,v=0,res=0;
	memset(lst,0,sizeof(lst));
	for(int i=1;i<=m;i++)if(!lst[a[i]])u++,lst[a[i]]=1;else break;
	memset(lst,0,sizeof(lst));
	for(int i=m;i>=1;i--)if(!lst[a[i]])v++,lst[a[i]]=1;else break;
	f[0][u]=g[0][v]=1;
	for(int i=1;i<=n;i++)for(int j=k-1,s=0;j>=1;j--)
	{
		s=(s+f[i-1][j])%P;
		f[i][j]=(s+1ll*f[i-1][j-1]*(k-j+1))%P;
	}
	for(int i=1;i<=n;i++)for(int j=k-1,s=0;j>=1;j--)
	{
		s=(s+g[i-1][j])%P;
		g[i][j]=(s+1ll*g[i-1][j-1]*(k-j+1))%P;
	}
	for(int i=0;i<=n-m;i++)
	{
		int s=0,t=0;
		for(int j=1;j<k;j++)s=(s+f[i][j])%P,t=(t+g[n-m-i][j])%P;
		res=(res+1ll*s*t)%P;
	}
	printf("%d\n",(ans+P-res)%P);
	return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a;
    cin>>a;
    int arr[a], dp[a];
    for (int i=0; i<a; i++) cin>>arr[i];
    dp[0]=0, dp[1]=abs(arr[0]-arr[1]);
    for (int i=2; i<a; i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[a-1]<<endl;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    string t = "";
    t += s[0];
    t += s[1];
    t += s[2];
    print(t);
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
    int b = sc.nextInt();  // input Integer
//    String a = sc.next();  // input String
    if (a>b){
      System.out.println(2*a-1);
    } else if (a==b){
      System.out.println(2*a);
    } else {
      System.out.println(2*b-1);
    }
  }
}


Measured memory_bytes: 23892
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

s = input_s

if s == "ABC"
  puts "ARC"
else
  puts "ABC"
end


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

int main() {
  int n,m;
  cin>>n>>m;
  int high[n];
  for(int i=0; i<n; i++) cin>>high[i];

  bool good[n];
  for(int i=0; i<n; i++) good[i]=true;

  for(int i=0; i<m; i++) {
    int a,b;
    cin>>a>>b;
    if(high[a-1]==high[b-1]) {
      good[a-1]=false;
      good[b-1]=false;
    }
    else if(high[a-1]>high[b-1]) good[b-1]=false;
    else good[a-1]=false;
  }

  int ans = 0;
  for(int i=0; i<n; i++) {
    if(good[i]) ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 4112
#include <stdio.h>
int main(){
  int a ,b ,i ,ans ,total[5]={} ,tmp=0;
  while( scanf( "%d %d" ,&a ,&b ) != EOF ){
    if( a == 0 && b == 0 ){
      break;
    }
    total[0] = a + b;

    for( i=1 ; i<5 ; i++ ){
      scanf( "%d %d" ,&a ,&b );
      total[i] = a + b;
    }
    
    for( i=0 ; i<5 ; i++ ){
      if( total[i] > tmp ){
	tmp = total[i];
	ans = i;
      }
    }
    
    switch(ans){
    case 0:
      printf( "A %d\n" ,total[ans] );
      break;
    case 1:
      printf( "B %d\n" ,total[ans] );
      break;
      
    case 2:
      printf( "C %d\n" ,total[ans] );
      break;
      
    case 3:
      printf( "D %d\n" ,total[ans] );
      break;
      
    case 4:
      printf( "E %d\n" ,total[ans] );
      break;
    }

    for( i=0 ; i<5 ; i++ ){
      total[i] = 0;
    }
    tmp = 0;
    ans = 0;
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
    string str,test;
    while(cin>>str>>test){
        vector<string> v;
        int N=str.size();
        for(int i=0;i<N;i++){
            v.push_back( str.substr(i,N-i) );
        }
        sort(v.begin(),v.end());
        int ans=N;
        for(int i=1;i<test.size();i++){
            bool flag=false;
            for(int j=0;j<test.size()-i+1;j++){
                string tmp = test.substr(j,i);
                vector<string>::iterator itr = lower_bound(v.begin(),v.end(),tmp);
                int z=(int)(itr-v.begin());
                if(z!=N && v[z].size() >= i){
                    if(tmp == v[z].substr(0,i)){
                        flag=true;
                        break;
                    }
                }
            }
            if(!flag){
                ans=i-1;
                break;
            }
        }
        cout<<ans<<endl;
        str.clear();
        test.clear();
    }
    
    return 0;
}

Measured memory_bytes: 10976
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<char, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    s = 'a' + s + 'a';
    vector<P> vec;
    REP(i,s.size()){
        if(s[i] != 'x'){
            vec.push_back(P(s[i], i));
        }
    }
    int i,j,k,l;
    if(vec.size() % 2 == 0){
        i = vec.size() / 2 - 1, j = vec.size() / 2;
        k = vec[vec.size() / 2 - 1].second;
        l = vec[vec.size() / 2].second;
    }else{
        i = vec.size() / 2 - 1, j = vec.size() / 2 + 1;
        k = vec[vec.size() / 2].second;
        l = vec[vec.size() / 2].second;
    }
    while(i >= 0){
        if(vec[i].first != vec[j].first){
            cout << -1 << endl;
            return 0;
        }
        i--;
        j++;
    }
    int ans = 0;
    while(k >= 0){
        while(k >= 0 && s[k] != s[l]){
            ans++;
            if(s[k] == 'x'){
                k--;
            }else{
                l++;
            }
        }
        k--;
        l++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1524
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
long long pri[110],n;
int check(int x){
	int cnt=0;
	for(int i=2;i<=100;i++){
		if(pri[i]>=x) cnt++;
	}
	return cnt;
}
int check(int x,int y){
	int cnt=0;
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++){
			if(i==j)continue;
			if(pri[i]>=x && pri[j]>=y)cnt++;
		}
	}
	return cnt;
}
int check(int x,int y,int z){
	int cnt=0;
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++){
			if(i==j)continue;
			for(int k=j+1;k<=100;k++){
				if(k==i)continue;
				if(pri[i]>=x && pri[j]>=y && pri[k]>=z)cnt++;
			}
		}
	}
	return cnt;
}
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		int p=i,cnt=2;
		while(p>1){
			while(p%cnt==0){
				pri[cnt]++;
				p/=cnt;
			}
			cnt++;
		}
	}
	cout<<check(74)+check(4,14)+check(2,24)+check(2,4,4)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
  long long N, K;
  long long X = 0;
  long long score = 0;
  long long Y = 0;
  long long scoreY = 0;
  long long mask;
  cin >> N >> K;
  vector<int> mb;
  long long A[100001], B[100001];
  for (int i=30;i > 0;i--) {
    if (K&(1<<i)) {
      mb.push_back(i);
    }
  }
  mask = K;
  for (long long i=0;i < N;i++) {
    long long AA, BB;
    cin >> AA >> BB;
    A[i] = AA;
    B[i] = BB;
    if (((~mask)&(X|A[i]))==0) {
      X = X|A[i];
      score += B[i];
    }
  }
  //  cout << "!" << endl;
  for (auto it=mb.begin();it!=mb.end();it++) {
    long long score_tmp = 0;
    int max_bit = *it;
    mask = K & ~(1<<max_bit);
    mask = mask | ~((~0)<<max_bit);
    X = 0;
    for (long long i=0;i < N;i++) {
      //      cout << i << endl;
      if (((~mask)&(X|A[i]))==0) {
	X = X|A[i];
      score_tmp += B[i];
      }
    }
    if (score_tmp > score) {
      score = score_tmp;
    }
  }
  cout << score << endl;

}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
#import math
import fractions #fractions.gcd()
sys.setrecursionlimit(1000000)

def main(): 

    N = int(input())
    A = list(map(int,input().split()))
    A_gcd_for=[]
    A_gcd_for.append(A[0])
    A_gcd_af=[]
    A_gcd_af.append(A[-1])
    for i in range(1,N):
        A_gcd_for.append(fractions.gcd(A_gcd_for[-1], A[i]))
        A_gcd_af.append(fractions.gcd(A_gcd_af[-1], A[N-i-1]))
    ans=0
    for i in range(N):
        if i==0: a = A_gcd_af[N-i-2]
        elif i==N-1: a = A_gcd_for[i-1]
        else: a = fractions.gcd(A_gcd_for[i-1], A_gcd_af[N-i-2])
        if a > ans:
            ans=a
    print(ans)

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 16132
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        long x = Long.parseLong(s.next());
        // double loggg = Math.log(5.0);

        for (long i = 1;;i++) {
            long expect5 = i*i*i*i*i - x;
            if (expect5 > 0) {
                for (long j = 1;;j++) {
                    if (j*j*j*j*j < expect5) {
                        continue;
                    } else if (j*j*j*j*j == expect5) {
                        System.out.println("" + i + " " + j);
                        return;
                    } else {
                        break;
                    }
                }
            } else if (expect5 < 0) {
                for (long j = -1;;j--) {
                    if (j*j*j*j*j > expect5) {
                        continue;
                    } else if (j*j*j*j*j == expect5) {
                        System.out.println("" + i + " " + j);
                        return;
                    } else {
                        break;
                    }
                }
            } else {
                System.out.println("" + i + " " + 0);
                return;
            }
        }
    }
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    int w[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> w[i];

    int mn = INF;
    for (int i = 1; i < n; i++)
    {
        int s1 = 0, s2 = 0;
        for (int j = 0; j < n; j++)
        {
            if (j <= i)
                s1 += w[j];
            else
                s2 += w[j];
        }
        mn = min(mn, abs(s1 - s2));
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
/*8_C*/
#include<stdio.h>
#include<string.h>
int main() {
    int i,a,len;
	char st[1201];
    int num;
    int alp[26]={0};
    while(scanf("%s",st) != EOF) {
        a=0;
        len = strlen(st);
        while(1) {
            num = st[a]-'a';
            if(st[a] >= 97 && st[a] <=122) {
                alp[num]++;
            } else if(st[a] >= 65 && st[a] <=90) {
                alp[num+32]++;
            }
            a++;
            if(a>=len) break;
        }
    }
    for(i=97;i<=122;i++) {
        printf("%c : %d\n",i,alp[i-97]);
    }
	return 0;
}


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

const ll INF=1000000000000000000;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>x(n);
    rep(i,n)cin>>x[i];
    ll ans=INF;
    for(ll i=0;i<n-k+1;i++){
        ll dx=abs(x[i]);
        ll dy=abs(x[i+k-1]);
        dx+=abs(x[i]-x[i+k-1]);
        dy+=abs(x[i+k-1]-x[i]);
        ll d=min(dx,dy);
        ans=min(ans,d);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <unordered_map>
using namespace std;
#define PB push_back
unordered_map<int,bool> m;
vector<int> v;
bool f(int n){
  if(m.find(n)!=m.end())return m[n];
  for(int i:v){
  if(i>n)break;
   	if(!f(n-i))return m[n]=true;
  }
  return m[n]=false;
}
int main(){
int n,k,temp;
  scanf("%d%d",&n,&k);
  while(n--){
scanf("%d",&temp);
    v.PB(temp);}
  if(f(k))printf("First\n");
  else printf("Second\n");
}

Measured memory_bytes: 8996
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  string line;
  getline(cin, line);
  if (line.length() >= 4 && line[0] == 'Y' &&
	  line[1] == 'A' && line[2] == 'K' && line[3] == 'I' )
  {
	cout << "Yes" << endl;
  }
  else
  {
	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def main():
    A, B, C = input().split(' ')

    if A == B and B == C:
        print('No')
    elif A == B:
        print('Yes')
    elif B == C:
        print('Yes')
    elif A == C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) {
        cin >> s[i];
    }
    vector<vector<int>> cnt(h, vector<int>(w));
    rep(i, h) {
        vector<int> done(w);
        rep(j, w) {
            if(s[i][j] == '#') {
                continue;
            }
            if(done[j]) {
                continue;
            }
            int l = 0;
            while(j+l < w) {
                if(s[i][j+l] == '#') {
                    break;
                }
                l++;
            }
            rep(k, l) {
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }
    rep(j, w) {
        vector<int> done(h);
        rep(i, h) {
            if(s[i][j] == '#') {
                continue;
            }
            if(done[i]) {
                continue;
            }
            int l = 0;
            while(i+l < h) {
                if(s[i+l][j] == '#') {
                    break;
                }
                l++;
            }
            rep(k, l) {
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    rep(i, h) {
        rep(j,w) {
            ans = max(ans, cnt[i][j]-1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<int> h;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    h.push_back(tmp);
  }

  sort(h.begin(), h.end());

  int diff = h[N - 1] - h[0];
  for (int i = 0; i <= N - K; i++) {
    int min = h[i];
    int max = h[i + K - 1];
    if (diff > max - min)
      diff = max - min;
  }

  cout << diff << endl;

  return 0;
}

Measured memory_bytes: 892
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())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
roots = uf.roots()
cnt = []
for r in roots:
    cnt.append(uf.size(r))
cnt.sort(reverse=True)
ans = cnt[0]
print(ans)


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

bool is_prime(int n){ //2以上のnが素数ならtrueを返す
    bool flag =true;
    for(int i=2; i*i <= n; i++){
        if(n%i == 0){
            flag = false;
        }
    }
    return flag;
}

int main(){
    int N;
    cin >> N;
    int cnt =0;

    for(int i=2; i<=55555; i++){
        if(is_prime(i) && i%5==1) {
            if(cnt < N-1){
                cout << i << " ";
            }
            if(cnt==N-1){
                cout << i;
            }
            cnt++;
        }
        if(cnt==N) {cout << endl; break;}
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vvint dp(n+1,vint(n+1,0));
    for(int i=n-1;i>=0;--i){
        for(int j=n-1;j>=0;--j){
            if(s[i]==s[j]){
                dp[i][j] = dp[i+1][j+1]+1;
            }
        }
    }
    int ans = 0;
    REP(i,n){
        REP(j,n){
            if(abs(i-j)>=dp[i][j]){
                ans = max(ans,dp[i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98176
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine().toLong

    val n = 1000000000L

    val bx = (n - s % n) % n
    val by = (s + bx) / n

    out.println(
      List(
        List(0, 0),
        List(n, 1),
        List(bx, by)
      ).map(_.mkString(" ")).mkString(" ")
    )

    out.flush()
  }
}

Measured memory_bytes: 25508
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	string s;
	cin>>s;
	int x=0;
	int y=753;
	int ans=100000000;
	int n=s.size();
	for(int i=0;i<n-2;i++){
	
		int z=100;
		x=0;
		for(int j=i;j<i+3;j++){
		
			x+=(int(s[j])-48)*z;
			z/=10;
		}
		if(abs(y-x)<ans){
		
			ans=abs(y-x);
		}

	}
	cout<<ans<<'\n';
	return 0;
}


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


void solve(long long N, long long K, std::vector<long long> l){
    //sort(l.begin(), l.end(), greater<long long>());
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    long long ans = 0;
    for(long long i = 0; i < K; ++i){
        ans = ans + l[i];
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> l(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&l[i]);
    }
    solve(N, K, std::move(l));
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
input=sys.stdin.readline

N=int(input())
L=[list(map(lambda x:int(x)-1,input().split())) for _ in range(N)]
q=deque(range(N))
days=[0]*N
pairs=[-1]*N
while q:
	a=q.popleft()
	if len(L[a])==0:continue
	b=L[a].pop(0)
	if pairs[b]==a:
		days[a]=days[b]=max(days[a],days[b])+1
		q.append(a);q.append(b)
	else:
		pairs[a]=b
print(max(days) if not any(L)else -1)

Measured memory_bytes: 35316
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        a--;
        p[i] = a;
    }
    int index = 0;
    int count = 0;
    while(1){
        if(index >= N-1) break;
        if(p[index] != index) index++;
        else{
            swap(p[index],p[index+1]);
            count++;
            index++;
        }
    }
    if(p[N-1] == N-1) count++;
    cout << count << endl;
    return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    ll N, K, result;
    cin >> N >> K;
    if (K == 0) {
        result = N * N;
    } else {
        result = 0;
        FOR(b, K + 1, N + 1) {
            ll q = N / b;
            ll r = N % b;
            result += (b - K) * q + max(0ll, r - K + 1);
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long double PI = acos(-1);
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
ll MOD = 1000000007;
ll fact(ll m) {
  if(m == 0 || m == 1) return 1LL;
  else return (m * fact(m-1LL)) % MOD;
}
bool custom(pair<ll, ll> a, pair<ll, ll> b) {
  if(a.first == b.first) return (a.second > b.second);
  else return a.first < b.first;
}
int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<ll> x(n);
  vector<ll> h(n);
  vector<pair<ll, ll>> xh(n);
  for(int i=0;i<n;i++) {
    cin >> x[i];
    cin >> h[i];
    xh[i].first = x[i];
    xh[i].second = h[i];
  }
  sort(xh.begin(), xh.end(), custom);
  for(int i=0;i<n;i++) {
    x[i] = xh[i].first;
    h[i] = xh[i].second;
  }
  vector<ll> damage(n);
  ll ans = 0;
  for(int i=0;i<n;i++) {
    if(i == 0) damage[i] = 0;
    else damage[i] = damage[i-1] + damage[i];
    h[i] -= damage[i];
    if(h[i] <= 0) continue;
    auto it = upper_bound(x.begin(), x.end(), x[i] + 2LL * d);
    int dist = distance(x.begin(), it);
    ll da;
    ll time;
    if(h[i] % a == 0) time = h[i] / a;
    else time = h[i] / a + 1;
    da = a * time;
    damage[i] += da;
    if(dist != n) damage[dist] -= da;
    ans += time;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//区間XORと区間和が等しい <=> その区間において二回以上立っているビットがない

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<vector<int>> B(20, vector<int>(N, 0)), S(20, vector<int>(N+1, 0));
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		for (int j = 0; j < 20; j++) {
			if (A[i] & (1 << j))B[j][i]++;
		}
	}
	for (int i = 0; i < 20; i++) {
		for (int j = 0; j < N; j++) {
			S[i][j + 1] = S[i][j] + B[i][j];
		}
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll tmp = INF;
		for (int j = 0; j < 20; j++) {
			auto itr = upper_bound(S[j].begin(), S[j].end(), S[j][i] + 1);
			tmp = min(tmp, (ll)(itr - S[j].begin()) - i - 1);
		}
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 33136
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pii>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        double u;
        double v;
        double sum=0;
        Fr(i,0,n-1){
            cin>>v;
            u=(double)1/v;
            sum+=u;
        }
        v=(double)1/sum;
        cout<<setprecision(8)<<v<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long a[n+1];
	for(int i=0;i<=n;i++){
		if(i>=2) a[i]=a[i-1]+a[i-2];
		else if(i==0) a[i]=2;
		else a[i]=1;
	}
	cout<<a[n]<<endl;
	return 0;
}
//递归函数会超时，不如用数组
//注意数据大时超出int范围 

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    
    double x1,x2,y1,y2,H,W,d;
    double distance;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    H=y2-y1;
    W=x2-x1;
   
    d=H*H+W*W;
    distance=(double)sqrt(d);
    printf("%f\n",distance);
    
    
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  cout << n * 800 - (n / 15 * 200) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

int main(){
    string a,b;
    cin >> a >> b;
    string c = a + b;
    int n = stoi(c);
    bool f = false;
    for(int i = 1; i * i <= n; i++){
        if(i * i == n) f = true;
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
void main() {
  auto N = readAs!ulong;
  auto arr = 5.iota.map!(i => readAs!ulong);
  writeln((ceil(N /arr.reduce!min.to!real) + 4).to!ulong);
}
// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int dp[100010];
int main(void) {
    int N, M;
    cin >> N >> M;
    vector<bool> no(N);
    for(int i = 0; i < M; i++) {
        int a;
        cin >> a;
        no[a] = true;
    }
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
        if (no[i]) continue;
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
        if (i >= 2) { 
            dp[i] += dp[i - 2];
            dp[i] %= MOD;
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
long n,aa[6]={0},i,j;
double a;
cin>>n;
for(i=0;i<n;i++){
cin >>a;
if(a<165)aa[0]++;
else if(a<170)aa[1]++;
else if(a<175)aa[2]++;
else if(a<180)aa[3]++;
else if(a<185)aa[4]++;
else aa[5]++;
}
for(j=0;j<6;j++){
cout<<j+1<<":";for(i=0;i<aa[j];i++)cout<<"*";cout<<endl;
}
return 0;
}

Measured memory_bytes: 1228
n = int(input())
li = [list(map(int,input().split())) for i in range(n-1)] #csf

for i in range(n-1):
    t = li[i][1] + li[i][0]
    for j in range(i+1,n-1):
        while True:
            if t >= li[j][1] and t%li[j][2] == 0:
                break
            else:
                t += 1
        t += li[j][0]
    print(t)
print(0)

Measured memory_bytes: 43100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	ll n,ans=0,m=0,a=0,r=0,c=0,h=0;
	cin >> n;;
	string str;
	rep(i, n) {
		cin >> str;
		if (str[0] == 'M') m++;
		if (str[0] == 'A') a++;
		if (str[0] == 'R') r++;
		if (str[0] == 'C') c++;
		if (str[0] == 'H') h++;
	}
	ll d[] = { m,a,r,c,h };
	rep(i, 5)
		REP(j, i + 1, 5)
		REP(k, j + 1, 5)
		ans += d[i] * d[j] * d[k];

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


Measured memory_bytes: 256
a, b, c, x, y = map(int,input().split())

ans = a*x + b*y

if x < y:
  ans = min(ans,2*x*c+(y-x)*b)
else:
  ans = min(ans,2*y*c+(x-y)*a)

print(min(ans,max(x,y)*c*2))

Measured memory_bytes: 3060
N, K ,Q = (int(nkq) for nkq in input().split())
A = []
score_list = [-1] + [K-Q for _ in range(N)]
for _ in range(Q):
    A.append(int(input()))

for a in A:
    score_list[a] += 1

for score in score_list[1:]:
    if score > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 12576
n = int(input())
A = list(map(int, input().split()))
A2 = []

for i in range(n):
    if A[i] % 2 == 0:
        A2.append(A[i])
        
count = 0
for a in A2:
    while a % 2 == 0:
        a = a // 2
        count += 1
        
print(count)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N;
    cin >> N;
    int A[N];
    int ans=0;
    rep(i,N) cin >> A[i];
    rep(i,N){
        if(A[A[i]-1]-1==i) ans++;
    }
    ans/=2;
    cout << ans << endl;



}


Measured memory_bytes: 640