akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){

  int N;
  cin>>N;
  
  string S;
  cin>>S;
  
  int sum=0;
  
  for(int i=0;i<N-2;i++){

    if(S.substr(i,3)=="ABC")sum++;
    
  }
  
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll calcNumOfCombination(ll n, ll r){
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n, p;
  cin >> n >> p;
  ll ev = 1, od = 0;
  rep(i, n){
    int a;
    cin >> a;
    if(a % 2 == 0){
      ev *= 2;
      od *= 2;
    }else{
      ll n = ev + od;
      ev = od = n;
    }
  }
  ll ans = 0;
  if(p % 2 == 0) ans = ev;
  else ans = od;
  // ans = od*ev;
  // if(p % 2 == 0){
  //   ll t = 0;
  //   rep2(i, 1, ev+1){
  //     t += calcNumOfCombination(ev, i);
  //   }
  //   cerr << ans << " " << t << endl;
  //   ans += t;
  // }
  cout << ans << endl;
  return 0;
}

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

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

int todir[256];
char tochr[4];

int h, w;
long long l;
string c[110];
int vis[110][110][4];

int main()
{
	for (int i = 0; i < 4; i++){
		todir["NESW"[i]] = i;
		tochr[i] = "NESW"[i];
	}

	while (cin >> h >> w >> l, h){
		memset(vis, -1, sizeof(vis));
		c[0] = c[h + 1] = string(w + 2, '#');
		for (int i = 1; i <= h; i++){
			cin >> c[i];
			c[i] = "#" + c[i] + "#";
		}
		int x, y, dir;
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				if (c[i][j] != '.' && c[i][j] != '#'){
					x = i;
					y = j;
					dir = todir[c[i][j]];
					c[i][j] = '.';
				}
			}
		}
		for (long long t = 0; t < l; t++){
			while (true){
				int nx = x + dx[dir];
				int ny = y + dy[dir];
				if (c[nx][ny] == '.') break;
				dir = (dir + 1) % 4;
			}
			if (~vis[x][y][dir]){
				t += (l - t - 1) / (t - vis[x][y][dir]) * (t - vis[x][y][dir]);
			}
			else vis[x][y][dir] = t;
			x += dx[dir];
			y += dy[dir];
		}
		cout << x << " " << y << " " << tochr[dir] << endl;
	}
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll N;
    cin >> N;
    vector<string> s(N);
    unordered_map<string, ll> m;
    rep(i, N) {
        cin >> s[i];
        SORT(s[i]);
        if (m.find(s[i]) == m.end()) {
            m[s[i]] = 1;
        } else {
            m[s[i]] += 1;
        }
    }

    ll ans = 0;
    for (auto x : m) {
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13416
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

const ll MOD = 1000000007;

const int MAX = 100000;
ll fac[MAX+1],finv[MAX+1],inv[MAX+1];

void COMinit(){
	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;
	}
}

ll COM(ll n, ll 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(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	
	//累積和
	vector<ll> sum(n+1,0);
	REP(i,n) sum[i+1] = (sum[i]+a[i])%MOD;
	
	COMinit();
	ll ans = 0;


	for(int range=k; range<=n; range++){
		int iminr = 0;
		int imaxr = range-1;
		int iminl = n-range;
		int imaxl = n-1;
		ll res = (sum[imaxl+1]-sum[imaxr]+MOD)%MOD - (sum[iminl+1]-sum[iminr]+MOD)%MOD;
		res = (res+MOD)%MOD;
		
		res *= COM(range-2, k-2);
		ans = (ans+res+MOD)%MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (n == 1 && a != b) {
        cout << "0";
        return;
    }
    ll ls = a * (n - 1) + b;
    ll ms = b * (n - 1) + a;
    if (ms < ls) {
        cout << "0";
        return;
    }
    cout << ms - ls + 1;
}

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

#define FastRead  ios_base::sync_with_stdio(0);cin.tie(0);
#define endl      "\n"
#define pi        acos(-1.0)

typedef long long ll;
typedef long long unsigned llu;

long long binomialCoeff(long long n, long long k)
{
    if(n<k)
        return 0;
    if(n==k)
        return 1;
    ll res = 1;

    if ( k > n - k )
        k = n - k;

    for (ll i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

int main()
{
    FastRead

    ll n,sum=0;

    cin>>n;

    vector<ll>v(n);
    map<ll,ll>mp,mc,ans;

    for(ll i=0; i<n; i++)
    {
        cin>>v[i];
        mp[v[i]]++;
    }

    for(auto it:mp)
        sum+=binomialCoeff(it.second,2);

    for(auto it:mp)
    {
        if(it.second>2)
            mc[it.first] = sum-binomialCoeff(it.second,2)+binomialCoeff(it.second-1,2);
        else
            mc[it.first] = sum-binomialCoeff(it.second,2);
    }

    for(ll i=0; i<n; i++)
        cout<<mc[v[i]]<<endl;
}


Measured memory_bytes: 18944
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input().rstrip()

vD = ["X",]*K
res = 0
for i,s in enumerate(T):
	np = vD[i]
	if s == "r":
		p, pt = "P", P
	if s == "s":
		p, pt = "R", R
	if s == "p":
		p, pt = "S", S

	if p != np:
		res += pt
	else:
		p = "X"
	vD.append(p)

print(res)


Measured memory_bytes: 4724
n = int(input())
w = [int(i) for i in input().split()]
sumw=-sum(w)
dif=[]
for i in range(0,n):
    sumw += 2*w[i]
    if sumw>=0:
        dif.append(abs(sumw))
        if i>=1:
            dif.append(abs(sumw-2*w[i]))
        else:
            break
        break
print(min(dif))

Measured memory_bytes: 3060
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int H,W;
    cin >> H >> W;
    int h,w;
    cin >> h >> w;
    cout << H*W-h*W-w*H+h*w << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int main(){

    int n,k;
    cin >> n >> k;
    int h[n];
    inrep(n,h);

    itn cnt = 0;
    rep(i,0,n)if(h[i] >= k)cnt++;
    P(cnt);
    
    return  0;
}


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

int main()
{
    int k,n;
    cin>>k>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maxD=0;
    for(int i=0;i<n-1;i++)
    {
        maxD = max(maxD,a[i+1]-a[i]);
    }

    maxD = max(maxD,k-a[n-1]+a[0]);
    cout<<k-maxD<<endl;

    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

int n,k;
ll ans = 0;
int main(){
  cin >> n >> k;
  if(k % 2 == 0){
    ll m = n / k + (n%k >= k/2 ? 1 : 0);
    ans = m * m * m;
  }
  ll m = n/k;
  ans += m * m * m;
  cout << ans << endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int x,y;
cin >> x >> y;
cout << (x-1)*(y-1) << endl;
}

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

vector<vector<int>> c(50, vector<int>(50));

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

vector<vector<bool>> seen(50, vector<bool>(50));
void dfs(vector<vector<int>> &c, int sy, int sx, int h, int w) {
    seen[sy][sx] = true;
    for(int i = 0; i < 8; i++){
        int ey = sy + dy[i], ex = sx + dx[i]; 
        if(ey < 0 || ey >= h || ex < 0 || ex >= w) continue;
        if(c[ey][ex] == 0 || seen[ey][ex]) continue;
        dfs(c, ey, ex, h, w);
    }
}

int main(){
    int w,  h;
    vector<int> cnt;
    int check = -1;
    cin >> w >> h;
    while (w != 0 || h != 0)
    {
        for(int i = 0 ; i < h; i++){
            for (int j = 0; j < w; j++)
            {
               cin >> c[i][j];
               seen[i][j] = false;
            }
        }
        cnt.push_back(0);
        check++;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if(!seen[i][j] && c[i][j] == 1){
                    dfs(c, i, j, h, w);
                    cnt[check]++;
                }
            }
        }
        cin >> w >> h;
    }
    for (int i = 0; i < cnt.size(); i++)
    {
        cout << cnt[i] << endl;
    }
    
}


Measured memory_bytes: 3352
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(2, n):
    if (p[i-2] > p[i-1] and p[i-1] > p[i]) or (p[i-2] < p[i-1] and p[i-1] < p[i]):
        ans += 1
    
print(ans)

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


int main() {
  
  string S,U,T;
  int A,B;
  
  cin>>S>>T;
  cin>>A>>B;
  cin>>U;
  
  if(S==U&&T==U){
    cout<<A-1<<" "<<B-1<<endl;
  }else if(S==U){
    cout<<A-1<<" "<<B<<endl;
  }else{
    cout<<A<<" "<<B-1<<endl;
  }
  
  
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  ll n;cin >> n;
  using pi = pair<ll,ll>;
  vector<pi> p(n);
  rep(i,n) {
    ll a; cin >> a;
    p[i] = {a, i};
  }

  sort(p.begin(), p.end(), [](pi a, pi b) {
			     return a.first > b.first;
			   });

  multiset<ll> st;
  st.insert(-1);
  st.insert(-1);
  st.insert(n);
  st.insert(n);

  ll res = 0;
  rep(i,n) {
    ll val = p[i].first;
    ll idx = p[i].second;
    st.insert(idx);
    auto it = st.find(idx);
    auto it3 = it; it--;
    auto it2 = it; it--;
    auto it1 = it; it++; it++; it++;
    auto it4 = it; it++;
    auto it5 = it;

    ll cnt = (*it5 - *it4)*(*it3 - *it2) + (*it4 - *it3)*(*it2 - *it1);
    res += cnt*val;
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
//include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
typedef long long int ll;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 

 
const ll N = 100005;
const ll mod = 10e8+7;
const long long int inf = 10000000000;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	
	string s;
	cin>>s;
	ll n = s.length();
	ll f = 1;
	for(ll i = 0,j=n-1;i<=j;i++,j--){
		if(s[i]!=s[j]) f = 0;
	}
	for(ll i = 0,j = (n-2)/2;i<=j;i++,j--){
		if(s[i]!=s[j]) f = 0;
	}
	if(f) cout<<"Yes\n";
	else cout<<"No\n";



}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
	string s, t = "CODEFESTIVAL2016";
	int ans = 0;
	cin >> s;
	rep(i, 0, s.size()){
		if(s[i] != t[i]) ans ++;
	}
	cout << ans << endl;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

	if(a >= 13){
		cout << b << '\n';
	}else if(a >= 6 and a <= 12){
		cout << b /2 << '\n';
	}else{
		cout << "0\n";
	}
}

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

const int MAXN = 1e6 + 10;

struct Q {
	int l,r,id,t;
} q[MAXN];

struct C {
	int pos,val;
} c[MAXN];

int n,m,qcnt,ccnt,now;
int l,r,t;
int a[MAXN];
int bl[MAXN],blk,siz;
int cnt[MAXN],ans[MAXN];

bool cmp(Q a,Q b) {
	return ((bl[a.l] ^ bl[b.l]) ? bl[a.l] < bl[b.l] : ((bl[a.r] ^ bl[b.r]) ? bl[a.r] < bl[b.r] : (bl[a.r] & 1 ? a.t > b.t : a.t < b.t)));
}

inline void add(int pos) {
	now += !(cnt[a[pos]]++);
}

inline void del(int pos) {
	now -= !(--cnt[a[pos]]);
}

inline void upd(int pos) {
	if(l <= c[pos].pos && c[pos].pos <= r) {
		now -= !(--cnt[a[c[pos].pos]]);
		now += !(cnt[c[pos].val]++);
	}
	swap(c[pos].val,a[c[pos].pos]);
}

int main () {
	scanf("%d%d",&n,&m);
	for(register int i = 1;i <= n; ++i)
		scanf("%d",&a[i]);
	char opt[10];
	for(register int i = 1,x,y,nowt = 0;i <= m; ++i) {
		scanf("%d%d",&x,&y);
		q[++qcnt].l = x;
		q[qcnt].r = y;
		q[qcnt].id = qcnt;
		q[qcnt].t = ccnt;
	}
	siz = sqrt(n);
	blk = ceil((double) n / siz);
	for(register int i = 1;i <= blk; ++i)
		for(register int j = (i - 1) * siz + 1;j <= i * siz; ++j)
			bl[j] = i;
	sort(q + 1,q + qcnt + 1,cmp);
	l = 1,r = 0,t = 0;
	for(register int i = 1,L,R,T;i <= qcnt; ++i) {
		L = q[i].l; R = q[i].r;
		while(l < L) del(l++);
		while(l > L) add(--l);
		while(r < R) add(++r);
		while(r > R) del(r--);
		ans[q[i].id] = now;
	}
	for(register int i = 1;i <= qcnt; ++i)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 19424
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector <ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    if (n % 2 == 0) {
        // i番目を使って、すでにj回skipしているような数
        vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
        dp[1][0] = a[1];
        dp[2][1] = a[2];
        for (int i = 3; i <= n; i++) {
            dp[i][0] = dp[i - 2][0] + a[i];
            dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
        }

        cout << max(dp[n][1], dp[n - 1][0]) << endl;
    } else {
        vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));
        dp[1][0] = a[1];
        dp[2][1] = a[2];
        dp[3][0] = a[1] + a[3];
        dp[3][2] = a[3];
        for (int i = 4; i <= n; i++) {
            dp[i][0] = dp[i - 2][0] + a[i];
            dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
            dp[i][2] = max(max(dp[i - 2][2], dp[i - 3][1]), dp[i - 4][0]) + a[i];
        }

        cout << max(max(dp[n][2], dp[n - 1][1]), dp[n - 2][0]) << endl;
    }

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W, N; 
	cin >> H >> W >> N; 
	int ans = 114514; 
	for(int i = 0; i <= H; i++){
		for(int j = 0; j <= W; j++){
			if(H * W - (H - i) * (W - j) >= N){
				ans = min(ans, i + j); 
			}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
def main():
    w, h, x, y, r = (int(e) for e in input().split())
    # 円が (0, 0) からはみ出ているか
    if x - r < 0 or y - r < 0:
        print("No")
    # 円が (w, h) からはみ出ているか
    elif x + r > w or y + r > h:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()



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

int main() {
  string L[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  rep(i,7) {
    if (s == L[i]) {
      cout << (7-i) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb emplace_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(auto i=(a); i<(b); i++)
#define dec(i,n,a) for(auto i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define EPS 3e-11
#define fcin ios_base::sync_with_stdio(false)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<
#define MAXN 505
#define LOGN 20
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

vector<int> adj[MAXN];
int par[MAXN], dist[MAXN], INF = 1e9;

bool bsf(int n) {
	queue<int> q;
	rep(i, 1, n+1) {
		if(par[i] == 0) {
			dist[i] = 0;
			q.push(i);
		}
		else dist[i] = INF;
	}
	dist[0] = INF;
	while(!q.empty()) {
		int v = q.front(); q.pop();
		rep(i, 0, sz(adj[v])) {
			int u = adj[v][i];
			if(dist[par[u]] == INF) {
				dist[par[u]] = dist[v] + 1;
				q.push(par[u]);
			}
		}
	}
	return (dist[0] != INF);
}

bool dfs(int v){
	if(!v) return 1;
	rep(i, 0, sz(adj[v])) {
		int u = adj[v][i];
		if(dist[par[u]] == dist[v] + 1 && dfs(par[u])) {
			par[u] = v;
			par[v] = u;
			return 1;
		}
	}
	dist[v] = INF;
	return 0;
}

int hopcroftKarp(int n) {
	rep(i,1,n+1) par[i]=0;
	int matching = 0;
	while(bsf(n)) rep(i, 1, n+1) if(!par[i] && dfs(i)) matching++;
	return matching;
}


pii vet[1010];

int main(){
	int n;
	scanf("%d", &n);
	rep(i,0,n+n){
		int x, y;
		scanf("%d%d", &x, &y);
		vet[i] = mp(x,y);
	}
	rep(i,0,n) rep(j,n,n+n) if(vet[i].x < vet[j].x && vet[i].y < vet[j].y)
		adj[i+1].pb(j+1), adj[j+1].pb(i+1);
	printf("%d\n", hopcroftKarp(2*n+2));
}


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

int main(){
    int n; cin >> n;
    long long a[200];
    for(int i = 0; i < n; i++) cin >> a[i];

    int flag = 0;
    int c = 0;

    for(int i = 0; i < 10000; i++){
        //if(flag == 0) c += 1;
        if(flag) break;
        //確かめる
        for(int j = 0; j < n; j++){
            if(a[j] % 2 != 0){
                flag = 1;
                break;
            }
            else a[j] = a[j] / 2;
            //cout << a[i] << " ";
        }
        if(flag == 0) c += 1;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> d(n, vector<ll>(n, INF)), r(n, vector<ll>(n, INF));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (d[i][j] <= l) r[i][j] = 1;
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (r[i][k] + r[k][j] < r[i][j]) r[i][j] = r[i][k] + r[k][j];
      }
    }
  }

  int q;
  cin >> q;
  for (; q > 0; q--) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    cout << (r[s][t] != INF ? r[s][t] - 1 : -1) << endl;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	SORT(a);
	ll ans = 0;

	if (a[0] >= 0 && a[n - 1] >= 0) {
		rep(i, n) {
			if (i == 0) {
				ans -= a[0];
			}
			else {
				ans += a[i];
			}
		}
		cout << ans << endl;

		int main = a[0];
		int last = a[n - 1];
		a.erase(a.begin());
		a.erase(--a.end());
		rep(i, n - 2) {
			printf("%d %d\n", main, a[i]);
			main -= a[i];
		}
		printf("%d %d\n", last, main);

	}
	else if (a[0] <= 0 && a[n - 1] <= 0) {
		rep(i, n) {
			if (i == n - 1) {
				ans += a[n-1];
			}
			else {
				ans -= a[i];
			}
		}
		cout << ans << endl;

		int last = a[n - 1];
		a.erase(--a.end());
		rep(i, n - 1) {
			printf("%d %d\n", last, a[i]);
			last -= a[i];
		}

	}
	else {
		rep(i, n) {
			ans += abs(a[i]);
		}
		cout << ans << endl;
		int main = a[0];
		int last = a[n - 1];
		a.erase(a.begin());
		a.erase(--a.end());
		rep(i, n - 2) {
			if (a[i] > 0) {
				printf("%d %d\n", main, a[i]);
				main -= a[i];
			}
			else {
				printf("%d %d\n", last, a[i]);
				last -= a[i];
			}
		}
		printf("%d %d\n", last, main);

	}
}



Measured memory_bytes: 2304
// Mon Sep 14 19:59:49 IST 2020  


#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = INT64_MAX;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
void printSet(multiset <int>v){
    cout << "===\n";
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}
int dp[2020];
int solve(int n){
    if(dp[n])
      return dp[n] ;
    int ways  = 1;
	for(int i = 3 ; i < n ; i ++)
      if(n-i > 2)
        ways = (ways + solve(n-i))%MOD1;
    
    return dp[n] = ways;
}
int tests(){ 
  int x;
  cin >> x;
  if(x < 3)
    return cout << 0 << '\n',0;
  cout << solve(x) << '\n';
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 


Measured memory_bytes: 3664
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ld> x(n), y(n);
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++)
        cin >> y[i];
    ld res = 0;
    for (int i = 0; i < n; i++)
    {
        res += abs(x[i] - y[i]);
    }
    cout << fixed << setprecision(10) << res << endl;
    res = 0;
    for (int i = 0; i < n; i++)
    {
        res += (x[i] - y[i]) * (x[i] - y[i]);
    }
    cout << fixed << setprecision(10) << pow(res, 0.5) << endl;
    res = 0;
    for (int i = 0; i < n; i++)
    {
        res += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
    }
    cout << fixed << setprecision(10) << pow(res, 1.0 / 3.0) << endl;
    res = 0;
    for (int i = 0; i < n; i++)
    {
        res = max(res, abs(x[i] - y[i]));
    }
    cout << fixed << setprecision(10) << res << endl;
}



Measured memory_bytes: 3424
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int c[MAX+1];

int main() {
	int n;cin>>n;
	rep1(i,n) c[i]=0;
	rep(i,n) {int a;cin>>a;if(a<=n) c[a]++;}
	int tmp=0;
	rep1(i,n) if(c[i]>=i) tmp+=i;
	cout<<n-tmp<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N;
  long long ans, x, y=0;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    if(i == 0) x = a.at(i);
    else y += a.at(i);
  }
  ans = fabs(x-y);
  for(int i = 1; i < N-1; i++){
    x += a.at(i);
    y -= a.at(i);
    if(ans > fabs(x-y)) ans = fabs(x-y);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
textList = list(input())
textVer = set(textList)
# print(texttextList\
textMax = {}
for t in textVer:
    maxlist = []
    maxcounter = 0
    for i in range(len(textList)):
        if textList[i] != t:
            maxcounter += 1
        else: # 同じ時
            maxlist.append(maxcounter)
            maxcounter = 0
    maxlist.append(maxcounter)
    maxlist.sort()
    maxlist.reverse()
    # print(maxlist)
    textMax[t] = maxlist[0]
timeMin = sorted(textMax.items(), key=lambda x: x[1])
print(timeMin[0][1])

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();
			long sum = 0;

			int a = n;
			for (int b = 1; b <= n; b++) {
				if (b <= k) {
					continue;
				}
				sum += (b-k)*(a/b);
				int rem = a%b;
				if (rem < k || rem == 0) {
					continue;
				}
				sum += k == 0 ? rem-k : rem-k+1;
			}

			out.println(sum);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int K;
  cin >> K;
  int x = 7 % K;
  set<int> s;
  long long ans = 1;
  while(s.count(x) == 0){
    if(x == 0){
      cout << ans << endl;
      return 0;
    }
    s.insert(x);
    x = (x * 10 + 7) % K;
    ++ans;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 50480
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int gcd(int a,int b)
{
	while(b^=a^=b^=a%=b);return a;
}
int main()
{
	cin>>a>>b>>c;
	int l=gcd(a,b);
	if(c%l!=0) printf("NO");
	else printf("YES");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

struct UnionFind {
    vector<int> par;    //par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> sz;     //要素数

    UnionFind(int N) : par(N),sz(N) { //最初は全てが根であるとして初期化
        rep(i, N){
            par[i] = i;
            sz[i] = 1;
        } 
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        sz[ry]+=sz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int k){//要素数を求める
        return sz[root(k)];
    }
};

int main(){
    lint N,M;
    cin >> N >> M;
    
    vector<pair<int,int>> p(M);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        p.at(i) = make_pair(a-1,b-1);
    }


    vector<lint> Ans;

    UnionFind UF(N);
    lint ans = N * (N - 1) / 2;

    for(int i = M - 1; i >= 0; i--){
        int a, b;
        tie(a, b) = p.at(i);
        Ans.push_back(ans);
        if(UF.same(a,b)) continue;
        lint N1 = UF.size(a);
        lint N2 = UF.size(b);

        ans -= N1 * N2;
        UF.unite(a,b);
    }
    
    reverse(Ans.begin(),Ans.end());
    rep(i,M){
        cout << Ans.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
int main() {
  ll n;
  cin>>n;
  vec d(n);
  loop(i,n){
    cin>>d[i];
  }
  ll ans=0;
  loop(i,n){
    loop(j,n){
      if(i==j){
        continue;
      }
      else{
        ans+=d[i]*d[j];
      }
    }
  }
  if(ans!=0){
  cout<<ans/2;
  }
  else{
    cout<<0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
#define PI 3.14159265
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int a,b,x;
cin>>a>>b>>x;
double thresh=(a*a*b)*1.0/2;
if(x>thresh){
    double h=(x*1.0/(a*a));
    double res=a*1.0/(2*b-2*h);
    res=atan(res)*180.0/PI;
    res=90-res;
    cout<<setprecision(10)<<res<<endl;
}
else{
    double res=2*x*1.0/(b*b*a);
    res=atan(res)*180.0/PI;
    res=90-res;
    cout<<setprecision(10)<<res<<endl;
}
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $q);

$queue = array();
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s %d", $name, $time);

    $queue[] = array(
        'name' => $name,
        'time' => $time,
    );
}

$current   = 0;

while (count($queue) > 0) {
    $queue_next = array();

    for ($i = 0; $i < count($queue); $i++) {
        $process = $queue[$i];

        if ($process['time'] - $q <= 0) {
            $current += $process['time'];
            echo $process['name']." $current\n";

            continue;
        }

        $current += $q;
        $process['time'] -= $q;

        $queue_next[] = $process;
    }

    $queue = $queue_next;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  rep1 (i, m) {
    rep1 (j, d) {
      int a = j % 10, b = j / 10;
      if (a <= 1 or b <= 1) continue;
      if (a * b == i) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#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>;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

int main() {
    int A, B; cin >> A >> B;
    cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	string S;
	cin >> S;
	int Z = S.size();
	int cnt = 0;
	for (int ia = 0; ia < Z - 1; ia++) {
		if (S.at(ia) != S.at(ia + 1)) {
			cnt++;
		}
	}
	cout << cnt << endl;
}



	


Measured memory_bytes: 512
n=int(input())
s=input()

#XX: SS or SW or WW or WS
#X:0 or 1
def checkNext(XX,X):
  dicNext={"SS":["S","W"],
          "SW":["W","S"],
           "WW":["S","W"],
           "WS":["W","S"]          
          }
  
  if X=="o":xNum=0
  else:xNum=1
  return dicNext[XX][xNum]

start=["SS","SW","WW","WS"]
for item in start:
  result=item
  for ox in s[1:-1]:
    result=result+checkNext(result[-2:],ox)
  #print(item,result)
  if checkNext(result[-2:],s[-1])==result[0]:
    if checkNext(result[-1]+result[0],s[0])==result[1]:
      print(result)
      exit()
print(-1)

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

using namespace std;

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

string s;

int main(){
    cin >> s;
    bool flag = false;
    REP(i, s.size()){
        if(s[i]=='9') flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
	int i,j;
	char c[3][3];
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			cin >> c[i][j];

		}
	}

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (i == j) {
				cout << c[i][j];
			}
		}
	}
	return 0;
}

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


using namespace std;
long long n;
long long k;
vector<long long> vec;

long long meme[100007];

long long solve(long long index){

    if(index==n-1){
        return 0;
    }
    
    if(meme[index]!=-1){
        return meme[index];
    }
    
    long long ret = 10000000000000000;
    long long sol = 10000000000000000;
    for(long long i = 1 ;i<=k ; i++){
        if(index+i<n){
            ret = abs (vec[index]- vec[index+i]) + solve(index+i); 
        }
        sol = min(sol,ret);
    }

    return meme[index] = sol;
}

int main(){
    cin>>n;
    cin>>k;
    memset(meme,-1,sizeof(meme));
    long long num;
    for(long long i = 0 ; i<n ; i++){
        cin>>num;
        vec.push_back(num);
    }
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 11040