akhauriyash/Code-Regression huggingface dataset:
s = list(input())

ans = 0
buffer = 1
for i in range(len(s) - 1):
    if s[i] == 'W':
        buffer = 1
        continue
    elif s[i + 1] == 'W':
        s[i] = 'W'
        s[i + 1] = 'B'
        ans += buffer
        # buffer = 1
    else:
        buffer += 1

print(ans)


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
  int a;
  cin >> a;
  if(a < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}


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

int main(void){
    int n,cnt=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        while(1){
            if(a[i]%2)break;
            a[i]/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    string s;
    int k;
    cin >> s >> k;
    vector<string> v;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= 5; j++){
            if(s.size() < i + j) continue;
            v.push_back(s.substr(i, j));
        }
    }
    sort(v.begin(), v.end());
    unique(v.begin(), v.end());
    cout << v[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
count = 1
prev = a[0]
dir = 0
1.upto(n-1) do |i|
  diff = a[i] - prev
  if dir == 0
    dir = diff
  else
    if diff * dir < 0
      dir = 0
      count += 1
    end
  end
  prev = a[i]
end
puts count


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

int main()
{
  std::string s;
  std::cin >> s;
  
  for(int i = 0; s[i] != NULL; i++)
  {
    if(i % 2 == 0)
    {
      std::cout << s[i];
    }
  }
  
  return 0;
}

Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  int N, M;
  cin >> N >> M;
  // if(N >= M){
  //   cout << 0 << endl;
  //   return 0;
  // }

  vector<int> X(M);
  for(int i=0; i<M; i++) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int> dist(M-1);
  for(int i=1; i<M; i++) dist[i-1] = X[i] - X[i-1];
  sort(dist.begin(), dist.end());

  int ans = 0;
  for(int i=0; i<M-1 - (N-1); i++) ans += dist[i];
  cout << ans << endl;

  return 0;
  // cout << fixed;//小数点を確実に10桁で表示するためのもの
  // cout << setprecision(10); 
}


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

int main(void){
  string str;
  int n,ans=0;

  cin >> n >> str;
  for (int i=0; i<n-2; i++){
    if (str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C')ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b, c;
    cin >> a >> b >> c;
    
    if (b/a > c)
        cout << c << endl;
    else
        cout << b/a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,maxsum=0,sum;
	cin >> N;
	if(N==1){
		cout << "1" << endl;
		return 0;
	}else if(N<=3){
		cout << "2" << endl;
		return 0;
	}else if(N<=7){
		cout << "4" << endl;
		return 0;
	}else if(N<=15){
		cout << "8" << endl;
		return 0;
	}else if(N<=31){
		cout << "16" << endl;
		return 0;
	}else if(N<=63){
		cout << "32" << endl;
		return 0;
	}else if(N<=100){
		cout << "64" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)


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

int main(){
    int n; cin>>n;
    string s=to_string(n);
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=2e5+5;

int par[N];
int si[N];
int ans=1;

int findpar(int v)
{
    if(v!=par[v])
        return par[v]=findpar(par[v]);
    return v;
}

void uni(int x,int y)
{
    x=findpar(x);
    y=findpar(y);
    if(x==y)
        return;
    if(si[x]>=si[y])
    {
        si[x]+=si[y];
        ans=max(ans,si[x]);
        par[y]=x;
    }
    else
    {
        si[y]+=si[x];
        ans=max(ans,si[y]);
        par[x]=y;
    }
}

int main()
    {
        Nitroboost;
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif

        int n,f;
        cin>>n>>f;

        for(int i=0;i<=n;i++)
        {
            par[i]=i;
            si[i]=1;
        }
        for(int i=1;i<=f;i++)
        {
            int x,y;
            cin>>x>>y;
            uni(x,y);
        }

        cout<<ans;
    }


Measured memory_bytes: 5208
#include <stdio.h>

int main(void) {
int height, width;
int i, r;

while(1) {
scanf("%d %d", &height, &width);

if(height == 0 && width == 0) break;

for (i = 0; i < height; i++){
for (r = 0; r < width; r++) {
if (i == 0 || i == height - 1 || r == 0 || r == width - 1)
printf("#");
else
printf(".");
}
printf("\n");
}

printf("\n");
}

return 0;
}


Measured memory_bytes: 2052
function main()
	d = split(readline())
	x1 = parse(Int64, d[1])
	y1 = parse(Int64, d[2])
	x2 = parse(Int64, d[3])
	y2 = parse(Int64, d[4])
	x3 = x2 + y1 - y2
	y3 = y2 - x1 + x2
	x4 = x3 + x1 - x2
	y4 = y3 + y1 - y2
	println(x3, " ", y3, " ", x4, " ",y4, " ")
end

main()

Measured memory_bytes: 121420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)

int main(){
    string S, T;
    cin >> S >> T;
    string ans="No";
    rep(i, S.len){
        if(S!=T){
            S.psb(S.at(0));
            erc(S, 0);
        }
        else{
            ans="Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int s;
   cin>>s;
   int c=s%100%10;
   if(c==3){
       cout<<"bon"<<endl;
   }
   else if(c==0){
       cout<<"pon"<<endl;
   }
   else if(c==1){
       cout<<"pon"<<endl;
   }
   else if(c==6){
       cout<<"pon"<<endl;
   }
   else if(c==8){
       cout<<"pon"<<endl;
   }
   else {
       cout<<"hon"<<endl;
   }
}


Measured memory_bytes: 3624
import heapq
import sys

input = sys.stdin.readline

def dijkstra(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

n,x,y = map(int,input().split())

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    edge[i].append((1,i+1))
    edge[i+1].append((1,i))
edge[x-1].append((1,y-1))
edge[y-1].append((1,x-1))

for i in range(n):
    edge[i] = tuple(edge[i])
edge = tuple(edge)

ans = [0 for _ in range(n)]
for i in range(n):
    #dijkstra(始点,edge)
    res = dijkstra(i,edge)
    for j in range(i+1,n):
        ans[res[j]] += 1

for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 85596
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr>void dump(Itr begin, Itr end) {
  for(;begin != end; ++begin) clog << ' ' << *begin;
  clog << LF;
}

int digit(i64 n)
{
  return (n < 10)? 1 : (1 + digit(n/10));
}

int f(i64 a, i64 b)
{
  return max(digit(a), digit(b));
}

signed main()
{
  i64 N;
  cin >> N;

  int ans = INF;
  for(i64 i = 1; i*i <= N; ++i) {
    if (N % i == 0) chmin(ans, f(i, N/i));
  }

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



Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 22:26:13
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    cout << max(a-2*b,0) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	int n[4];
	cin >> n[0] >> n[1] >> n[2] >> n[3];
	sort(n, n + 4);
	if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9)cout << "YES" << endl;
	else cout << "NO" << endl;
	end;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int n;
int a[3][105];
int f[3][105];
int main()
{
	scanf("%d",&n);
	for(int j=1;j<=2;j++)
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[j][i]);
	}
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			f[i][j]=max(f[i-1][j],f[i][j-1])+a[i][j];
		}
	}
	cout<<f[2][n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){if(a<b){return a;}return b;}

int main(void){
  int n, m, x, i;
  scanf("%d%d%d", &n, &m, &x);
  int ary[100] = {0};
  int left = 0;
  int right = 0;
  for(i = 0; i < m; i++){
    int ai;
    scanf("%d", &ai);
    ary[ai]++;
  }
  
  for(i = 0; i < x; i++){
    left += ary[i];
  }
  for(i = x + 1; i < n; i++){
    right += ary[i];
  }
  printf("%d\n", min(left, right));
  return 0;
}

Measured memory_bytes: 128
import numpy as np
import itertools
N, M, Q = map(int, input().split())
G = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    G.append([a, b, c, d])

ans = 0

A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A)
score = np.zeros(n, np.int32)
for a, b, c, d in G:
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())


Measured memory_bytes: 46816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] ary = new String[H];

		for (int i = 0; i < H; i++) {
			ary[i] = sc.next();
		}
		if (H == 1) {
			for (int i = 0; i < 2; i++) {
				System.out.println(ary[0]);
			}
		} else {
			for (int i = 0; i < H * 2; i++) {
				System.out.println(ary[i / 2]);
			}
		}

	}
}

Measured memory_bytes: 23508
#include <stdio.h>

int main(void)
{
  int N, i, j;
  scanf("%d", &N);
  float v[N], box;
  for(i = 0; i < N; i ++){
    scanf("%f", &v[i]);
  }
  for(i = 0; i < N; i ++){
    for(j = 0; j < N-1; j ++){
      if(v[j] > v[j+1]){
        box = v[j+1];
        v[j+1] = v[j];
        v[j] = box;
      }
    }
  }
  /*for(i = 0; i < N; i ++){
    printf("%f", v[i]);
  }*/
  box = v[0];
  for(i = 1; i < N; i ++){
    box = (box + v[i]) / 2;
  }
  printf("%f", box);

  return 0;
}


Measured memory_bytes: 128
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int cnt[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  int ret = cnt[0] + cnt[1];
  FOR(i, 1, 100000) {
    chmax(ret, cnt[i-1]+cnt[i]+cnt[i+1]);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 640
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
  A=list(map(int,input().split()))
  p=C
  for j in range(M):p+=A[j]*B[j]
  if p>0:count+=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
 
void solve()
{
    ll x,n,val;
    cin >> x >> n;
    ll arr[105]= {0};
    rep(i,n)
    {
        cin >> val;
        arr[val]=1;
    }
    for(int i=x,j=x;; i--,j++)
    {
        if(arr[i]==0)
        {
            cout << i << "\n";
            return;
        }
        else if(arr[j]==0)
        {
            cout << j << "\n";
            return;
        }
    }
 
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int t=1;
    while(t--)
    {
        solve();
    }
}

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

using namespace std;

int main(){
    int n, m, c;
    vector<int> B;
    vector<vector<int>> A;

    cin >> n >> m >> c;
    B.resize(m);
    for (auto& b: B) cin >> b;
    A.resize(n, vector<int>(m));
    for (auto& a_: A) for (auto& a: a_) cin >> a;

    int ans = 0;
    for (int i = 0; i < n; i++){
        long long sum = c;
        for (int j = 0; j < m; j++){
            sum += A[i][j] * B[j];
        }
        if (sum > 0)
            ans++;
    }
    
    cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e5+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

int N, A, B;
vi adj[NMAX];


int findA(int u, int p){
    int res = adj[u].size()/2;
    if(u != 0 and adj[u].size() % 2 == 0) res --;
    for(int v : adj[u]) if(v != p) res += findA(v, u);
    return res;
}

int check(vi &v, int excl){
    for(int i = 0, j = v.size()-1; i < j; i++, j--){
        if (i == excl) i++;
        if (j == excl) j--;
        if(i >= j) continue;
        if(v[i] + v[j] > B) return false;
    }
    return true;
}

int leastUp(int u, int p){
    vi vals;
    for(int v : adj[u]) if (v != p) vals.pb(leastUp(v, u) + 1);
    //cout << u << ": ";
    //for(int k : vals) cout << k << " ";
    //cout << endl;
    if(vals.size() == 0) return 0;
    if(vals.size()%2 == 0) {
        if( u == 0 ){
            sort(vals.begin(), vals.end());
            for(int i = 0, j = vals.size()-1; i < j; i++, j--) if(vals[i] + vals[j] > B) return B+1;
            return 0;
        }
        vals.pb(0);
    }
    sort(vals.begin(), vals.end());
    if(vals.back() > B) return B+1;
    int lb = -1, rb = vals.size();
    while(lb+1 != rb) {
        int mb = (lb+rb)/2;
        if(check(vals, mb)) rb = mb;
        else lb = mb;
    }
    if(rb == vals.size()) return B+1;
    //cout << "leastUp " << u << ": " << vals[rb] << endl;
    return vals[rb];
}

int ok(int b){
    B = b;
    //cout << "B = " << b << endl;
    int l = leastUp(0, 0);
    //cout << "l = " << l << " B = " << B << endl;
    return l <= B;
}

signed main(){
    fast_io();
    cin >> N;
    adj[0].pb(0);
    FOR(i, 0, N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    A = findA(0, 0);
    int lb = 0, rb = N;
    while(lb + 1 != rb) {
        int mb = (lb+rb)/2;
        if(ok(mb)) rb = mb;
        else lb = mb;
    }

    cout << A << " " << rb << endl; 
    
}


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

using namespace std;

template <typename T>
struct BIT
{
    int N, K;
    vector<T> bit;

    BIT(int X)
    {
        bit = vector<T>(X + 1, 0);
        N = X + 1;
        K = pow(2, (int)(log(X) / log(2)));
    }

    void add(int idx, T w)
    {
        for (int x = idx; x <= N; x += x & -x)
        {
            bit[x] += w;
        }
    }

    T sum(int idx)
    {
        T res = 0;
        for (int x = idx; x > 0; x -= x & -x)
            res += bit[x];
        return res;
    }
};

void solve()
{
    long n, k;
    cin >> n >> k;
    vector<long> as(n), bs(n + 1);
    set<long> s;
    s.insert(0);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        as[i] -= k;
        bs[i + 1] = bs[i] + as[i];
        s.insert(bs[i + 1]);
    }
    int cnt = 1;
    map<long, int> mp;
    for (long x : s)
    {
        mp[x] = cnt++;
        //cout << x << ' ' << mp[x] << endl;
    }
    for (int i = 0; i <= n; i++)
    {
        bs[i] = mp[bs[i]];
    }
    BIT<long> bit(cnt + 1);
    long ans = 0;
    for (int r = 0; r <= n; r++)
    {
        ans += bit.sum(bs[r]);
        bit.add(bs[r], 1);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


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

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	double x1, y1, x2, y2, distance;
	cin >> x1 >> y1 >> x2 >> y2;
	distance = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
	cout << fixed << setprecision(6) << distance << endl;
	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3288
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, K; cin >> N >> K;

    ll ans = 0;
    for(int b=1; b<=N; b++) {
        int p = N / b;
        int r = N % b;
        ans += max(b - K, 0) * p + max(r - K + 1, 0);
    }
    if (K == 0) ans -= N;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
b = gets.chomp.split(' ').map(&:to_i)
c = gets.chomp.split(' ').map(&:to_i)
res = 0

for i in 0..n-2 do
    if a[i+1] == a[i] + 1 then
        res += c[a[i]-1]
    end

    res += b[a[i]-1]
end

res += b[a[n-1]-1]

puts res

Measured memory_bytes: 1788
n,k=[int(x) for x in input().rstrip().split()]
dic={}
for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a not in dic:
    dic[a]=b
  else:
    dic[a]+=b

dic=sorted(dic.items(),key=lambda x:x[0])

now=0
for i,v in dic:
  now+=v
  if k<=now:
    print(i)
    break


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

inputs = []

for i in range(3):
    inp = [int(x) for x in input().split(' ')]
    inputs.append(inp)

def solve(n, inputs):
    a = inputs[0]
    b = inputs[1]
    c = inputs[2]

    satisfaction = 0
    last = -1
    dish = -1
    for d in range(n):
        dish = a[d]        
        if dish == last + 1:
            satisfaction += c[dish-2]
        last = a[d]        
        satisfaction += b[dish-1]

    print(satisfaction)

solve(n, inputs)

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

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

    int ans = 0;
    rep(i, s.size() - t.size() + 1) {
        int cnt = 0;
        rep(j, t.size()) if (s[i + j] == t[j]) cnt++;
        ans = max(ans, cnt);
    }

    cout << t.size() - ans << endl;
    return 0;
}


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

using namespace std;

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

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

  vector<int> a(n);
  for(int i = 0; i < a.size(); i++) {
    cin >> a.at(i);
  }

  int primeCount = 0;
  for(int i = 0; i < a.size(); i++) {
    if(is_prime(a.at(i))) {
      primeCount++;
    }
  }

  cout << primeCount << endl;

  return 0;
}



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

int main(void){
    int A, B, C, D, ans=0;
    cin >> A >> B >> C >> D;

    ans = min(B, D) - max(A, C);

    if(ans < 0) cout << "0\n";
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    ll sum[N + 1] = {};
    for(ll i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
    ll ans = 1145148931919810;
    for(ll i = 2; i <= N - 2; i++){
        ll mid1 = sum[i] / 2, mid2 = (sum[N] + sum[i]) / 2;
        ll po = lower_bound(sum, sum + i, mid1) - sum;
        ll yo = lower_bound(sum + i, sum + N, mid2) - sum;
        ll dis[] = {-4, -3, -2, -1, 0, 1, 2, 3, 4};
        for(ll j = 0; j < 9; j++){
            for(ll k = 0; k < 9; k++){
                ll pos1 = po + dis[j], pos2 = yo + dis[k];
                if(!(0 < pos1 && pos1 < i && i < pos2 && pos2 < N)) continue;
                vector<ll> tmp = {sum[pos1], sum[i] - sum[pos1], sum[pos2] - sum[i], sum[N] - sum[pos2]};
                sort(tmp.begin(), tmp.end());
                ans = min(ans, tmp[3] - tmp[0]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
    int n; cin >> n;
    vector<int> A(n);
    for(int i=0; i<n; i++) cin >> A[i];

    ll ans=0;
    for(int i=0; i<n; i++){
        while(A[i]%2==0){
            ans++;
            A[i]/=2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  int cnt=0;
  for(int A=1;A<=N;A++){
    cnt+=(N-1)/A;
  }
  cout<<cnt<<endl;
  return 0;                       
}

Measured memory_bytes: 3632
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C, D, E, F = map(int, input().split())

    ws, ss = set(), set()
    for a in range(F // A + 1):
        for b in range(F // B + 1):
            w = 100 * (a * A + b * B)
            if w != 0 and w <= F:
                ws.add(w)
    for c in range(F + 1):
        for d in range(F + 1):
            if c * C + d * D <= F:
                ss.add(c * C + d * D)

    best = 0
    ans = (0, 0)
    for w in ws:
        for s in ss:
            if w + s > F or s > w * E // 100:
                continue
            if best <= ((100 * s) / (w + s)):
                best = (100 * s) / (w + s)
                ans = (w + s, s)

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4076
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    String str = sc.next();
    String[] strList = str.split("");

    int[] t = new int[n + 1];
    for (int i = 1; i < n; i++) {
      if(strList[i-1].equals("A") && strList[i].equals("C")) {
        t[i + 1] = t[i] + 1;
      } else {
        t[i + 1] = t[i];
      }
    }

    for (int i = 0; i < q; i++) {
      int start = sc.nextInt();
      int end = sc.nextInt();
      System.out.println(t[end] - t[start]);
    }
  }
}


Measured memory_bytes: 78368
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define int long long
const int MAX=1e9+7;
int n,a[55],b[55],ans=MAX,sum,vis[55],p,q,g[55];
int find(){
	int tot=0;
	int l=1,r=0;
	int sum=0;
	while(tot<n){
		//
		//printf("%d\n",tot);
		//
		if(l>r){
			for(int i=1;i<=n;i++){
				if(vis[i]==0){
					vis[i]=1;
					r++;
					g[r]=i;
					tot++;
					sum++;
					break;
				}
			}
		}
		while(l<=r){
			for(int i=1;i<=n;i++){
				if(vis[i]==1) continue;
				if((a[i]+p==a[g[l]]&&b[i]+q==b[g[l]])||(a[i]-p==a[g[l]]&&b[i]-q==b[g[l]])){
					tot++;
					r++;
					g[r]=i;
					vis[i]=1;
				}
			}
			l++;
		}
	}
	//
	//printf("%d %d %d\n",sum,p,q);
	//
	return sum;
}
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%lld",&n);
	if(n==1){
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int i=1;i<=n;i++) vis[i]=0;
			p=a[i]-a[j];
			q=b[i]-b[j];
			if(p==0&&q==0) continue;
			ans=min(ans,find());
		}
	}
	/*if(n==47) printf("34\n");
	else*/ printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

bool compare(pair<int, string>&a, pair<int, string> &b)
{
    return a.first >= b.first;
}

int main() {
    fio;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    cin >> t;
    unordered_map<string, int> mp;
    mp["AC"] = 0;
    mp["TLE"] = 0;
    mp["WA"] = 0;
    mp["RE"] = 0;
    for (int i = 0; i < t; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC" << " x " << mp["AC"] << endl;
    cout << "WA" << " x " << mp["WA"] << endl;
    cout << "TLE" << " x " << mp["TLE"] << endl;
    cout << "RE" << " x " << mp["RE"] << endl;
    return 0;

}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(x,1000) {
    int keta = 1;
    int nx = x/10;
    vector<int> d(1,x%10);
    while (nx) {
      keta++;
      d.push_back(nx%10);
      nx /= 10;
    }
    if (keta != n) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(i,m) {
      if (d[p[i].first-1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    N = int(input())
    W = list(map(int, input().split()))

    total = sum(W)
    ans = float('inf')
    w = 0
    for n in W:
        w += n
        ans = min(ans, abs(w - (total - w)))
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

void largest_rectangle_in_a_histogram() {
	int N; cin >> N;
	vector<int> h(N); rep(i, 0, N) { cin >> h[i]; }
	using P = pair<int, int>;
	stack<P> st;
	st.emplace(-1, -1);
	int ans = 0;
	rep(i, 0, N) {
		if (st.top().first == h[i])
			continue;
		int pos = i;
		while (st.top().first >= h[i]) {
			chmax(ans, st.top().first*(i - st.top().second));
			pos = st.top().second;
			st.pop();
		}
		st.emplace(h[i], pos);
	}
	while (st.size()) {
		chmax(ans, st.top().first*(N - st.top().second));
		st.pop();
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	largest_rectangle_in_a_histogram();
	return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

vi pw(vi a, ll e) {
  int n = sz(a);
  vi b(n);
  rep(i, 0, n)
    b[i] = i;
  while (e) {
    if (e & 1) {
      vi nb(n);
      rep(i, 0, n)
        nb[i] = a[b[i]];
      b = nb;
    }
    vi na(n);
    rep(i, 0, n)
      na[i] = a[a[i]];
    a = na;
    e >>= 1;
  }
  return b;
}

// aaaaaaaaaaaaaaaa
void solve() {
  int n; ll k;
  scanf("%d%lld", &n, &k);
  vi a(n);
  rep(i, 0, n) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  a = pw(a, k);
  printf("%d\n", a[0] + 1);
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


Measured memory_bytes: 6448
#include "bits/stdc++.h"
using namespace std;
 
int h, w;
int df[81][81];
int dp[81][81][6400];

int mdiff(int x, int y, int del) {
	if (x == h-1 && y == w-1) return min(abs(del - df[x][y]), abs(del + df[x][y]));
	
	if (del >= 6400) return INT_MAX;
	if (dp[x][y][del] != -1) return dp[x][y][del];
	
	int md = INT_MAX;
	if (x < h-1) {
		// can go down
		md = min(md, mdiff(x+1, y, abs(del+df[x][y])));
		md = min(md, mdiff(x+1, y, abs(del-df[x][y])));
	}
	if (y < w-1) {
		// can go right
		md = min(md, mdiff(x, y+1, abs(del+df[x][y])));
		md = min(md, mdiff(x, y+1, abs(del-df[x][y])));
	}
	return dp[x][y][del] = md;
}
  
int main() {
	
	cin >> h >> w;
	
	for (int i=0; i<81; i++) for (int j=0; j<81; j++) for (int k=0; k<6400; k++) dp[i][j][k] = -1;
	
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cin >> df[i][j];
		}
	}
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			int x;
			cin >> x;
			df[i][j] -= x;
			df[i][j] = abs(df[i][j]);
		}
	}
	
	cout << mdiff(0, 0, 0) << endl;
	
	
}


Measured memory_bytes: 164352
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int l, r;
    l = 0; r = INFINITY;
    int N, M; cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int tmp_l; cin >> tmp_l;
        int tmp_r; cin >> tmp_r;

        l = max(tmp_l, l);
        r = min(tmp_r, r);
    }

    if(r-l >= 0) cout << r-l+1 << endl;
    else cout << 0 << endl;
}


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

int main(int argc,char** argv){
	int D,N;
	cin >> D >> N;
	if(N==100){
		N = N+1;
	}

	if(D==0)
		cout << N;
	else if(D==1)
		cout << 100 * N;
	else
		cout << 10000 * N;

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


	
	public static void main(String[] args) throws NumberFormatException, IOException {
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
	        String str = "";
	        StringTokenizer st;
	        while ((str = br.readLine()) != null) {
	            st = new StringTokenizer(str, " ");
	            if(st.countTokens() > 2)
	            	System.out.println("Only 2 numbers per dataset allowed.");
	            int n1;
				int n2;
				try {
					n1 = Integer.parseInt(st.nextToken());
					n2 = Integer.parseInt(st.nextToken());
		            if(n1<0 || n2 < 0 || n1 > 1000000 || n2 > 1000000)
		            	System.out.println("Out of range. 0 ??? a, b ??? 1,000,000");
		            
		            str = String.valueOf(n1+n2);
		            System.out.println(str.length());
				} catch (NumberFormatException e) {
					System.out.println("Only number as follows allowed: 0 ??? a, b ??? 1,000,000");
				}
	        }
	}

}

Measured memory_bytes: 24416
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <queue>
#include <map>
#include <string>
#define INF 99999999
using namespace std;
const int MAXN = 505;

int main(){
    int n;
    while(cin >> n){
        int a = sqrt(n);
        cout << a*a << endl;
    }
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int a = 0;
	int h, n;
	cin >> h >> n;
	rep(i, n) {
		int j; cin >> j;
		a += j;
	}

	if (h <= a) cout << "Yes" << endl;
	else cout << "No" << endl;




	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
char a,b;
int main(){
	cin>>a;
	getchar();
	cin>>b;
	if (a==b) cout<<'='<<endl;
	else if (a>b) cout<<">"<<endl;
	else if (a<b) cout<<"<"<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
const int N = 100010;

struct edge{ int to, pre; }e[N << 1]; int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int w[N], ans = 0;
void dfs(int x, int f) {
	w[x] = 0; int cnt[19]; rep(i,0,18) cnt[i] = 0;
	reg(i,x) if (v != f) { dfs(v, x); rep(j,0,18) if (w[v] >> j & 1) cnt[j]++; }
	int t = 0; dep(i,18,0) if (!cnt[i]) t = i; else if (cnt[i] >= 2) break;
	ans = max(ans, t);
	w[x] = 1 << t; rep(i,t + 1,18) if (cnt[i]) w[x] |= 1 << i;
}

int main() {
	int n; scanf("%d",&n);
	rep(i,1,n - 1) { int a, b; scanf("%d%d",&a,&b), ins(a, b), ins(b, a); }
	dfs(1,0); printf("%d\n",ans);
	return 0;
}

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

int64_t cnt (int64_t a) {
  int64_t ans = 0;
  if (a == 1) {
    return 1;
  }
  ans = cnt(a/2) * 2 + 1;
  return ans;
}

int main () {
  int64_t N;
  cin >> N;
  
  cout << cnt(N) << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum P = 998244353L;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    int[] LS, RS;
    foreach (_; 0..K) {
        auto lr = readln.split.to!(int[]);
        LS ~= lr[0];
        RS ~= lr[1];
    }

    auto DP = new long[](N+1);
    DP[1] = 1;
    DP[2] = P - 1;
    foreach (i; 1..N+1) {
        (DP[i] += DP[i-1]) %= P;
        foreach (j; 0..K) {
            auto l = LS[j];
            auto r = RS[j]+1;
            if (i+l <= N) (DP[i+l] += DP[i]) %= P;
            if (i+r <= N) (DP[i+r] += P - DP[i]) %= P;
        }
    }
    writeln(DP[N]);
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  if((a*b)%2) std::cout << "Odd" << std::endl;
  else std::cout << "Even" << std::endl;

  return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, M, K;

void init()
{
	cin >> N >> M >> K;
}

int culc(int n, int m)
{
	return n * M + m * N - 2 * n * m;
}

void solve()
{
	rep(n, N+1) rep(m, M+1) {
		if (culc(n, m) == K) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
import math
N,M,k = map(int,input().split())
p = N*M
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

P = cmb(p-2,k-2)
Q = N*(N-1)*(N+1)*M*M//6
R = M*(M-1)*(M+1)*N*N//6
print((P*(Q+R))%(10**9+7))

Measured memory_bytes: 11536
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=998244353;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
int main()
{
	lli n;
	cin>>n;
	lli ani=0;
	for(lli i=1;i<=n;i++){
		if(i%5==0 || i%3==0);
		else ani+=i;
	}
	cout<<ani;
	
	
	
    return 0;
}

Measured memory_bytes: 3632
class UnionFind(n: Int) {
    private val parent = IntArray(n, {-1})
    private val rank = IntArray(n, {0})
    private val size = IntArray(n, {1})
    private var numTree = n
    
    fun find(x: Int): Int {
        if (parent[x] == -1) {
            return x
        } else {
            parent[x] = find(parent[x])
            return parent[x]
        }
    }
    
    fun isSame(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }
    
    fun getSize(): Int {
        return numTree
    }
    
    fun sizeOf(x: Int): Int {
        return size[find(x)]
    }
    
    fun rankOf(x: Int): Int {
        return rank[find(x)]
    }
    
    fun unite(x: Int, y: Int) {
        val parentX = find(x)
        val parentY = find(y)
        
        if (parentX == parentY) {
            return
        }
        
        numTree--
        
        if (rank[parentX] < rank[parentY]) {
            parent[parentX] = parentY
            size[parentY] += size[parentX]
        } else {
            parent[parentY] = parentX
            size[parentX] += size[parentY]
            if (rank[parentX] == rank[parentY]) {
                rank[parentX]++
            }
        }
    }
}

fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    
    val bridges = Array(M, { val (a, b) = readInputLine().split(" ").map { it.toInt() - 1 }; Pair(a, b)})
    
    var ans = 0
    
    for (i in 0 until M) {
        val uf = UnionFind(N)
        for (j in 0 until M) {
            if (i == j) {
                continue
            }
            uf.unite(bridges[j].first, bridges[j].second)
        }
        if (uf.getSize() == 2) {
            ans++
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}



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

int a[100004][3];
int dp[100004][3];

void solve(){
    int n;
    cin >> n;
    // int h[n];
    for(int i = 0 ; i < n ; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    
    dp[n-1][0] = a[n-1][0];
    dp[n-1][1] = a[n-1][1];
    dp[n-1][2] = a[n-1][2];
    
    for(int i = n-2 ; i >= 0 ; i--){
        dp[i][0] = a[i][0] + max(dp[i+1][1], dp[i+1][2]);
        dp[i][1] = a[i][1] + max(dp[i+1][0], dp[i+1][2]);
        dp[i][2] = a[i][2] + max(dp[i+1][1], dp[i+1][0]);
    }
    
    cout << max(dp[0][0], max(dp[0][1], dp[0][2]));
}

int main(){
   solve();
}




Measured memory_bytes: 5912
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{	
	int a,b,c;
	double d;
	while (cin >> a>>b )
	{
	
		{
			if(b<10) c=a*10+b;
			else if(b==100) c=a*1000+b;
			else c=a*100+b;
		}
		d=sqrt(c)	;
		{
			if(d==int(d))cout <<"Yes"<<endl;
			else cout <<"No"<<endl;
		}
		
		
		}	


	return 0;
}

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

vector<string> S = {"dreamer", "dream", "erase", "eraser"};

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

   reverse(s.begin(), s.end());
   for (int i = 0; i < S.size(); i++) {
      reverse(S[i].begin(), S[i].end());
   }

   int n = s.size();
   for (int i = 0; i < n; ) {
      bool ok = false;
      for (int j = 0; j < S.size(); j++) {
         if (s.substr(i, S[j].size()) == S[j]) {
            i += S[j].size();
            ok = true;
            break;
         }
      }
      if (!ok) {
         puts("NO");
         return 0;
      }
   }

   puts("YES");

   return 0;
}

Measured memory_bytes: 512