akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s; cin >> s;
    if (s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# B - Colorful Creatures
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = 1
num = sum(A)
for i in range(0,N-1):
    num -= A[i]
    if num*2<A[i]:
        break
    ans += 1
print(ans)

Measured memory_bytes: 14320
#include<stdio.h>
#define N 100
#define INFTY 20000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int M[N][N];
int n;
int prim(){
  int color[N],d[N],p[N];
  int v,i,mincost,sum,u;

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    u=-1;
    mincost=INFTY;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost = d[i];
	u=i;
      }
    }
    if(u == -1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(M[u][v]<d[v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
    sum=0;
    for(i=0;i<n;i++)
      if(p[i]!=-1)
	sum+=M[i][p[i]];    
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf ("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  printf("%d\n",prim());
  return 0;
}
  

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=int64_t;

ll keisan(ll n,ll x) {
  if (0<=n) {
    return (n/x)+1;
  } else {
    return 0;
  }
}

int main() {
  ll a,b,x; cin >>a >>b >>x;
  ll ans=keisan(b,x)-keisan(a-1,x);
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 200010;
struct data {
    int x, y;
    bool operator < (const data & a) const { return y < a.y; }
} a[maxn];
int n;
int main()
{
    read(n);
    rep(i, 1, n) read(a[i].x), read(a[i].y);
    sort(a + 1, a + 1 + n);
    int cur = 0;
    rep(i, 1, n) {
        cur += a[i].x;
        if(cur > a[i].y) { puts("No"); return 0; }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1792
S = input()
N = len(S)

for i in range(1,N+1):   
    s = {x for x in S}
    for j in range(N+1-i):
        s &= {x for x in S[j:j+i]}
        if s==set():
            break
    else:
        break   
print(i-1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int a[100005];
#define R register int
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	for(R i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
	}
	int ans = 1e10;
	for(R i = 1; i + k - 1<= n; i++) {
		int temp;
		if(a[i] <= 0 && a[i + k - 1] <= 0)temp = abs(a[i]);
		else if(a[i] >= 0 && a[i + k - 1] >= 0)temp = a[i + k - 1];
		else temp = min(abs(a[i]),abs(a[i + k - 1])) * 2 + max(abs(a[i]),abs(a[i + k - 1]));
		ans = min(ans,temp);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

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

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

    int count = 0;

    if(s[0] == 'R') count++;
    if(s[1] == 'R') count++;
    if(s[2] == 'R' && s[1] == 'R') count++;
    if(s[2] == 'R' && count == 0) count++;

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3184
import math

a, b, c, d = map(int, input().split())
lcm = (c * d) // math.gcd(c, d)

a -= 1

x = a // c
y = a // d
z = a // lcm

ans1 = a - (x + y - z)

x = b // c
y = b // d
z = b // lcm

ans2 = b - (x + y - z)

print(ans2 - ans1)

Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A, B, K; cin >> A >> B >> K;
	repe(i, A, B) {
		if (i < A + K || i > B - K) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
test1 = A+B
test2 = A-B
test3 = A*B
if test1 >= test2 and test1 >= test3:
  print(test1)
elif test2 >= test1 and test2 >= test3:
  print(test2)
elif test3 >= test1 and test3 >= test2:
  print(test3)
	


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const long long MOD = 1e9 + 7;

class Combination {
    //a^p%mod
    ll powmod(ll a, ll p) {
        ll ans = 1LL;
        ll mul = a;
        // p >>=1 <-> p=(p >> 1)
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    ll mod;
    vector<ll> fact;
    vector<ll> revFact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    ll get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return move(ret);
};

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

  map<int,int> mp = prime_factor(M);
  /*r(auto itr=mp.begin();itr!=mp.end();itr++){
    cout << itr->first << " " << itr->second << endl;
  }*/

  Combination comb(100100,MOD);

  ll ans=1LL;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    int cnt = itr->second;

    ans*=comb.get(N+cnt-1,cnt);
    ans%=MOD;
  }

  cout << ans << endl;
}

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

int main(void){
    
    //A,Bを入力
    int A, B;
    cin >> A >> B;
    
    //3パターンのボタンの押し方を試し、獲得枚数の一番多いものを出力する
    int ans = 0;
    ans = max(ans, A + A - 1);
    ans = max(ans, B + B - 1);
    ans = max(ans, A + B);
    cout << ans << endl;
}

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

void trace(int A[],  int N) {
    for(int i = 0; i < N; i++) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for(i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int A[100], n;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    trace(A, n);
    insertionSort(A, n);
}

Measured memory_bytes: 1164
// inputに入力データ全体が入る
function main(input) {
	console.log(input.split('1').length - 1)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29560
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    string s,t;
    cin>>s>>t;
    cout<<t<<s;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int i, j;
	int x[10000];

	
	for (i = 0;; i++) {
			scanf("%d", &x[i]);
			if (x[i] == 0)
				break;
	}
	for (j = 0;i>0; j++,i--) {
		printf("Case %d: %d\n", j + 1, x[j]);
	}

	return 0;
}

Measured memory_bytes: 1892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>N>>S;
  char L=S.at(0);
  ans=1;
  for(int i=1; i<N; ++i){
    if(L!=S.at(i)){
      ans++;
      L=S.at(i);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int n, a[300010];
long long sleft[300010], sright[300010];

int main() {
	cin >> n;
	for (int i = 1; i <= 3 * n; i++) cin >> a[i];

	priority_queue< int, vector<int>, greater<int> >  q;
	long long s = 0;
	for (int i = 1; i <= 2 * n; i++) {
		q.push(a[i]);
		s += a[i];
		if (q.size() > n) {
			s -= q.top();
			q.pop();
		}
		sleft[i] = s;
	}

	priority_queue<int> pq;
	s = 0;
	for (int i = 3 * n; i >= n; i--) {
		pq.push(a[i]);
		s += a[i];
		if (pq.size() > n) {
			s -= pq.top();
			pq.pop();
		}
		sright[i] = s;
	}

	long long res = -1e15;
	for (int i = n; i <= 2 * n; i++) res = max(res, sleft[i] - sright[i + 1]);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5624
using System;

namespace AOJ.Volume0
{
    public class PhysicalExperiments
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                double v = float.Parse(input);
                // 必要なNを計算
                double N = ((v * v / 19.6) + 5) / 5;
                int ans = (int)Math.Ceiling(N);
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 5724
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int index,len, rem;
		String s,t,answer;
		
			// 整数の入力
		
		s = sc.next();
		sc.close();
		answer="Yes";
		len=s.length();
		LoopA: for(index=0;index<len;index++) {
			rem=index%2;
			if(rem==0) {
				if(s.substring(index,index+1).equals("R")) {
				}
				else if(s.substring(index,index+1).equals("U")) {
				}
				else if(s.substring(index,index+1).equals("D")) {
				}
				else {
					answer="No";
					break LoopA;
				}
			}	
			else {
				if(s.substring(index,index+1).equals("L")) {
				}
				else if(s.substring(index,index+1).equals("U")) {
				}
				else if(s.substring(index,index+1).equals("D")) {
				}
				else {
					answer="No";
					break LoopA;
				}
				
			}
		}
		System.out.print(answer);

			// 出力
 
	}
}	

Measured memory_bytes: 22740
module Main where
import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Data.Functor
import Control.Monad

solve :: [Int] -> [Int] -> String
solve d1 d2 = if checkFaces (setFace d2 [d1 !! 0, d1 !! 1]) d1 then "Yes" else "No" where
    checkFaces a = iter (indices a) where
        iter [] [] = True
        iter (i:xs) (j:ys) 
            | a!i == j = iter xs ys
            | otherwise = False

setFace :: [Int] -> [Int] -> Array Int Int 
setFace pl [t, f] = search where
        dice = listArray (0, 5) pl
        search = rollUntil 0 t "W" $ case dice of
            _   | dice!3 == f  -> roll "ES" dice
                | dice!2 == f  -> roll "WS" dice
                | otherwise -> rollUntil 1 f "S" dice
        roll [] d = d
        roll (c:cs) d = roll cs $ case c of
            'N' -> d // [(0, d!1), (1, d!5), (4, d!0), (5, d!4)]
            'E' -> d // [(0, d!3), (2, d!0), (3, d!5), (5, d!2)]
            'W' -> d // [(0, d!2), (2, d!5), (3, d!0), (5, d!3)]
            'S' -> d // [(0, d!4), (1, d!0), (4, d!5), (5, d!1)]
        rollUntil p x c = iter where
            iter d  | d!p == x = d
                    | otherwise = iter (roll c d)
                                
readLine:: IO [Int]
readLine = map read . words <$> getLine

main :: IO() 
main = do
    d1 <- readLine
    d2 <- readLine
    putStrLn (solve d1 d2)



Measured memory_bytes: 3728
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int input_number  = Integer.parseInt(scan.next());
    int input_number2 = Integer.parseInt(scan.next());
    if (input_number > input_number2) {
      System.out.println("a > b");
    } else if (input_number == input_number2) {
      System.out.println("a == b");
    } else {
      System.out.println("a < b");
    }
	}
}



Measured memory_bytes: 25880
#include<stdio.h>
#include <stdlib.h>

int min(int a, int b){
    return (a > b) ? b : a;
}
// int min_cost(int i, int h[]){
//     if(i == n-1)
//         return 0;
//     else if(i == n-2)
//         return abs(h[n-1]-h[n-2]);
//     else{
//         cost = min(h[i]-h[i+1]+cost[])
//     }
// }

int main(){
    int n, h[100007], cost[100007],i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    cost[n-1] = 0;
    cost[n-2] = abs(h[n-2]-h[n-1]);
    for(i=n-3;i>=0;i--){
        cost[i] = min(cost[i+1]+abs(h[i]-h[i+1]), cost[i+2]+abs(h[i]-h[i+2])); 
    }
    printf("%d\n", cost[0]);
    return 0;
}

Measured memory_bytes: 896
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	m := scanInt(sc)
	ps := make([]pos, n)
	cs := make([]pos, m)
	for i := range loop0(n) {
		ps[i] = pos{x: scanInt(sc), y: scanInt(sc)}
	}
	for i := range loop0(m) {
		cs[i] = pos{x: scanInt(sc), y: scanInt(sc)}
	}
	for _, j := range ps {
		min := math.MaxInt64
		minIdx := -1
		for i, c := range cs {
			v := dist(c, j)
			if min > v {
				min = v
				minIdx = i + 1
			}
		}
		fmt.Println(minIdx)
	}
	return
}

func dist(x, y pos) int {
	return abs(x.x-y.x) + abs(x.y-y.y)
}
func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

type pos struct{ x, y int }

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1812
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string w;
	cin >> w;

	map<char, int> character_num;
	for (int i = 0; i < w.size(); i++) {
		character_num[w[i]]++;
	}

	bool is_beautiful = true;
	for (auto &kv:character_num) {
		if (kv.second%2 != 0) {
			is_beautiful = false;
		}
	}

	if (is_beautiful) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N>>Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21752
N = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))

cnt = 0
for i in range(N):
    l =min(A[i],B[i])
    #A[i] -= l                       #残存モンスター数
    B[i] -= l                       #さらに勇者が倒せるモンスターの数
    cnt += l
    if B[i] > 0:                    #倒す余裕がある場合
        r = min(A[i+1],B[i])
        A[i+1] -= r                 #本来のA[i+1]から勇者が倒したモンスターrを引く
        B[i] -= r
        cnt += r
print(cnt)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9+7
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
 
 
int main(){
    int n,k;
    cin>>n>>k;
    double p[n];
    double a[n];
    rep(i,n){
        cin>>p[i];
        a[i]=(p[i]+1)/2;
    }
    vector<double> s(n+1,0);
    rep(i,n){
        s[i+1]=s[i]+a[i];
    }
    double ans=0;
    for(int i=0;i+k-1<n;i++){
        ans=max(ans,s[i+k]-s[i]);
    }
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 4992
from functools import reduce
from fractions import gcd
def lcm(x,y):return x*y//gcd(x,y)
def lcmm(l):return reduce(lcm,l)

N = int(input())

T = []
for i in range(N):
    t = int(input())
    T.append(t)

print(lcmm(T))

Measured memory_bytes: 64620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0<<endl;
		return 0;
	}
	ll ans=2,i;
	if(n==m){
		for(i=n;i>1;i--){
			ans*=i;
			ans%=1000000007;
		}
		for(i=n;i>1;i--){
			ans*=i;
			ans%=1000000007;
		}
	}
	else{
		ans=1;
		for(i=n;i>1;i--){
			ans*=i;
			ans%=1000000007;
		}
		for(i=m;i>1;i--){
			ans*=i;
			ans%=1000000007;
		}
	}
	
	cout<<ans<<endl;
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
char a[MAXN];

void work(){
    scanf("%s",a+1);
    int N=strlen(a+1);
    a[0]='0';
    int ans=0;
    int add=0;
    for(int i=N;i>=0;i--){
        int x=a[i]-'0';
        x+=add;
        int y=0;
        if(i>0) y=a[i-1]-'0';
        if(x<=4){
            ans+=x;
            add=0;
        }
        else{
            ans+=10-x;
            add=1;
            if(x==5&&y<=4){
                add=0;
            }
        }
    }
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main(){

    string s;
    int a, b;
    cin >> a >> b;
    cin >> s;

    bool done = true;

    for (int i = 0; i < s.size(); i++){
        if (i == a && s[i] == '-'){
            done = true;
        }
        else if (i == a){
            done = false;
            break;
        }
        else if (s[i] >= '0' && s[i] <= '9'){
            done = true;
        } 
        else {
            done = false;
            break;
        }
    }

    if (done) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a') {
    cout << "vowel" << endl;
  }
  else if (c == 'i') {
    cout << "vowel" << endl;
  }
  else if (c == 'u') {
    cout << "vowel" << endl;
  }
  else if (c == 'e') {
    cout << "vowel" << endl;
  }
  else if (c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = INF;
	for (int b = 0; b < 2; b++) {
		bool plus = b;
		ll sum = 0;
		ll cost = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			if (plus) {
				if (sum <= 0) {
					cost += 1 - sum;
					sum = 1;
				}
			}
			else {
				if (sum >= 0) {
					cost += sum + 1;
					sum = -1;
				}
			}
			plus ^= 1;
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
}

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

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << (min(A, B) + min(C, D)) << endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll x;
    cin >> n >> x;;
    ll r = 0;
    ll past;
    cin >> past;
    if(past > x) {
        r += past - x;
        past = x;
    }
    for(int i=1; i<n; i++) {
        ll a;
        cin >> a;
        ll d = past + a - x;
        if(d > 0) {
            r += d;
            a -= d;
        }
        past = a;
    }
    cout << r << endl;

}

Measured memory_bytes: 384
local n, y = io.read("*n", "*n")

local result = {-1, -1, -1}
for i = 0, n do
    for j = 0, n - i do
        local k = n - i - j
        if 10000*i + 5000*j + 1000*k == y then
            result[1], result[2], result[3] = i, j, k
        end
    end
end

print(table.concat(result, " "))

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int n;
  cin >> n;
  int Amax = INT_MIN;
  vector<int> A(n);
  for (int& Ai : A) {
    cin >> Ai;
    Amax = max(Amax, Ai);
  }
  // sort(A.begin(), A.end());

  // dp[i] = true  -> A contains none of the divisors of i less than i.
  // vector<bool> dp(Amax, true);
  vector<int> table(Amax + 1);

  for (int Ai : A) {
    for (int e = Ai; e <= Amax; e += Ai) {
      table[e]++;
    }
  }

  int ret = 0;
  for (int Ai : A) {
    if (table[Ai] == 1) ++ret;
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 8016
n = int(input())
kokuban = list(map(int,input().split()))

min = 100000000000000000
for i in range(n):
  tmp = kokuban[i]
  atta = 0
  while tmp%2==0:
    atta += 1
    tmp //= 2
  if min > atta:
    min = atta
print(min)





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

using namespace std;

int ans,vis=1,n;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x==vis) vis++,ans++;
	}
	if(ans==0) cout<<-1<<endl;
	else cout<<n-ans<<endl;
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

int x,y,n,ans,fl,a[305][305];
char s[355];

int main()
{
	n=read();
	for(int i=1; i<=n; ++i){
		scanf("%s",s+1);
		for(int j=1; j<=n; ++j)a[i][j]=s[j]-'a';
	}
	
	for(int d=-n+1; d<n; ++d){
		fl=1;
		for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j){
			x=j+d;
			y=i-d;
			if(x>n)x-=n;
			if(y<=0)y+=n;
			if(x<=0)x+=n;
			if(y>n)y-=n;
			if(a[x][y]!=a[i][j]){
				fl=0;
				break;
			}
		}
		if(fl){
			if(d>=0)ans+=n-d;
			else ans+=n+d;
//			if(!d)ans+=n;
//			else ans+=(n-d)<<1;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
h, w = map(int, input().split())
a = [""]*h
for i in range(h):
  a[i] = input().split()

for i in range(h):
  for j in range(w):
    if a[i][j] == "snuke":
      print("{}{}".format(chr(65+j), str(i+1)))
      exit()

Measured memory_bytes: 3060
A,B,C,K=list(map(int,input().split()))
nokori=K
maisu1=0
maisu2=0
maisu3=0
while True:
    if A<=nokori:
        maisu1=A
        nokori=nokori-maisu1
    else:
        maisu1=nokori
        break

    if B<=nokori:
        maisu2=B
        nokori=nokori-maisu2
    else:
        maisu2=nokori
        break
    
    maisu3=nokori
    break

print(maisu1-maisu3)

Measured memory_bytes: 9212
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let config: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp
    };
    let mut max;
    let mut min;
    if config[1] + config[2] > config[0] {
        min = config[1] + config[2] - config[0];
    } else {
        min = 0
    }
    max = {
        if config[1] < config[2] {
            config[1]
        } else {
            config[2]
        }
    };
    println!("{} {}", max, min);
}


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



int main(){
  int i,j;
  int H, W; // 入力用整数
  cin >> H >> W;
  // 入力用 Bool型 2次元配列
  bool ** arr = new bool *[H];
  for(i = 0;i < H;i++){
    arr[i] = new bool[W];
  }
  // 黒が出てきたか記録
  bool *xs = new bool[H];
  bool *ys = new bool[W];
  // 初期化
  for(i = 0;i < H;i++){
    xs[i] = false;
  }
  for(i = 0;i < W;i++){
    ys[i] = false;
  }

  char s;
  for(i = 0;i < H;i++){
    for(j = 0;j < W;j++){
      cin >> s;
      if(s == '.'){ // (i, j) が白の場合
        arr[i][j] = false;
      }
      else{ // (i, j) が黒の場合
        arr[i][j] = true;
        xs[i] = true; // xsに記録
        ys[j] = true; // ysに記録
      }
    }
  }
  for(i = 0;i < H;i++){
    if(xs[i]){ // 黒がある場合(消されないもの)
      for(j = 0;j < W;j++){
        if(ys[j]){ // 黒がある場合(消されないもの)
          if(arr[i][j]){
            cout << '#';
          }
          else{
            cout << '.';
          }
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
y //= 1000
c = -1
for i in range(min(n,y)+1):
    if (y - i) % 5 != 0: continue
    if n - i <= (y - i)/5 and (y - i)/5 <= 2*(n - i):
        c = i
        break
if c == -1:
    print(-1,-1,-1)
else:
    a = (y-c)//5 - n + c
    b = n - a - c
    print(a,b,c)

Measured memory_bytes: 39664
#include<stdio.h>

int main()
{
  int a,b,c,count,i;
  scanf("%d %d %d", &a, &b, &c);
  for (i = a; i <= b; i++) {
    if (c%i==0) {
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    int ans=1;
    int max=1;
    int pre_ans=1;
    for(int i=2;i<=n;i++){
        ans=i*i;
        while(ans<=n){
            pre_ans=ans;
            ans*=i;
        }
        if(pre_ans>max)max=pre_ans;
    }
    cout << max << endl;
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 1e9 + 3;
const ll Log = 35;

vector<pll> V, V0;

ll dp[Log];

bool CMP(pll a, pll b){
	return a.S * b.F < a.F * b.S;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, t;
	cin >> n >> t;
	ll a, b;	
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		b += a + 1;
		if(a == 0) V0.pb({a, b});
		else V.pb({a, b});
	}
	sort(all(V0));
	sort(all(V), CMP);
	fill(dp, dp + Log, Inf);
	dp[0] = 0;
	for(auto x : V){
		a = x.F;
		b = x.S;
		for(int i = Log - 1; i > 0; i--){
			dp[i] = min(dp[i], (a + 1) * (dp[i - 1]) + b);
		}
	}
	ll ans = 0;
	for(int i = 0; i < Log; i++){
		if(dp[i] > t) continue;
		ll res = i;
		ll T = dp[i];
		for(auto x : V0){
			if(T + x.S <= t){
				res ++;
				T += x.S;
			}
		}
		ans = max(ans, res);
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6512
A, B, C = [int(i) for i in input().split()]

five = 0
seven = 0
for x in [A, B, C]:
    if x == 5:
        five += 1
    elif x == 7:
        seven += 1

ans = five == 2 and seven == 1

print("YES" if ans else "NO")
print()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a[3],b[3],p=0;
    rep(i,3)cin>>a[i];
    rep(i,3)cin>>b[i];
    if(a[0]>b[0])rep(i,3)swap(a[i],b[i]);
    else if(a[0]==b[0]&&a[1]>b[1])rep(i,3)swap(a[i],b[i]);
    else if(a[0]==b[0]&&a[1]==b[1]&&a[2]>b[2])rep(i,3)swap(a[i],b[i]);
    if(a[1]<b[1])p++;
    if(a[1]==b[1]&&a[2]<b[2])p++;
    cout<<b[0]-a[0]+p<<endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s, t;
	int ans=INF;
	int cnt = 0;
	cin >>s>>t;
	for (int i = 0; i < s.size() - t.size()+1;i++){
		cnt = 0;
		rep(j, t.size()) { cnt += (t[j] != s[i + j]); }
		chmin(ans, cnt);
	//	clog << cnt << endl;
	} cout << ans << endl;
}

Measured memory_bytes: 3616
#![allow(unused_imports)]
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
    }

    let mut ans = vec![0; n + 1];
    for x in 1..100 {
        if x * x > n {
            break;
        }
        for y in x..100 {
            if x * x + y * y + x * y > n {
                break;
            }
            for z in y..100 {
                let v = d(x, y, z);
                if v <= n {
                    if x == y && y == z {
                        ans[v] += 1;
                    } else if x == y || y == z {
                        ans[v] += 3;
                    } else {
                        ans[v] += 6;
                    }
                } else {
                    break;
                }
            }
        }
    }
    for k in 1..=n {
        println!("{}", ans[k]);
    }
}

fn d(x: usize, y: usize, z: usize) -> usize {
    x * x + y * y + z * z + x * y + y * z + z * x
}


Measured memory_bytes: 2184
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vector<int> depth(N, -1);
    function<pair<int, int>(int, int, int)> dfs = [&](int v, int p, int d) {
      depth[v] = d;
      int cnt = 1;
      bool oddloop = false;
      for (int u : G[v]) {
        if (u == p) continue;
        if (depth[u] != -1) {
          oddloop |= (d - depth[u]) % 2 == 0;
        } else {
          auto ch = dfs(u, v, d + 1);
          cnt += ch.first;
          oddloop |= ch.second;
        }
      }
      return make_pair(cnt, oddloop);
    };
    ll sum = 0, oddloop = 0, trivial = 0;
    for (int i = 0; i < N; i++) {
      if (depth[i] != -1) continue;
      auto res = dfs(i, -1, 0);
      if (res.first == 1) continue;
      sum += res.first;
      if (res.second) {
        ++oddloop;
      } else {
        ++trivial;
      }
    }
    ll res = 1ll * N * N - sum * sum;
    res += 2 * (oddloop + trivial) * (oddloop + trivial) -
           2 * oddloop * (oddloop + trivial) + oddloop * oddloop;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int m, d; cin >> m >> d;
	int ans = 0;
	int a = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			a = j;
			int tmp = a % 10;
			a = a / 10;
			if (tmp >= 2 && a >= 2 && tmp*a == i) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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


void solve(long long N, std::vector<long double> x, std::vector<std::string> u){
  long double acc = 0;
  for(long long i = 0; i < N; i++){
    if(u[i] == "BTC"){
      acc += (x[i] * 380000.0);
    }
    else{
      acc += x[i];
    }
  }

  cout << std::fixed << std::setprecision(20) << acc << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long double> x(N);
  std::vector<std::string> u(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%Lf",&x[i]);
    std::cin >> u[i];
  }
    solve(N, std::move(x), std::move(u));
    return 0;
}


Measured memory_bytes: 3812
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long int a[n];
  long long int c = 1;
  long long int count = 0;
  cin >> a[0];
  count = a[0]-1;
  a[0] = 1;
  for(int i=1;i<n;i++){
    cin >> a[i];
      if(c+1==a[i])
	c = a[i];
      else if(c+1<a[i]){
	count += a[i]/(c+1);
	a[i] %= (c+1);
	if(a[i]==0) count--;
      }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

void clockman(int time1) {
	
	cout << 1.0*(clock() - time1)/CLOCKS_PER_SEC<< endl;
	return;
}

int main()
{	
	int n;
	cin >> n;
	int k = n % 10;
	if (k == 2 || k == 4 || k == 5 || n == 7 || k == 9)cout << "hon" << endl;
	else if (k == 3)cout << "bon" << endl;
	else cout << "pon" << endl;
	
	return 0;
}



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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  vector<llong> a(n);

  int even = 0;
  REP(i,n){
    cin >> a[i];
    if(a[i] % 2 == 0){
      even++;
    }
  }
  if(even != n){
    cout << "first" << endl;
  }else{
    cout << "second" << endl;
  }

  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n,m;
    long long ans = 0;
    cin >> n >> m;
    vector<int> x(m),sa(m-1);
    for(int i = 0;i < m;i++) cin >> x[i];
    sort(x.begin(),x.end());
    for(int i = 0;i < m-1;i++){
        sa[i] = (x[i+1]-x[i]);
    }
    sort(sa.begin(),sa.end(),greater<int>());
    for(int i = n-1;i < m-1;i++){
        ans += sa[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024