akhauriyash/Code-Regression huggingface dataset:
/*
ID: Aldew
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("lamps.in");
//ofstream fout("lamps.out");


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

    if (x >= 400 && x <= 599) cout << 8 << endl;
    else if (x >= 600 && x <= 799) cout << 7 << endl;
    else if (x >= 800 && x <= 999) cout << 6 << endl;
    else if (x >= 1000 && x <= 1199) cout << 5 << endl;
    else if (x >= 1200 && x <= 1399) cout << 4 << endl;
    else if (x >= 1400 && x <= 1599) cout << 3 << endl;
    else if (x >= 1600 && x <= 1799) cout << 2 << endl;
    else if (x >= 1800 && x <= 1999) cout << 1 << endl;


    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    String[] S = new String[N];
    long[] count = new long[5];
    long ans = 0;

    for (int i = 0; i < N; i++){
      S[i] = scanner.next();
    }
    for (int i = 0; i < N; i++){
      if(S[i].charAt(0) == 'M'){
        count[0]++;
      } else if (S[i].charAt(0) == 'A'){
        count[1]++;
      } else if (S[i].charAt(0) == 'R'){
        count[2]++;
      } else if (S[i].charAt(0) == 'C'){
        count[3]++;
      } else if (S[i].charAt(0) == 'H'){
        count[4]++;
      }
    }
    ans = count[0] * count[1] * count[2] + count[0] * count[1]* count[3] +
    count[0] * count[1] * count[4] + count[0] * count[2] * count[3] +
    count[0] * count[2] * count[4] + count[0] * count[3] * count[4] +
    count[1] * count[2] * count[3] + count[1] * count[2] * count[4] +
    count[1] * count[3] * count[4] + count[2] * count[3] * count[4];

    System.out.println(ans);
  }
}


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

int main()
{
 int mn = INT_MAX , mx = INT_MIN;
 int n;
 cin >> n;
 int ara[n+10];

 for(int i=0; i<n; i++)
 {
     cin >> ara[i];
     mn = min(mn,ara[i]);
     mx = max(mx,ara[i]);

 }
 int ans = INT_MAX;

 for(int i=mn; i<=mx; i++)
 {
     int tmp = 0;
     for(int j=0; j<n; j++)
     {
         tmp += (ara[j]-i)*(ara[j]-i);
     }

     ans = min(ans,tmp);

 }

 cout << ans << endl;




 }


Measured memory_bytes: 3552
s = input()

ans = 10**9

for cand in set(s):
  cnt = 0
  a = 0
  for tmp in s:
    if tmp != cand:
      cnt+=1
    else:
      if a < cnt:
        a = cnt
      cnt = 0
  if a < cnt:
    a = cnt
  if ans > a:
    ans = a
    
print(ans)

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

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

    int m = 2*n - 1;
    if (x == m or x == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;


    rep(i, 0, m)
    {
        int now = (x - n + i) % m;
        if (now < 0 ) now += m;
        ++now;
        printf("%d ", now);

    }
    cout << endl;
    return 0;
}

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

const int N = 5e2;
long long dp[N][N];
int a[N];
long long ps[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		ps[i] = ps[i - 1] + a[i];
	for (int i = 2; i<=n; i++)
		for (int l = 1, r = i + 1; r <= n + 1; l++, r++) {
			dp[l][r] = 1e16;
			for (int j = l + 1; j<r; j++)
				dp[l][r] = min(dp[l][r], dp[l][j] + dp[j][r] + ps[r - 1] - ps[l - 1]);
		}

	cout << dp[1][n + 1];
	cin >> n;
	return  0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string a,b;
int s1,s2;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=a.size()+b.size();i++)
		if(i&1) cout<<a[s1++];
		else cout<<b[s2++];
	cout<<endl;
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  cout << 6 - (a+b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';
ll i, j, le;

int main()
{
	IOS;
	int t;
	t = 1;
	while (t--)
	{
		ll ans = -1;
		string k;
		cin >> k;
		ll n = k.size();
		ll n2 = stoi(k);
		if (k[n - 1] == '1' || k[n - 1] == '3' || k[n - 1] == '9' || k[n-1]=='7')
		{
			ans = 1;
			ll num = 7;
			while (1)
			{
				if (num % n2 == 0)
					break;
				else
				{
				num=(((num*10)%n2+7)%n2);
				ans++;
				}
			}
			cout << ans << e;
		}
		else
		{
			cout << -1 << e;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func invert(s []byte) []byte {
	res := make([]byte, len(s))
	for i := range s {
		if s[i] == '0' {
			res[i] = '1'
		} else {
			res[i] = '0'
		}
	}
	return res
}

func main() {
	defer stdout.Flush()
	_ = readInt()
	k := readInt()
	s := []byte(readString())

	println(max(solve(s, k), solve(invert(s), k-1)))
}

func solve(s []byte, k int) int {
	b := 0
	i := 0
	for i < len(s) && s[i] == '1' {
		i++
	}
	j := i
	for p := 0; p < k; p++ {
		for j < len(s) && s[j] == '0' {
			j++
		}
		for j < len(s) && s[j] == '1' {
			j++
		}
	}
	ans := j - b
	for j < len(s) {
		for b < len(s) && s[b] == '1' {
			b++
		}
		for b < len(s) && s[b] == '0' {
			b++
		}
		for j < len(s) && s[j] == '0' {
			j++
		}
		for j < len(s) && s[j] == '1' {
			j++
		}
		tmp := j - b
		ans = max(ans, tmp)
	}
	//eprintln(ans)
	return ans
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

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


Measured memory_bytes: 1152
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
// #include <bits/stdc++.h>
#include <vector>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <random>
#include <queue>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <cstring>
#include <deque>

 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<cd> vcd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vl> vvl;


#define FOR(i,a,b) for (int i=a; i<b; i++)
#define F0R(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = b; i > a; i--)
#define F0Rd(i,a) for (int i = a; i > -1; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define que queue
#define pa pair
#define ex(m,i) m.find(i)!=m.end()
#define nex(m,i) m.find(i)==m.end()
#define ms(arr,i) memset(arr,i,sizeof(arr))

#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy
const double epsilon = 1e-12;
const int ds[4][2] = {
    {-1,0},
    {1,0},
    {0,-1},
    {0,1}
};

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

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    int s; cin >> s;
    vl dp(s+5,0);
    dp[0] = 1;
    for(int i = 0; i < s; i++){
        for(int j = 3; i + j <= s; j++){
            dp[i+j]+=dp[i]%MOD;
        }
    }

    printf("%lld\n",dp[s]%MOD);
    
    return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,m,S,T;
vector<int>v[N];
int vis[N][4],dis[N][4];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int s,t;
		cin>>s>>t;
		v[s].pb(t);
	}	
	cin>>S>>T;
	for(int i=1;i<=n;i++)for(int j=0;j<3;j++)dis[i][j]=1e9;
	dis[S][0]=dis[S][1]=dis[S][2]=0;
	priority_queue<pair<int,int> >q;
	q.push({0,S});
	while(!q.empty()){
		auto k=q.top();
		q.pop();
		if(-k.fi%3==0&&k.se==T)return cout<<dis[T][0]/3<<endl,0;
		for(auto x:v[k.se]){
			dis[x][(-k.fi+1)%3]=min(dis[x][(-k.fi+1)%3],-k.fi+1);
			if(vis[x][(-k.fi+1)%3])continue;
			q.push({k.fi-1,x});
			vis[x][(-k.fi+1)%3]=1;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> x(m), y(m);
  rep(i, m) cin >> x[i] >> y[i];
  map<int, int> mp;
  rep(i, m) mp[x[i]]++;
  int mx = 0;
  for (auto e : mp)
    chmax(mx, e.second);
  vector<int> x2;
  for (auto e : mp) {
    if (e.second == mx)
      x2.push_back(e.first);
  }
  int ans = mx;
  mp = map<int, int>();
  rep(i, m) mp[y[i]]++;
  mx = 0;
  for (auto e : mp)
    chmax(mx, e.second);
  vector<int> y2;
  for (auto e : mp) {
    if (e.second == mx)
      y2.push_back(e.first);
  }
  ans += mx;
  int cnt = 0;
  sort(x2.begin(), x2.end());
  sort(y2.begin(), y2.end());
  rep(i, m) {
    auto itx = lower_bound(x2.begin(), x2.end(), x[i]);
    auto ity = lower_bound(y2.begin(), y2.end(), y[i]);
    if (*itx == x[i] && *ity == y[i])
      cnt++;
  }
  if (cnt < (ll)x2.size()*(ll)y2.size())
    cout << ans << endl;
  else
    cout << ans-1 << endl;
  return 0;
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	map<string,int> my_m;
	int n = s.size();
	string t;
	rep(i,n){
		For(j,1,k+1){
			// i 文字目から j 文字を取る
			if (i + j > s.size()) continue;
			t = s.substr(i,j);
			my_m[t] += 1;
		}
	}
	int count = 1;
	for(auto x:my_m){
		if (count == k){
			cout << x.first << endl;
			return 0;
		}
		count ++ ;
	}
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    ans = max(c - (a - b), 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<vector<int>> edges;
vector<bool> visited;
vector<int> ans;

void dfs(int cur) {
    if (visited[cur]) {
        return;
    }
    for (auto &next : edges[cur]) {
        dfs(next);
    }
    ans.push_back(cur);
    visited[cur] = true;
}

int main(void) {
    int V, E;
    cin >> V >> E;

    edges.resize(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edges[t].push_back(s);
    }

    visited.resize(V, false);

    for (int i = 0; i < V; i++) {
        if (!visited[i]) {
            dfs(i);
        }
    }

    for (auto v : ans) {
        cout << v << endl;
    }

    return 0;
}



Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication52
{
    class Program
    {
        static void Main()
        {
            int[] a = new int[1000];
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "") break;
                int[] b = s.Split(',').Select(int.Parse).ToArray();
                a[b[0] - 1]++;
            }
            int[] c = new int[1000];
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null) break;
                int[] b = s.Split(',').Select(int.Parse).ToArray();
                c[b[0] - 1]++;
            }
            for(int e = 0; e < 1000; e++)
            {
                if (a[e] != 0 && c[e] != 0)
                {
                    Console.WriteLine("{0} {1}",e+1,a[e]+c[e]);
                }
            }
        }
    }
}

Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long K, long long N, std::vector<long long> A)
{
  LL maxim = K - (A[N - 1] - A[0]);

  for (int i = 0; i < N - 1; i++)
  {
    maxim = max(maxim, A[i + 1] - A[i]);
  }
  cout << K - maxim << endl;
}

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


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

template <typename T>
T zero_sum_ranges(vector<T> A, ll k) {
    T n = A.size();
    T sum[n + 1] = {};
    map<T, T> mp;
    for(size_t i = 0; i < n; i++) {
        sum[i + 1] = (sum[i] + A[i]) % k;
    }
    T ret = 0;
    for(size_t i = 0; i <= n; i++) {
        if(mp.count(sum[i])) ret += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ret << endl;
}

int main() {
    ll n, m, i, j, k;
    ll p;
    cin >> n >> p;
    vector<ll> dp(n);
    string s;
    cin >> s;
    ll md = 1;
    for(i = n - 1; i >= 0; i--) {
        dp[n - 1 - i] = ((s[i] - '0') * md) % p;
        md *= 10;
        md %= p;
    }
    if(p != 2 && p != 5)
        zero_sum_ranges(dp, p);
    else {
        ll ret = 0;
        for(i = 0; i < n; i++) {
            if((s[i] - '0') % p == 0) ret += i + 1;
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 5764
A,B,C,D=map(int,input().split())

# CDの最小公倍数 = CD/CDの最大公約数
def euclid(C,D):
    return C if D==0 else euclid(D,C%D)

E=C*D//euclid(C,D)

ac=A//C
ad=A//D
acd=A//E
bc=B//C
bd=B//D
bcd=B//E

ans=(B-A+1) - (bc-ac+bd-ad-bcd+acd)

if A%C==0 or A%D==0:
    ans-=1
print(ans)



Measured memory_bytes: 3060
//(最大座標)-(最小座標)を駒を動かす。
//その中から訪れないところを引く
//訪れないところは訪れる座標の間のうち大きい順にN-1個

#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(void){
    int N, M;
    scanf("%d %d",&N, &M);
    int X[M];
    for(int i = 0; i < M; i++){
        scanf("%d",&X[i]);
    }
    qsort(X,M,sizeof(int),compare);
    int between[M-1];
    int bsum =0;
    for(int i = 0; i < M-1; i++){
        between[i] = abs(X[i]-X[i+1]);
    }
    qsort(between,M-1,sizeof(int),compare);
    for(int i = M-2; i > (M-2)-(N-1); i--){
        bsum += between[i];
    }

    int ans = 0;
    if(N > M) ans = 0;
    else ans = (X[M-1]-X[0]) - bsum;

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

    return 0;
}


Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxN = 100005;
const int MOD = 10000;
const int INF = 1e9+7;
int n,k;
char s[maxN];
int a[maxN];
int b[maxN];
pii p[maxN];
int main()
{
	scanf("%d %d",&n,&k);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		a[i] = s[i]-'0';
	}
	int st = 0,end = 0;
	a[0] = 1,a[n+1] = 1;
	int tot = 0;
	for(int i=1;i<=n;i++)
	{
		if(a[i] == 0 && a[i-1] == 1)
		{
			st = i;
		}
		if(a[i] == 0 && a[i+1] == 1)
		{
			end = i;
			p[++tot] = pii(st,end);
		}
	}
	p[0] = pii(0,0);
	p[tot+1] = pii(n+1,n+1);
	int ans = 0;
	if(tot<k)
		ans = n;
	else
	{
		for(int i=1;i<=tot;i++)
		{
			int j = min(tot,i+k-1);
			int L = p[i-1].second+1;
			int R = p[j+1].first -1;
			ans = max(R-L+1,ans);
		} 
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        while (x)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

vec divisor(ll n)
{
    vec d;
    for(ll i=1; i*i<n; ++i) {
        if(n % i == 0) {
            d.pb(i);
            d.pb(n / i);
        }
    }
    ASC(d);

    return d;
}

int main()
{
    ll N, M;
    cin >> N >> M;

    ll m = 1;
    vec D = divisor(M);
    FORR(d,D) {
        if(d >= N) m = MAX(m,M/d);
    }
    PR(m);

    return 0;
}

/*



*/

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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<int> vc;
   for(int i = 0;i < n;i++) {
      int x;
      cin >> x;
      vc.push_back(x);
   }
   int count = 0;
   bool flag = true;
   while(flag) {
      for(int i = 0;i < n;i++) {
         if(vc[i]%2==1) {
            flag = false;
         } else {
            vc[i]/=2;
         }
      }
      if(flag) {
         count++;
      }
   }
   cout << count << endl;
}



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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll tm=n;
    for(ll i=sqrt(n);i>0;i--)
    {
        if(n%i==0)
        {
            tm=i;
            break;
        }
    }
    ll tm2= n/tm;
    cout<< tm+tm2-2;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int H, W;
  int a[505][505];
  cin >> H >> W;
  queue<int> que;
  int cnt = 0;
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }
  rep(i, H) {
    rep(j, W) {
      if (a[i][j] % 2 == 1 ) {
        if (j == W-1 && i != H-1) {
          a[i][j]--;
          a[i+1][j]++;
          que.push(i+1);
          que.push(j+1);
          que.push(i+2);
          que.push(j+1);
          cnt++;
        }
        else if (j != W-1 || i != H-1) {
          a[i][j]--;
          a[i][j+1]++;
          que.push(i+1);
          que.push(j+1);
          que.push(i+1);
          que.push(j+2);
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  while(!que.empty()) {
    rep(i, 4) {
      if (i != 3)
        cout << que.front() << ' ';
      else
        cout << que.front();
      que.pop();
    }
    cout << endl;
  }
}


Measured memory_bytes: 6144
import math
import time


t = time.time()
def iip():
    return [int(i) for i in input().split()]

def main():
    H, N = iip()
    mp_for_damage = [10**9 for i in range(H+1)]
    mp_for_damage[0] = 0
    ab = []

    for i in range(N):
        ab.append(iip())

    ab= sorted(ab, key=lambda x:x[0]/x[1], reverse=True)

    for i in range(N):
        a, b = ab[i]

        for k in range(1, min(a, H) + 1):
            mp_for_damage[k] = min(mp_for_damage[k], b)
            # print(k, b)

        if a >= H:
            mp_for_damage[H] = min(mp_for_damage[H], b)
            continue

        if a < H and mp_for_damage[a] < b:
            continue

        for j in range(H-a+1):
            mp_for_damage[j+a] = min(mp_for_damage[j+a], mp_for_damage[j] + b)

    #print(mp_for_damage)
    #print(mp_for_damage)
    print(mp_for_damage[H])

    #print(time.time() - t)

main()

Measured memory_bytes: 41324
#include <iostream>
using namespace std;
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,y3,x4,y4;
  x3 = x2 + y1 - y2;
  y3 = y2 - x1 + x2;
  x4 = x1 + y1 - y2;
  y4 = y1 - x1 + x2;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}

Measured memory_bytes: 3720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HussienMoustafa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDistanceEditorial solver = new BDistanceEditorial();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDistanceEditorial {
        public void solve(int testNumber, Scanner s, PrintWriter out) {
            int n = s.nextInt(), cnt = 0;
            double d = s.nextInt();
            while (n-- != 0) {
                double x = s.nextInt(), y = s.nextInt();
                if (Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) <= d) {
                    cnt++;
                }

            }
            out.println(cnt);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 46516
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <cmath>

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


ll syakutori2d(const vi &a, int th)
{
    ll ans = 0;
    for (size_t i = 0, j = a.size(); i < a.size(); i++)
    {
        for (; j > 0; j--)
        {
            if (a[i] + a[j - 1] >= th)
            {
                ans += j;
                break;
            }
        }
    }
    return ans;
}

template<class PredT>
int bs(vi &a, int left, int right, PredT pred)
{
    std::sort(begin(a), end(a), std::greater<int>());
    while (left + 1 < right)
    {
        int center = (left + right) / 2;
        ll cv = syakutori2d(a, center);
        if (pred(cv))
            right = center;
        else
            left = center;
    }

    return right;
}



ll syakutori2d_sum(const vi &a, ll M, int min)
{
    vll b(a.size()+1);
    b[0] = 0;
    for (size_t i = 0; i < a.size(); i++)
    {
        b[i+1] = b[i] + a[i];
    }

    ll ans = 0;
    for (size_t i = 0, j = a.size(); i < a.size(); i++)
    {
        for (; j > 0; j--)
        {
            if (a[i] + a[j - 1] > min)
            {
                M -= j;
                ans += (ll)a[i] * j + b[j];
                break;
            }
        }
    }
    ans += min * M;
    return ans;
}


int main()
{
    int N;
    ll M;
    cin >> N >> M;
    vi A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    int min = bs(A, 0, 300000, [M](ll v){ return v < M; }) - 1;
    ll ans = syakutori2d_sum(A, M, min);
    cout << ans << endl;
}


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
ll n, m, a[maxn];
map<int, int> M, N;
set<int> S;
string s;

int exp(int a, int b)
{
    if(b==0)return 1;
    if(b==1) return a;
    int x = exp(a, b/2);
    x*=x;
    if(b%2)return x*a;
    return x;
}
void solve()
{
    cin >> n;
    vector<int> v;
    for(int i = 1; i < 1000; i++)
        for(int j = 2; j < 10; j++)
            v.pb(exp(i, j));
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++)
    {
        if(v[i]>n)
        {
            cout << v[i-1];
            return;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solve();
}


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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  int D=0;
  int ans=1;
  while(D+L.at(ans-1)<=X){
    D += L.at(ans-1);
    ans ++;
    if(ans==N+1){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

n=int(input())
s=deque(input())


left=0
right=0
for i in range(n):
  if s[i]=="(":
    left+=1
  else:
    if left>0:
      left-=1
    else:
      right+=1
    
      

for _ in range(left):
    s.append(")")
    

for _ in range(right):
    s.appendleft("(")

print("".join(s))


Measured memory_bytes: 9380
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long K;
        static long[] A;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var S = new String[N];

            for (int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }

            var AB = 0;
            var A = 0;
            var B = 0;
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                var len = S[i].Length;
                if (S[i][0] == 'B' && S[i][len-1] == 'A')
                {
                    AB++;
                }
                else if(S[i][0] == 'B')
                {
                    B++;
                }else if (S[i][len - 1] == 'A')
                {
                    A++; 
                }

                ans += CulAB(S[i]);
            }

            if(AB >= 2)
            {
                ans += AB - 1;
            }
            
            if(AB > 0)
            {
                if(A > 0)
                {
                    ans++;
                    A--;
                }

                if (B > 0)
                {
                    ans++;
                    B--;
                }
            }

            if(A*B > 0)
            {
                ans += Min(A, B);
            }


            Console.WriteLine(ans);
        }
        
        static long CulAB(String S)
        {
            long ans = 0;
            for (int i = 0; i < S.Length-1; i++)
            {
                if (S[i] == 'A' && S[i+1] == 'B')
                {
                    ans++;
                }
            }

            return ans;
        }

        static bool check(double mid)
        {
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += (long)(A[i] / mid);
            }

            return ans <= K;
        }
    }


}


Measured memory_bytes: 27952
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
using namespace std;
int a[1144], b[1144];
signed main() {
	int n, h, w, cnt = 0;
	cin >> n >> h >> w;
	for (int i = 0; i < n; i++)cin >> a[i]>>b[i];
	for (int i = 0; i < n; i++) {
		if (a[i] >= h && b[i] >= w)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <tuple>
#include <utility>
#include <algorithm>
using namespace std;

typedef tuple<string,int,int> item;

bool compare(const item &l, const item &r){
  if(get<0>(l) !=get<0>(r)) return get<0>(l) < get<0>(r);
  if(get<1>(l) != get<1>(r)) return get<1>(l) > get<1>(r);
  return true;
}

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

  vector<item> SP;
  SP.resize(N);

  int count=1;
  for(auto &s : SP){
    get<2>(s) = count++;

    cin >> get<0>(s) >> get<1>(s);
  }

  sort(SP.begin(),SP.end(),compare);
  for(auto &sp: SP){
    cout << get<2>(sp)<<endl;
  }


}


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

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int cnt = 0, bcnt = 0;
    rep(i, n) {
        if (s[i] == 'a' && cnt < a + b) {
            cout << "Yes" << endl;
            cnt++;
        } else if (s[i] == 'b') {
            if (cnt < a + b && bcnt < b) {
                cout << "Yes" << endl;
                cnt++;
            } else {
                cout << "No" << endl;
            }
            bcnt++;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 896
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let h: i32 = read();
    let w: i32 = read();

    let mut ans_w = '-';
    let mut ans_h = -1;
    let snuke = vec!['s', 'n', 'u', 'k', 'e'];
    for hi in 0..h {
        'inner: for wi in 0..w {
            let s: String = read();
            let v: Vec<char> = s.chars().collect();
            for i in 0..5 {
                if snuke[i] != v[i] {
                    continue 'inner;
                }
            }
            ans_w = (b'A' + wi as u8) as char;
            ans_h = hi + 1;
        }
    }
    println!("{}{}", ans_w, ans_h)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long  long 
#define ar array

using namespace std ;
                                                                                              
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

    int n , a , b  ; 
    cin >> n >> a >> b  ; 
    int k = n/(a+b) ; 
    int r = n%(a+b) ; 
    cout << (k*a + min(r, a))  ;

                
}








Measured memory_bytes: 3656
#include <stdio.h>
#include <math.h>
#define N 500001

typedef struct{
  double x;
  double y;
}P;


void kock(int n,P p1,P p2){
  P s,u,t;
  if(n==0)return;
  s.x=(2*p1.x+1*p2.x)/3;
  s.y=(2*p1.y+1*p2.y)/3;
  t.x=(2*p2.x+1*p1.x)/3;
  t.y=(2*p2.y+1*p1.y)/3;
  u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

  kock(n-1,p1,s);
  printf("%lf %lf\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%lf %lf\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%lf %lf\n",t.x,t.y);
  kock(n-1,t,p2);
}


int main(){
  int n,i;
  P p1={0,0},p2={100,0};

  scanf("%d",&n);
  printf("%lf %lf\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%lf %lf\n",p2.x,p2.y);
  return 0;
}




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

int h,w,a[500][500],st=0; 
string sa;
string ss(int t)
{
	stringstream s;
	s.str("");
	s<<t;
	return s.str();
}


int print()
{
	cout<<st<<endl<<sa;
	return 0;
}
int main()
{
	int i,j,s=0;
	cin>>h>>w;	
	for(i=0;i<h;i++)//input two dimension array 
	{
		for(j=0;j<w;j++)
		{
			cin>>a[i][j];			
		}
		for(j=0;j<w-1;j++)
		{
			if(a[i][j]%2==1) 
			{
			 	a[i][j+1]++;st++;
			 	sa+=ss(i+1);sa+=" ";sa+=ss(j+1);
			 	sa+=" ";sa+=ss(i+1);sa+=" ";sa+=ss(j+2);sa+="\n";
			}			
		}			
	}	
	for(i=0;i<h-1;i++)
	{
		if(a[i][w-1]%2==1)
		{
			a[i+1][w-1]++;st++;
		 	sa+=ss(i+1);sa+=" ";sa+=ss(w);
		 	sa+=" ";sa+=ss(i+2);sa+=" ";sa+=ss(w);sa+="\n";
		} 
	}
	print();
		
    return 0;
}

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

int main(){
	int n; cin >> n;
	int debt = 100000;
	for(int i=0; i<n; i++){
		debt *= 1.05;
		if((debt%1000) != 0)
			debt += 1000-(debt%1000);
	}
	cout << debt << endl;
	return 0;
}

Measured memory_bytes: 3064
// ProblemURL : https://atcoder.jp/contests/abc114/tasks/abc114_c
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ct := 0
	check := func(n int) bool {
		a, b, c := false, false, false
		for i := n; i > 0; i /= 10 {
			switch i % 10 {
			case 3:
				a = true
			case 5:
				b = true
			case 7:
				c = true
			default:
				return false
			}
		}
		return a && b && c
	}

	var dfs func(int)
	dfs = func(x int) {
		if x > n {
			return
		}
		if check(x) {
			ct++
		}
		if y := x*10 + 3; y <= n {
			dfs(y)
		}
		if y := x*10 + 5; y <= n {
			dfs(y)
		}
		if y := x*10 + 7; y <= n {
			dfs(y)
		}
	}
	dfs(0)
	fmt.Println(ct)
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y;
	cin>>x>>y;
	if(x*2<=y&&x*4>=y&&!(y&1)){
		cout<<"Yes";
	}else cout<<"No";
	RE 0;
}




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


int main(){
  int p;
  cin>>p;
  char s[10000];
      cin>>s;
  int n=strlen(s);

  for(int i=0;i<n;i++){
    if(s[i]+p<=90)
      s[i]=s[i]+p;
      else 
      s[i]=s[i]+p-90+64;


  }
 
  cout<<s;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    long long k,a,b;
    long long sum=0LL;
    cin>>k>>a>>b;
    if(a+1LL>=b||k<a+1) sum=1LL;
    else
    {
        k-=(a+1);
        sum+=b;
        long long te=k/2;
        sum+=te*(b-a);
        k-=te*2;
    }
   cout<<sum+k;
    return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int h = 100, w = 100;
	vector<vector<bool>> v(h, vector<bool>(w));
	for (int i = 0; i < h / 2; i++) {
		for (int j = 0; j < w; j++) {
			v[i][j] = true;
		}
	}
	for (int i = 0; i < a - 1; i++) {
		v[i / (w / 2) * 2][i % (w / 2) * 2] = false;
	}
	for (int i = 0; i < b - 1; i++) {
		v[h - 1 - i / (w / 2) * 2][w - 1 - i % (w / 2) * 2] = true;
	}
	cout << h << " " << w << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ".#"[v[i][j]];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

const int N = 2005;

const int MOD = 1000000007;
int arr[N];

int32_t main()
{


    IOS

    int n, k;
    cin >> n >> k;

    k%=MOD;

    for(int i = 1; i<= n; i++)
    {
    	cin >> arr[i];
    }


    int invcount = 0;

    for(int i = 1; i <= n; i++)
    {
    	int ans = 0;
    	for(int j = 1; j <= n; j++)
    	{
    		if(arr[i] > arr[j])ans++;
    		if(arr[i] > arr[j] and i < j)invcount+=k;
    		invcount %= MOD;
    	}
    	ans %= MOD;
    	invcount %= MOD;
    	int f = k*(k-1)/2;
    	f%=MOD;

    	invcount += (f*ans);
        invcount %= MOD;
    }

    cout << invcount%MOD;




    return 0;
}




Measured memory_bytes: 256
# coding: utf-8
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

INF=10**9

d=[INF for i in range(N)]
edges=[0 for i in range(N)]
d[0]=0
queue=[]
queue.append(0)

while queue:
    u=queue.pop(0)
    for i in range(len(G[u])):
        if d[G[u][i]]==INF:
            queue.append(G[u][i])
            d[G[u][i]]=d[u]+1

k=d[N-1]
m=N-1
queue.append(N-1)

while k>d[N-1]//2+1:
    u=queue.pop(0)
    for i in range(len(G[u])):
        if d[G[u][i]]==d[u]-1:
            queue.append(G[u][i])
            k=d[u]
            m=u

queue=[]
queue.append(m)
unused=[True for i in range(N)]
unused[m]=False

sunuke=1

while queue:
    u=queue.pop(0)
    sunuke+=len(G[u])-1
    for i in range(len(G[u])):
        if d[G[u][i]]>d[u] and unused[G[u][i]]:
            queue.append(G[u][i])
            unused[G[u][i]]=False

if sunuke>=-(-N//2):
    print("Snuke")
else:
    print("Fennec")
    
    
    
    



Measured memory_bytes: 26808
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
using namespace std;
namespace std{
  template<class T> bool operator<(const complex<T> &a,const complex<T> &b)
  {
    return a.real()== b.real() ? a.imag()<b.imag():a.real()<b.real();
  }
  /*
 template<class T> bool operator-(const complex<T> &a)
  {
     return complex<T>(real()-a.real(),imag()-a.imag());
  }
  */
};

#define X real()
#define Y imag()

double det(complex<double> a,complex<double> b)
{
  return a.X*b.Y-a.Y*b.X;
}

int count_data(vector<complex<double> > data)
{
  sort(data.begin(),data.end());
  int k=0;
  vector<complex<double> >ans(data.size()*2);
  //  for(int i=0;i<data.size();i++)
  //    {
  //   cout<<data[i].X<<" "<<data[i].Y<<endl;
  //  }
  for(int i=0;i<data.size();i++)
    {
      while(k>1 && det(ans[k-1]-ans[k-2],data[i]-ans[k-1])<=0)
	k--;
      ans[k++]=data[i];
    }
  for(int i=data.size()-2,t=k;i>=0;i--)
    {
      while(k>t && det(ans[k-1]-ans[k-2],data[i]-ans[k-1])<=0)
	k--;
      ans[k++]=data[i];
    }
  return k-1;
}


int main()
{
  int n;
  for(;cin>>n,n;)
    {
      double a,b;
      char tmp;
      vector<complex<double> >data;
      for(int i=0;i<n;i++)
	{
	  cin>>a>>tmp>>b;
	  data.push_back(complex<double>(a,b));
	}
      cout<<n-count_data(data)<<endl;
    }


}

Measured memory_bytes: 1244
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

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

    int x[n], y[n], h[n];
    int hmin = 1e9+1;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] < hmin) {
            hmin = h[i];
        }
    }

    for (int x0 = 0; x0 <= 100; x0++) {
        for (int y0 = 0; y0 <= 100; y0++) {
            for (int h0 = hmin; h0 <= hmin + 200; h0++) {
                bool f = true;
                for (int i = 0; i < n; i++) {
                    if (h[i] != max(h0-abs(x0-x[i])-abs(y0-y[i]), 0)) {
                        f = false;
                        break;
                    }
                }
                if (f) {
                    cout << x0 << " " << y0 << " " << h0 << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
h = []
w = []
while True:
    a,b = map(int, raw_input().split())
    h.append(a)
    w.append(b) 
    if a == 0 and b == 0:
        break

for h,w in zip(h,w):    
    if h == 0 and w == 0:
        break;
    else:
        r = "#"
        for x in xrange(w-1):
            r = r + "#"
        for x in xrange(h):
	    print r
    print

Measured memory_bytes: 6448
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
 

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = n / 500;
  n %= 500;
  ans *= 1000;
  ans += (n / 5) * 5;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256