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

using namespace std;

int main()
{
   int n,a,sum=0,temp=0;
   cin>>n;
   int v[n]={0},b[n],c[n];
   for(int i=1;i<=n;i++)
   {
       cin>>v[i];
   }
   for(int i=1;i<=n;i++)
   {
       cin>>b[i];
   }
   for(int i=1;i<=n-1;i++)
   {
       cin>>c[i];
   }
   for(int i=1;i<=n;i++)
   {
       temp=v[i];
       sum=sum+b[temp];
       if(v[i]==v[i-1]+1 && i!=1)
       {
           sum=sum+c[temp-1];
       }

   }
   cout<<sum;
}


Measured memory_bytes: 256
n = int(input())
cs = [ (s,k) for s in ['S', 'H', 'C', 'D'] for k in range(1,14) ]
for _ in range(n):
    s,k = input().split()
    cs.remove((s,int(k)))
for (s, k) in cs:
    print(s, k)

Measured memory_bytes: 7704
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int ans;
	if(n<2)ans=1;
	else if(n<4)ans=2;
	else if(n<8)ans=4;
	else if(n<16)ans=8;
	else if(n<32)ans=16;
	else if(n<64)ans=32;
	else ans=64;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] a = new int[N];

		for(int i = 0 ; i < N ; i++){
			a[i] = sc.nextInt();
		}

		sc.close();
/*
		for(int i = 0 ; i < N ; i++){
			System.out.println(a[i]);
		}
*/
		long count = 0;
		for(int i = 0 ; i < N-1 ; i++){
			if(a[i]+a[i+1]>X){
				count += (a[i]+a[i+1])-X;

				if( (a[i]+a[i+1])-X <= a[i+1]){
					a[i+1] = X-a[i];
				}
				else{
					a[i] = a[i]-(X-a[i+1]);
					a[i+1] = 0;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 50828
#include<bits/stdc++.h>
using namespace std;
bool isprime(int num){
  if(num<=1) return false;
  if(num==2) return true;
  if(num%2==0) return false;
  for(int i=2;i*i<=num;i++){
    if(num%i==0) return false;
  }
  return true;
}
int main(){
  int a,d,n;
  while(1){
    cin>>a>>d>>n;
    if(a==0 && d==0 && n==0) break;
    int cnt=0;
    int r;
    for(int i=0;;i++){
      r = a + i*d;
      if(isprime(r)) {
	cnt++;
	//cout<<cnt<<" "<<r<<endl;
      }
      if(cnt==n) break;
    }
    cout<<r<<endl;
  }
  return 0;
}



Measured memory_bytes: 3060
N = int(input())
L = list(map(int,input().split()))
accum = [0 for i in range(N+10)]
L_sum = sum(L)
ans = 10**100
for i in range(len(L)):
    accum[i+1] = accum[i] + L[i]
for i in range(1,len(L)):
  #  print(accum[i],L_sum-accum[i])
    ans = min(ans,abs(2*accum[i]-L_sum))
print(ans)


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

int main(void) {
  char s[10], a[10], b[10];
  int i, j;
  a[4] = 0, b[4] = 0;
  while( 1 ) {
    int ans = 0;
    scanf("%s", s);
    if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
      if(s[0] == '0') break;
      else {
        printf("NA\n");
        continue;
      }
    }
    while(s[0] != '6' || s[1] != '1' || s[2] != '7' || s[3] != '4') {
      for(i = 0; i < 4; ++i) a[i] = s[i], b[i] = s[i];
      for(i = 0; i < 4; ++i) for(j = i + 1; j < 4; ++j) {
        char t;
        if(a[i] > a[j]) t = a[i], a[i] = a[j], a[j] = t;
        if(b[i] < b[j]) t = b[i], b[i] = b[j], b[j] = t;
      }
      int na = atoi(a), nb = atoi(b);
      int num = nb - na;
      for(i = 3; i >= 0; --i) {
        s[i] = num % 10 + '0';
        num /= 10;
      }
      ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin >> N >> L;
  double s = N*L + 0.5*N*(N+1) - N;
  if(L < 0){
    if(1-L <= N){
    cout << s << endl;
    }
    else{
      cout << s-L+1-N << endl;
    }
  }
  if(L==0){
    cout << s << endl;
  }
  if(L == 1){
    cout << s-1 << endl;
  }
  if(L > 1){
    cout << s-L << endl;
  }
}

    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,keta,d[10][10],a,b;
	long long cnt;
	scanf("%d",&n);
	for(i=0;i<10;i++)	{
		for(j=0;j<10;j++)	d[i][j]=0;
	}
	keta=1;
	for(i=1;i<=n;i++)	{
		if(i>=keta*10)	keta*=10;
		a=i/keta;
		b=i%10;
		d[a][b]++;
	}
	cnt=0;
	for(i=0;i<10;i++)	{
		for(j=0;j<10;j++)	{
			cnt=cnt+d[i][j]*d[j][i];
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

// int main(){
//     ll a;
//     double b;
//     cin >> a >> b;

//     long long bt = b * 100;
//     long long b1 = bt % 10;
//     bt /= 10;
//     long long b10 = bt % 10;
//     bt /= 10;
//     long long b100 = bt % 10;

//     long long ans100 = a * b100 * 100;
//     long long ans10 = a * b10 * 10;
//     long long ans1 = a * b1;
    
//     long long ans = ans100;
//     ans += ans10;
//     ans += ans1;

//     ans /= 100;

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

int main(){
    long double a, b;
    cin >> a >> b;
    
    long long ans = a * b;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    long long n ;
    double long d ;
    cin>>n>>d ;
    vector<vector<long long >> arr(n,vector<long long >(2)) ;
    long long c=0;
    for(int i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1] ;
    for(int i=0;i<n;i++)
    {
        double long dist=sqrt((arr[i][0]*arr[i][0])+(arr[i][1]*arr[i][1])  );
        if(dist<=d)
          c++ ;
    }
    cout<<c<<endl; 
    return 0;
}

Measured memory_bytes: 14472
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!
var num = 0


for i in a...b {
  if (i%c) == 0 {
    num += 1
  }
}
print(num)


Measured memory_bytes: 14184
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define mid (l+r+1)/2
#define f first
#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 1e18
#define EPS 1e-11
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,x,t,f;
int main(){
    Hossam_Yehia;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> x;
        if(x%4==0)++f;
        else if(x%2==0)++t;
    }
    cout<<(((f+(t/2))>=n/2)?"Yes\n":"No\n");
    re 0;
}

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

struct UF{
	vector<int> v;
	int N;
	UF(int n){N=n;v=vector<int>(n,-1);};
	int find(int x){
		if(v[x]<0) return x;
		return v[x]=find(v[x]);
	}
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(x<y) v[y]=x;
		else v[x]=y;
	}
};

int main(){
	int n,m;
	cin >> n >> m;
	UF uf(n);
	for(int i=0;i<m;i++){
		int x,y,z;
		cin >> x >> y >> z;
		x--,y--;
		uf.unite(x,y);
	}
	int ans=0;
	for(int i=0;i<n;i++) if(uf.find(i)==i) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,D;
  cin >> N >> D;
  
  vector<int> A(N*100);
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
     cin >> A.at(j+100*i);
    }
  }
  
  int count=0;
  
  for(int i=0; i<N; i++){
    for(int k=0; k<N-i-1; k++){
      int sum=0;
      for(int j=0; j<D; j++){
        sum+=pow(A.at(j+i*100)-A.at(j+(i+k+1)*100),2);
      }
      int natural=pow(sum,0.5);
      double ans=pow(sum,0.5);
      if(natural==ans) count++;
    }
  }
  
  cout << count << endl;
  
  
  
  
}

Measured memory_bytes: 384
a=list(map(int,input().split()))
try:
  b=list(map(int,input().split()))
  out=-1
  for i in range(102):
    if i in b:
      continue
    if abs(out-a[0])>abs(i-a[0]):
      out=i
  print(out)
except EOFError:
  print(a[0])

  

Measured memory_bytes: 8976
N, D = map(int, input().split())
X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    
ans = 0

for x,y in zip(X,Y):
    if (x**2+y**2)**(1/2) <= D:
        ans += 1
        
print(ans)

Measured memory_bytes: 24788
import java.util.*;

public class Main{
	public static void main(String[] args) {
		int num = new Scanner(System.in).nextInt();
			switch(num % 10){
				case 2:
				case 4:
				case 5:
				case 7:
				case 9:
				System.out.println("hon");
				break;

				case 0:
				case 1:
				case 6:
				case 8:
				System.out.println("pon");
				break;

				case 3:
				System.out.println("bon");
				break;
			}
		}
	}

Measured memory_bytes: 35732
a = input().rstrip().split(' ')
A,B,C,K = int(a[0]),int(a[1]),int(a[2]),int(a[3])
s = 0

if K - A <= 0:
    print(K)
else:
    K -= A
    if K - B <= 0:
        print(A)
    else:
        K -= B
        print(A-K)

Measured memory_bytes: 9200
#include<cstdio>
#include<algorithm>
using namespace std;
void link(int x,int y){
	printf("%d %d\n",x,y);
}
int main(){
	int n;
	scanf("%d",&n);
	if((1<<__builtin_ctz(n))==n)
		return puts("No"),0;
	puts("Yes");link(1,n+2);
	for(int i=2;i<n;i+=2)
		link(1+n,i),link(i,i+1),link(1+n,i+1+n),link(i+1+n,i+n);
	if(~n&1){
		int m=n&-n;
		link(n,n+m+1);link(n+n,n-m);
	}
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }
    
    return;
}


int main(){
    int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d",&k);
    printf("%d",a[k-1]);
}


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

int main()
{
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i])
                {
                    if (a[i] + a[j] > a[k])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
int n,x,y;
int f[2001][2001];
int vis[20001];
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			f[i][j]=f[j][i]=j-i;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(i<=x&&j>=y)
				f[i][j]-=y-x-1;
			if(i>x&&i<y)
				f[i][j]=min(f[i][j],f[i][x]+f[y][j]+1);
			if(j>x&&j<y)
				f[i][j]=min(f[i][j],f[j][y]+f[x][i]+1);
			f[j][i]=f[i][j];
		}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			vis[f[i][j]]++;
	for(int i=1;i<=n-1;i++)
		printf("%d\n",vis[i]);
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
ll N;cin>>N;vl A(N);rep(i,N)cin>>A[i];
  ll ans=A[0];
  rep(i,N-1){
    ans =__gcd(ans,A[i+1]);
  }
  cout<<ans<<endl;
}








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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()
#define TST(H) (#H);

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll dp[3010][3010][4];

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int r,c, k;
	cin >>r >>c >>k;
	vector<VI> dt(r+3, VI(c+3));
	rep(i, k){
		int y, x, v;
		cin >>y >>x >>v;
		dt[y-1][x-1] = v;
	}


	rep(y, r)  rep(x,c){
		repr(i, 2, 0){
			dp[y][x][i+1] = max(dp[y][x][i+1], dp[y][x][i] + dt[y][x]);
		}
		rep(i, 4){
			dp[y+1][x][0] = max(dp[y+1][x][0], dp[y][x][i]);
			dp[y][x+1][i] = max(dp[y][x+1][i], dp[y][x][i]);
		}
	}
	ll ans = 0;
	rep(i, 4) ans = max(ans, dp[r-1][c-1][i]);
	cout << ans <<"\n";
	

	return 0;
}



Measured memory_bytes: 320900
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};
//vector<int> dy = {1, 1, 1, 0, -1, -1, -1, 0};
//vector<int> dx = {1, 0, -1, -1, -1, 0, 1, 1};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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




int main(){
  ll N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  ll p = 0, m = 0;
  rep(i, N){
    if(A[i] < 0) m++;
  }

  if(m % 2){
    ll ans = 0;
    ll m = INFL;
    rep(i, N){
      ans += abs(A[i]);
      m = min(m, abs(A[i]));
    }
    ans -= 2 * m;
    cout << ans << endl;
  }else{
    ll ans = 0;
    rep(i, N) ans += abs(A[i]);
    cout << ans << endl;
  }

}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		String t = getStr(st);
		String[] t1 = t.split("");
		t = getStr(st);
		String[] t2 = t.split("");
		int ans = 0;
		for (int i=0;i<3;i++) {
			if(t1[i].equals(t2[i])) {
				ans++;
			}
		}
		anser(ans);
	}

	private static String getStr(BufferedReader st) throws Exception, IOException {
		String str = st.readLine();
		return str;
	}

	private static void anser(int num) {
		System.out.println(num);
	}
}


Measured memory_bytes: 23252
n, m = (int(i) for i in input().split())

correction = []
for j in range(n):
   correction += [input().split()]


list_and = correction[0][1::]
for j in range(1, n):
   list_and = set(list_and) & set(correction[j][1::])
   list_and = list(list_and)

print(len(list_and))

Measured memory_bytes: 3060
import java.util.*;

class Main {

   public static void main(String[] args) {
       new Solver().run();
   }

}


class Solver {

    private boolean isPrime(long n) {
        if (n == 0 || n == 1) return false;
        if (n == 2) return true;

        if (n % 2 == 0) return false;

        for (long i = 3; i * i <= n; i+=2) {
            if (n % i == 0) return false; 
        }   
        return true;
    } 

 
    private boolean isLikely2017(int n) {
        if (n == 2) return false;
        return isPrime(n) && isPrime((n + 1) / 2);
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int Q = sc.nextInt();
        int[] l = new int[Q];
        int[] r = new int[Q];
        for (int i = 0; i < Q; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        int[] S = new int[100002];
        S[0] = 0;
        for (int i = 0; i < 100001; i++) {
            if (isLikely2017(i)) {
                S[i+1] = S[i] + 1;
            } else {
                S[i+1] = S[i];
            }
        }

        //for (int i = 0; i < 20; i++) {
        //    System.out.println(String.format("S[%d]=%d ", i, S[i]) + isLikely2017(i));
        //}

        for (int i = 0; i < Q; i++) {
           int ans  = S[r[i] + 1] - S[l[i]];
           System.out.println(ans);
        }


    }
}

Measured memory_bytes: 91612
#include <stdio.h>
int main(void){
int a,b,c,d;
int first,end;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
if(a>c){
  first=a;
  if(b>d){
    end=d;
  }else{
    end=b;
  }
}else{
  first=c;
  if(b>d){
    end=d;
  }else{
    end=b;
  }
}
if(b>c){ 
  if(d>a){
  printf("%d\n",end-first);
  }
  if(a>=d){
  printf("0\n");
  }
}
if(c>=b){
  printf("0\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return ('0' <= c && c <= '9')?(c - '0'):-1;}

// TODO: write
int main() {
  int n;cin>>n;
  vector<string> a(n);rep(i,n)cin>>a[i];
  rep(i,n)sort(all(a[i]));
  sort(all(a));
  
  ll ans = 0;
  string old = a[0];
  int cnt = 0;
  rep(i,n){
    if(i){
      if(old == a[i])cnt++;
      else cnt = 0;

      if(cnt != 0){
        ans += cnt;
      }
      old = a[i];
    }
  }
  print(ans);
  return 0;
}



Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int N;

ll memo[101][101];
ll combi(int n, int k) {
    if (memo[n][k]) return memo[n][k];
    else if (k == 1) return n;
    else if (n == k) return 1;
    memo[n][k] = combi(n - 1, k - 1) + combi(n - 1, k);
    return memo[n][k];
}

int main() {
    cin >> N;

    if (N % 2) {
        const int M = combi(N, 2) - N / 2;
        write(M);

        for (int i = 1; i < N; ++i) {
            cout << i << " " << N << "\n";
        }

        for (int i = 1; i < N; ++i) {
            for (int j = 1; j < i; ++j) {
                if (i + j != N) {
                    cout << i << " " << j << "\n";
                }
            }
        }

        return 0;
    }
    else {
        const int M = combi(N, 2) - N / 2;
        write(M);

        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j < i; ++j) {
                if (i + j != N + 1) {
                    cout << i << " " << j << "\n";
                }
            }
        }

        return 0;
    }
}

Measured memory_bytes: 384
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
v1=Counter(V[::2]).most_common()
v2=Counter(V[1::2]).most_common()
if len(v1) ==1:
  v1.append([0,0])
if len(v2) == 1:
  v2.append([0,0])
if v1[0][0]==v2[0][0]:
  print(min(n-v1[0][1]-v2[1][1],n-v1[1][1]-v2[0][1]))
else:
  print(n-v1[0][1]-v2[0][1])

Measured memory_bytes: 20700
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

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

  for (int i = 0; i < s.size(); i++){
    if(i%2 == 0) cout << s[i];
  }

  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  if(n % 2 == 0){
    m = (n-2)*n/2;
    cout << m << endl;
    for(int i = 1;i <= n;i++){
      for(int j = 1;j <= n;j++){
        if(j != i && j != n+1-i && i < j){
          cout << i <<  " " << j << endl;
        }
      }
    }
  }else{
    n -= 1;
    m = (n-2)*n/2+n;
    cout << m << endl;
    for(int i = 1;i <= n;i++){
      for(int j = 1;j <= n;j++){
        if(j != i && j != n+1-i && i < j){
          cout << i << " " << j << endl;
        }
      }
    }
    n += 1;
    for(int i = 1; i < n;i++){
      cout << n << " " << i << endl;
    }
  }
}
    
          
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;

using namespace std;

//problem_C
int main(){
    long double a;
    long double b;
    cin >> a >> b;
    cout << ll(floor(a*b)) << endl;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		char c [] =x.toCharArray();
		Arrays.parallelSort(c);
		if(c[0]== c[1] && c[2] == c[3] && c[2]!=c[1])
			System.out.println("Yes");
		else 
			System.out.println("No");

	}

}


Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  ll x, y;
  cin >> x >> y;
  if(x % y == 0)cout << -1 << endl;
  else cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int x;
		int k;
		Scanner sc = new Scanner(System.in);
		k = sc.nextInt();
		x = sc.nextInt();

		int min = x - k + 1;
		int max = x + k - 1;

		if(k == 1) {
			System.out.println(x);
			System.exit(0);
		}
		for(int i = min ; i <= max ; i++) {
			System.out.println(i);
		}

		sc.close();

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    ll k;cin >> k;
    vl a(n),b(m);
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    rep(i,m-1)b[i+1]+=b[i];
    rep(i,n-1)a[i+1]+=a[i];
    //rep(i,m)cout << b[i] <<" ";
    ll res=0;
    ll p=upper_bound(all(b),k)-b.begin();
    res=p;
    rep(i,n){
        ll t=k-a[i];if(t<0)continue;
        ll p=upper_bound(all(b),t)-b.begin();
        //cout << p <<endl;
        chmax(res,p+i+1);
    }
    cout << res <<endl;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> H(N);
  vector<bool> A(N,true);
  for(int &i:H)
    cin>>i;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    if(H[a-1]>=H[b-1])
      A[b-1]=false;
    if(H[a-1]<=H[b-1])
      A[a-1]=false;
  }
  int i=0;
  for(bool b:A)
    if(b)
      i++;
  cout<<i<<endl;
}

Measured memory_bytes: 3760
#初期data
input_number = int(input())
input_list = list(map(int, input().split()))
exchange_count = 0

#アルゴリズム
for i in range(input_number):
    min_data = input_list[i]
    min_number = -1
    for j in range(i+1, input_number):
        if min_data > input_list[j]:
            min_data = input_list[j]
            min_number = j
    if min_number != -1:
        input_list[i], input_list[min_number] = input_list[min_number], input_list[i]
        exchange_count += 1

#処理の実行
print(" ".join(map(str, input_list)))
print(exchange_count)



Measured memory_bytes: 5600
#include <stdio.h>

int main(void) {
	int m, f, r;
	char c[6] = {'F','A','B','C','D'};
	int grade;
	
	while (scanf("%d %d %d", &m, &f, &r), ~m || ~f || ~r) {
		if (!(~m && ~f)) grade = 0;
		else if (m + f >= 80) grade = 1;
		else if (m + f >= 65) grade = 2;
		else if (m + f >= 50) grade = 3;
		else if (m + f >= 30) {
			if (r >= 50) grade = 3;
			else grade = 4;
			
		}
		else grade = 0;
		
		
		printf("%c\n", c[grade]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
        int max,o,item=0;
        while(cin>>max){
                if(max==0) break;
                for(int i=0;i<9;i++){
                        cin>>o;
                        item += o;
                } 
                cout<<max-item<<endl;
                item=0;
        }
}

Measured memory_bytes: 0
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    int a = S[0] - '0';
    int b = S[1] - '0';
    int c = S[2] - '0';
    int d = S[3] - '0';

    for (int i = 0; i < 2<<3; ++i) {
        int ans = a;
        char op1, op2, op3;
        if (i & (2<<2)) {
            ans += b;
            op1 = '+';
        }
        else {
            ans -= b;
            op1 = '-';
        }
        if (i & (2<<1)) {
            ans += c;
            op2 = '+';
        }
        else {
            ans -= c;
            op2 = '-';
        }
        if (i & (2<<0)) {
            ans += d;
            op3 = '+';
        }
        else {
            ans -= d;
            op3 = '-';
        }
        if (ans == 7) {
            std::cout
                << a
                << op1
                << b
                << op2
                << c
                << op3
                << d
                << "=7" << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int m,d,c=0;
  cin>>m>>d;
  for(int i=4;i<m+1;i++)
  {
    for(int j=22;j<d+1;j++)
    { if(j/10>1&&j%10>1&&(j/10)*(j%10)==i)
        c++;}}
cout<<c<<endl;
return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int a[n+1] = {};
  int ans = 0;
  for(int i = 0; i < k; i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int p;
      cin >> p;
      a[p-1] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    if(a[i]==0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll dp[n+1][w+1];
    ll wt[n+1],val[n+1];
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(j<wt[i])
                dp[i][j]=dp[i-1][j];
            else 
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+val[i]);
        }
    }
    cout<<dp[n][w];
}


Measured memory_bytes: 82472
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> lst;
    for (int i = 0; i < 50000; ++i) {
        if (i*108/100 == N) {
            printf("%d\n", i);
            return 0;
        }
    }
    puts(":(");
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
	}

	as := make([]int, n)
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = n*i + 1
		bs[n-i-1] = n*i + 1
	}

	for i, p := range ps {
		as[p-1] += i
	}

	fmt.Println(strings.Trim(fmt.Sprint(as), "[]"))
	fmt.Println(strings.Trim(fmt.Sprint(bs), "[]"))
}


Measured memory_bytes: 6180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    int d;
    cin >> d;
    out((n + (2 * d + 1 - 1)) / (2 * d + 1));
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       String s = sc.next();
       
       if (a >= 3200){
           System.out.println(s);
       } else {
           System.out.println("red");
       }
        
    }
}

Measured memory_bytes: 35872
from itertools import product

INF = 10 ** 9

N, *A = map(int, input().split())
L = [int(input()) for _ in range(N)]


def estimate(lst):
    if any(not p for p in lst):
        return INF

    ret = 0
    for p, g in zip(lst, A):
        ret += abs(g - sum(p)) + (len(p) - 1) * 10
    return ret


ans = INF
for prd in product(range(4), repeat=N):
    pieces = [[] for _ in range(3)]
    for bamboo_ind, target_kadomatsu in enumerate(prd):
        if target_kadomatsu == 3: continue
        pieces[target_kadomatsu].append(L[bamboo_ind])
    if ans > (res := estimate(pieces)):
        ans = res
print(ans)


Measured memory_bytes: 9220
import sys


def solve(N: int, Y: int):
    for i in range(N+1):
        for j in range(N+1-i):
            k = N - i - j
            if 10000*i+5000*j+1000*k == Y:
                print(i, j, k)
                return

    print("-1 -1 -1")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
ll inf=1e18;
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	ll a[n][n];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	vector<ll> pre(1<<n);
	for(int mask=0;mask<(1<<n);mask++){
		ll val=0;
		for(int i=0;i<n;i++){
			if((mask & (1<<i)) != 0){
				for(int  j=i+1;j<n;j++){
					if((mask & (1<<j)) !=0 ){
						val+=a[i][j];
					}
				}
			}
		}
		pre[mask]=val;
	}
	vector<ll> dp(1<<n,-inf);
	dp[0]=0;
	for(int mask=0;mask<(1<<n);mask++){
		vector<ll> rem;
		for(int i=0;i<n;i++){
			if((mask & (1<<i))==0) rem.push_back(i);
		}
		for(int i=0;i<(1<<rem.size());i++){
			int smallmask=0;
			for(int j=0;j<rem.size();j++){
				if((i & (1<<j)) !=0 ) smallmask|=(1<<rem[j]);
			}
			int temp=mask|smallmask;
			dp[temp]=max(dp[temp],dp[mask]+pre[smallmask]);
		}
	}
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
int main(){
        int a, b, c; cin >> a >> b >> c;
        swap(a, b); swap(a, c);
        cout << a << " " << b << " " << c << endl;
    return 0;
}



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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll a, b, c;

int main(void)
{

    cin >> a >> b >> c;

    bool ans = sqrtl(a * b) < ((c - b - a) / 2.0l);

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }


    return 0;
}

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

Int n, ans;
vector<Int> a, b;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(auto &i:a) cin >> i;
	b.resize(a.size());
	for(Int i=a.size()-2; i>=0; --i){
		if(a[i] >= a[i+1])
			b[i] = b[i+1] + 1;
		ans = max(ans, b[i]);
	}
	cout << ans << "\n";
}

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

namespace abc123_a
{
    class Program
    {
        static void Main(string[] args)
        {           
           
            int[] num = new int[5];
            for(int i = 0; i < 5; i++)
            {
                num[i] = int.Parse(Console.ReadLine());
            }


            int k = int.Parse(Console.ReadLine());
            int x = 0;
            for (int i=0;i<5;i++)
            {
                for (int j = i+1; j < 5; j++)
                {
                    if (num[j] - num[i] > k)
                    {
                        x++;
                    }
                       
                }
            }


            if (x==0)
            {
                Console.Write("Yay!");
            }
            else
            {
                Console.Write(":(");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
 
  cin>>a>>b;
   int c=b-a;
  out((1+c)*c/2-b);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	double N, T, A;
	cin >> N >> T >> A;
	vector<double> H(N);
	vector<double> t(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	for (int i = 0; i < N; i++) {
		t[i] = T - 0.006 * H[i];
	}
	double ans = 100000;
	int rec = 0;
	for (int i = 0; i < N; i++) {
		if (ans > fabs(t[i] - A)) {
			ans = fabs(t[i] - A);
			rec = i + 1;
		}
	}
	cout << rec << endl;
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

bool isprime[10000001];

void sieve(ll N){
  
  fill(isprime,isprime+10000001,true);
  isprime[0]=isprime[1]=false;
  
  for(ll i=2;i*i<=N;i++){
    if(isprime[i]){
      for(ll j=i*2;j<=N;j+=i){
	isprime[j]=false;
      }
    }
  }
}

vector<int> getPrime(const int n) {
    const int ub = (n - 1) / 2;
    const int sqrtub = (sqrt(n) - 1) / 2;
    vector<int> res;
    if (n <= 1) return res;
    res.push_back(2);

    bool *isNotPrime = new bool[ub + 1];
    for (int i = 0; i <= ub; i++)isNotPrime[i] = (i % 3 == 1);
    isNotPrime[1] = false;
    
    for (int i = 2; i <= sqrtub; i++) {
        if (!isNotPrime[i]) {
            int d = i * 2 + 1;
            for (int j = 3 * i + 1; j <= ub; j += d) {
                isNotPrime[j] = true;
            }
        }
    }
    for (int i = 1; i <= ub; i++) {
        if (!isNotPrime[i]) {
            res.push_back(i * 2 + 1);
        }
    }
    delete[] isNotPrime;
    return res;
}

int main(void){

  /*
  //sieve(10000000);

  //int res[10001];
  fill(res,res+10001,0);
  res[1]=2;
  for(int i=2,j=0;j<10001;i++)
    if(isprime[i])res[j+1]=res[j++]+i;
  */
  vector<int>res=getPrime(10000000);
  for(int i=0;i+1<res.size();i++)res[i+1]+=res[i];
  int a;
  while(cin >> a,a){
    cout << res[a-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 11788
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
 
struct Node {
    int value = 0;
    vector<int> children;
};
 
int main() {
    int n, q;
    cin >> n >> q;
 
    vector<Node> nodes(n + 1);
 
    for (int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        nodes[a].children.push_back(b);
        nodes[b].children.push_back(a);
    }
 
    for (int i = 0; i < q; ++i) {
        int p, x;
        cin >> p >> x;
        nodes[p].value += x;
    }
 
    queue<int> que;
    que.push(1);
    
    vector<bool> visited(n + 1);
 
    while (!que.empty()) {
        int cur = que.front();
        que.pop();
        visited[cur] = true;
 
        for (int idx : nodes[cur].children) {
            if (visited[idx]) continue;
            nodes[idx].value += nodes[cur].value;
            que.push(idx);
        }
    }
 
    for (int i = 1; i <= n; ++i) {
        cout << nodes[i].value << ' ';
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 16372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

// int last[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};

int main(){

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

    int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;

    if(m1 == m2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }

    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W;
  cin >> H >> W;
  VVI cs(10, VI(10, 1e9));
  REP(i,10) REP(j,10)
	cin >> cs[i][j];
  REP(k,10) REP(i,10) REP(j,10)
	mini(cs[i][j], cs[i][k] + cs[k][j]);

  LL ans = 0;
  REP(y,H) REP(x,W){
	int a;
	cin >> a;
	if(a < 0) continue;
	ans += cs[a][1];
  }
  cout << ans << endl;  

  return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    int l;
    cin >> l;
    long double ans = (l / 3.0) * (l / 3.0) * (l / 3.0);
    cout << fixed << setprecision(7) << ans;

    return 0;
}

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

int main(){
    int N;
    int A[200000]={};
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(A,A+N);
    int b = A[N/2];
    long long sum=0;
    for(int i=0;i<N;i++){
        sum += abs(A[i] - b);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024