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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int A, B;
    cin >> A >> B;
    if(B%A)
        cout  << B-A << endl;
    else 
        cout  << B+A << endl;
    return 0;
}


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

int main() {
    double x;
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	x = ((c - a) * (c - a)) + ((d - b) * (d - b));
	printf("%.6f \n", sqrt(x));
}



Measured memory_bytes: 3192
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[100005];
int h[100005];
int main(){
  int N;cin>>N;
  int i,j,k,l;
  rep(i,N) cin>>h[i];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<N;i++){
    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
  }
  cout<<dp[N-1]<<endl;

}


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

using namespace std;
typedef pair<int, char> P;

bool isSame(vector<P> b, vector<P> s) {
    for (int i = 0; i < b.size(); i++)
        if (b[i] != s[i]) return false;
    return true;
}

int main(void) {
    int N, n;
    char c;
    cin >> N;

    vector<P> v;
    for (int i = 0; i < N; i++) {
        cin >> c >> n;
        v.push_back(P(n, c));
    }

    vector<P> b = v, s = v;
    for (int i = N - 1; i >= 0; i--)
        for (int j = 0; j < i; j++) {
            if (b[j].first > b[j + 1].first)
                swap(b[j], b[j + 1]);
        }
    
    for (int i = 0; i < N - 1; i++) {
        int minj = i;
        for (int j = i + 1; j < N; j++)
            if (s[j].first < s[minj].first) minj = j;
        swap(s[minj], s[i]); 
    }

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << b[i].second << b[i].first;
    }
    cout << endl;
    cout << "Stable\n";

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << s[i].second << s[i].first;        
    }
    cout << endl;
    if (isSame(b, s)) cout << "Stable\n";
    else cout << "Not stable\n";

    return 0;
}


Measured memory_bytes: 3068
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	int n, n0;
	int wei = 0, ans = 0;
	cin >> n;
	n0 = n;
	while (n0 > 0) {
		wei++;
		n0 = n0 / 10;
	}
	if (wei % 2 == 0) for (int i = 1; i <= wei - 1; i += 2) ans += 9 * (pow(10, i - 1));
	else {
		if (wei == 1) ans = n;
		else {
			for (int i = 1; i <= wei - 2; i += 2) ans += 9 * (pow(10, i - 1));
			ans += (n - pow(10, wei - 1) + 1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

long long p[1000043], c[1000043], tot;

void Divide(long long x) {
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      p[++tot] = i;
    }
    while (x % i == 0) {
      ++c[tot];
      x /= i;
    }
  }
  if (x > 1) {
    p[++tot] = x;
    ++c[tot];
  }
}

int main(int argc, char const *argv[]) {
  long long n;
  scanf("%lld", &n);
  Divide(n);
  long long ans = 0;
  for (long long i = 1; i <= tot; ++i) {
    for (long long j = 1; ; ++j) {
      if (j * (j + 1) / 2 > c[i]) {
        ans += j - 1;
        break;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::string s; std::cin >> s;
  std::vector<int> r(n+1), w(n+1);
  for(int i=1; i<=n; i++) {
    if ( s[i-1] == 'W' ) w[i] = w[i-1]+1;
    else w[i] = w[i-1];
  }
  for(int i=n; i>=1; i--) {
    if ( s[i-1] == 'R' ) r[i-1] = r[i]+1;
    else r[i-1] = r[i];
  }

  int ans = 1e9;
  for(int i=0; i<=n; i++) {
    int nr = r[i];
    int nw = w[i];
    int nc = std::abs(nr-nw) + std::min(nr,nw);
    //std::cout << i << " : " << nr << " " << nw << " -> " << nc << std::endl;
    ans = std::min(nc,ans);
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
int main(){
    double n,k; cin >> n >> k;
    vector<double> p(n);
    vector<double> s(n+1);
    for(int i=0;i<n;++i) cin >> p[i];
    s[0] = 0;
    for(int i=0;i<n;++i) s[i+1] = s[i] + p[i];
    int m=0;
    for(int i=0;i<n;++i){
        if(k+i>n) break;
        int reg = s[k+i] - s[i];
        if(m<reg) m = reg;
    }
    double ans = (double)(k+m)/2;
    cout << fixed << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>

constexpr long long max = 1e9;

int main()
{
  long long s;
  scanf("%lld", &s);
  printf("0 0 1 1000000000 %lld %lld\n", (s + max - 1) / max, (s + max - 1) / max * max - s);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int H  = keyboard.nextInt();
		int W = keyboard.nextInt();
		int h  = keyboard.nextInt();
		int w = keyboard.nextInt();

		System.out.println(H*W -(h*W+w*H-h*w));
		keyboard.close();	
	}
}

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

#define pb push_back

typedef long long ll;

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

	int n;
	cin >> n;
	
	int lastDig = n % 10;
	
	if (lastDig == 0 || lastDig == 1 || lastDig == 6 || lastDig == 8) {
		cout << "pon\n";
	} else if (lastDig == 3) {
		cout << "bon\n";
	} else {
		cout << "hon\n";
	}
	
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long  INF = 1LL << 60;
 
int main() {
    int n, k;
    cin >> n >> k;
    long long h[200010], dp[200010];
    for(int i=0; i<n; ++i)  cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 200010; ++i) dp[i] = INF;

    //初期条件
    dp[0] = 0;

    for(int i = 0; i < n; ++i){
      for(int j = 1; j <= k; ++j) {
    		chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
    
    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 3328
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

/*int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int powermod(int A, int p, int MOD = mod){
    A%=MOD;
    int res  = 1;
    while(p){
        if(p&1)
            res = ((__int128)res*A)%MOD;
        
        A = ((__int128)A*A)%MOD;
        p>>=1;
    }

    return res;
}*/

//bool comp()
//{
//}

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        int a,b,n;
        cin>>n;
        if(n>=30)
        cout<<"Yes"<<"\n";
        else
        cout<<"No"<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
if N == 0:
    print('0')
else:
    k = 1
    ans = []
    while(True):
        if N % ((-2) ** k) == 0:
            ans.append('0')
        else:
            ans.append('1')
            N -= (-2) ** (k - 1)
        if N == 0:
            break
        else:
            k += 1
    print(''.join(ans[::-1]))

Measured memory_bytes: 3060
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define F first
#define S second
#define sz(x) (int)x.size() - 1
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 3e5 + 5;


inline void solve() {
 int n, k;string s;
 cin >> n >> s >> k;
 char ch = s[k-1];
 for(auto &i : s)
    if(i != ch)
    i = '*';
    cout << s;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t; while(t--)
                solve();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> d(n),dist(n);
    long long ans = 1;
    for(int i = 0;i < n;i++){
        cin >> d[i];
        dist[d[i]]++;
    }
    if(d[0] != 0 || dist[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1;i < n;i++){
        for(int j = 1;j <= dist[i];j++){
            ans = ans * dist[i - 1] % MOD2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
/*input
0 1 0
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let v: Vec<i32> = read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    if (v[0] == 1 && v[1] == 1 && v[2] == 0) || (v[0] == 0 && v[1] == 0 && v[2] == 1) {
        println!("Open");
    } else {
        println!("Close");
    }
}



Measured memory_bytes: 5024
#include <iostream>
#include <string>

using namespace std;

int* ac_count;

int count(int l, int r){
    return ac_count[r-1] - ac_count[l-1];
}

void init(string s){
    ac_count[0] = 0;
    for(int i = 1;i<s.size();i++){
        ac_count[i] = (s[i-1]=='A' && s[i] == 'C') ? ac_count[i-1] + 1 : ac_count[i-1];
    }
    // ac_count[s.size()-1] = ac_count[s.size()-2];
    return;
}

// void print(string s){
//     for(int i=0;i<s.size();i++){
//         cout << ac_count[i] << " ";
//     }
//     cout << endl;
// }

int main(){
    int n,q,l,r;
    cin >> n >> q;
    string s;
    cin >> s;

    ac_count = (int*)malloc(sizeof(int)*100000);
    init(s);
    // print(s);

    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << count(l,r) << endl;
    }
    free(ac_count);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
const int MOD=998244353;
long A[3001], ans[3001][3001];
bool flg[3001][3001];
long pw(long a, long n){ long b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }

long dp(int i, int j){
  if(i==0){ return (j)?0:1; }
  if(j==0){ return pw(2, i); }
  if(flg[i][j]){ return ans[i][j]; }
  flg[i][j]=true;
  if(j-A[i]>=0){ return ans[i][j]=((2*dp(i-1, j))%MOD+dp(i-1, j-A[i]))%MOD; }
  else{ return ans[i][j]=(2*dp(i-1, j))%MOD; }
}

int main(){
  int N, S; cin >> N >> S;
  REP(i, N){ cin >> A[i+1]; }
  cout << dp(N, S) << "\n";
}

Measured memory_bytes: 82880
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c <= 21) {
		cout << "win";
	}
	else cout << "bust";
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
int rev[1024]={};
int main(){
	cin >> n >> m;
	for(int i=0;i<m;++i){
		int c,d;
		cin >> c >> d;
		rev[c]++;
		rev[d]--;
	}
	for(int i=0;i<n;++i) rev[i+1]+=rev[i];
	int answer=n+1;
	for(int i=0;i<=n;++i) if(rev[i]) answer+=2;
	cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include <utility>
using namespace std;
#define MAX 100000

int A[MAX], L[MAX], R[MAX];

int  partition(int p, int r){
    int x = A[r];
    int i = p - 1;
    int t;
    
    for(int j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            t = A[j];
            A[j] = A[i];
            A[i] = t;
        }
    }
    
    t = A[r];
    A[r] = A[i + 1];
    A[i + 1] = t;
    
    return i+1;
}

int main(){
    int n, center;
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    
    center = partition(0, n-1);
    
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        
        if(i != center) cout << A[i];
        else cout << "[" << A[i] << "]";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3404
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)

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

Measured memory_bytes: 24852
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

const double EPS = 1e-8;
const int INF = 100000000;

using namespace std;

struct Point{
    int x, y, z;
    double dx, dy, dz;
    Point() : x(INF), y(INF), z(INF) {}
    bool operator < (const Point& p) const {
        if(x != p.x) return x < p.x;
        if(y != p.y) return y < p.y;
        return z < p.z;
    }
    bool operator == (const Point& p) const {
        return x == p.x && y == p.y && z == p.z;
    }
};

void produce(int N, int S, int W, vector<Point>& ps){
    int g = S;
    for(int i = 0; i < N; i++){
        Point p;
        p.x = (g/7)    %100 + 1;
        p.y = (g/700)  %100 + 1;
        p.z = (g/70000)%100 + 1;
        if( g%2 == 0 ) { g = (g/2); }
        else           { g = (g/2) ^ W; }
        ps.push_back(p);
    }
}

double dist(double x, double y, double z){
    return sqrt(x * x + y * y + z * z);
}

double dist(const Point& p, const Point& q){
    return dist(p.dx - q.dx, p.dy - q.dy, p.dz - q.dz);
}

void normlize(vector<Point>& ps){
    for(int i = 0; i < ps.size(); i++){
        int x = ps[i].x, y = ps[i].y, z = ps[i].z;
        double l = dist(x, y, z);
        ps[i].dx = 1.0 * x / l;
        ps[i].dy = 1.0 * y / l;
        ps[i].dz = 1.0 * z / l;
    }
}

pair<Point, Point> make(Point a, Point b){
    if(b < a) swap(a, b);
    return make_pair(a, b);
}

void output(pair<Point, Point> p){
    printf("%d %d %d %d %d %d\n", p.first.x, p.first.y, p.first.z, p.second.x, p.second.y, p.second.z);
}

int main(){
    int M, N, S, W;
    while(cin >> M >> N >> S >> W){
        if(M + N < 2) break;

        vector<Point> ps(M);
        REP(i, M){
            cin >> ps[i].x >> ps[i].y >> ps[i].z;
        }
        produce(N, S, W, ps);
        normlize(ps);

        sort(ps.begin(), ps.end(), [](const Point& a, const Point& b){
                if(a.dx != b.dx) return a.dx < b.dx;
                if(a.dy != b.dy) return a.dy < b.dy;
                return a.dz < b.dz;
                });

        double min_dist = 1e16;
        pair<Point, Point> answer = make_pair(Point(), Point());

        for(int i = 0; i < ps.size(); i++){
            for(int j = i + 1; j < ps.size(); j++){
                if(ps[j].dx - ps[i].dx > min_dist + EPS) break;
                double d = dist(ps[i], ps[j]);
                if(d < EPS) continue;
                if(d < min_dist - EPS || (d < min_dist + EPS && make(ps[i], ps[j]) < answer)){
                    min_dist = d;
                    answer = make(ps[i], ps[j]);
                }
            }
        }

        assert(answer.first.x < INF);
        output(answer);

    }
    return 0;
}

Measured memory_bytes: 10132
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

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

  int a, b, t; cin >> a >> b >> t;

  print(t / a * b);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<char>> a(n,vector<char>(n));
    vector<vector<char>> b(m,vector<char>(m));
    REP(i, n){
        cin >> a[i];
    }
    REP(i, m){
        cin >> b[i];
    }
    bool able = false;
    REP(i, n-m+1){
        REP(j, n-m+1){
            bool flag = true;
            REP(k, m){
                REP(l, m){
                    if (b[k][l] != a[k+i][l+j]) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                able = true;
            }
        }
    }
    Yes(able);
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
const int N=105;
char s[N];
int main()
{
	int k;
	scanf("%s",s);
	scanf("%d",&k);
	int n=strlen(s);
	int p=0;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			p=1;
			break;
		}
	}
	if(p==0){
		printf("%lld",1ll*n*k/2);
	}
	else{
		ll ans=0;
		int sum=1;
		for(int i=1;i<n;i++){
			if(s[i]==s[i-1]){
				sum++;
			}
			else{
				ans+=sum/2;
				sum=1;
			}
		}
		ans+=sum/2;
//		printf("%lld ",ans);
		int l=0,r=n-1;
		while(s[l]==s[0])l++;
		l--;
		while(s[r]==s[0])r--;
		r++;
		
		sum=(l+1+n-r)/2;
		int x=1;
		for(int i=l+2;i<r;i++){
			if(s[i]==s[i-1]){
				x++;
			}
			else{
				sum+=x/2;
				x=1;
			}
		}
		sum+=x/2;
		ans+=1ll*(k-1)*sum;
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 128
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


vector<int> bagsize(N/3,0); 
void solve()
{
	int n,w ;
	cin >> n >> w; 
	vector<pair<int,int>> items(n);
	for(auto &it : items) cin >> it.ff >> it.ss ;
	sort(all(items));
	bagsize[0] = 0 ;
	for(auto it : items){
		for(int i = w; i >= 0 ; --i){
			if(i + it.ff > w) continue ;
			bagsize[i + it.ff] = max(bagsize[i+it.ff], bagsize[i] + it.ss);
		}
	}

	cout << *max_element(all(bagsize));
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint t1,t2,a1,a2,b1,b2;
	scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2);

	if(a1<b1){
		swap(a1,b1);
		swap(a2,b2);
	}

	lint d=(a1-b1)*t1+(a2-b2)*t2;
	if     (d> 0) return puts("0"),0;
	else if(d==0) return puts("infinity"),0;

	d=-d;
	lint ans;
	if((a1-b1)*t1%d==0) ans=2*(((a1-b1)*t1)/d);
	else                ans=2*(((a1-b1)*t1)/d+1)-1;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	
	int a, b;
	
	while( cin >> a >> b ) {

		int count = 0;
		
		if( a==0 && b==0)
		break;	
		
		for(int i=1;i<=a;i++)
		for(int j=i+1;j<=a;j++)
		for(int k=j+1;k<=a;k++) {
		
		if( i + j + k == b )
		count++;
	}
	
	cout << count << "\n";
}
	return 0;
}


Measured memory_bytes: 3088
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string s, t;
	cin >> s >> t; 
	cout << t+s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}

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

    string S;
    int i= 0;
    for(char c='1'; i<N; i++){
        S = S+c;
        c+=1;
    }
    string A, B;
    rep(j, N){
        char c;
        cin >> c;
        A+=c;
    }

    rep(j, N){
        char c;
        cin >> c;
        B+=c;
    }
    int num=1;
    int numa=0, numb=0;
    do{
        if(S == A){
            numa = num;
        }
        if(S == B){
            numb = num;
        }
        num++;
    }while (next_permutation(S.begin(), S.end()));


    cout << abs(numa-numb) << endl;
    return 0;
}

Measured memory_bytes: 888
A, B, C, D = map(int, input().split())
x = 0
if A <= C:
  if B <= D and B >= C:
    x = abs(B - C)
  elif D < B:
    x = abs(D - C)
elif C < A:
  if B <= D:
    x = abs(B - A)
  elif D < B and A <= D:
    x = abs(A - D)
print(x)


Measured memory_bytes: 3060
//AtCoder ABC103 A - Task Scheduling Problem
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    vector<ll> a3(3+1);
    vector<ll> id={1,2,3};
    for(ll i=1;i<=3;++i){
        cin>>a3[i];
    }
    ll ans=INT64_MAX;
	do {
		ll cst=0;
        cst+=abs(a3[id[1]]-a3[id[0]]);
        cst+=abs(a3[id[2]]-a3[id[1]]);
        ans=min(ans,cst);
    } while (std::next_permutation(id.begin(), id.end()));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll p,q,r,a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>p>>q>>r;
	a=p+q;b=q+r;c=p+r;
	ll ans=min(min(a,b),c);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

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

const int N_MAX = 100000;
const int Q_MAX = 100000;

int Q;
int l[Q_MAX];
int r[Q_MAX];

bool is_prime[N_MAX + 1];
int acc[N_MAX + 1];

void solve() {
  fill(is_prime, is_prime + N_MAX + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= N_MAX; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j <= N_MAX; j += i) is_prime[j] = false;
  }
  FOR(i, 1, N_MAX) {
    acc[i] = acc[i - 1] + (is_prime[i] && is_prime[(i + 1) / 2]? 1 : 0);
  }
  REP(i, Q) printf("%d\n", acc[r[i]] - acc[l[i] - 1]);
}

void input() {
  scanf("%d", &Q);
  REP(i, Q) scanf("%d%d", l + i, r + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args){

	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
      int K = sc.nextInt();
      int p[] = new int[N];

      for(int i=0;i<N;i++){
        p[i] = sc.nextInt();
      }
      Arrays.sort(p);
      int total = 0;
      for(int j=0;j<K;j++){
      	total = total + p[j];
      }
      System.out.println(total);

    }
}

Measured memory_bytes: 38756
#include <iostream>
#include <string>
#include <vector>

long long comb[51][51];

int main() {
  int N, P;
  std::cin >> N >> P;
  int even = 0, odd = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    std::cin >> a;
    if (a % 2 == 1) ++odd;
    else ++even;
  }
  long long ans = 0;
  if (odd == 0) ans = 1LL << N;
  else ans = 1LL << (N - 1);
  if (P == 1) ans = (1LL << N) - ans;
  std::cout << ans << std::endl;
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

ll k,a,b;

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

	cin>>k>>a>>b;
	if(a>=k) cout<<1<<endl;
	else if(b>=a) cout<<-1<<endl;
	else {
		k-=a;
		ll d=a-b;
		ll t=2*(k/d+!!(k%d))+1;
		cout<<t<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
double cut[32][32][32];
pair<int,int> way[32][32];
int main() {
	int n, m, s, g;
	while(cin >> n >> m, n) {
		cin >> s >> g;
		fill((double*)cut, (double*)cut + 32 * 1024, 1e100);
		fill((pair<int,int>*)way, (pair<int,int>*)way + 1024,make_pair(0,0));
		for (int i = 0; i < m; i++) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			way[x][y] = way[y][x] = make_pair(d,c);
		}
		priority_queue<tuple<double, int, int, int>, vector<tuple<double, int, int, int>>, greater<tuple<double, int, int, int>>> que;
		que.push(make_tuple(0., s, 1,0));
		while (!que.empty()&&(get<1>(que.top())!=g||get<2>(que.top())!=0)){
			auto a = que.top();
			que.pop();
			for (int i = 1; i <= n; i++) {
				if (way[get<1>(a)][i].second == 0)continue;
				if (i == get<1>(a)||i==get<3>(a))continue;
				if (get<2>(a)>way[get<1>(a)][i].second)continue;
				if (get<2>(a) == 0)continue;
				for (int j = max(0, get<2>(a)-1); j <= get<2>(a)+1; j++) {
					if (cut[i][j][get<1>(a)]>get<0>(a) + (double)way[get<1>(a)][i].first / get<2>(a)) {
						que.push(make_tuple(get<0>(a) + (double)way[get<1>(a)][i].first / get<2>(a), i, j,get<1>(a)));
						cut[i][j][get<1>(a)] = get<0>(a) + (double)way[get<1>(a)][i].first / get<2>(a);
					}
				}
			}
		}
		if (que.empty())cout << "unreachable" << endl;
		else cout << fixed << setprecision(10) << get<0>(que.top()) << endl;
	}
	return 0;
}

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

int main() {
    string s; cin >> s;
    int n = s.length();
    int ans = n;

    for (int i = 0; i < n-1; i++) {
        if (s[i] != s[i+1]) {
            // cout << ans << endl;
            ans = min(ans, max(i+1, n-i-1));
            // cout << i << " " << s[i] << " " << s[i+1] << " " <<
            // i+1 << " " << n-i-1 << " " << ans << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
a = LIST()

A = sorted([x//2 for x in a], reverse=True)

lcm = A[-1]
for x in A:
	lcm = lcm*x//gcd(lcm, x)

r = lcm//A[0]
n = M//A[0]


for x in A:
	if lcm//x%2 == 0:
		print(0)
		exit()
#2p+1が1<=2p+1<=n の範囲で rの倍数となるpの個数
if r%2 == 0:
	print(0)
else:
	print(n//r - n//(2*r))

Measured memory_bytes: 21040
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,j,k,n,s;
  char ca[201],can[201];
 
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
      
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
 
    printf("%s\n", ca);
  }
 
  return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <cstdio>
// #include <stack>
// #include <vector>
// #include <string>
// #include <algorithm>
using namespace std;

bool linearSearch(int n, int A[], int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) {
        i++;
    }
    return i != n;
}

int main() {
    int n, S[10001], q, t, result;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    result = 0;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &t);
        if (linearSearch(n, S, t)) {
            result++;
        }
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 3248
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n;
    cin >> n;
    map <string, ll> m;
    rep(i,n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << nl;
    cout << "WA x " << m["WA"] << nl;
    cout << "TLE x " << m["TLE"] << nl;
    cout << "RE x " << m["RE"] << nl;
}

int main(){
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3664
import sys
import numpy as np

def binary_search(array, num):
    # numより真に大きいはじめのindex
    if array[-1] <= num:
        return -1
    left = -1
    right = N-1
    while right - left > 1:
        mid = int((left + right)/2)
        if array[mid] <= num:
            left = mid
        else:
            right = mid
    return right

a_index = []
b_index = []

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split(" ")))
A = np.sort(A)
B = list(map(int, sys.stdin.readline().strip().split(" ")))
B = np.sort(B)
C = list(map(int, sys.stdin.readline().strip().split(" ")))
C = np.sort(C)

for a in A:
    a_index.append(binary_search(B, a))
    
for b in B:
    b_index.append(binary_search(C, b))


b_index = list(map(lambda x: N-x if (x != -1) else 0, b_index))

bb = []
tmp = np.sum(b_index)
for i in range(N):
    bb.append(tmp)
    tmp = tmp - b_index[i]

res = 0
for a_i in a_index:
    if a_i == -1:
        continue
    res += bb[a_i]
print(str(res))



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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, r, x, y, s, b, d;
    cin >> t;
    ll z;
   
    if(t>=30)cout<<"Yes"<<endl;
    else     cout<<"No"<<endl;
    
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<ll, ll> P;


void warshall_floyd(int n, vector<vector<int>> &distances) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
            }
        }
    }
}

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> grid(h, vector<char>(w, 0));

    rep(y, h) rep(x, w) cin >> grid[y][x];


    auto to_id = [&](int y, int x) {
        return y * w + x;
    };


    vector<vector<int >> distance(h * w, vector<int>(h * w, INT_MAX / 100));
    rep(i, h * w) distance[i][i] = 0;


    auto to_next = [&](int y, int x, P p) {
        return P(y + p.first, x + p.second);
    };

    vector<P> directions = {
            P(1, 0),
            P(-1, 0),
            P(0, 1),
            P(0, -1),
    };

    rep(y, h) {
        rep(x, w) {
            for (P p : directions) {
                P next = to_next(y, x, p);
                int ny = next.first;
                int nx = next.second;
                if (ny == -1 || ny == h) continue;
                if (nx == -1 || nx == w) continue;
                if (grid[y][x] == '#') continue;
                if (grid[ny][nx] == '#') continue;

                int f_id = to_id(y, x);
                int t_id = to_id(ny, nx);
                distance[f_id][t_id] = 1;
                distance[t_id][f_id] = 1;
            }
        }
    }

    warshall_floyd(w * h, distance);

    int ans = 0;

    rep(i, w * h) {
        rep(j, w * h) {
            if (distance[i][j] == INT_MAX / 100) continue;
            cmax(ans, distance[i][j]);
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 896
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,m = LI()
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def same(x,y):
    return root(x) == root(y)

def union(x,y):
    x = root(x)
    y = root(y)

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

xyz = [LI() for _ in range(m)]
for x,y,z in xyz:
    if root(x-1) != root(y-1):
        union(x-1,y-1)
f = defaultdict(lambda :0)
ans = 0
for i in range(n):
    if f[root(i)] == 0:
        ans += 1
        f[root(i)] = 1

print(ans)




Measured memory_bytes: 90544
def main():
    n,x = map(int, input().split())
    num_list = list(map(int, input().split()))

    sum = 0
    ans = 1

    for i in num_list:
        sum += i
        if sum <= x:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int x, y;

    cin >> x >> y;
    cout << x + y / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ld long double
ld a, b, c, d, e, f, x, y;
ld shish(ld a)
{
	if (a == 0) { return a; }
	
	a *= 1000;
	if (a > 0) {
		a += 0.51;
	}
	else {
		a -= 0.51;
	}
	a = (ld)((int)a);
	a /= 1000;
	return a;
}
int main() {
	while (cin >> a >> b >> c >> d >> e >> f) {
		y = (a*f - c*d) / (ld)(a*e - b*d);
		x = (c*e - f*b) / (ld)(a*e - b*d);

		x = shish(x);
		y = shish(y);
		if (x == 0) { cout << "0.000"; }
		else {
			cout << fixed << setprecision(3) << x;
		}
		cout << " ";
		if (y == 0) { cout << "0.000" << endl; }
		else{
			cout << fixed << setprecision(3) << y << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi t,a;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    t.resize(n);
    a.resize(n);
    rep(i,n){
        cin>>t[i]>>a[i];
    }
    ll nt=1,na=1;
    ll t1=0,a1=0;
    ll t2=0,a2=0;
    ll ans = 0;
    rep(i,n){
        ll tmp = max(nt/t[i],na/a[i]);
        while(1){
            if(tmp*t[i] >= nt && tmp*a[i] >= na){
                break;
            }
            tmp++;
        }
        t1 = tmp*t[i];a1 = tmp*a[i];
        na = a1;
        nt = t1;
    }
    print(na+nt);
    return 0;
}

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

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


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

int main() {
	ll x;
	cin >> x;

	ll ans = 0;

	if (x >= 500) {
		ans += 1000 * (x/500);
		x %= 500;
	}

	if (x >= 5)  {
		ans += 5 * (x/5);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256