akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<fstream>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define mod 1000000007
#define All(v) v.begin(),v.end()

using namespace std;

string s[51];
int main()
{
    bool w = 0, b = 0;
    int n,m;
    cin >> n >> m;
    for(int i=0; i<n; i++)
        cin >> s[i];
    bool ok = 0;
    string tot;
    for(int i=0; i<m; i++)
    {
        string t;
        cin >> t;
        tot += t;
    }

    for(int i=0; i<n-m+1; i++)
        for(int j=0; j<n-m+1; j++)
        {
            string tmp;
            for(int r=0; r<m; r++)
                for(int c=0; c<m; c++)
                    tmp += s[r+i][c+j];
         //   cout << tmp << endl;
            if(tmp == tot)
                ok = 1;
        }


    if(ok)
        cout << "Yes\n";
    else
        cout << "No\n";






    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string a, b; cin >> a >> b;
  string result = a==b ? "H" : "D";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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; }

typedef pair <ll,ll> P;

bool pairCompareF(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

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

    cout << N*(N+1) / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int gcd(int a, int b) {
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int X;
    cin >> X;
    int lcm = X*360/gcd(X, 360);
    cout << lcm/X << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
	char w[20],s[]={"CODEFESTIVAL2016"};
	int i,j=0;
	scanf("%s",w);
	for(i=0;s[i];i++){
		if(s[i]-w[i])j++;
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int K, N;
    cin >>K>>N;
    int A[N];
    for(int i=0;i<N;i++)
        cin>>A[i];
    int clock=0;
    clock = A[N-1]-A[0];
    int k[N];
    for(int i=0;i<N;i++){
        k[i]=A[i+1]-A[i];
    }
    int max=0;
    int num=0;
    for(int i=0;i<N-1;i++){
        if(k[i]>max){
            max = k[i];
            num = i;
        }
    }
    int sum=0;
    for(int i=0;i<num;i++){
        sum = sum+k[i];
    }
    sum = sum +(K-A[num+1])+A[0];
    
    
    if(clock<sum)
        sum = clock;
    else
        sum = sum;
    cout<<sum;
}

Measured memory_bytes: 1792
#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>;
const int mod = 1000000007;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    rep(i,n) cin >> x[i] >> y[i];
    vector<int> p(n);
    rep(i,n) p[i] = i;
    int cnt = 0;
    double k = 0;

    auto check = [&](int i,int j){
        int xx = x[i] - x[j];
        int yy = y[i] - y[j];
        double kk = sqrt(xx*xx+yy*yy);
        return kk;
    };

    do
    {
        cnt++;
        rep(i,n-1){
            k += check(p[i],p[i+1]);
        }
    } while (next_permutation(p.begin(),p.end()));
    


    double ans = k/cnt;
    printf("%.10f",ans);
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int main() {
    string s;
    cin >> s;
    forn(i, (int)s.size() - 1) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vs s(n);
    int ml = 0;
    rep(i, n) {
      string t;
      cin >> t;
      cmax(ml, t.size());
      s[i] = string(1, t.front());
      rep(j, t.size() - 1) {
        if (string("aiueo").find(t[j]) != string::npos) {
          s[i] += string(1, t[j + 1]);
        }
      }
    }
    ([&]() {
      loop(k, 1, ml + 1) {
        if (([&]() {
              set<string> v;
              rep(i, n) {
                string x = s[i].substr(0, min<int>(s[i].size(), k));
                if (v.count(x)) return false;
                v.insert(x);
              }
              cout << k << endl;
              return true;
            })()) return;
      }
      cout << -1 << endl;
    })();
  }
}

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

using namespace std;
string s, w;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> s;
    cin >> w;
    string mn = s;
    mn = 'z'  + mn;
    int n = s.size();
    int m = w.size();
    for (int i = 0; i < n - m + 1; i++) {
        bool ok = true;
        string pattern = s;
        for (int j = 0; j < m; j++) {
            char c1 = s[i + j];
            char c2 = w[j];
            if (s[i + j] == '?') {
                pattern[i + j] = w[j];
                continue;
            }
            if (s[i + j] != w[j]) {
                ok = false;
                break;
            }
        }
        if (!ok) continue;
        for (int j = 0; j < n; j++)
            if (pattern[j] == '?') pattern[j] = 'a';
        mn = min(pattern, mn);
    }
    if (mn.size() != n) {
        cout << "UNRESTORABLE\n";
    }
    else cout << mn << "\n";
    return 0;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;

  if (min(a, b) == 1) {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 1; i <= max(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      vec.push_back(i);
    }
  }

  cout << vec[vec.size() - k] << endl;
}


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

using namespace std;

typedef long long ll;
typedef string str;

ll k;
str s, s1;

int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL); cout.tie(NULL);
  	cin >> k;
  	cin >> s;
  	s1 = "";
  	if (s.length() <= k)
    {
      	cout << s;
      	return 0;
    }
  	else 
    {
        for (ll i = 0; i <= k - 1; i++) s1 += s[i];
  	    for (ll i = 1; i <= 3; i++) s1 += '.';
  	    cout << s1;
    }
}

Measured memory_bytes: 3652
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        a:[u64;n]
    }

    let mut a = a;
    a.sort_by_key(|x| !x);

    //tabで移動
    if a[m - 1] * 4 * m as u64 >= a.iter().sum::<u64>() {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
  int N, A;
  cin >> N >> A;
  int num = N;
  if(N / 500 >= 1) num = N - (500 * (N / 500));
  if(A - num >= 0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;

const int N = 200005;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if((b - a) % 2) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a%2 == 0 || b%2 == 0 || c%2 == 0) {
        cout << 0 << endl;
    } else {
        cout << min(a*b, min(b*c, a*c)) << endl;
    }
}
































Measured memory_bytes: 256
mod = 10**9+7
mod2 = 998244353
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
n,k = map(int,input().split())
ans = 0
for i in range(k,n+2):
  ans += n*(n+1)//2-(n-i)*(n-i+1)//2-i*(i-1)//2+1
  ans %= mod
print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    string s; cin>>s;
    ll n=s.size(),ans=0,cnt=0;
    rep(i,n){
        if(s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C'){
            cnt++;
            ans=max(ans,cnt);
        }else cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define maxn 200050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const double eps = 1e-6;
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL qpow(LL x,LL y){LL re=1,base=x%mod;while(y){if(y&1)re=(re*base)%mod;base=(base*base)%mod;y>>=1;}return re;}
LL a[maxn];
LL fisum[maxn],basum[maxn]; 
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	mm(fisum,0),mm(basum,0);
	for(int i=1;i<=n;i++){
		cin>>a[i];
		fisum[i]=fisum[i-1]+a[i];
	}
	basum[n]=a[n];
	for(int i=n-1;i>=1;i--) basum[i]=basum[i+1]+a[i];
	LL ans=INF;
	for(int i=1;i<n;i++) ans=min(ans,abs(fisum[i]-basum[i+1]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#これで？
def 解():
    import sys
    input = sys.stdin.readline
    N,Q = [int(_) for _ in input().split()]
    S = " " + input() + " "
    aC = [[ _.rstrip() for _ in  _.split()] for _ in sys.stdin.readlines()]
    iL = 0
    iR = N+1
    for t,d in aC[::-1]:
        if t == S[iL+1] and d == "L" and iL < N+1:
                iL += 1
        elif t == S[iL] and d == "R" and 0 < iL:
                iL -= 1

        if t == S[iR-1] and d == "R" and 0 < iR:
                iR -= 1
        elif t == S[iR] and d == "L" and  iR < N+1:
                iR += 1
        if iL == N+1 or iR ==0 or iR <= iL:
            print(0)
            exit()
    print(iR-iL-1)
解()


Measured memory_bytes: 39504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii,int> tri;
typedef vector<int> vi;

vector< vector<pii> > d;
vi ans;

void dfs1(const vector<vi> &t){
  int v = 0, p = -1, out = 0;
  stack<tri> s;
  s.push( tri(pii(v,p), out) );

  while( not s.empty() ){
    tri x = s.top(); s.pop();
    v = x.first.first, p = x.first.second, out = x.second;

    if(out){
      int cnt = 0;
      for(int u : t[v]){
	if(p==u) continue;
	pii tmp(1,u);
	if(d[u].size()) tmp.first = d[u][0].first + 1;
	d[v].push_back(tmp);
	cnt++;
      }
      sort(d[v].begin(), d[v].end());
      reverse(d[v].begin(), d[v].end());
    }else{
      s.push( tri( pii(v,p), 1) );
      for(int u : t[v]){
	if(p==u) continue;
	s.push( tri( pii(u,v), 0) );
      }
    }
  }
}

void dfs2(const vector<vi> &t){
  int v = 0, p = -1, len = 0;
  stack<tri> s;
  s.push( tri(pii(v,p), len) );

  while( not s.empty() ){
    tri x = s.top(); s.pop();
    v = x.first.first, p = x.first.second, len = x.second;

    int res = len;
    if(d[v].size()) res = max(res, d[v][0].first);
    ans[v] = res;

    for(int u : t[v]){
      if(p==u) continue;
      int tmp = len;
      if(d[v].size() >= 2){
	if(d[v][0].second == u){
	  tmp = max(tmp, d[v][1].first);
	}else{
	  tmp = max(tmp, d[v][0].first);
	}
      }

      s.push( tri( pii(u,v), tmp + 1) );
    }
  }
 
}

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

  vector<vi> t(n);
  rep(i,n-1){
    int u,v;
    cin >> u >> v; u--; v--;
    t[u].push_back(v);
    t[v].push_back(u);
  }

  d = vector< vector<pii> >(n);
  dfs1(t);

  ans = vi(n,0);
  dfs2(t);
 

  for(int i=0;i<n;i++){
    cout << 2*n-2 - ans[i] << endl;
  }
}

Measured memory_bytes: 13916
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    int a ,b;
    cin >> a >> b;
    if(a < 10 && b < 10)
        cout << a * b;
    else 
        cout << "-1";
    
    
    
}

    

	


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++)
#define ANS(ans) cout << ans << endl


int main() {
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):

    def cal_p (l):
        p = 0
        for ai,bi,ci,di in zip(a,b,c,d):
            if l[bi-1]-l[ai-1] == ci:
                p+=di
        return p

    max_p = [0]

    def ser (l, prev, dep):
        if dep == N:
            # print(l)
            return cal_p(l)
        else:
            for i in range(prev, M+1):
                max_p[0] = max(ser(l + [i], i, dep+1), max_p[0])
            return 0
    
    max_p = max(ser([],1,0), max_p[0])
    print(max_p)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73976
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

vector<t3> E;
vector<int> G[MX];
int ans[MX] = {};
int start[MX] = {};

void dfs(int x){
	for(int &t = start[x]; t < G[x].size(); t++){
		int e = G[x][t];
		int a, b, c;
		tie(a, b, c) = E[e];
		if( c ) continue;
		E[e] = t3(a, b, -1);
		E[e^1] = t3(b, a, 1);
		dfs(b);
	}
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int t = 0; t < 2; t++){
		for(int i = 1; i <= N; i++){
			int a;
			scanf("%d", &a);
			if( a == -1 ) a = 0;
			G[a].push_back(E.size());
			E.emplace_back(a, i, 0);
			G[i].push_back(E.size());
			E.emplace_back(i, a, 0);
		}
	}

	for(int i = 1; i <= N; i++){
		if( G[i].size()%2 ) return !printf("IMPOSSIBLE\n");
	}
	printf("POSSIBLE\n");

	dfs(0);

	for(int i = 0; i < N; i++){
		int a, b, c;
		tie(a, b, c) = E[i*2];
		ans[a] += c;
		ans[b] -= c;
	}
	for(int i = 1; i <= N; i++) printf("%d ", ans[i]);
	printf("\n");
}



Measured memory_bytes: 20268
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n],count=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
for(int i=1;i<n-1;i++){
  if(a[i-1]<a[i]&&a[i]<a[i+1]||a[i+1]<a[i]&&a[i]<a[i-1]){
    count++;
  }
}
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

int main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

    string s, t; cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 3652
#include<iostream>
#include<map>
using namespace std;
int main(void)
{
	int N;
		cin >> N;
	map <int,int > a,b;
	
	int max_A=0,max_AN=0;
	int max_A2=0;
	int max_B=0,max_BN=0;
	int max_B2=0;
	
	for(int i=0;i<N;i++){
		int x;cin >> x;
		if(!(i%2)){
			a[x]++;
			if(a[x]>max_A){
				max_A=a[x];
				max_AN=x;
			}
			else if(a[x]>max_A2)
				max_A2=a[x];
		}
		else{
			b[x]++;
			if(b[x]>max_B){
				max_B=b[x];
				max_BN=x;
			}
			else if(b[x]>max_B2)
				max_B2=b[x];
		}
	}
	
	int ans=0;
	if(max_AN==max_BN){
		if(max_A>max_B)
			ans=max_A+max_B2;
		else if(max_A<max_B)
			ans=max_A2+max_B;
		else{
			ans=max_A;
			ans+=max(max_B2,max_A2);
		}
	}
	else
		ans=max_A+max_B;
	
	
	cout << N-ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string w, res; cin >> w;
    int wsize = w.size();
    vector<char> wv;
    res = "Yes";
    for (int i = 0; i < wsize; i++)
    {
        wv.push_back(w[i]);
    }
    sort(wv.begin(), wv.end());
    if (wsize % 2 != 0) res = "No";
    if (res != "No")
    {
        for (int j = 0; j < wsize; j++)
        {
            if (wv[j] != wv[j+1]) res = "No";
            j++;
            if (res == "No") break;
        }
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
n,A,B,C = map(int, input().split())
l=[]
for i in range(n):
  l.append(int(input()))
# 1,1,10
def dfs(cur,a,b,c):
  if cur == n:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 10**12
  ret0=dfs(cur+1,a,b,c)
  ret1=dfs(cur+1,a+l[cur],b,c)+10
  ret2=dfs(cur+1,a,b+l[cur],c)+10
  ret3=dfs(cur+1,a,b,c+l[cur])+10
  return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	int ans=0,a[n];
  	for(int i=0;i<n;i++)
  	{
  		cin>>a[i];
	}
	float sum=accumulate(a,a+n,0);
	sum/=n;
	int temp=sum;
	if(temp+0.5<sum)
		sum=(int)ceil(sum);
	else
		sum=(int)sum;
	for(int i=0;i<n;i++)
	{
		ans+=pow(abs(sum-a[i]),2);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
void partition(int* arr, int head,int tail);
void printAns(int arr[], int len,int stan);
int main() {
	using namespace std;
	int len;
	cin >> len;
	int* arr = new int[len];
	for (int i = 0; i < len; i++)
		cin >> arr[i];
	partition(arr, 0, len - 1);
	return 0;
}
void partition(int* arr, int head, int tail) {
	int stan = arr[tail];
	int board = head - 1;							//board is on the left of the array at the beginning
	for (int j = head; j < tail; j++) {				//go through the array
		if (arr[j] <= stan) {
			board++;								//give space for element behind board
			std::swap(arr[board], arr[j]);
		}
	}
	std::swap(arr[board + 1], arr[tail]);
	printAns(arr, tail - head+1,board+1);
}
void printAns(int arr[], int len, int stan) {
	using std::cout;
	using std::endl;
	for (int i = 0; i < len; i++)
	{
		if (i)
			cout << " ";
		if (i == stan)
			cout << "[" << arr[i] << "]";
		else
			cout << arr[i];
	}
	cout << endl;
}


Measured memory_bytes: 3480
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <regex>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x,a;
	cin>>x>>a;
	if(x<a) cout<<0<<endl;
	else cout<<10<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
  int n, k;cin >> n >> k;
  vec a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans = 0;
  rep(j, k){
    ans += a[j];
  }
  cout << ans;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int dp[101][4][4][4];

void input()
{
    cin >> N;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    // AGCT を 0123 に対応させる

    // 初期化
    dp[0][3][3][3] = 1;

    for (int i = 0; i < N; i++)
    { // index
        for (int c1 = 0; c1 < 4; c1++)
        { // 最後から1文字目の文字
            for (int c2 = 0; c2 < 4; c2++)
            { // 最後から2文字目の文字
                for (int c3 = 0; c3 < 4; c3++)
                {                               //最後から3文字目の文字
                    if (dp[i][c1][c2][c3] == 0) // 条件に当てはまるものがない場合
                        continue;
                    for (int a = 0; a < 4; a++)
                    {                                     // 新しく追加する文字
                        if (a == 2 && c1 == 1 && c2 == 0) // AGC
                            continue;
                        if (a == 2 && c1 == 0 && c2 == 1) // GAC
                            continue;
                        if (a == 1 && c1 == 2 && c2 == 0) // ACG
                            continue;
                        if (a == 2 && c1 == 1 && c3 == 0) // A_GC
                            continue;
                        if (a == 2 && c2 == 1 && c3 == 0) // AG_C
                            continue;

                        dp[i + 1][a][c1][c2] += dp[i][c1][c2][c3];
                        dp[i + 1][a][c1][c2] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0; // 長さNの文字列の個数の和を取る

    for (int c1 = 0; c1 < 4; c1++)
    {
        for (int c2 = 0; c2 < 4; c2++)
        {
            for (int c3 = 0; c3 < 4; c3++)
            {
                ans += dp[N][c1][c2][c3];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
 ll a,b,c,d,k;
 cin>>a>>b>>c>>d>>k;
 ll t=a*60+b,s=c*60+d;
 if(s<t)s+=24*60;
 cout<<max(0ll,s-t-k)<<"\n";
}

Measured memory_bytes: 3608
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e6 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	string ans;
	cin >> str;
	for (auto &c : str)
	{
		if (c != 'B') ans.push_back(c);
		else if (!ans.empty()) ans.pop_back();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from pprint import pprint
 
n,m,q = map(int, input().split())
 
ql = [list(map(int,input().split())) for _ in range(q)]
 
#print(n)
#print(m)
#print(q)
#pprint(ls)
 
masterlist = []
minilist = [0] * n
i = 0
 
 
def saiki(before_a,i,minilist):
    if i > n-1:
        masterlist.append([minilist[j] for j in range(n)])
        return
    for Ai in range(before_a,m+1):
        minilist[i] = Ai
        saiki(Ai,i+1,minilist)
 
#for before_a in range(1,m+1):
#    saiki(before_a,where,minilist)
 
before_a = 1
saiki(before_a,i,minilist)
 
#pprint(masterlist)
#pprint(ql)
 
dmax = 0
 
for a_mini in masterlist:
    dtemp = 0
    for ql_mini in ql:
        if a_mini[ql_mini[1]-1] - a_mini[ql_mini[0]-1] == ql_mini[2]:
            dtemp += ql_mini[3]
        else:
            pass
    if dtemp >= dmax:
        dmax = dtemp
 
print(dmax)

Measured memory_bytes: 95592
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k, s) = (v[0] as usize, v[1] as usize, v[2]);
    for _ in 0..k {
        print!("{} ", s);
    }
    if s >= 100000000 {
        for _ in k..n {
            print!("{} ", 1);
        }
    } else {
        for _ in k..n {
            print!("{} ", s + 1);
        }
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
	int N, M; cin >> N >> M;
	vector<string> A(N), B(M);
	for( string &k : A )cin >> k;
	for( string &k : B )cin >> k;
	for( int i = 0; i < N - M + 1; i++ ){
		for( int j = 0; j < N - M + 1; j++ ){ // kokomade heikouidou
			for( int k = 0; k < M; k++ ){
				for( int l = 0; l < M; l++ ){
					if( A[k+i][l+j] != B[k][l]) goto end;
				}
			}
			cout << "Yes" << endl;
			return 0;
			end:;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;

int main(void){

  int n,m,k;
  double *v_table,*v_table_tmp;
  //unsigned long long *v_table,*v_table_tmp;

  for(cin>>n,cin>>m,cin>>k;n!=0 or m!=0 or k!=0;cin>>n,cin>>m,cin>>k){

    v_table = new double[n*m+1];
    //v_table = new unsigned long long[n*m+1];
    v_table_tmp = new double[n*m+1];
    //v_table_tmp = new unsigned long long[n*m+1];    
    
    //cout << n << "," << m << "," << k << endl;
    
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	v_table[i*m+j+1] = 0;
	v_table_tmp[i*m+j+1] = 0;	
      }
    }
    v_table[0] = 1.0;
    
    for(int i=1;i<=n;i++){

      for(int c_i=0;c_i<n;c_i++){
	for(int c_j=0;c_j<m;c_j++){
	  v_table_tmp[c_i*m+c_j+1] = 0;	
	}
      }
      
      for(int j=i;j<=i*m;j++){

	for(int k=j-m;k<j;k++){
	  if(k < 0) continue;
	  else{
	    v_table_tmp[j] += v_table[k]/m;
	    //v_table_tmp[j] += v_table[k];	    
	  }
	}
	
      }

      for(int c_i=0;c_i<n;c_i++){
	for(int c_j=0;c_j<m;c_j++){
	  v_table[c_i*m+c_j+1] = v_table_tmp[c_i*m+c_j+1];
	}
      }
      v_table[0] = 0;

      for(int c_i=0;c_i<n;c_i++){
	for(int c_j=0;c_j<m;c_j++){
	  //cout << "v[" << c_i*m+c_j+1 << "]:" << v_table[c_i*m+c_j+1] << endl;
	}
      }
      //cout << "~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
    }
    

    double exp=0;

    for(int c_i=0;c_i<n;c_i++){
      for(int c_j=0;c_j<m;c_j++){
	//cout << "v[" << c_i*m+c_j+1 << "]:" << v_table[c_i*m+c_j+1] << endl;
	if(c_i*m+c_j+1 <= k){
	  exp += v_table[c_i*m+c_j+1];
	}
	else{
	  exp += (c_i*m+c_j+1-k)*v_table[c_i*m+c_j+1];	    
	}
      }
    }
    //cout << "exp:" << exp << endl;
    cout << fixed << setprecision(8) << exp << endl;        
    delete[] v_table;      
    //cout << "++++++++++++++++++++++++++++++++++++++++++" << endl;    
    
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int Ans=0;
  for(int i=0; i<N-1; i++){
    set<int> T;
    for(int j=0; j<i+1; j++){
      for(int k=i+1; k<N; k++){
        if(S.at(j)==S.at(k)){
          T.insert(S.at(j));
        }
      }
    }
    Ans=max(Ans, (int)T.size());
  }
  cout << Ans << endl;
}

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

int main(void){

  int n;
  cin >> n;
  long long sum = 0;
  vector<int>b(n-1);
  long long i;
  for(i = 0;i<n-1;i++){
    cin >> b[i];
  }
  
  if(n == 2){
    sum = 2 * b[0];
  }
  
  else{
      
  for(i = 0;i<n;i++){
    
    if(i == n-1){
      sum += b[i-1];
    }
    
    else if(i == 0){
      sum += b[i];
    }

    else if(i != 0 && i != n-1){
      if(b[i-1] < b[i]){
        sum += b[i-1];
      }
      else{
        sum += b[i];
      }
    }

    
    
  }
}
  cout << sum << endl;
  
  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
signed main() {
	int n, a, b; cin >> n >> a >> b;
	if (a % 2 == b % 2)cout << (b - a) / 2 << endl;
	else {
		if (a > b)swap(a, b);
		int ans = a + (b - a - 1) / 2;
		a = n - a + 1; b = n - b + 1; swap(a, b);
		ans = min(ans, a + (b - a - 1) / 2);
		cout << ans << endl;
	}
}

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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
    FasterIO;

    int n;
    string a, b, c;

    while(cin>>n>>a>>b>>c){
        int cnt=0;

        for(int i=0; i<n; i++){
            if(a[i]==b[i] && b[i]==c[i]);

            else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i])
                cnt++;
            else
                cnt+=2;
        }

        cout<<cnt<<endl;
    }

    return 0;
}



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

#define MOD 1000000007ll
#define pb     push_back
#define mp     make_pair
#define MAX 100005
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()

int n;
string s;
stack<char> st;

int main(int argc, char const *argv[])
{
  cin >> n;
  cin >> s;
  int fr = 0, ls = 0;

  for(int i = 0 ; i < (int)s.size() ; i++){
  	if(s[i] == '(')
  		st.push('(');
    else{
    	if(!st.empty())
    		st.pop();
    	else
    		fr++;
    }
  }

  while(!st.empty())
  {
  	st.pop();
  	ls++;
  }

  string sa, sb;

  for(int i = 0 ; i < fr ; i++)
  	sa.pb('(');

  for(int j = 0 ; j < ls ; j++)
  	sb.pb(')');

  s = sa + s + sb;
  cout << s;			




  return 0;
}  


Measured memory_bytes: 256
// Circle_in_a_Rectangle.cs

// ????????¢?????????????????????????????????????????????????????°?????????
// ????????¢?????????????????????????????¨??????????????????????????§?¨? (W,H) ????????????????????????????????????????????????????????§?¨? (x,y) ??¨?????? r ??§?????????????????????
// ??\????????????????????? W, H, x, y, r ?????????

using System;

class Circle_in_a_Rectangle{
    static void Main(){
        
        var str = Console.ReadLine();
        string[] s = str.Split(' ');
        
        // ????????¢
        var W = int.Parse(s[0]);
        var H = int.Parse(s[1]);
        
        // ?????????????????§?¨?
        var x = int.Parse(s[2]);
        var y = int.Parse(s[3]);
        
        // ????????????
        var r = int.Parse(s[4]);
        
        // ??????4?????????????????????????????§?¨?
        
        var North = y + r; // ?????????
        var South = y - r; // ?????????
        var West = x - r; // ?\???????
        var East = x + r; // ??±??????
        
        if ( North <= H && South >= 0 && West >= 0 && East <= W )
        {
            Console.WriteLine("Yes");
        }
        
        else{
            Console.WriteLine("No");
        }
        
        
    }
}

Measured memory_bytes: 8996
#include<iostream>
#include<set>
using namespace std;
using ll = long long;

int Q[200500];

int main() {
	set<int>s;
	int  n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		Q[x] = i;
	}
	s.insert(-1);
	s.insert(n);
	ll ans = 0;
	for (int v = 1; v <= n; v++) {
		int p = Q[v];//v番目の数
		auto it = s.upper_bound(p);
		int r = *it;
		int l = *(--it);
		ans += v * 1ll * (r - p) * 1ll * (p - l);
		s.insert(p);
	}
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	string a,b,c;
	cin>>a>>b>>c;
	string ans="";
	ans+=(a[0]-32);ans+=(b[0]-32);ans+=(c[0]-32);
	cout<<ans;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	if( n % k == 0 ){
		cout << "0" << endl;
	} else {
		cout << "1" << endl;
	}
	return 0;
}

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

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());

    int num = a[2] - a[1];
    a[0] += num;
    if(a[0]%2 == a[2]%2){
        num += (a[2]-a[0]) / 2;
    }else{
        num += (a[2]-a[0]) / 2 + 2;
    }
    cout << num << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main() {
	int n, d;
	int ans;

	scanf("%d %d", &d, &n);
	ans = pow(100, d)*n;
	if (n == 100) {
		ans +=pow(100, d);
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
import numpy as np
K = int(input())
l = [0] *(K+1)
res = 0
for i in range(1,K+1):
    for j in range(1, K+1):
        gcd_ab = np.gcd(i,j)
        l[gcd_ab] +=1

for i in range(1, K+1):
    for j in range(1,K+1):
        gcd_c = np.gcd(i,j)
        res += l[j]* gcd_c


print(res)


Measured memory_bytes: 27196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,Q = map(int,readline().split())
AB = [list(map(int,readline().split())) for i in range(N-1)]

graph = [[] for _ in range(N+1)] #隣接リスト
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

#親のノードに子を入れてくdfs
stack = [1]
parent = [0]*(N+1)
order = []
while stack:
    x = stack.pop()
    order.append(x)
    for i in graph[x]:
        if i == parent[x]:
            continue
        parent[i] = x
        stack.append(i)

query = [0]*(N+1)

for i in range(Q):
    p,x = map(int,readline().split())
    query[p] += x

#全ての親についての累積和を取る。
#この時、親方向に逆流しないように注意。
for x in order:
    a = query[x]
    for y in graph[x]:
        if y == parent[x]: #逆流防止弁
            continue
        query[y] += a

print(*query[1:])

        


Measured memory_bytes: 119640
S = input()
n = len(S)
prev = S[0]
k = 1
x = 0
for i in range(n):
    if S[i] == prev:
        x += 1
    else:
        k = max(k, min(i, n + x - i))
        x = 1
        prev = S[i]
k = max(k, x)
print(k)





Measured memory_bytes: 3188
N, X, Y = map(int, input().split())
ans = [0 for _ in range(N-1)]
for i in range(1, N+1):
    for j in range(i+1, N+1):
        d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X))
        ans[d-1] += 1
for v in ans:
    print(v)

Measured memory_bytes: 47836
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    N = int(input())
    P = prime_factorize(N)
    C = collections.Counter(P)
    # print(C)

    ans = 0
    for k, v in C.items():
        x = 1
        while v - x >= 0:
            v -= x
            x += 1
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef queue<int> qi;

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n%2&&m%2?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		x -= sc.nextDouble();
		y -= sc.nextDouble();
		System.out.printf("%.6f\n", Math.sqrt(x*x + y*y));
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[55];
int main() {
    ll n;
    cin >> n;
    for(int i = 1; i <= 50; i ++) {
        a[i] = n/50LL + i - 1;
    }
    n %= 50;
    for(int i = 1; 1LL*i <= n; i ++) {
        for(int j = 1; j <= 50; j ++)
            a[j]--;
        a[i] += 51;
    }
    cout << 50 << endl;
    for(int i = 1; i < 50; i ++)cout << a[i] << ' ';
    cout << a[50] << endl;
    return 0;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> el(n + 1, 0), er(n + 2, 0), wl(n + 1, 0), wr(n + 2, 0);
    s = "#" + s;
    for(int i = 1; i <= n; i++){
        el[i] = el[i - 1] + (s[i] == 'E');
        wl[i] = wl[i - 1] + (s[i] == 'W');
    }
    for(int i = n; i >= 1; i--){
        er[i] = er[i + 1] + (s[i] == 'E');
        wr[i] = wr[i + 1] + (s[i] == 'W');
    }
    int ans = INT_MAX;
    for(int i = 1; i <= n; i++){
        int yo = wl[i - 1] + er[i + 1];
        ans = min(ans, yo);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 5652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[0]+A[1]) %24 << endl;
}

Measured memory_bytes: 256