akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String c = sc.next();
		String b = "aiueo";
		
		if (b.contains(c)) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}

		sc.close();
	}
}


Measured memory_bytes: 23892
N, L = [int(i) for i in input().split()]

s = (N + 2*L - 1) / 2 * N
max_t = L + N - 1
if L >= 0:
    min_t = L
else:
    if max_t < 0:
        min_t = max_t
    else:
        min_t = 0

print(int(s - min_t))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
r, d, x = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(a, file=sys.stderr)

#surfixes = ("dream", "dreamer", "erase", "eraser")

def doit(r, d, x, n):
  for i in range(10):
    x = r * x - d
    print(x)
    
  
try:
  doit(r, d, x, 0)
except Exception as e:
  print(e, file=sys.stderr)


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int d, c;
  cin >> d >> c;

  cout << (d * c) << endl;
}


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

int main() {
  int n, wlimit;
  cin >> n >> wlimit;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) cin >> w.at(i) >> v.at(i);
  vector<vector<long>> dp(n + 1, vector<long>(wlimit + 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= wlimit; j++) {
      dp.at(i + 1).at(j) = (j >= w.at(i)) ? max(dp.at(i).at(j), dp.at(i).at(j - w.at(i)) + v.at(i))
        : dp.at(i).at(j);
    }
  }
  cout << dp.at(n).at(wlimit) << endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin >> N;
    if(N == 0){
        cout << "0" << endl;
        return 0;
    }
    
    string s = "";
    ll tmp = N;
    int sign = 1;
    while(tmp != 0){
        int res = tmp % 2;
        if(res != 0){
            tmp -= sign;
            s.insert(0,"1");
        } else {
            s.insert(0,"0");
        }
        sign *= -1;
        tmp /= 2;
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for (int i=0; i<N; ++i) cin >> P[i];
    for (int i=0; i<N; ++i) cin >> C[i];

    for (int i=0; i<N; ++i) --P[i];
    ll res = -LINF;
    for (int i=0; i<N; ++i) {
        ll sum = 0;
        int cur = i, len = 0;
        do {
            cur = P[cur];
            sum += C[cur];
            ++len;
        } while (cur != i);
        ll tmp = 0;
        int cnt = 0;
        do {
            cur = P[cur];
            tmp += C[cur];
            ++cnt;
            if (cnt > K) break;
            if (sum > 0) chmax(res, tmp + sum * ((K - cnt) / len));
            else chmax(res, tmp);
        } while (cur != i);
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll a[100010];
ll k;

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

	cin>>k;
	REP(i,k) cin>>a[k-1-i];

	ll l=2;
	ll r=2;
	REP(i,k){
		//cout<<i<<":"<<l<<" "<<r<<endl;
		if(a[i]>r){
			cout<<-1<<endl;
			return 0;
		}
		ll l2=l;
		if(l%a[i]!=0) l2+=a[i]-l%a[i];
		//cout<<l2<<endl;
		if(l2>r){
			cout<<-1<<endl;
			return 0;
		}
		l=l2;
		ll r2=r-r%a[i];
		if(r2<l){
			cout<<-1<<endl;
			return 0;
		}
		r=r2+a[i]-1;
	}

	cout<<l<<" "<<r<<endl;

	return 0;
}




Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        continue
    elif h[i-1] <= h[i]-1:
        h[i]-=1
    elif h[i-1] == h[i]:
        continue
    else: 
        print("No")
        exit()
print("Yes")

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  ll sum = 0;
  FOR(i, 1, N+1){
    if(i%3 != 0 && i% 5!=0){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3624
n = int(input())
p = [int(i) for i in input().split()]

flag = 0
for i in range(1,n-1):
    A = p[i-1] < p[i] and p[i] < p[i+1]
    B = p[i+1] < p[i] and p[i] < p[i-1]
    if A or B:
        flag = flag + 1
print(flag)

Measured memory_bytes: 3060
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    map<int, int> cnt;
    for (int i = 0; i < N; i += 2) {
        if (cnt.find(A[i]) != cnt.end()) {
            ++cnt[A[i]];
        } else {
            cnt[A[i]] = 1;
        }
    }

    sort(A, A + N);

    int ans = 0;
    for (int i = 0; i < N; i += 2) {
        if (cnt.find(A[i]) == cnt.end() || cnt[A[i]] == 0) {
            ++ans;
        } else {
            --cnt[A[i]];
        }
    }

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


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

using namespace std;

int i;
char s[100005];

int main(){
	scanf("%s", s);
	int l = strlen(s);
	
	int paper = 0;
	int rock = 0;
	int score = 0;
	
	for(i = 0; i < l; i++){
		if(s[i] == 'g'){
			if(paper < rock){
				score++;
				paper++;
			}
			else
			rock++;
		}
		else{
			if(paper < rock){
				paper++;
			}
			else{
				rock++;
				score--;
			}
		}
	}
	
	printf("%d\n", score);
}


Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> W(n + 1, 0), E(n + 1, 0);
    for(int i = 0 ; i < n ; i++){
        W[i + 1] = W[i];
        if(s[i] == 'W'){
            W[i + 1]++; 
        }
        E[n - i - 1] = E[n - i];
        if(s[n - i - 1] == 'E'){
            E[n - i - 1]++;
        }
    }
    int ans = n;
    for(int i = 1 ; i <= n ; i++){
        int cnt = W[i - 1] + E[i];
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;


int main()
{
	char s[100005];
	char t[100005] = {0};
	int k, r;
	int len;

	scanf("%s%d", s, &k);
	len = strlen(s);
	r = k;

	for(int pos = 0; pos < len - 1; ++pos) {

		t[pos] = s[pos];
		int needed = ('z' - s[pos] + 1) % 26;

		if(needed <= r) {
			t[pos] = 'a';
			r = r - needed;
			continue;
		}
	}

	t[len - 1] = 'a' + (s[len - 1] - 'a' + r) % 26;

	printf("%s\n", t);

	return 0;
}


Measured memory_bytes: 512
import queue
def solve(n):
    if n < 10:
        return n
    cnt = 0
    next = queue.Queue()
    for i in range(1, 10):
        next.put(i)
        cnt += 1
    while True:
        i = next.get()
        for j in range(i % 10 - 1, i % 10 + 2):
            if j < 0 or 9 < j:
                continue
            next.put(i * 10 + j)
            cnt += 1
            if cnt == n:
                return i * 10 + j
k = int(input())
next = queue.Queue
print(solve(k))


Measured memory_bytes: 45032
N = gets.to_i
points = []
N.times do |i|
  points[i] = gets.split.map(&:to_i)
end
points.sort_by!{|x| -x[2]}

list = {}
# initial
for cx in 0..100 do
  for cy in 0..100 do
    h = points[0][2] + (points[0][0] - cx).abs + (points[0][1] - cy).abs
    list[[cx,cy]] = h
  end
end


for i in 1...N do
  for cx in 0..100 do
    for cy in 0..100 do
      next if list[[cx,cy]] == nil
      if points[i][2] != 0
        h = points[i][2] + (points[i][0] - cx).abs + (points[i][1] - cy).abs
        if list[[cx,cy]] == h
          next
        else
          list.delete([cx,cy])
        end
      else
        h1 = [list[[cx,cy]] - (points[i][0] - cx).abs - (points[i][1] - cy).abs, 0].max
        list.delete([cx,cy]) if h1 != 0
      end
    end
  end
end

ans1 = 0
ans2 = 0
ans3 = 0

if N == 1
  puts "#{points[0][0]} #{points[0][1]} #{points[0][2]}"
else
  list.each{|k,v|
    ans1,ans2 = k
    ans3 = v
  }
  puts "#{ans1} #{ans2} #{ans3}"
end

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

int main(){
    
    string s;
    cin >> s;
    
    int n = s.size();
    
    for(int i = 0; i < n; i++){
        string current = s.substr(0, n - i - 1);
        //cout << current << endl;
        int newsize = current.size();
        if(newsize%2 == 0){
            int mid = newsize/2;
            string first = current.substr(0, mid);
            string last = current.substr(mid);
            if(first == last){
                //cout << first << " " << last << endl;
                cout << current.size() << endl;
                return 0;
            }
            
        }
    }
    
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math


INF = 10 ** 20

def main():
    n = getN()
    nums = getList()
    sm = sum(nums)
    ans = sm % 2
    if n % 2 == 1:
        if ans == 1:
            print("First")
        else:
            print("Second")
        return
    if n % 2 == 0:
        mn = min(nums)
        if ans == 1:
            if sm == mn * n:
                print("Second")
            else:
                print("First")

        else:
            if mn % 2 == 1:
                print("First")
            else:
                print("Second")

    # print(ans)
    # if ans == 0:
    #     print("Second")
    # else:
    #     print("First")

if __name__ == "__main__":
    main()


Measured memory_bytes: 28776
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b;
    int[] x, y;

    x = new int[1];
    y = new int[1];
    a = sc.nextInt();
    b = sc.nextInt();
    extgcd(a, b, x, y);
    out.println(x[0] + " " + y[0]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static void extgcd(int a, int b, int[] x, int[] y){
    int tmp;
    x[0] = 1; y[0] = 0;
    if(b != 0){
      extgcd(b, a % b, y, x);
      y[0] -= (a / b) * x[0];
    }
    return;
  }
}

Measured memory_bytes: 17348
using System;

class Point
{
    public decimal x { get; set; }
    public decimal y { get; set; }
}

namespace volume0_0021cs
{
    class Program
    {
        static decimal calcSlope(Point p1, Point p2)
        {
            if (p2.x == p1.x)
            {
                if (p2.y == p1.y)
                {
                    return 0;
                }
                else
                {
                    return decimal.MaxValue;
                }
            }
            else
            {
                return (p2.y - p1.y) / (p2.x - p1.x);
            }
        }

        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            for (int count = 0; count < n; ++count)
            {
                string pointsStr = Console.ReadLine();
                var temp = pointsStr.Split(new char[] { ' ' });
                Point[] p = new Point[4];
                for (int i = 0; i < 4; i++)
                {
                    p[i] = new Point();
                    p[i].x = decimal.Parse(temp[i * 2]);
                    p[i].y = decimal.Parse(temp[i * 2 + 1]);
                }
                if (calcSlope(p[0], p[1]) == calcSlope(p[2], p[3]))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 5824
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int i,j,n;
	bool flag, ans=false;
	string s,t;
	cin >> s;
	cin >> t;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		flag = true;
		for(j=0; j<n; ++j){
			if(s[j] != t[(i+j)%n]){
				flag = false;
				break;
			}
		}
		if(flag){
			ans = true;
			break;
		}
	}
	cout << ((ans)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
// #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef int ll;
const ll MAXN = 5e5+5;
const ll MAX = 1e5+5;
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll powmod(ll a,ll b,ll mod){ll ret=1;while(b>0){if(b&1)ret=ret*a%mod;b>>=1;a=a*a%mod;}return ret;}
inline ll multi(ll a,ll b,ll mod){ll ret=0;while(b){if(b&1)ret=(ret+a)%mod;b>>=1;a<<=1;a%=mod;}return ret;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll d=exgcd(b,a%b,x,y);ll tmp=x;x=y;y=tmp-a/b*x;return d;}
inline ll inverse(ll a,ll b){ll x,y;ll d=exgcd(a,b,x,y);if(d!=1)return -1;return (x%b+b)%b;}



int main(){
	int n,flag=0;
	scanf("%d",&n);
	while(n){
		if(n%10==7)flag=1;
		n/=10;
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3684
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=200010, M=100010;
int n,m;
int ff[N],have[N];

struct edges{
	int x,y;
}e[M];

int cmp(edges a,edges b){
	return a.x<b.x;
}

int main(){
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=1; i<=m; ++i){
		scanf("%d%d",&x,&y);
		e[i] = (edges){x,y};
	}
	sort(e+1,e+m+1,cmp);
	for(int i=1; i<=n; ++i) have[i] = 1;
	for(int i=1; i<=m; ++i){
		y = e[i].y;
		have[y] = have[y+1] = have[y]+have[y+1]-ff[y];
		ff[y] = have[y];
	}
	printf("%d",have[1]);
	for(int i=2; i<=n; ++i){
		printf(" %d",have[i]);
	}
	printf("\n");
	return 0;
}

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

using namespace std;

int main()
{
  long int N;
  long int RN;
  cin >> N;

  RN = (int)sqrt(N);
  double dif = (double)N / RN;

  while(!(lround(dif) == dif)){
    RN--;
    dif = (double)N / RN;                                                                 
  }

  cout << RN+(long int)dif - 2 << endl;


  return 0;
}

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

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if((S == "P" || S == "W" || S == "G") && i < N-1){
      continue;
    }
    else if(S != "Y" && i == N-1){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;

int main(void){
    int n;
    cin >> n;
    float A[MAX];
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    float ans=0;
    for(int i=0; i<n; i++){
        ans += 1.0/A[i];
    }
    cout << 1.0/ans;
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Bits
import Data.List
import Control.Monad

update :: VUM.IOVector Int -> B.ByteString -> IO () 
update vec bs
    | h == 'M' = VUM.modify vec (+1) 0
    | h == 'A' = VUM.modify vec (+1) 1
    | h == 'R' = VUM.modify vec (+1) 2
    | h == 'C' = VUM.modify vec (+1) 3
    | h == 'H' = VUM.modify vec (+1) 4
    | otherwise = VUM.modify vec (+1) 5
    where
        h = B.head bs

enum :: Int -> Int -> [Int]
enum n l
    | l == 0 = []
    | otherwise = (n .&. 1) : enum (shiftR n 1) (l - 1)

solve :: VU.Vector Int -> Int
solve vec
    | len < 3 = 0
    | len == 3 = VU.product vec
    | otherwise = sum $ map (comb vec) [0..2^len-1]
    where
        len = VU.length vec
        comb :: VU.Vector Int -> Int -> Int
        comb vec i
            | (length $ filter (==1) es) /=3 = 0
            | otherwise = foldl' step 1 (zip (VU.toList vec) es)
                where
                    es = enum i len
                    step acc (v,b)
                        | b == 1 = acc * v
                        | otherwise = acc

main = do
    n <- readLn :: IO Int
    vec <- VUM.replicate 6 0
    forM_ [1..n] $ \i -> do
        bs <- B.getLine
        update vec bs 
    vec' <- VU.freeze vec
    let vec'' = VU.filter (/=0) $ VU.init vec'
    print $ solve vec''

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;

map<int,pii> mp;

int main(){

    int n,m;

    cin >> n >> m;


    for(int i=0;i<m;i++){
        int x; string str;
        cin >> x >> str;

        if(str=="WA"){
            if(mp[x].ff==0) mp[x].ss++;
        }
        else mp[x].ff = 1;

    }

    ll s1=0,s2=0;

    for(auto x:mp){
        s1 += x.ss.ff;
        if(x.ss.ff==1) s2 += x.ss.ss;
    }

    cout << s1 << " " << s2 << endl;

    return 0;
}


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

void KnapSack()
{
    ll n,W;
    cin>>n>>W;
    ll wo[n],vo[n];
    ll keep[n+1][W+1],V[n+1][W+1];
    for(ll i=0;i<=W;i++){
        V[0][i]=0;
    }
    for(ll i=0;i<n;i++){
        V[i][0]=0;
    }
    for(ll i=1;i<=n;i++){
        cin>>wo[i]>>vo[i];
        for(ll w=1;w<=W;w++){

            if((wo[i]<=w) && (vo[i]+V[i-1][w-wo[i]]>V[i-1][w]) ){
                V[i][w]=vo[i]+V[i-1][w-wo[i]];
                keep[i][w]=1;
            }
            else{
                V[i][w]=V[i-1][w];
                keep[i][w]=0;
            }
        }
    }
    ll K=W;
    /*
    for(ll i=n;i>=1;i--){
        if(keep[i][K]==1){
            cout<<i<<" ";
            K=K-wo[i];
        }
    }
    */
    cout<<V[n][W];

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


Measured memory_bytes: 158080
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

int n, m; // 道の数，街の数
int edges[10][10];

int dijkstra(int from, int to) {
    int visited[m];
    fill(visited, visited + m, 0xffffff);
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    que.push(make_pair(0, from));
    visited[from] = 0;
    while (!que.empty()) {
        pair<int, int> current = que.top();
        que.pop();
        const int dist = current.first;
        const int pos = current.second;
        if (pos == to) {
            return dist;
        }
        for (int i = 0; i < m; i++) {
            const int d = dist + edges[pos][i];
            if (visited[i] > d) {
                visited[i] = d;
                que.push(make_pair(d, i));
            }
        }
    }
    return -1;
}

int main() {
    while (cin >> n, n) {
        memset(edges, 0x3, sizeof(edges));
        
        m = 0;
        for (int i = 0; i < n; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            edges[a][b] = edges[b][a] = c;
            m = max(a, max(b, m));
        }
        m++;
        
        int res, res_time = 0x7fffffff;
        for (int i = 0; i < m; i++) {
            int total = 0;
            for (int j = 0; j < m; j++) {
                total += dijkstra(i, j);
            }
            if (total < res_time) {
                res_time = total;
                res = i;
            }
        }
        
        cout << res << ' ' << res_time << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A;cin>>A;
    cout<<A/3<<endl;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 3e5+5;
const int M = 11;

int n;
int m;
int A[N];
pair < int , int > Q[N];
int mx[N];
int stp[N];

bool cmp(pair < int , int > a , pair < int , int > b){
    if(a.first > b.first)
        return 1;
    if(a.first == b.first){
        if(a.second > b.second)
            return 1;
    }
    return 0;
}

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &A[i]);
    }
    sort(A + 1 , A + n + 1);
    /*for(int i = 1; i <= n; i++){
        cout << A[i] << " ";
    }
    cout << endl;*/
    for(int i = 1; i <= m; i++){
        int B , C;
        scanf("%d%d" , &B , &C);
        Q[i] = {C , B};
    }
    sort(Q + 1 , Q + m + 1 , cmp);
    int willstep = 1;
    for(int i = 1; i <= m; i++){
        int curB = Q[i].second;
        int curC = Q[i].first;
        if(willstep <= n){
            mx[willstep] = curC;
            stp[willstep] = curB;
            //cout << curC << " " << curB << " " << willstep << endl;
            willstep += curB;
            willstep = min(willstep , n + 1);
        }
    }
    int I = 0;
    for(int i = 1; i <= n; i++){
        if(mx[i] && !stp[I]){
            I = i;
        }
        if(stp[I] && A[i] < mx[I]){
            A[i] = mx[I];
            stp[I]--;
        }
    }
    long long sm = 0;
    for(int i = 1; i <= n; i++){
        sm += A[i];
    }
    printf("%lld\n" , sm);
}


Measured memory_bytes: 3456
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

N, K  = LI()
S = SI().strip()

print(S[:K-1] + S[K-1].lower() + S[K:])


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

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

    const int d = a / b;
    const int r = a % b;
    const double f = a / static_cast<double>( b );

    std::cout.setf( std::ios_base::fixed,std::ios_base::floatfield );
    std::cout << std::setprecision( 15 )
        << d << " " << r << " " << f
        << std::endl;

    return 0;
}

Measured memory_bytes: 1248
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int a = 0, b = 0, c = 0, d = 0;
        var key = new Scanner(System.in);
        var t = key.nextInt();
        for (int i = 0; i < t; i++) {
            String s = key.next();
            switch (s) {
                case "AC":
                    a++;
                    break;
                case "WA":
                    b++;
                    break;
                case "TLE":
                    c++;
                    break;
                case "RE":
                    d++;
                    break;
                default:
            }
        }
        System.out.println("AC x "+a);
        System.out.println("WA x "+b);
        System.out.println("TLE x "+c);
        System.out.println("RE x "+d);
    }
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;

ll gcd(ll a, ll b)
{
	ll m=min(a, b), M=max(a, b);
	if(m==0) return M;
	return gcd(m, M%m);
}

ll powmod(ll x, ll y)
{
	ll ans=1;
	while(y>0)
	{
		if(y%2) ans=(ans*x)%P;

		x=(x*x)%P;
		y/=2;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	ll n;
	cin>>n;
	ll ans=((powmod(10, n) + powmod(8, n))%P - (2*powmod(9, n))%P + P) % P;
	on(ans);
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

string Main(int a, int b, int c)
{
    if(a+b+c >= 22) {
        return "bust";
    }
    else {
        return "win";
    }
}

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    cout << Main(A, B, C) << endl;
    return 0;
}

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

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

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

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

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

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

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

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

void solve(long long A, long double B)
{
  LL BB = (int)(B * 100 + 0.001);
  cout << A * BB / 100 << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long double B;
  scanf("%Lf", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		int y = s.nextInt();
		while(x != 0 || y != 0){
			if(x < y){
				System.out.println(x + " " + y);
			}else{
				System.out.println(y +" "+x);
			}
			 x = s.nextInt();
			 y = s.nextInt();
		}
	}
	

}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int digit_sum(int n){
  if(n==0){
    return 0;
  }else{
    int res = 0;
    res = n%10;
    res += digit_sum(n/10);
    return res;
  }
}

int main(){
  
  int n;
  cin>>n;
  int b[n-1];
  REP(i,n-1){
    cin>>b[i];
  }
  vector<int> a(n,100010);
  REP(i,n-1){
    a[i] = min(a[i],b[i]);
    a[i+1] = min(a[i+1],b[i]);
  }
  int ans=0;
  REP(i,n){
    ans += a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int iINF = 100100100;
int main()
{
  int x,n,tmp;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  vector<int> comp(103),get;
  comp[0] = -1;
  for(int i = 1; i < 103; ++i) comp[i] = i - 1;
  rep(i,n) {
    cin >> tmp;
    get.push_back(tmp);
  }
  auto itr = comp.begin();
  bool er = false;
  while(itr != comp.end()) {
    er = false;
    rep(i,n) {
      if ((*itr) == get[i]) {
        itr = comp.erase(itr);
        er = true;
        break;
      }
    }
    if (!er) ++itr;
  }
  
  int ans = iINF;
  int diff = iINF;
  rep(i,comp.size()) {
    if (abs(x - comp[i]) < diff) {
      diff = abs(x - comp[i]);
      ans = comp[i];
    }
  }
  cout << ans << endl;
  
  return 0; 
}

Measured memory_bytes: 3632
h,w = map(int,input().split())
ans = h*w
for i in range(1,h):
    A = w*i
    if w%2 == 0 or (h-i)%2 == 0:
        B = ((h-i)*w)//2
        C = ((h-i)*w)//2
    else:
        if h-i <= w:
            B = (h-i)*((w//2)+1)
            C = (h-i)*(w//2)
        else:
            B = ((h-i)//2 + 1) * w
            C = ((h-i)//2) * w
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))

for i in range(1,w):
    A = h*i
    if (w-i)%2 == 0 or h%2 == 0:
        B = ((w-i)*h)//2
        C = ((w-i)*h)//2
    else:
        if w-i <= h:
            B = (w-i)*((h//2)+1)
            C = (w-i)*(h//2)
        else:
            B = ((w-i)//2 + 1) * h
            C = ((w-i)//2) * h
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))
print(ans)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b;
  cin>>a>>b;
  if(b%a==0) COUT(b+a);
  else COUT(b-a);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const int mod=1e9+7;
int n,m,fac[2000001],inv[2000001];
inline int C(int x,int y) {
	return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline int kuai(int p,int q,int mod) {int tot=1;for(;q;p=(ll)p*p%mod,q>>=1) if(q&1) tot=(ll)tot*p%mod;return tot;}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	if((2*n-m)%3||(2*m-n)%3||2*m-n<0||2*n-m<0) return cout<<0<<'\n',0;
	int now1=(2*n-m)/3,now2=(2*m-n)/3,now=now1+now2;
	fac[0]=1;for(res i=1;i<=now;++i) fac[i]=(ll)fac[i-1]*i%mod;
	inv[now]=kuai(fac[now],mod-2,mod);
	for(res i=now-1;~i;--i) inv[i]=(ll)inv[i+1]*(i+1)%mod;
	cout<<C(now1+now2,now1)<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,k,x,y,dis[N][N];
char s[N][N];
typedef pair<int,int> pii;
queue<pii> Q;
const int fx[4]={1,0,-1,0},fy[4]={0,1,0,-1};
int main()
{
scanf("%d%d%d",&n,&m,&k);
for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
if (s[i][j]=='S') x=i,y=j,s[i][j]='.';
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
dis[i][j]=1e9;
dis[x][y]=0;
int ans=1e9;
Q.push(pii(x,y));
while (!Q.empty()){
pii now=Q.front();Q.pop();
int x=now.first,y=now.second;
ans=min(ans,x-1);
ans=min(ans,y-1);
ans=min(ans,n-x);
ans=min(ans,m-y);
if (dis[x][y]==k) continue;
for (int i=0;i<4;i++){
int a=x+fx[i],b=y+fy[i];
if (s[a][b]!='.') continue;
if (dis[a][b]>dis[x][y]+1) dis[a][b]=dis[x][y]+1,Q.push(pii(a,b));
}
}
printf("%d\n",(ans+k-1)/k+1);
return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  bool b=true;
  int a[100000];
  rep(i,n){
    cin>>a[i];
    if(a[i]!=0) b=false;
  }
  if(b){cout<<"Yes"<<endl;return 0;}
  else{
    if(n%3!=0){cout<<"No"<<endl;return 0;}
    sort(a,a+n);
    vector<pair<int,int> > num;
    num.push_back(make_pair(a[0],(int)1));
    int p=0;
    repi(i,1,n){
      if(num[p].first==a[i]){
	num[p].second++;
      }else{
	num.push_back(make_pair(a[i],(int)1));
	p++;
      }
    }
    if(num.size() > 3){cout<<"No"<<endl;}
    else{
      if(num.size() ==3){
	if(num[0].scd==num[1].scd && num[1].scd==num[2].scd){
	  int xo=num[0].fst^num[1].fst;
	  xo^=num[2].fst;
	  if(xo==0){cout<<"Yes"<<endl;}
	  else cout<<"No"<<endl;
	}
	else cout<<"No"<<endl;
      }
      else if(num.size()==2){
	if(num[0].scd==num[1].scd*2 && num[1].fst==0){cout<<"Yes"<<endl;}
	else if(num[1].scd==num[0].scd*2 && num[0].fst==0){cout<<"Yes"<<endl;}
	else cout<<"No"<<endl;
      }
      else cout<<"No"<<endl;
    }
  }
    

  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> b(n-1);
    rep(i, 0, n-1) cin >> b[i];
    ll ans = b[0] + b[n-2];
    rep(i, 0, n-2){
        ans += min(b[i], b[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
struct Generator{
    int a, b, C, M;
    Generator(int A, int B){
        a = A, b = B, C = ~(1<<31), M = (1<<16)-1;
    }
    int generate() {
      a = 36969 * (a & M) + (a >> 16);
      b = 18000 * (b & M) + (b >> 16);
      return (C & ((a << 16) + b)) % 1000000;
    }
};

const int INF = 100000000;
typedef pair<int, int> Point;

void insert(int x, int y, set<Point>& s){
    const Point np(x, y);
    auto itr = s.lower_bound(np);
    if((--itr)->second <= y) return ;
    itr++;
    vector<Point> removes;
    while(itr->second >= y){
        removes.push_back(*itr);
        itr++;
    }
    for(Point p : removes){
        s.erase(p);
    }
    s.insert(np);
    /*
    for(auto p : s){
        printf("(%d, %d) ", p.first, p.second);
    }
    cout << endl;
    */
}

int main(){
    int M, N, A, B;
    const int MAX = 1000000;
    while(cin >> M >> N >> A >> B && (M + N) != 0){
        vector<vector<Point>> rect(MAX);
        for(int i = 0; i < M; i++){
            int x;
            Point p;
            cin >> x >> p.first >> p.second;
            rect[x].push_back(p);
        }
        Generator gen(A, B);
        for(int i = 0; i < N; i++){
            Point p;
            int x = gen.generate();
            p.first = gen.generate();
            p.second = gen.generate();
            rect[x].push_back(p);
        }

        vector<set<Point>> sets(N + M + 1);
        for(auto& s : sets){
            s.insert(Point(INF, -1));
            s.insert(Point(-1, INF));
        }

        int answer = 0;
        for(const vector<Point>& points : rect){
            vector<pair<int, Point>> querys;
            for(const Point& p : points){
                int x = p.first, y = p.second;
                int l = -1, r = answer + 1;
                while(r - l > 1){
                    int c = (l + r) / 2;
                    auto itr = sets[c].lower_bound(Point(x, -INF));
                    if((--itr)->second < y){
                        l = c;
                    }else{
                        r = c;
                    }
                }
                querys.emplace_back(r, p);
                answer = max(answer, r + 1);
            }
            for(const auto& query : querys){
                int k = query.first;
                Point p = query.second;
                //printf("%d (%d, %d)\n", k, p.first, p.second);
                insert(p.first, p.second, sets[k]);
            }
        }
        cout << answer << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 3e5 + 5;

int N, ans;

int gcd(int a, int b) {
	if(a < b) swap(a, b);
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) for(int k=1; k<=N; k++) ans += gcd(i, gcd(j, k));
	cout << ans;
}

Measured memory_bytes: 3652
use std::cmp::max;
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: i64 = sc.read();
    let x: i64 = sc.read();
    let d: i64 = sc.read();

    if d == 0 {
        if x == 0 {
            println!("1");
        } else {
            println!("{}", n + 1);
        }
        return;
    }

    let (x, d) = if d > 0 { (x, d) } else { (-x, -d) };

    let mut map = BTreeMap::new();
    map.insert(0, vec![(0, 0)]);
    for i in 1..(n + 1) {
        let add = (i * x) / d;
        let from = (i - 1) * i / 2 + add;
        let to = (n - 1 + n - i) * i / 2 + add;
        let mut m = (i * (x % d)) % d;
        if m < 0 {
            m += d;
        }
        map.entry(m).or_insert(Vec::new()).push((from, to));
    }

    let mut ans = 0;
    for (_, mut v) in map.into_iter() {
        v.sort();
        let (mut cur_from, mut cur_to) = v[0];
        for (from, to) in v.into_iter() {
            if cur_to < from {
                ans += cur_to - cur_from + 1;
                cur_from = from;
                cur_to = to;
            } else {
                cur_to = max(cur_to, to);
            }
        }

        ans += cur_to - cur_from + 1;
    }

    println!("{}", ans);

    // S = zX + yD
    // 0+1+2+...+(z-1) <= y <= (N-z) + (N-z+1) + ... + (N-1)
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 37116