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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  bool ans=false;
  REP(i,s.size()){
    if(s==t){
      ans=true;
      break;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }

  cout << (ans ?  "Yes" : "No" ) << endl;


}



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

static const long long MOD=1000000007;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    
    long long res=0;
    long long two_factor=1;
    for(int d=0;d<60;++d){
        long long zero=0,one=0;
        for(int i=0;i<n;++i){
            if(a[i]&(1LL<<d)) ++one;
            else ++zero;
        }
        long long temp = ((zero*one)%MOD)*two_factor%MOD;
        res=(res+temp)%MOD;
        two_factor=two_factor*2%MOD;
    }
    
    cout<<res<<endl;
}

Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+7;
int a[maxn];
vector<int> ans;vector<int> vec;vector<int> rem;
long double f(int u,int k)
{
	long double right=(long double)rem[u-1]/(long double)(k-u);
	return right;
}
int SanFen(int l,int r,int k) //找凸点  
{  
    while(l < r-1)  
    {  
        int mid  = (l+r)/2;  
        int mmid = (mid+r)/2;  
        if( f(mid,k) > f(mmid,k) )  
            l = mid;  
        else  
            r = mmid;  
    }  
    return f(l,k) > f(r,k) ? l : r;  
}  

int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		a[x]++;
	}
	for(int i=1;i<maxn;i++)if(a[i]) vec.push_back(a[i]);
	sort(vec.begin(),vec.end(),greater<int>());
	for(int i=vec.size();i<=n;i++) vec.push_back(0);
	rem.push_back(n-vec[0]);
	for(int i=1;i<n;i++)rem.push_back(rem[i-1]-vec[i]);
	ans.push_back(n);
	for(int kpl=2;kpl<=n;kpl++)
	{
		int k=kpl;
		int l=SanFen(1,k,k);
		if(l>=k) l=k-1;
		if(l<=0) l=1;
		int cnt=rem[l-1]/(k-l);
		if(l>=0&&k!=l+1)
		cnt=min(cnt,rem[l]/(k-l-1));
		if(l+1<k-1)
		cnt=min(cnt,rem[l+1]/(k-l-2));
		cnt=min(cnt,n/k);
		ans.push_back(cnt);
	}
	for(auto u:ans) cout<<u<<endl;
 } 

Measured memory_bytes: 6768
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	mp := map[int][]int{}
	for i := 0; i < n-1; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		ar[a-1]++
		ar[b-1]++
		if v, ok := mp[a-1]; ok {
			mp[a-1] = append(v, b-1)
		} else {
			mp[a-1] = []int{b - 1}
		}
		if v, ok := mp[b-1]; ok {
			mp[b-1] = append(v, a-1)
		} else {
			mp[b-1] = []int{a - 1}
		}
	}
	sum := 0
	max := 1
	cr := make([]int, 0, n)
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		sum += v
		if max < v {
			max = v
		}
		cr = append(cr, v)
	}
	sort.Ints(cr)
	ur := make([]bool, n)
	first := -1
	for k, v := range mp {
		if len(v) == 1 {
			first = k
			break
		}
	}
	dr := make([]int, n)
	use := 0
	er := mp[first]
	dr[first] = cr[len(cr)-1-use]
	ur[first] = true
	use++
	for len(er) != 0 {
		temp := []int{}
		for _, v := range er {
			if ur[v] {
				continue
			}
			dr[v] = cr[len(cr)-1-use]
			ur[v] = true
			use++
			mm := mp[v]
			for _, vv := range mm {
				if ur[vv] {
					continue
				}
				temp = append(temp, vv)
			}
		}
		er = temp
	}
	fmt.Println(sum - max)
	for i, v := range dr {
		if i == 0 {
			fmt.Print(v)
		} else {
			fmt.Printf(" %d", v)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 5632
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

p = [0] * N
q = [0] * N

p[0] = a[0] if a[0] > 0 else 0
q[0] = a[0]

for i in range(1, N):
  p[i] = p[i - 1] + (a[i] if a[i] > 0 else 0)
  q[i] = q[i - 1] + a[i]

ans = 0
for i in range(N - K + 1):
  t = i + K - 1
  x = p[-1] - p[t] + (p[i - 1] if i != 0 else 0)
  ans = max(ans, x)
  x += q[t] - (q[i - 1] if i != 0 else 0)
  ans = max(ans, x)

print(ans)


Measured memory_bytes: 86880
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)

info = sorted(info,key = lambda x: x[2])
end = 0

for x in range(101):
    for y in range(101):
        H = info[n-1][2] + abs(x-info[n-1][0]) + abs(y-info[n-1][1])
        for i in range(n-1):
            if info[i][2] != max(0,H - abs(x-info[i][0]) - abs(y- info[i][1])):
                break
        else:
            print(x,y,H)
            end = 1
            
        if end == 1:
            break
    if end == 1:
        break

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

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

const long long INF = 1LL << 60;

int main(void){

  long long  N;
  cin >> N;

  long long h[N];
  for (int i=0; i<N; ++i){cin >> h[i];}

  long long dp[N];
  for (int i=0; i<N; ++i){dp[i] = INF;}

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i=2; i<N; ++i){
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;




  return 0;
}



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

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

    vector<vector<int>> index(10);
    for (int i = 0; i < n; i++) {
        int x = s.at(i) - '0';
        index.at(x).push_back(i);
    }

    int cnt = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                if ((index.at(i).size() == 0) || (index.at(j).size() == 0) || (index.at(k).size() == 0)) continue;

                int l = *index.at(i).begin(), r = *index.at(k).rbegin();
                for (int m = 0; m < (int)index.at(j).size(); m++) {
                    if ((l < index.at(j).at(m)) && (index.at(j).at(m) < r)) {
                        cnt++;
                        break;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 512
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = std.nextInt();
        }

        PriorityQueue<Integer> pq = new PriorityQueue<>(n);
        for (int i = 0; i < n; i++) {
            pq.add(d[i]);
        }

        int divCount = n / 2;

        int value = 0;
        for (int i = 0; i < divCount; i++) {
            value = pq.poll();
        }

        int nextValue = pq.poll();

        int totalCount = nextValue - value;
        System.out.println(totalCount);
    }
}


Measured memory_bytes: 50488
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 4000
ll dp[N], dp2[N];

int main(){
	ll a[2], b[2], e, f;
	cin>>a[0]>>a[1]>>b[0]>>b[1]>>e>>f;
	for(int i = 0; i <= f/100; i+=1*a[0])
		for(int j = i; j <= f/100; j+=1*a[1])
			dp[j] = 1;
	for(int i = 0; i <= f; i+=b[0])
		for(int j = i; j <= f; j+=b[1])
			dp2[j] = 1;
	P res = P(100, 0);
	rep(i, f/100+1) rep(j, f+1){
		if(i*100+j>f) break;
		if(!dp[i]||!dp2[j]) continue;
		if(j>i*e) continue;
		if((res.fst)*j>=res.snd*(i*100+j)) res = P(i*100+j, j);
	}
	cout<<res.fst<<" "<<res.snd<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while(1){
    ll h, w;
    cin >> h >> w;
    if(h == 0 && w == 0) return 0;
    REP(i,h){
      REP(j,w){
        if(i==0 || i==h-1 || j==0 || j==w-1) cout << "#";
        else cout << ".";
      }
      cout <<endl;
    }
    cout <<endl;
  }


  return 0;
}






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

int main() {
    string s;
    cin >> s;
    int len = s.length();
    int cnt1 = 0,cnt2 = 0;
    for(int i = 0;i < len;++i) {
        if(s[i] != '0'+(i%2)) cnt1++;
        
        if(s[i] != '0'+(1-i%2)) cnt2++;
    }
    cout << min(cnt1,cnt2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll N,cnt=0,b=0;
    string s;
    cin>>N;
    cin>>s;
    for(ll i=0;i<N;i++)
    {
        if(s[i]=='I')
            cnt++;
        else
        {
            cnt--;
        }
        b=max(b,cnt);
    }
    cout<<b<<endl;
  return 0;
}



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

int sum_num(int);

int main(void){
  int n,a,b;
  cin >>n>>a>>b;
  int sum;
  int cnt = 0;
  for(int i = 1;i<=n;i++){
    sum = sum_num(i);
    if(sum >= a && sum <= b){
        cnt += i;
        //cout << i << "," << sum<<endl;
    }
  }
  cout << cnt <<endl;

    // int n;
    // cin >> n;
    // cout <<sum_num(n)<<endl;
  return 0;
}

int sum_num(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n -=  n%10;
    n /= 10;
    //cout << n << "," <<sum<< endl;
  }
  return sum;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const int MOD = 1000000007;

//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){fill((T*)array,(T*)(array+N),val);}

int dp[100005];
int broken[100005];
int main(){
    int h,w;
    cin>>h>>w;
    Vs S(h);
    REP(i,h) cin>>S[i];

    V<Vi> Sh(h,Vi(w,1));
    V<Vi> Sw(h,Vi(w,1));
    REP(i,h){
        REP(j,w){
            if(S[i][j] == '#'){
                Sh[i][j] = 0;
                Sw[i][j] = 0;
            }
        }
    }

    REP(i,h){
        REP2(j,1,w){
            if(Sw[i][j] == 0) continue;
            Sw[i][j] += Sw[i][j-1];
        }
        REPD(j,w-2){
            if(Sw[i][j] == 0) continue;
            Sw[i][j] = max(Sw[i][j],Sw[i][j+1]);
        }
    }

    REP(i,w){
        REP2(j,1,h){
            if(Sh[j][i] == 0) continue;
            Sh[j][i] += Sh[j-1][i];
        }
        REPD(j,h-2){
            if(Sh[j][i] == 0) continue;
            Sh[j][i] = max(Sh[j][i],Sh[j+1][i]);
        }
    }

    int ans = 0;
    REP(i,h){
        REP(j,w){
            ans = max(ans,Sh[i][j]+Sw[i][j]-1);
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

#define M_PI 3.1415926535

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

	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;

		n -= a;
		if (n < 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    vector<P> num(n);
    rep(i,n){
        int k;
        cin >> k;
        num[i] = make_pair(k,i);
    }
    sort(num.begin(),num.end());
    reverse(num.begin(),num.end());
    if(num[0] == num[1]){
        rep(i,n){
            cout << num[0].first << endl;
        }
    }
    else{
        rep(i,n){
            if(i == num[0].second) cout << num[1].first << endl;
            else cout << num[0].first << endl;
        }
    }
}

Measured memory_bytes: 4772
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
S = list(str(input()))
N = len(S)

ans = [0 for i in range(N)]
# R
cnt = 0
for i in range(N):
    if S[i] == "R":
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i-1] += math.ceil(cnt / 2)
        cnt = 0

#L
# S.reverse()
for i in range(N-1,-1,-1):
    if S[i] == "L":
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i+1] += math.ceil(cnt / 2)
        cnt = 0

for i in range(N):
    print(ans[i],end=" ")
print()


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> p_list;
    rep(i, n) {
        vector<int> temp;
        temp.push_back(i + 1);
        int p;
        cin >> p;
        temp.push_back(p);
        p_list.push_back(temp);
        temp.clear();
    }

    // sort by price
    sort(p_list.begin(),p_list.end(),[](const vector<int> &alpha,const vector<int> &beta){return alpha[1] < beta[1];});

    int total = 0;
    rep(i, k) {
        total += p_list[i][1];
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
string S;

int main() {
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		S[i] -= 'A';
		S[i] += N;
		S[i] %= 26;
		S[i] += 'A';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll a=100;
    ll x;
    cin>>x;
    ll cnt=0;
    while (a<x)
    {
        ll b=a*0.01;
        a+=b;
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++) std::cin >> h[i];
    std::vector<std::vector<int>> edg(n);
    for (int i = 0; i < m; i++) {
        int a, b; std::cin >> a >> b;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        bool flag = true;
        for (int c : edg[i]) {
            flag &= h[i] > h[c];
        }
        cnt += flag;
    }
    std::cout << cnt << std::endl;
    return 0;
}



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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (b-a <= 2*k-1) {
    for (int i=a; i<=b; ++i) {
      cout << i << endl;
    }
  } else {
    for (int i=a; i<a+k; ++i) {
      cout << i << endl;
    }
    for (int i=b-k+1; i<=b; ++i) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int i = 1;
        while (a <= b/2) {
            a *= 2;
            i++;
        }
        System.out.println(i);
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;
      cin>>n;
      int arr[n];
      long int c=0;
      for(int i=0;i<n;i++)
      {     cin>>arr[i];
          
      }
    long int mini=arr[0];
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=mini)
        {
            c=c+1;
            mini=arr[i];
        }
        else
        {
            continue;
        }
    }
    
    
    cout<<c;
      return 0;
    }

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

using namespace std;

using int64 = long long;

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int count = 1;
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] != s[i + 1]) count++;
  }

  count -= 2 * k;
  if (count < 1) count = 1;

  cout << n - count << endl;
}

Measured memory_bytes: 512
object Main extends App {
	import scala.math._
	val A = scala.io.StdIn.readInt
	val B = scala.io.StdIn.readInt
	val C = scala.io.StdIn.readInt
	val D = scala.io.StdIn.readInt

	println(min(A,B) + min(C,D))

}

Measured memory_bytes: 27208
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		long N = sc.nextLong();
		long X = sc.nextLong();
		System.out.println(solve(N, X));
	}

	static long solve(long n, long x) {
		if (x * 2 == n) {
			return x * 3;
		}
		if (x * 2 > n) {
			return solve(n, n - x);
		}
		if ((n - x) % x == 0) {
			return n + (n - x) / x * 2 * x - x;
		}
		long ans = n + ((n - x) / x - 1) * 2 * x + x;
		long size = (n - x) % x + x;
		return ans + solve(size, x) - (n - x) % x;
	}
}


Measured memory_bytes: 9936
#include<stdio.h>

#define MAX 201

int main(void)
{
  int i,j,k,D,N,T[MAX],A[MAX],B[MAX],C[MAX],dp[MAX][MAX],z,S;
  scanf("%d%d",&D,&N);
  for(i=0;i<=D-1;i++)
    {
      scanf("%d",&T[i]);
    }
  for(i=0;i<=N-1;i++)
    {
      scanf("%d%d%d",&A[i],&B[i],&C[i]);
    }
  for(i=0;i<=N-1;i++)
    {
      for(j=0;j<=D-1;j++)
	{
          dp[j][i]=0;
	}
    }
  for(i=1;i<=D-1;i++)
    {
      for(j=0;j<=N-1;j++)
	{
	  if(A[j]<=T[i] && T[i]<=B[j])
	    {
	      for(k=0;k<=N-1;k++)
		{
		  if(A[k]<=T[i-1] && T[i-1]<=B[k])
		    {
		      if(C[j]>=C[k])
			{
		          z=C[j]-C[k]+dp[i-1][k];
			}
		      else
			{
			  z=C[k]-C[j]+dp[i-1][k];
			}
		      if(dp[i][j]<=z)
			{
			  dp[i][j]=z;
			}
		    }
		}
	    }
	}
    }
      S=0;
      for(i=0;i<=N-1;i++)
	{
	  if(S<=dp[D-1][i])
	    {
	      S=dp[D-1][i];
	    }
	}
      printf("%d\n",S);
      return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX=100005;
const ll INF=0x3f3f3f3f3f3f3f;
ll a[MAX*3],b[MAX],c[MAX],ans=-INF,n;
priority_queue<ll> u;
int main(){
    scanf("%lld",&n);
    for(ll i=0;i<3*n;i++) scanf("%lld",&a[i]);
    for(ll i=0;i<n;i++) u.push(-a[i]),b[0]+=a[i];
    for(ll i=0;i<n;i++){
        u.push(-a[i+n]);
        int t=u.top();
        u.pop();
        b[i+1]=b[i]+a[i+n]+t;
    }
    while(!u.empty()) u.pop();
    for(ll i=n-1;i>=0;i--) u.push(a[2*n+i]),c[n]+=a[2*n+i];
    for(ll i=n-1;i>=0;i--){
        u.push(a[n+i]);
        int t=u.top();
        u.pop();
        c[i]=c[i+1]+a[i+n]-t;
    }
    for(ll i=0;i<=n;i++) ans=max(ans,b[i]-c[i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5108
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] a = in.ii(N);
        int max = 0;
        for (int i = 0; i < N; i++) {
            if (max < a[i]) {
                max = a[i];
            }
        }

        int half = max / 2;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int now = Math.min(a[i], max - a[i]);
            int temp = Math.min(ans, max - ans);
            if (temp < now && now <= half) {
                ans = a[i];
            }
        }

        out.println(max + " " + ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 37928
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int n;
  
  while( cin >> n && n != 0 )
    {
      int k = 0;

      for ( auto i = 1; i <= n; ++i )
        {
          int j = i;
          
          while( j % 5 == 0 )
            {
              ++k;
              j /= 5;
            }
        }
      cout << k << endl;
    }
  
  return 0;
}

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

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

  long long ans = 0;
  vector<long long> a(s.size() + 1), b(s.size() + 1);

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<') a[i + 1] = a[i] + 1;
  }

  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '>') b[i] = b[i + 1] + 1;
  }

  for (int i = 0; i <= s.size(); i++) ans += max(a[i], b[i]);
  cout << ans << endl;
}


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

int N, w[1000];
int dp[1001][1001];

int rec(int left, int right) {
    if(~dp[left][right]) return dp[left][right];
    if(left >= right) return 0;

    bool ret = 0;
    if(!(abs(left - right) % 2)) {
        rec(left + 1, right), rec(left, right - 1);
    } else {
        for(int i = left + 1; i < right; i += 2) {
            ret |= rec(left, i) & rec(i + 1, right);
        }
        ret |= rec(left + 1, right - 1) & (abs(w[left] - w[right]) <= 1);
    }
    return dp[left][right] = ret;
}

int maxi[1001];
int calc(int idx) {

    if(maxi[idx]) return maxi[idx];
    if(idx > N) return 0;

    int ret = 0;
    ret = calc(idx + 1);
    for(int i = idx + 1; i < N; i += 2) {
        if(dp[idx][i]) {
            ret = max(calc(i + 1) + (i - idx + 1), ret);
        }
    }
    return maxi[idx] = ret;
}

int main() {
    while(cin >> N, N) {
        for(int i = 0; i < N; i++) {
            cin >> w[i];
        }

        fill_n(maxi, 1001, 0);
        fill_n(*dp, 1001*1001, -1);
        for(int i = 0; i < N - 1; i++) {
            if(abs(w[i] - w[i + 1]) <= 1) {
                dp[i][i + 1] = true;
            }
        }
        rec(0, N - 1);
        cout << calc(0) << endl;
    }
}

Measured memory_bytes: 6936
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  char s[110];
  scanf("%s",s);
  int i,n=strlen(s),cnt[200]={0};
  for(i=0;i<n;i++){
    int num=s[i]-'a';
    //printf("%d\n",num);
    cnt[num]++;
  }
  for(i=0;i<26;i++){
  //  printf("%d\n",cnt[i]);
    if(cnt[i]%2==1&&cnt[i]!=0){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
/****************************************
	Sahil Gangurde
	Learning through WA, TLE, SIGESV
****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b;
	cin>>a>>b;
	cout<<a*b<<"\n";
	return 0;
}


Measured memory_bytes: 3604
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 123;
int n , m, k;
string s;
int a[N];
int dp[N][3];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> s;
	int ans = 0 , n = sz(s);
	s = '$' + s;
	dp[1][1] = 1;
	if(s[1] != s[2])
		dp[2][1] = 2;
	dp[2][2] = 1;		
	for(int i = 3 ; i <= n ; i++){
		if(s[i] != s[i - 1])
			dp[i][1] = dp[i - 1][1] + 1;
	 	dp[i][1] = max(dp[i][1] , dp[i - 1][2] + 1);
		if(i != 3 && (s[i - 3] != s[i - 1] || s[i - 2] != s[i]))
			dp[i][2] = dp[i - 2][2] + 1;
		dp[i][2] = max(dp[i][2] , dp[i - 2][1] + 1);
//		cout << dp[i][1] << ' ' << dp[i][2] << '\n';	
	}
	cout << max(dp[n][1] , dp[n][2]);
//	cout << dp[n][1] << ' ' << dp[n][2] << ' ';
}


Measured memory_bytes: 6736
// Cliff Climbing
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int w = sc.nextInt(), h = sc.nextInt();
			if ((w | h) == 0)
				break;
			int[][] cliff = new int[h][w];
			int[][][] costs = new int[2][h][w];
			for (int i = 0; i < h; i++) {
				Arrays.fill(cliff[i], -1);
				Arrays.fill(costs[0][i], -1);
				Arrays.fill(costs[1][i], -1);
			}
			List<Integer> gx = new ArrayList<Integer>();
			List<Integer> gy = new ArrayList<Integer>();
			PriorityQueue<Node> queue = new PriorityQueue<Node>();
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					char c = sc.next().charAt(0);
					if (Character.isDigit(c))
						cliff[i][j] = c - '0';
					else if (c == 'S') {
						cliff[i][j] = 0;
						queue.add(new Node(j, i, 0, 'R'));
						queue.add(new Node(j, i, 0, 'L'));
					} else if (c == 'T') {
						cliff[i][j] = 0;
						gx.add(j);
						gy.add(i);
					} else if (c == 'X')
						cliff[i][j] = -1;
				}
			while (!queue.isEmpty()) {
				Node node = queue.poll();
				int tx = node.x;
				int ty = node.y;
				int tc = node.cost;
				char tf = node.foot;
				if (tf == 'R') {
					if (costs[0][ty][tx] >= 0 && costs[0][ty][tx] <= tc)
						continue;
					costs[0][ty][tx] = tc;
					for (int lx = -3; lx <= -1; lx++)
						for (int ly = -3 - lx; ly <= 3 + lx; ly++) {
							int x = tx + lx;
							int y = ty + ly;
							if (x >= 0 && x < w && y >= 0 && y < h
									&& cliff[y][x] >= 0)
								queue.add(new Node(x, y, tc + cliff[y][x], 'L'));
						}
				} else {
					if (costs[1][ty][tx] >= 0 && costs[1][ty][tx] <= tc)
						continue;
					costs[1][ty][tx] = tc;
					for (int rx = 1; rx <= 3; rx++)
						for (int ry = -3 + rx; ry <= 3 - rx; ry++) {
							int x = tx + rx;
							int y = ty + ry;
							if (x >= 0 && x < w && y >= 0 && y < h
									&& cliff[y][x] >= 0)
								queue.add(new Node(x, y, tc + cliff[y][x], 'R'));
						}
				}
			}
			int result = -1;
			for (int i : gy)
				for (int j : gx)
					for (int k = 0; k < 2; k++) {
						if (result == -1)
							result = costs[k][i][j];
						else if (costs[k][i][j] >= 0)
							result = Math.min(result, costs[k][i][j]);
					}
			System.out.println(result);
		}
		sc.close();
	}

	static class Node implements Comparable<Node> {
		int x, y, cost;
		char foot;

		Node(int i, int j, int c, char f) {
			x = i;
			y = j;
			cost = c;
			foot = f;
		}

		public int compareTo(Node anotherNode) {
			if (this.foot == anotherNode.foot)
				return this.cost - anotherNode.cost;
			return this.foot - anotherNode.foot;
		}

	}
}

Measured memory_bytes: 73872
N = int(input())
if N<105:
    print(0)
elif N<107:
    print(1)
else:
    ans = 1
    for i in range(107,N+1,2):
        div = 0
        if i%2==0:
            continue
        for j in range(1,i+1):
            if i%j==0:
                div += 1
        if div==8:
            ans += 1
    print(ans)


Measured memory_bytes: 38640
#include<stdio.h>

int main(){

  int n,v,j,i,c,x;

  scanf("%d" ,&n);


  int a[1000];
  for( i = 0; i < n; i++){
    scanf("%d" ,&a[i]);
  }
  if(i < 1){
    return 0;
  }
  
  
  for( x = 0; x < n-1; x++){
  printf("%d ",a[x]);
  }
   printf("%d",a[x]);
     printf("\n");

    for( c = 1; c <= n - 1; c++){
	 v = a[c];
         j = c - 1;
	 while( j >= 0 && a[j] > v ){
	   a[j+1] = a[j];
	   j--;
	   a[j+1] = v;
		  }
       
	 for( x = 0; x < n-1; x++){
	   printf("%d ",a[x]);
	 }
	  printf("%d",a[x]);
	  printf("\n");
    }
     
	 return 0;
    }
    



Measured memory_bytes: 2064
/*
 *  * main.cpp
 *   *
 *    */

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<cassert>
using namespace std;

long long dp[200003][3];
int n, l, r;
int C[129];
int MOD = 1000000007;
char s[300005];
int ss[28];
int main() {

    string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int r, l;
    char s[3];
    scanf("%s", s);
    string d = string(s);
    for (int i = 0; i < 7; ++i) 
        if (days[i] == d) {
            printf("%d\n", 7 - i);
            break;
        }

    return 0;
}


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

int main(){
	int n, point, runner, out;
	string input;
	cin >> n;
	for(int i = 0; i < n; i++){
		point = 0;
		runner = 0;
		out = 0;
		while(true){
			cin >> input;
			if(input=="HIT"){
				runner++;
				if(runner>3){
					point++;
					runner = 3;
				}
			}
			else if(input=="HOMERUN"){
				point = point + runner + 1;
				runner = 0;
			}
			else{
				out++;
				if(out==3){
					break;
				}
			}
		}
		cout << point << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 998244353
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type* arr = new type[n];
#define forn(i, n) for (int i = 1; i <= n; i++)
#define me0(x) memset(x, 0, sizeof(x))
#define me1(x) memset(x, -1, sizeof(x))
#define tests(x) \
    int x;       \
    cin >> x;    \
    while (x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int INF = 1e18;
const int N = 2e5 + 2;
void run() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int n, arr[N];
void solve() {
    cin >> n;
    int x = 0;
    forn(i, n) {
        cin >> arr[i];
        x ^= arr[i];
    }
    forn(i, n) {
        cout << (x ^ arr[i]) << " ";
    }
}
int32_t main() {
    run();
    solve();
    return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			A /= 2;
			B += A;
		}
		else {
			B /= 2;
			A += B;
		}
	}
	cout << A << " " << B << endl;
	return 0;
}

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


int main(){
    int N;
    int d[100000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> d[i];
    }

    sort(d, d+N);

    int K = d[N/2];
    int D = K - d[N/2-1];

    cout << D;

    return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int iti [] = new int [128];
		iti ['A'] = 1;
		iti ['B'] = 0;
		iti ['C'] = 0;
		int change = 0;
		while(true){
			try{
				String a = in.next();
				char[] num = a.toCharArray();
				change = iti[num[0]];
				iti[num[0]] = iti[num[2]];
				iti[num[2]] = change;
			}catch(Exception e){
				for(char i = 'A';i <= 'C';i++){
					if(iti[i] == 1){
						System.out.println(i);
					}
				}
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 17144
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n, k;
  readf (" %d %d", &n, &k);
  int c;
  while (n > 0) {
    ++c;
    n /= k;
  }
  writeln (c);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int par[200005], ran[200005], par2[200005], ran2[200005];
int n, k, l;

void init(int n, bool road) {
	if (road) {
		FOR(i, n) {
			par[i] = i;
			ran[i] = 0;
		}
	}
	else {
		FOR(i, n) {
			par2[i] = i;
			ran2[i] = 0;
		}
	}
}

int find(int x, bool road) {
	if (road) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x], true);
	}
	else {
		if (par2[x] == x) return x;
		else return par2[x] = find(par2[x], false);
	}
	
}

void unite(int x, int y, bool road) {
	if (road) {
		x = find(x, true);
		y = find(y, true);
		if (x == y) return;
		if (ran[x] < ran[y]) par[x] = y;
		else {
			par[y] = x;
			if (ran[x] == ran[y]) ran[x]++;
		}
	}
	else {
		x = find(x, false);
		y = find(y, false);
		if (x == y) return;
		if (ran2[x] < ran2[y]) par2[x] = y;
		else {
			par2[y] = x;
			if (ran2[x] == ran2[y]) ran2[x]++;
		}
	}
}

bool same(int x, int y, bool road) {
	if (road) return find(x, true) == find(y, true);
	else return find(x, false) == find(y, false);
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k >> l;
	init(n, true);
	FOR(i, k) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;
		unite(p, q, true);
	}
	init(n, false);
	FOR(i, l) {
		int r, s;
		cin >> r >> s;
		r--;
		s--;
		unite(r, s, false);
	}
	map<pair<int, int>, int> mp;
	FOR(i, n) {
		mp[make_pair(find(i, true), find(i, false))]++;
	}
	FOR(i, n) {
		cout << mp[make_pair(find(i, true), find(i, false))];
		if (i < n-1) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    if n in [7,5,3]:
        return 'YES'

    return 'NO'


print(main())


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

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

  REP(i,w+2) cout << "#";
  cout << endl;
  REP(i,h) {
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  REP(i,w+2) cout << "#";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

ll N, ans, dp[2020][2020], rs[2020], bs[2020];
string S;

const int MAX = 100002;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

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

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


int main(){
	pre_comb();
	cin >> S;
	N = S.size();
	if(S[0] == '0') dp[1][0] = 1, dp[0][1] = 0, rs[0] = 2, bs[0] = 0;
	else if(S[0] == '2') dp[1][0] = 0, dp[0][1] = 1, rs[0] = 0, bs[0] = 2;
	else dp[1][0] = 1, dp[0][1] = 1, rs[0] = 1, bs[0] = 1;
	rep(i, N-1){
		rs[i+1] = rs[i] + ('2' - S[i+1]);
		bs[i+1] = bs[i] + (S[i+1] - '0');
	}
	for(int sum=2; sum<=N; sum++){
		rep(j, sum+1){
			int i = sum-j;
			if(j==0){
				if(S[sum-1] < '2' || rs[sum-2] >= sum-j) dp[i][j] = dp[i-1][j];
			}else if(j==sum){
				if(S[sum-1] > '0' || bs[sum-2] >= j) dp[i][j] = dp[i][j-1];
			}else{
				if(S[sum-1] < '2' || rs[sum-2] >= sum-j) dp[i][j] += dp[i-1][j];
				if(S[sum-1] > '0' || bs[sum-2] >= j) dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	rep(i, N+1) ans = (ans + comb(N, rs[N-1]-i) * dp[i][N-i] % mod) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 33280
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;

long double pi = 3.14159265358979;

long double x[2],y[2];

long double dist(){
    return sqrt((x[0]-x[1])*(x[0]-x[1]) + (y[1]-y[0])*(y[1]-y[0]));
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int k;
    string s;
    cin>>k>>s;
    int n = s.size();
    if(n<=k)cout << s << endl;
    else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3616
# coding: utf-8
# Your code here!

import sys

N, M = map(int, input().rstrip().split(' '))

memo = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().rstrip().split(' '))
    a -= 1
    b -= 1
    
    if a == 0:
        memo[b][0] = 1
    elif b == N-1:
        memo[a][1] = 1
        
for i in range(N):
    if memo[i][0] == 1 and memo[i][1] == 1:
        print('POSSIBLE')
        sys.exit()
        
print('IMPOSSIBLE')

Measured memory_bytes: 65780
'use strict'

const main = arg => {
 const input = arg.trim().split("\n")[0].split(" ").map(num => parseInt(num, 10));
 const A = input[0];
 const B = input[1];
 let mark = "==";
 if(A > B){ mark = ">"; }
 if(A < B){ mark = "<"; }

 console.log("a "+ mark +" b");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 15364
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

int main() {
	long long N, M;
	vector<vector<long long> > drink;
	cin >> N >> M;
	drink.resize(N);
	for (long long i = 0; i < N; ++i) {
		drink[i].resize(2);
		cin >> drink[i][0] >> drink[i][1];
	}
	sort(drink.begin(), drink.end());

	long long sum = 0;
	long long number = 0;
	long long preNumber = 0;
	for (int i = 0; i < N; ++i) {
		preNumber = number;
		number += drink[i][1];

		if (number > M) {
			long long buf = M - preNumber;
			sum += drink[i][0] * buf;
			break;
		}
		sum += drink[i][0] * drink[i][1];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 5760
import numpy as np
n, d = map(int, input().split())
point = np.array(
    [
        np.array(list(map(int, input().split()))) for i in range(n)
    ]
)


def calc(a, b):
    return np.sqrt(sum((a - b)**2))


ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        k = calc(point[i], point[j])
        if k.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 12452
for i in range(1,301):
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    else:
        for d in range(h):
            for t in range(w):    
                if (t+d)%2==0:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


Measured memory_bytes: 7000
def main():
    N, A, B = map(int, input().split())
    S = input()

    flag = 0
    m = A+B
    counter = 0
    f_counter = 0
    for i in range(len(S)):
        if S[i] == "a" and (counter+1)<=m:
            counter += 1
            print("Yes")
        elif S[i] == "b" and (counter+1<=m and f_counter+1 <= B):
            counter+=1
            f_counter += 1
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	for (int t = 0; t < k; t++) {
		vector<int> v(n);
		for (int i = 0; i < n; i++) {
			int l = i - a[i];
			int r = i + a[i];
			v[max(0, l)]++;
			if (r + 1 < n) v[r + 1]--;
		}
		for (int i = 1; i < n; i++) {
			v[i] += v[i - 1];
		}
		a = v;
		if (*min_element(a.begin(), a.end()) == n) break;
	}
	for (auto t : a) {
		cout << t << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 4452