akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var queue = new Queue<long>(LongList().OrderByDescending(x => x));
            var list = new List<long>();
            long prev = queue.Dequeue();
            for (long now = queue.Dequeue(); list.Count < 2;) {
                if(now == prev) {
                    list.Add(now);
                    if (!queue.Any()) break;
                    prev = queue.Dequeue();
                    if (!queue.Any()) break;
                    now = queue.Dequeue();
                } else {
                    prev = now;
                    if (!queue.Any()) break;
                    now = queue.Dequeue(); 
                }
            }

            if(list.Count == 2) {
                Console.WriteLine(list.First() * list.Last());
            } else {
                Console.WriteLine(0);
            }

        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

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


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

    int count = 0;
    for(int j=0; j<N; j++){
        if(h[j] >= K){
            count++;
        }
    }

    cout << count;

    return 0;
}

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

class Bundle {
public:
  Bundle(int t, int b) : top_(t), bottom_(b) {}
  int top() const {return top_;}
  int bottom() const {return bottom_;}
  int size() const {return bottom() - top() + 1;}
  int count(int r) const {
    if(r < top()) return 0;
    if(bottom() <= r) return size();
    return r - top() + 1;
  }
  Bundle split(int i) {
    Bundle res(i, bottom());
    bottom_ = i - 1;
    return res;
  }
private:
  int top_, bottom_;
};

int main() {
  int n;
  while(cin >> n, n) {
    int m;
    cin >> m;
    int p, q, r;
    cin >> p >> q >> r;

    vector<Bundle> bundle;
    bundle.emplace_back(1, n);

    for(int k = 0; k < m; ++k) {
      int x, y;
      cin >> x >> y;
      int cnt = 0;
      for(int i = 0; i < bundle.size(); ++i) {
        cnt += bundle[i].size();
        if(cnt < x) continue;
        if(cnt != x) bundle.insert(begin(bundle) + i + 1, bundle[i].split(bundle[i].top() + bundle[i].size() - (cnt - x)));
        cnt = x;
        ++i;
        for(int j = i; j < bundle.size(); ++j) {
          cnt += bundle[j].size();
          if(cnt < y) continue;
          if(cnt != y) bundle.insert(begin(bundle) + j + 1, bundle[j].split(bundle[j].top() + bundle[j].size() - (cnt - y)));
          auto A = vector<Bundle>(begin(bundle), begin(bundle) + i);
          auto B = vector<Bundle>(begin(bundle) + i, begin(bundle) + j + 1);
          auto C = vector<Bundle>(begin(bundle) + j + 1, end(bundle));
          bundle = A;
          bundle.insert(begin(bundle), begin(B), end(B));
          bundle.insert(begin(bundle), begin(C), end(C));
          break;
        }
        break;
      }
    }

    int answer = 0;
    int cnt = 0;
    for(int i = 0; i < bundle.size(); ++i) {
      cnt += bundle[i].size();
      if(cnt < p - 1) continue;
      if(cnt != p - 1) bundle.insert(begin(bundle) + i + 1, bundle[i].split(bundle[i].top() + bundle[i].size() - (cnt - p + 1)));
      cnt = p - 1;
      ++i;
      for(int j = i; j < bundle.size(); ++j) {
        cnt += bundle[j].size();
        if(cnt < q) continue;
        if(cnt != q) bundle.insert(begin(bundle) + j + 1, bundle[j].split(bundle[j].top() + bundle[j].size() - (cnt - q)));
        for(int k = i; k <= j; ++k) answer += bundle[k].count(r);
        break;
      }
      break;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int n,a[100050];long long mem[100050];

long long solve(int idx)
{
    if(idx==n-1)
        return 0;
    if(idx>=n)
        return 1500000000;
    if(mem[idx]!=-1)
        return mem[idx];
    int op1,op2;
    //if(idx<n-1)
        op1=solve(idx+1)+abs(a[idx]-a[idx+1]);
    //if(idx<n-2)
        op2=solve(idx+2)+abs(a[idx]-a[idx+2]);
    return mem[idx]=min(abs(op1),abs(op2));
}

int main() {

    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        mem[i]=-1;
    }
    solve(0);
    cout<<mem[0];

	return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int m = n/100;
    int k = n - (m*100);
    int l = k/10;
    int i = k%10;
    if(m==7||l==7||i==7){
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}


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

using namespace std;

int data[100005];

int main()
{
  int n,mx=0,ans=INT_MAX,mxid=-1;
  double tmp;

  scanf("%d",&n);
  for(int c=0;c<n;c++)
  {
    scanf("%d",&data[c]);
    if (data[c]>mx)
    {
      mx=data[c];
      mxid=c;
    }
  }
  tmp=(double)mx/2;
  for(int c=0;c<n;c++)
  {
    if (mxid==c)continue;
    if (abs(data[c]-tmp)<abs(ans-tmp))ans=data[c];
  }
  printf("%d %d\n",mx,ans);
}


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

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#define pii pair<int,int>

const ll mod = 1e9+7;

int main()
{
	int n,k,mn = n+1,x,idx=-1;

	cin >> n >> k;

	for(int i = 0;i < n;i++){
		cin >> x;
		if(x == 1)idx = i;
	}
	int ans = 0;
	for(int i = 0;i < n-1;i+=k-1){
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  vector<int> h(200000,0);
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(h[i] >= k){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
string S;
vector<char> cs(10);

long long int f(string s, int cnt)
{
  long long int sum = 0;
  if (cnt == S.size())
  {
    long long int tmp = 0;
    for (int i = 0; i < s.size(); i++)
    {
      char c = s.at(i);
      if (c != '+')
      {
        int ic = c - '0';
        tmp = tmp * 10 + ic;
        if (i == s.size() - 1)
        {
          sum += tmp;
        }
      }
      else
      {
        sum += tmp;
        tmp = 0;
      }
    }
    return sum;
  }
  sum += f(s + '+' + cs.at(cnt), cnt + 1);
  sum += f(s + cs.at(cnt), cnt + 1);
  return sum;
}

int main()
{
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    cs.at(i) = S.at(i);
  }
  string s(1, S.at(0));
  cout << f(s, 1) << endl;
}

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

using P = pair<char,int>;

string s;
int main(){
  cin >> s;
  vector<int> dp(s.size() + 2,1e9);
  dp[s.size() + 1] = 0;
  dp[s.size()] = 1;
  vector<int> from(26,s.size() + 1);
  vector<P> rev(s.size() + 1);
  rev[s.size()] = {'a',s.size() + 1};

  for(int i = s.size() - 1;i >= 0;i--){
    from[s[i] - 'a'] = i + 1;
    rep(j,0,25){
      if(dp[from[j]] + 1 < dp[i]){
        dp[i] = dp[from[j]] + 1;
        rev[i] = {j + 'a' , from[j]};
      }
    }
  }

  int now = 0;
  while(now < s.size() + 1){
    cout << rev[now].first;
    now = rev[now].second;
  }

  cout << endl;
}


Measured memory_bytes: 2948
/*
  Contest 110
  A - Maximize the Formula
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    std::vector<int> v(3, 0);
    std::cin >> v[0] >> v[1] >> v[2];
    std::sort(v.rbegin(), v.rend());
    std::cout << std::stoi(std::to_string(v[0]) + std::to_string(v[1])) + v[2] << std::endl;

    return 0;
}


Measured memory_bytes: 3716
import numpy as np
import sys

N = int(input())
I = np.array(sys.stdin.read().split(), np.int64)
A = I[:N]
B = I[N:2*N]
C = I[2*N:]

A.sort()
C.sort()

ans = 0
for i in range(N):
	b = B[i]
	A_cnt = np.searchsorted(A, b, side='left')
	C_cnt = np.searchsorted(C, b, side='right')
	ans += A_cnt * (N-C_cnt)

print(ans)

Measured memory_bytes: 56024
#include<iostream>

using namespace std;

int main()
{
	int n,t,cnt=0;
	int arr[100] = { 0 };

	cin >>n;
	for (int i = 0; i != n; ++i)
	{
		cin >> arr[i];
	}
	
	for (int i = 0; i != n - 1; ++i)
	{
		for (int j = n-1; j != 0; --j)
		{
			if (arr[j] < arr[j-1])
			{
				++cnt;
				t = arr[j];
				arr[j] = arr[j-1];
				arr[j-1] = t;
			}
		}
	}

	for (int i = 0; i != n; ++i)
	{
		cout << arr[i];
		if (i == n - 1)
		{
			cout << endl;
			break;
		}
		cout << " ";
	}
	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 3088
n,m=map(int,input().split())
ans=0
if n==m:
  ans=1
  for i in range(n):
    ans=(ans*(n-i)*(m-i))%(10**9+7)
  ans=(ans*2)%(10**9+7)
elif n+1==m:
  ans=m
  for i in range(n):
    ans=(ans*(n-i)*(m-i-1))%(10**9+7)
elif m+1==n:
  ans=n
  for i in range(m):
    ans=(ans*(m-i)*(n-i-1))%(10**9+7)
print(ans)

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

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[] = {0, -1, 0, 1, -1, 1, -1, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<int> b(9);
    rep(i, 0, n){
        if(a[i] >= 3200) b[8]++;
        else b[a[i]/400]++;
    }
    int mn = INF, mx = 0;
    int cnt = 0;
    rep(i, 0, 8){
        if(b[i]) cnt++;
    }
    mn = max(1, cnt);
    mx = cnt+b[8];
    cout << mn << " " << mx << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll dp[100005][3];

int main()
{
	start_routine();
	fastio;
	

    ll n;cin>>n;
    ll happy[n+1][3];
    for(ll i=1;i<=n;i++)
    	for(ll j=0;j<3;j++)
    		cin>>happy[i][j];

   	for(ll i=1;i<=n;i++)
   	{
   		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+happy[i][0];
   		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+happy[i][1];
   		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+happy[i][2];
   	}

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

	end_routine();
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
using namespace std;
int INF = 99999;
/*
問題文
snuke 君は自転車を買いに来ました。 snuke 君はすでに買う自転車を決めたのですが、
その自転車にはベルが付いていないため、 自転車とは別にベルも買う必要があります。

snuke 君は安全意識が高いので、ベルをどちらの手でも鳴らせるよう、
両方のハンドルに 1 つずつ 付けることにしました。

お店にあるベルは 3 種類で、それぞれ a円、 b円、 c円です。 
この 3 つのうち、異なる 2 つのベルを選んで買うときの、値段の合計の最小値を求めて下さい。

制約
1≤a,b,c≤10000
a,b,c は整数
*/
int min_p(int a, int b, int c){
	if(a < INF) INF = a;
	if(b < INF) INF = b;
	if(c < INF) INF = c;

	return INF; 
}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min_p(a+b,a+c,b+c) << endl;

}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector< vector<char> > a((H+2), vector<char> ((W+2), '#'));
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      if (i!=0 && i!=H+1) {
        if (j!=0 && j!=W+1) {
          cin >> a.at(i).at(j);
        }
      }
    }
  }
  
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":	" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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

int main() {
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) {
    cin>>a[i]; a[i]--;
  }

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

  vector<ll> b(n);
  rep(i, n) {
    b[i] = a[i]-i;
  }
  sort(b.begin(),b.end());

  ll ans = LINF;
  rep(j, 2) {
    ll tmp = 0;
    rep(i, n) tmp += abs(a[i]-(b[(n+j)/2]+i));
    mins(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6428
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int c[3][3];
    REP(i, 3){
        REP(j, 3) cin >> c[i][j];
    }
    bool flag = true;
    REP(j, 2){
        int x1 = c[0][j] - c[0][j + 1];
        int x2 = c[1][j] - c[1][j + 1];
        int x3 = c[2][j] - c[2][j + 1];
        if (x1 != x2 || x2 != x3) flag = false;
    }
    REP(i, 2){
        int y1 = c[i][0] - c[i + 1][0];
        int y2 = c[i][1] - c[i + 1][1];
        int y3 = c[i][2] - c[i + 1][2];
        if (y1 != y2 || y2 != y3) flag = false;
    }
    if (flag) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!

using namespace std;


int main() {
	long long H;
	cin >> H;
	for (int i = 0; i < 100000; i++) {
		if (pow(2, i) <= H && H < pow(2, i + 1)) {
			cout << (long long)pow(2, i + 1) - 1 << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


template<class T> struct SegmentTree {
  int N;
  const T Inf = INT_MAX;
  vector<T> node;
  SegmentTree(int n_){
    N = 1; while (N < n_) N *= 2;
    node.assign(2*N-1, Inf);
  }

  // a番目をxに変更する
  void update(int a,T x){
    a += N-1; node[a] = x;
    while (a > 0){
      a = (a-1)/2;
      node[a] = min(node[2*a+1], node[2*a+2]);
    }
  }

  // [a,b) の最小値を出力。見ているノード k が [l,r) に対応
  T getmin(int a,int b,int k=0,int l=0,int r=-1){
    if (r == -1) r = N;
    if (b <= l || r <= a) return Inf;
    if (a <= l && r <= b) return node[k];
    T vl = getmin(a,b,2*k+1,l,(l+r)/2);
    T vr = getmin(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

int N;

int main() {
  int Q; cin >>N >>Q;
  SegmentTree<ll> st(N);
  rep(qq, Q){
    int com; cin >>com;
    if (com == 0){
      int a; ll x; cin >>a >>x;
      st.update(a, x);
    }else{
      int s,t; cin >>s >>t; t++;
      cout <<st.getmin(s,t) <<endl;
    }
  }
}



Measured memory_bytes: 5016
import sys,math,copy,queue,itertools,bisect,collections
from heapq import *
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

S = input()
if S == 'ABC': print('ARC')
else: print('ABC')

Measured memory_bytes: 68652
/// 01:00 08/09/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;

class FenwickTree {
private:
    vector<ll> tree;
    ll n{};

    ll cumilativeSum(ll index) {
        ll ans = 0;
        while (index >= 0) {
            ans += this->tree[index];
            decrement(index);
        }
        return ans;
    }

    static void increment(ll &index) {
        index |= (index + 1);
    }

    static void decrement(ll &index) {
        index = (index & (1 + index)) - 1;
    }

    void initializeVector(vector<ll> &v) {
        for (ll i = 0; i < n; i++) {
            this->setIndex(i, v[i]);
        }
    }

    void setSize(ll _n) {
        this->n = _n;
        this->tree.resize(_n);
    }

public:
    explicit FenwickTree(ll _n, ll initialValue = 0) {
        setSize(_n);
        fill(this->tree.begin(), this->tree.end(), initialValue);
    }

    explicit FenwickTree(ll _n, vector<ll> &initialVector) {
        setSize(_n);
        this->initializeVector(initialVector);
    }


    void incrementIndex(ll index, ll value) {
        while (index < n) {
            this->tree[index] += value;
            increment(index);
        }
    }

    void setIndex(ll index, ll value) {
        ll currentValue = this->getValueAtIndex(index);
        ll delta = value - currentValue;
        this->incrementIndex(index, delta);
    }

    void incrementRange(ll start, ll end, ll value) {
        incrementIndex(start, value);
        if (end + 1 < n) {
            incrementIndex(end + 1, -value);
        }
    }

    ll rangeSum(ll start, ll end) {
        ll sumTillEnd = this->cumilativeSum(end);
        ll sumToSubtract = this->cumilativeSum(start - 1);
        ll ans = sumTillEnd - sumToSubtract;
        return ans;
    }

    // update for range update and point query
    ll getValueAtIndex(ll index) {
        return rangeSum(index, index);
    }

};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    ll q;
    cin >> q;
    vector<ll> v(n);
    for (auto &x:v) {
        cin >> x;
    }
    FenwickTree fenwickTree(n, v);
    while (q--) {
        ll t, a, b;
        cin >> t >> a >> b;
        if (!t) {
            fenwickTree.incrementIndex(a, b);
        } else {
            cout << fenwickTree.rangeSum(a, b - 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 12172
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int max(int &a,int &b){if(a>b){return a;}else{return b;}}
int min(int &a,int &b){if(a>b){return b;}else{return a;}}
int ar_max(vector<int> &v){
  int max_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]>max_val){max_val=v[i];}
  }
  return max_val;
}
int ar_min(vector<int> &v){
  int min_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]<min_val){min_val=v[i];}
  }
  return min_val;
}

/* Binary Search(v,N,flag)
  flag = true -> return ind(int) 挿入index
  flag = false -> return in(0or1) 入ってるかどうか*/
int b_search(vector<int> &v, int &N, bool flag=true){
  sort(v.begin(),v.end());
  int left=0,right=v.size()-1,ind;
  if (N < v[left]){return 0;}
  if (N > v[right]){return right+1;}
  while(true){
    ind = (left+right)/2;
    if (v[ind]>N){right = ind;}
    else if(v[ind]<N){left = ind;}
    else if(v[ind]==N){
      if(flag){return ind;}
      else{return 1;}
    }

    /* 終了判定*/
    if (right-left<=1){
      if(flag){
        if(v[left]==N){
          return left;
        }else{
          return right;
        }
      }else{
        if(v[left]==N || v[right]==N){return 1;}
        else{return 0;}
      }
    }
  }
}


int main(void){
  int A,B;
  cin >> A >> B;
  if(A==1){A=14;}
  if(B==1){B=14;}
  if(A>B){
    cout << "Alice" << endl;
  }else if(A==B){
    cout << "Draw" << endl;
  }else{
    cout << "Bob" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

using namespace std;

void re(int& x);

void pr(int x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

int n;

void solve()
{
    re(n);
    if ( (n&(n-1)) == 0) {
        ps("No");
        return;
    }

    ps("Yes");
    ps(1, 2);
    ps(2, 3);
    ps(3, n+1);
    ps(n+1,n+2);
    ps(n+2,n+3);

    for (int i = 4; i < n; i+=2) {
        ps(i,i+1);
        ps(i+1,1);
        ps(1,n+i);
        ps(n+i,n+i+1);
    }

    if (n % 2 == 0) {
        int bb = 1<<__lg(n);
        
        ps(n, bb+1);
        int rem = n ^ bb;
        ps(n + rem, 2*n);
    }
}

int main() {

    solve();
}

void re(int& x) { scanf("%d", &x); }

void pr(int x) { printf("%d", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}



Measured memory_bytes: 2304
#include<stdio.h>
int main(){
    char num[4];
    int check, a;
    int flag = 0;

    scanf("%c%c%c%c",&num[0],&num[1],&num[2],&num[3]);

    if(num[0] == num[1])flag=1;
    if(num[1] == num[2])flag=1;
    if(num[2] == num[3])flag=1;

    if(flag == 0){
        printf("Good\n");
    }else{
        printf("Bad\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	List<Integer> power = new ArrayList<>();
    	for (int i = 0; i < 3*N; i++) {
    		power.add(sc.nextInt());
    	}
    	long count = 0;
    	Collections.sort(power, Collections.reverseOrder());
    	for (int i = 1; i < 2*N; i+=2) {
    		count += power.get(i);
    	}
    	System.out.println(count);
    }
}

Measured memory_bytes: 99652
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



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

    
    ll n;
    cin>>n;
    vll v(n);
    rep(i,n){
        cin>>v[i];
    }
    ll ans=0;
    sort(all(v));
    ll s=n/2;
    ans=v[s]-v[s-1];
    if(v[s]==v[s-1]) ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1152
#ifndef _WIN32
#include<iostream>
#endif
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long LL;
#define FOR(i,bg,ed) for(int (i)=(bg);(i)<(ed);(i)++)
#define REP(i,n) FOR(i,0,n)
struct cww {
	cww() {
		ios::sync_with_stdio(false);
		cin.tie(0);
	}
};
template<typename T>
inline bool chmax(T& l, T r) {
	bool res = l < r;
	if (res)l = r;
	return res;
}

typedef vector<LL> V;
typedef vector<V> VV;
const LL INF = 1e15;
int main() {
	int R, C, RR, CC;
	cin >> R >> C;
	VV X(R,V(C)), Y(R, V(C));
	REP(i, R)REP(j, C)cin >> X[i][j];
	REP(i, R)REP(j, C)cin >> Y[i][j];

	cin >> RR >> CC;
	VV Z(RR, V(CC));
	REP(i, RR)REP(j, CC)cin >> Z[i][j];
	LL res = -INF;
	REP(i, R)REP(j, C)if (i + RR <= R&&j + CC <= C) {
		bool f = true;

		REP(a, RR)
			REP(b, CC)
			f &= (Y[i + a][j + b] == Z[a][b]);
		if (f) {
			LL ans = 0;
			REP(a,RR)
				REP(b, CC)
					ans += X[i + a][j + b];
			

			chmax(res, ans);
		}


	}

	if (res == -INF)cout << "NA" << endl;
	else cout << res << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	int64 n;
	cin >> n;
	if (n % 2 == 1) {
	    cout << 0 << endl;
		return 0;
	}
	
	n /= 2;
	
	int64 ans = 0;
	int64 deg = 5;
	while (n >= deg) {
	    ans += n / deg;
		deg *= 5;
	}
	
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def henkan(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return henkan(num // 26 - 1) + chr(90)
    else:
        return henkan(num // 26) + chr(64 + num % 26)


n = int(input())
print(str(henkan(n)).lower())


Measured memory_bytes: 9168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        string[] a = Read.Strs();
        Console.WriteLine(int.Parse(a[0]+a[1]+a[2])%4==0?"YES":"NO");
    }
    public static Boolean uso() { return false; }
    public static int gcd(int a, int b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static int lcm(int a, int b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;
int n, k, d, a, vis[111], ans;

int main(){
    cin >> n >> k;
    ans = n;
    for (int i = 1; i <= k; i++){
        cin >> d;
        for (int j = 0; j < d; j++){
            cin >> a;
            vis[a]++;
            if (vis[a]==1) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    rep(i, 0, N) {
        cin >> w[i] >> v[i];
    }

    ll dp[N + 1][W + 1] = {};
    rep(i, 1, N + 1) {
        rep(j, 0, W + 1) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j - w[i - 1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 79104
#include<iostream>
using namespace std;
int main()
{
    int n,i,a,l=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if(i%2==0 &&a%2==1)
            l++;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());
            var A = ReadLine().Split().Select(long.Parse).ToArray();

            var len = A[0];
            var ans = 0L;
            for (int i = 1; i < N; i++)
            {
                if(len > A[i])
                {
                    ans += len - A[i];                    
                }
                else
                {
                    len = A[i];
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 47932
#include <iostream>
#include <vector>

using namespace std;

int main(){

	int R,C;
	int field[10][10000];
	while(cin >> R >> C && !(R == 0 && C == 0)){
		for(int i = 0; i < R; i++){
			for(int j = 0; j < C; j++){
				cin >> field[i][j];
			}
		}
		int field2[10][10000];
		int maxMochi = 0;
		for(int S = 0; S < (1 << R); S++){
			for(int i = 0; i < R; i++){
				if((S >> i) & 1){
					for(int j = 0; j < C; j++){
						field2[i][j] = (field[i][j] == 0 ? 1 : 0);
					}
				}
				else{
					for(int j = 0; j < C; j++){
						field2[i][j] = (field[i][j]);
					}
				}
			}
			int sumCnt = 0;
			for(int i = 0; i < C; i++){
				int cnt = 0;
				for(int j = 0; j < R; j++){
					if(field2[j][i])
						cnt++;
				}
				sumCnt += max(cnt,R-cnt);
			}
			maxMochi = max(maxMochi,sumCnt);
		}
		cout << maxMochi << endl;
	}

	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
#define MAXN 10010
#define MAXY 2010
#define INF 0x3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int a,b;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	if(a==1 && b==2 || a==2 && b==1)
	cout<<3;
	else if(a==1 && b==3 || a==3 && b==1)
	cout<<2;
	else
	cout<<1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  rep(i, N) {
    int a;
    cin >> a;
    if(!mp.count(a)) mp[a] = 1;
    else             mp[a]++;
  }
  if(mp.size() % 2 == 1)
    cout << mp.size() << endl;
  else
    cout << mp.size() - 1 << endl;
  return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
constexpr double eps = 1e-9;
int main() {
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f) {
        double x = (c*e - b*f) / (a*e - b*d);
        double y = (c - a*x) / b;
        if(fabs(x) < eps) x = 0;
        if(fabs(y) < eps) y = 0;
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int indexi;
double ans;
double ans1=1;
double tab[3000];
int kab[3000];
double dp[3001][3001];
double parcours(int index,int nb)
{
  if(nb >(indexi/2))return 0;
  if(index == indexi)return 1;
  if(dp[index][nb]!= -1){return dp[index][nb];}
  //debugs(index,nb);
  double ans =1;ans*= ((double)(1-tab[index]))*(parcours(index+1,nb+1));
  //debug(ans1);
  double ans1 =1;ans1*= ((double)tab[index])*parcours(index+1,nb);
  return dp[index][nb]=(ans+ans1);
}
int main()
{
  cin>>indexi;
  for (int i = 0; i < indexi; ++i)
  {
    for (int j = 0; j < indexi; ++j)
    {
      dp[i][j]=-1;
    }
  }
  for (int i = 0; i < indexi; ++i)
  {
    cin>>tab[i];
  }
  cout<<fixed<<setprecision(10)<<parcours(0,0);
  return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int ,int> P;
const int    INF = (int)1e9;
const int    MOD = (int)1e9+7;
const double EPS = (double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout << fixed << setprecision(20);
    };
};

const int MAX = 1000000;

//1<=k<=n<=10^7
//p:素数
long long fac[MAX], finv[MAX], inv[MAX];

//前処理Ｏ(n)
void CombInit() {
    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;
    }
}


// 二項係数計算Ｏ(1)_nCk
long long Comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main(){
  int H,W,A,B;cin>>H>>W>>A>>B;

  CombInit();

  int ans=0;
  for(int i=0;i<H-A;i++){
    ans+=(Comb(B + i - 1, B - 1)%MOD)*(Comb((W - B - 1) + (H - i - 1), W - B - 1)%MOD);
    ans%=MOD;
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 23680
s=input()
odd=["R", "U", "D"]
even=["L", "U", "D" ]

cnt=1
for i in s:
  if cnt%2==1:
    if i not in odd:
      print("No")
      exit()
  else:
    if i not in even:
      print("No")
      exit()
  cnt+=1
print("Yes")
      
      
  

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

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

using namespace std;

using ll = long long;

template <class T>
struct edge {
    size_t to;
    T cost;
    edge(size_t to, T cost = 1) : to(to), cost(cost) {}
};

template <class T>
class graph {
private:
    const size_t count_nodes;
    const bool is_directed;
public:
    vector<edge<T>> *edges;
    graph(size_t count_nodes, bool is_directed = true) : count_nodes(count_nodes), is_directed(is_directed) {
        edges = new vector<edge<T>>[count_nodes];
    }
    ~graph() {
        delete [] edges;
    }
    size_t size() const { return count_nodes; }
    void make_edge(size_t u, size_t v, T cost) {
        edges[u].push_back(edge<T>(v, cost));
        if (!is_directed)
            edges[v].push_back(edge<T>(u, cost));
    }
};

template <class T>
vector<T> dijkstra(const graph<T> &g, const int start) {
    vector<T> dist(g.size());
    bool *used = new bool[g.size()]();
    priority_queue<pair<T, size_t>, vector<pair<T, size_t>>, greater<pair<T, size_t>>> q;
    dist[start] = 0;
    q.push(pair<T, size_t>(dist[start], start));
    used[start] = true;
    while (!q.empty()) {
        T dist_v;
        size_t v;
        tie(dist_v, v) = q.top();
        q.pop();
        if (dist[v] < dist_v)
            continue;
        for (edge<T> e: g.edges[v]) {
            size_t w = e.to;
            T dist_v_w = dist_v + e.cost;
            if (!used[w] || dist[w] > dist_v_w) {
                dist[w] = dist_v_w;
                q.push(pair<T, size_t>(dist[w], w));
                used[w] = true;
            }
        }
    }
    delete [] used;
    return dist;
}

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

    int N, Q, K;
    cin >> N;
    graph<ll> g(N, false);
    REP(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        g.make_edge(a, b, c);
    }
    cin >> Q >> K;
    --K;
    vector<ll> dist = dijkstra(g, K);
    REP(_, Q) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        ll result = dist[x] + dist[y];
        cout << result << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,flag =0;
//    cin>>t;
//    while(t--){
      double a,b,h,m;
      cin>>a>>b>>h>>m;
      double theta = 2.0 * pi * (h / 12.0 +  (m / 60.0) / 12.0 - m/60.0);
      double ans = a * a + b * b - 2.0 * a * b * cos(theta);
      cout<<setprecision(9)<<fixed<<sqrt(ans)<<endl;
//	  }
//	}
}

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0);cin.tie(0)
int main(){
    IO;
    int a,b,devide,ct=0;
    cin>>a>>b>>devide;
    for(int i=a;i<=b;i++) if(i%devide==0) ct++;
    cout<<ct<<"\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    bool swi;
    if(s.substr(0, 1) == "0"){
        swi = 0;
    }else{
        swi = 1;
    }

    vector<int > vec;

    if(swi == 0){
        vec.push_back(0);
    }

    int f = 0;
    int cont = 1;
    for(int i = 0; i < s.length()-1; i++){
        if(swi == 0){
            if(s.substr(i, 1) == "0" && s.substr(i+1, 1) == "1"){
                vec.push_back(cont);
                swi = 1;
                cont = 1;
            }else{
                cont++;
            }
        }else{
            if(s.substr(i, 1) == "1" && s.substr(i+1, 1) == "0"){
                vec.push_back(cont);
                swi = 0;
                cont = 1;
            }else{
                cont++;
            }
        }

    }
    vec.push_back(cont);

    //数合わせ
    /*
    if(ans.size() % 2 != 0){
        ans.push_back(0);
    }
    */

    //確認
    /*
    for(int i = 0; i < vec.size(); i++){
        cout << vec[i];
    }
    cout << endl;
    */

    int range = 2 * K + 1;
    int left = 0;
    int right = 0;
    int temp = 0;
    int ans = 0;

    for(int i = 0; i < vec.size(); i += 2){
        int Nextleft = i;
        int Nextright = min(i + range, (int)vec.size());
        //前の左端から今回の左端まで（差分）
        while(Nextleft > left){
            temp -= vec[left];
            left++;
        }
        //前の右端から今回の右端まで（差分）
        while(Nextright > right){
            temp += vec[right];
            right++;
        }

        ans = max(ans, temp);

    }

    cout << ans << endl;


} 

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
	double A,B,C,D,E;cin>>A>>B>>C>>D>>E;
  	int A_one=(int)A%10%10;if(A_one==0) A_one+=9;
  	int B_one=(int)B%10%10;if(B_one==0) B_one+=9;
  	int C_one=(int)C%10%10;if(C_one==0) C_one+=9;
	int D_one=(int)D%10%10;if(D_one==0) D_one+=9;
  	int E_one=(int)E%10%10;if(E_one==0) E_one+=9;
  	int minnum = min({A_one,B_one,C_one,D_one,E_one});
      if(minnum == A_one)
        cout << A + (ceil(B/10)*10) + (ceil(C/10)*10) + (ceil(D/10)*10) + (ceil(E/10)*10) << endl;
      else if(minnum == B_one)
        cout << B + (ceil(A/10)*10) + (ceil(C/10)*10) + (ceil(D/10)*10) + (ceil(E/10)*10) << endl;
      else if(minnum == C_one)
        cout << C + (ceil(B/10)*10) + (ceil(A/10)*10) + (ceil(D/10)*10) + (ceil(E/10)*10) << endl;
 	 else if(minnum == D_one)
        cout << D + (ceil(B/10)*10) + (ceil(C/10)*10) + (ceil(A/10)*10) + (ceil(E/10)*10) << endl;
	  else if(minnum == E_one)
        cout << E + (ceil(B/10)*10) + (ceil(C/10)*10) + (ceil(D/10)*10) + (ceil(A/10)*10) << endl;  
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.map { 'x' }.joinToString("")
    println(s)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33784
var
 s:ansistring;
 i,sum:longint;
 p:boolean;
begin
 readln(s);
 for i:=1 to length(s) do
  begin
   if p=false then
    begin
     if s[i]='p' then dec(sum);
    end
   else if s[i]='g' then inc(sum);
   p:=not(p);
  end;
 writeln(sum);
end. 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    REP(i, N + 1) {
        REP(j, N + 1) {
            int k = N - i - j;
            if (k < 0) continue;
            if (Y == 10000 * i + 5000 * j + 1000 * k) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
using namespace std;
int main(){
	int a, b, d, r;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	double w;
	w = double( a ) / double( b );
	cout << d << " " << r << " " << setprecision(6) << fixed << w << endl;
	return 0;
}


Measured memory_bytes: 3280