akhauriyash/Code-Regression huggingface dataset:
(let ((n (read-line)))
     (if (or (equal (aref n (1- (length n))) #\2)
             (equal (aref n (1- (length n))) #\4)
             (equal (aref n (1- (length n))) #\5)
             (equal (aref n (1- (length n))) #\7)
             (equal (aref n (1- (length n))) #\9))
         (format t "hon")
         (if (or (equal (aref n (1- (length n))) #\0)
                 (equal (aref n (1- (length n))) #\1)
                 (equal (aref n (1- (length n))) #\6)
                 (equal (aref n (1- (length n))) #\8))
             (format t "pon")
             (format t "bon"))))

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

int m, x, y;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		cin >> m >> x >> y;
		if(m == 0 && x == 0 && y == 0) return 0;
		vector<int> p;
		readVector(m, p);
		int tmp = 0, ans = 0;
		for(int i=1; i<m; ++i){
			if(x <= i && i <= y && p[i-1] - p[i] >= tmp){
				ans = i;
				tmp = p[i-1] - p[i];
			}
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3112
# ある学校には、N人の生徒がいます。
# 生徒たちをいくつかのグループに分け、グループごとにあるテーマについて話し合ってもらうこととなりました。
# あなたは、2人以下のグループだと効果的な話し合いが出来ないと考えており、なるだけ多くのグループを
# 3人以上にしたいです。生徒たちを上手く分けて、3人以上のグループの数を最大化してください。

# 標準入力から生徒数 N を取得する
input_num = int(input())

# 取得した N人から、3人以上のグループが最大数になるよう算出して出力する
result = int(input_num / 3)
print(result)


Measured memory_bytes: 9052
#include<stdio.h>
int main()
{
	int n;
	char s[100];
	int x=0,i,c=0;
	scanf("%d %s",&n,s);
	if(n%2!=0){
		printf("No\n");
	}
	else{
		x=n/2;
		for(i=0;i<x;i++){
			if(s[i]==s[i+x]) c++;
		}
		if(c==x){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	ll l, r; cin>>l>>r;
	ll dp[2][2][60]={};
	for(int i=0; i<60; i++){
		if(l>=(1ll<<(i+1)) || r<(1ll<<i)) continue;
		int p=0, q=0;
		if((1ll<<i)>l) p=1;
		if(r>=(1ll<<(i+1))) q=1;
		dp[p][q][i]=1;
	}
	for(int i=59; i>=1; i--){
		(dp[1][1][i-1]+=3*dp[1][1][i])%=MOD;
		if((r&(1ll<<(i-1)))==0){
			(dp[1][0][i-1]+=dp[1][0][i])%=MOD;
		}else{
			(dp[1][1][i-1]+=dp[1][0][i])%=MOD;
			(dp[1][0][i-1]+=2*dp[1][0][i])%=MOD;
		}
		if((l&(1ll<<(i-1)))!=0){
			(dp[0][1][i-1]+=dp[0][1][i])%=MOD;
		}else{
			(dp[1][1][i-1]+=dp[0][1][i])%=MOD;
			(dp[0][1][i-1]+=2*dp[0][1][i])%=MOD;
		}
		if((r&(1ll<<(i-1)))==0 && (l&(1ll<<(i-1)))!=0){
			
		}else if((r&(1ll<<(i-1)))==0){
			(dp[0][0][i-1]+=dp[0][0][i])%=MOD;
		}else if((l&(1ll<<(i-1)))!=0){
			(dp[0][0][i-1]+=dp[0][0][i])%=MOD;
		}else{
			(dp[0][1][i-1]+=dp[0][0][i])%=MOD;
			(dp[1][0][i-1]+=dp[0][0][i])%=MOD;
			(dp[0][0][i-1]+=dp[0][0][i])%=MOD;
		}
	}
	ll ans=0;
	for(int i=0; i<2; i++) for(int j=0; j<2; j++) (ans+=dp[i][j][0])%=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
} 
int main() {
   int n,m;cin>>n>>m;
   vector<P> p(m);
   rep(i,m){
       cin>>p.at(i).second>>p.at(i).first;
   }
   sort(ALL(p));
   ll hoji= -1*INF;
   int ans=0;
   rep(i,m){
       if(hoji<=p.at(i).second){hoji=p.at(i).first;ans++;}
   }
   cout<<ans<<endl;
}

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


int main(){

    
    int n, t, i;

    vector<int> a4, a2, a0;


    cin >> n;

    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> t;

         if( t % 4 == 0 ) a4.push_back(t);

         else if( t % 2 == 0 ) a2.push_back(t);

         else a0.push_back(t);

         }


    if( a2.size() == 0 ){

        if( a4.size() >= a0.size() || a4.size() + 1 == a0.size() ) cout << "Yes" << endl;

        else cout << "No" << endl;

        }

    else{

          if( a4.size() >= a0.size() ) cout << "Yes" << endl;

          else cout << "No" << endl;

        }



    return 0;

    }


Measured memory_bytes: 1012
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()


using namespace std;

int A, B;

int N, M,C,D;


int main(){
	cin >> N;
	vector <int> AAA(N);
	
	rep(i, N) cin >> AAA[i];
	
	int res = 0;

	rep(i, N) {
		while(AAA[i] % 2 == 0) {
			AAA[i] = AAA[i] / 2; //6-3 stop 
			res++;
		}
	}
		cout << res;



}
		
		




Measured memory_bytes: 256
//diverta22019_b.cpp
//Sat Jun 15 20:50:04 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
int n;
vector<P> dot;

int main(){
	cin >> n;

	for (int i=0;i<n;i++){
		ll first,second;
		cin >> first >> second;
		P temp = make_pair(first,second);
		dot.push_back(temp);
	}
	if (n==1){
		cout << 1 << endl;
		return 0;
	}
	sort(dot.begin(),dot.end());

	vector<P> difs;
	for (int i=0;i<n-1;i++){
		for (int j=i+1;j<n;j++){
			P temp;
			temp.first = dot[j].first-dot[i].first;
			temp.second = dot[j].second-dot[i].second;
			difs.push_back(temp);
		}
	}

	sort(difs.begin(),difs.end());
	ll first = difs[0].first;
	ll second = difs[0].second;
	int count = 1;
	int final = 1;
	ll finalfirst = first;
	ll finalsecond = second; 
	for (int i=1;i<difs.size();i++){
		if (difs[i].first == first &&
			difs[i].second == second){
			count++;
		}else {
			if (final<count){
				final = count;
				finalfirst = difs[i-1].first;
				finalsecond = difs[i-1].second;
			}
			count = 1;
			first = difs[i].first;
			second = difs[i].second;
		}
	}

	cout << n-final << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if not arr:
        arr.append([n, 1])
    return arr


def solve():
    N = int(rl())
    
    counter = defaultdict(int)
    for x in range(1, N + 1):
        facts = factorization(x)
        for fact, exp in facts:
            counter[fact] += exp
    
    M = len(counter.keys())
    nums = tuple(counter.values())
    div75 = (1, 3, 5, 15, 25, 75)
    dp = [[0] * 76 for _ in range(M + 1)]
    dp[0][1] = 1
    for i in range(M):
        for div0 in div75:
            for div1 in div75:
                if div0 * div1 <= 75 and div1 <= nums[i] + 1:
                    dp[i + 1][div0 * div1] += dp[i][div0]
    print(dp[M][75])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9728
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {
	long long ans = 0;
	int num = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			num++;
		}
		else if (s[i] == 'W') {
			ans += num;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

using Int = int;

struct ModInt {
    static constexpr Int mod = 1e9 + 7;
    Int v;

    ModInt(long long _v = 0) : v(set(_v)) {}
    ModInt(const ModInt &r) : v(set(r.v)) {}

    inline static Int set(const auto x) { return x < 0 ? (x % mod) + mod : x % mod; }
    inline void set() { v = set(v); }

    bool operator<(ModInt r) const { return v < r.v; }
    bool operator>(ModInt r) const { return r.v < v; }
    bool operator==(ModInt r) const { return v == r.v; }
    bool operator!= (ModInt r) const { return v != r.v; }

    ModInt operator-() const { return ModInt(v ? mod - v : v); }
    ModInt &operator=(const ModInt &r) { if (this != &r) v = set(r.v); return *this; }
    ModInt &operator+=(ModInt r) { (v += r.v) %= mod; return *this; }
    ModInt &operator-=(ModInt r) { (v -= r.v - mod) %= mod; return *this; }
    // ModInt &operator*=(ModInt r) { v = (__uint128_t(v) * r.v) % mod; return *this; }
    ModInt &operator*=(ModInt r) { v = 1ULL * v * r.v % mod; return *this; }
    ModInt &operator/=(ModInt r) { *this *= r.inv(); return *this; }
    ModInt operator+(ModInt r) const { return ModInt(*this) += r; }
    ModInt operator-(ModInt r) const { return ModInt(*this) -= r; }
    ModInt operator*(ModInt r) const { return ModInt(*this) *= r; }
    ModInt operator/(ModInt r) const { return ModInt(*this) /= r; }

    ModInt inv() const {
        long long a = v, b = mod, u = 1, w = 0;
        while (b) {
            long long t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * w, w);
        }
        return ModInt(u);
    }

    ModInt pow(Int e) {
        ModInt a = *this, x(1);
        for ( ; 0 < e; e >>= 1) { if (e & 1) x *= a; a *= a; }
        return x;
    }
    inline ModInt pow(ModInt &e) { return pow(e.v); }
};
std::ostream &operator<<(std::ostream &os, const ModInt &r) { return os << r.v; }
std::istream &operator>>(std::istream &is, ModInt &r) { is >> r.v; r.set();return is; }

ModInt Factorial(int n) {
    ModInt fact = n;
    while (--n) fact *= n;
    return fact;
}
inline ModInt InvFactorial(int n) { return Factorial(n).inv(); }

ModInt Permutation(int n, int k) {
    if (k < 0 || n < k) return ModInt(0);
    ModInt p = 1;
    for (int i = 1; i <= k; ++i) p *= n--;
    return p;
}
ModInt Choose(int n, int k) {
    if (n < 0 || k < 0 || n < k) return ModInt(0);
    k = std::min(k, n - k);
    ModInt p = 1, q = 1;
    for (int i = 1; i <= k; ++i) {
        p *= n--;
        q *= i;
    }
    return p / q;
}
ModInt MultiChoose(const int n, const int k) {
    if (n < 0 || k < 0) return ModInt(0);
    else return k == 0 ? 1 : Choose(n + k - 1, k);
}

ModInt Solve() {
    int n, m;
    cin >> n >> m;
    if (1 < abs(n - m)) return 0;

    ModInt res;
    if (n <= m) res = Factorial(n) * Factorial(m);
    if (m <= n) res += Factorial(n) * Factorial(m);

    return res;
}

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

    cout << Solve() << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	int d = 0;
	int t = n;
	while(t > 0){
		d += t % 10;
		t /= 10;
	}

	if(n % d == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> A(N);
  rep(i,N) cin >> A[i];

  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      ans = max(ans, abs(A[i] - A[j]));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
import math

n, a, b = map(int, input().split())


def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c


mod = 10**9+7

ans = pow(2, n, mod)
ans -= 1
ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)

while ans<0:
    ans+=mod
    
print(ans)

Measured memory_bytes: 3188
import * as fs from 'fs';

export function Main(input: string) {
    const lines = input.split('\n');    // ?
    const k = parseInt(lines[0]);   // ?
    const [a, b] = lines[1].split(' ').map(int => parseInt(int));   // ?

    let result = 'NG';
    for (let i = ~~(a / k) * k; i <= b; i += k) {
        if (i >= a) {
            result = 'OK';
            break;
        }
    }

    //output

    console.log(result);
}

// Don't edit this line!
Main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29684
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int K;
    int X;
    cin >> K >> X;
    int L = -1000 * 1000;
    int R = 1000 * 1000;

    L = max(L, X - K + 1);
    R = min(R, X + K - 1);

    for (int i = L; i <= R; ++i) {
        cout << i << (i == R ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 1;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] lens = new int[n];
		for(int i=0; i<n; i++){
			lens[i] = sc.nextInt();
		}

		int[] where = new int[n + 1];
		where[0] = 0;
		for(int i=0; i<n; i++){
			where[i + 1] = where[i] + lens[i];
			if(where[i + 1] <= x){
				ans++;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Stack{
    private:
        int top = 0;

    public:
        int stck[1000];
        void push(int x);
        int pop();
        bool is_empty();
        bool is_full();
};

void Stack::push(int x){
    top++;
    stck[top] = x;
}

int Stack::pop(){
    top--;
    return stck[top + 1];
}

bool Stack::is_empty(){
    if (top == 0)
        return true;
    else
        return false;
}

bool Stack::is_full(){
    if (top == 100)
        return true;
    else
        return false;
}

int main(){
    Stack rpn;
    int a, b;
    char s[100];
    while (cin>>s){
        if (s[0] == '+'){
            a = rpn.pop();
            b = rpn.pop();
            rpn.push(a + b);
        }
        else if (s[0] == '-'){
            b = rpn.pop();
            a = rpn.pop();
            rpn.push(a - b);
        }
        else if (s[0] == '*'){
            a = rpn.pop();
            b = rpn.pop();
            rpn.push(a * b);
        }
        else{
            rpn.push(atoi(s));
        }
    }
    cout << rpn.pop() << endl;
}


Measured memory_bytes: 3112
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [a,b,h,m] = spi[0].split(' ').map(e => parseInt(e));
    const sho = h * 30 + m * 0.5;
    const lon = 6 * m;
    const kakudo = sho - lon;
    const ans = a * a + b * b - 2 * a * b * Math.cos(Math.PI / 180 * kakudo);
    console.log(Math.sqrt(ans));
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30560
#include <bits/stdc++.h>
using namespace std;
char s[100 + 5][100 + 5];
int main(){
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin>>s[i];
	}
	for(int i = 1;i <= n;i++){
		for(int j = i + 1;j <= n;j++){
			if(strcmp(s[i],s[j]) == 0){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	char ch = s[1][strlen(s[1]) - 1];
	for(int i = 2;i <= n;i++){
		char ch1 = s[i][0];
		if(ch != ch1){
			cout<<"No"<<endl;
			return 0;
		}
		ch = s[i][strlen(s[i]) - 1];
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int x, a, b, c, d;
int recive;
int main() {
	scanf("%d", &recive);
	a = recive / 1000;
	b = (recive - a * 1000) / 100;
	c = (recive - a * 1000 - b * 100) / 10;
	d = recive - a * 1000 - b * 100 - c * 10;


	int num = 0;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				num = a;
				if(i) {
					num += b;
				}
				else {
					num -= b;
				}
				if(j) {
					num += c;
				}
				else {
					num -= c;
				}
				if(k) {
					num += d;
				}
				else {
					num -= d;
				}
				if(num == 7) {
					printf("%d", a);
					if(i) {
						printf("+");
					}
					else {
						printf("-");
					}
					printf("%d", b);
					if(j) {
						printf("+");
					}
					else {
						printf("-");
					}
					printf("%d", c);
					if(k) {
						printf("+");
					}
					else {
						printf("-");
					}
					printf("%d", d);
					printf("=7\n");
					return 0;
				}
			}
		}
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

struct edge {
    int from, to;
    ll cost;
};

class BellmanFord {
    int V;
    int E;
    vector<edge> edges;
    vector<ll> dist;
    vector<bool> negative;

public:
    BellmanFord(int v, int e) : V(v), E(e), negative(v) {
        dist.resize(V, INF);
    }

    void add_edge(int from, int to, ll cost) {
        edges.push_back({from, to, cost});
    }

    ll get_total_cost(int v) {
        return dist[v];
    }

    // v に到達するまでに負ループがあるかを検出する
    bool is_negative(int v) {
        return negative[v];
    }

    // ベルマンフォード法の実行・全辺の負閉路を検出 trueを返す時に負閉路を含む
    bool exec() {
        bool updated = false;
        dist[0] = 0;
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    dist[edge.to] = dist[edge.from] + edge.cost;
                    if (i == V - 1) updated = true;
                }
            }
        }

        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < E; ++j) {
                edge edge = edges[j];
                if (dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost) {
                    negative[edge.to] = true;
                }
                if (negative[edge.from]) {
                    negative[edge.to] = true;
                }
            }
        }
        return updated;
    }
};

void Main() {
    int N, M;
    cin >> N >> M;
    BellmanFord bellmanFord(N, M);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        bellmanFord.add_edge(a, b, -c);
    }
    bellmanFord.exec();

    if (bellmanFord.is_negative(N - 1)) {
        cout << "inf" << '\n';
    } else {
        cout << -bellmanFord.get_total_cost(N - 1) << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
n=int(input())
a=[i for i in range(n+1) if i%2==1]
def cal(k):
  num=0
  for l in range(1,k+1):
    if k%l==0:
      num+=1
  return num
    
ans=0
for j in range(len(a)):
  if cal(a[j])==8:
    ans+=1
print(ans)

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

int main() {
    int n, sum = 0, mx = 0;
    scanf("%d", &n);
    for(int x, i = 1; i <= n; ++i) {
        scanf("%d", &x);
        sum += x;
        mx = std::max(mx, x);
    }
    if(mx < sum - mx) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for _ in range(n+1)]

for _ in range(n-1):
    a, b, c = map(int,input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])

q, k = map(int, input().split())
d = [0] * (n+1)

def dfs(x, c, p):
    global tree
    d[x] = c
    for l, c_ in tree[x]:
        if l == p:
            continue
        else:
            dfs(l, c_+c, x)

dfs(k, 0, -1)
for i in range(q):
    a, b = map(int, input().split())
    print(d[a]+d[b])



Measured memory_bytes: 137932
#include <cstdio>
#include <cmath>

#define PI 3.1415926535898
#define ANGLE (PI/180.0)
int main() {
  int step,dir;
  double x=0.0, y=0.0, angle=0.0;
  
  while(1){
    scanf("%d,%d", &step, &dir);
    if(step==0 && dir==0) break;
    x += (double)(step) * sin(angle * ANGLE);
    y += (double)(step) * cos(angle * ANGLE);
    angle += (double)dir;
  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

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

int main() {
  int A, B;
  scanf("%d%d", &A, &B);

  if ((A + B) % 2 == 0) {
    printf("%d", (A + B) / 2);
  } else {
    printf("IMPOSSIBLE");
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace AtCoder_B___Echo
{
    class Program
    {
        const string yes = "Yes";
        const string no = "No";
        static void Main(string[] args)
        {
            string length = Console.ReadLine();
            string s = Console.ReadLine();
            int halflength = s.Length / 2;
            Console.WriteLine(s.Take(halflength).SequenceEqual(s.Skip(halflength)) ? yes : no);
        }
    }
}


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

int main(){
	char arr[4];
	
	cin>>arr;
	int num=0;
	for(int i=0;i<3;i++){
		if(arr[i]==arr[i+1]){
			num=1;
			break;
		}
	}
	
	if(num==1){
		printf("Bad\n");
	}else{
		printf("Good\n");
	}
	
	return 0;
}




















 

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int a, b, x; cin >> a >> b >> x;
    if(a <= x && a + b >= x) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
# 参考 : https://atcoder.jp/contests/abc165/submissions/16921279
# 参考 : https://atcoder.jp/contests/abc165/submissions/16832189
from collections import deque
n,m,q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(q)]
a,b,c,d = [list(i) for i in zip(*l)]
# 数列 A の基(最初は1を入れておく)
queue = deque([[1]])
ans = 0
# 数列 A の候補がなくなる(キューが空になる)まで探索
while queue:
    # 数列 A を前から一つ取り出す
    x = queue.popleft()
    # 数列 A が長さ N か
    if len(x) == n:
        s = 0
        # 実際に何点取得できるか
        for i in range(q):
            if x[b[i]-1] - x[a[i]-1] == c[i]:
                s += d[i]
        ans = max(ans,s)
    else:
        # 違う場合、後ろに数字を付け足す
        # 付け足す数字は取り出した数列 A の一番後ろの値から M まで
        # 最終的に長さが 1 , 2 ... N となり、if の条件を満たすようになる
        for j in range(x[-1],m+1):
            y = x + [j]
            queue.append(y)
print(ans)
# 制約
# 2 <= N <= 10
# 1 <= M <= 50
# 1 <= Q <= 50
# なのでこの探索は間に合う
# 入力例 1 は A[1,3,4]
# 入力例 2 は A[1,1,1,4]
# 入力例 3 は A[1,1,1,1,1,1,1,1,1,10]
# が最大得点となる

Measured memory_bytes: 16716
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    int arr[n];
    loop(n,i,0)
        cin>>arr[i];
    int res=0;
    loop(n,i,0){
        if(arr[i]==i+1)
            res++;
    }
    loop(n-1,i,0){
        if(arr[i]==i+1&&arr[i+1]==i+2)
            res--,i++;
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

int main(){
	int N, M;
	cin >> N >> M;
	int s[M], c[M], num[N];
	
	for(int i = 0 ; i < N ; i++)
		num[i] = -1;
	
	bool ans = true;
	for(int i = 0 ; i < M ; i++){
		cin >> s[i] >> c[i];
		if(num[s[i]-1] == -1) num[s[i]-1] = c[i];
		else{
			if(num[s[i]-1] != c[i]){
				ans = false;
				break;
			}
		}
	}
	
	if(ans){
		if(num[0] == 0 && N > 1) cout << "-1" << endl;
		else{
			for(int i = 0 ; i < N ; i++)
				if(num[i] == -1) num[i] = 0;
				
			if(num[0] == 0 && N > 1) num[0] = 1;
			
			for(int i = 0 ; i < N ; i++)
				cout << num[i];
		}
	}
	else cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int x, n; cin >> x >> n;
  set<int> p;
  for(int i = 0; i < n; i++){
    int pi; cin >> pi;
    p.insert(pi);
  }
  int ans = 0;
  for(int i = x; ; i++){
    if(p.find(i) == p.end()){
      ans = i;
      break;
    }
  }
  for(int i = x; ; i--){
    if(p.find(i) == p.end()){
      if(ans - x >= x - i) ans = i;
      break;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
from scipy.sparse.csgraph import floyd_warshall


def main():
    H, W = map(int, input().split())
    S = []

    def get_index(h, w):
        return h * W + w

    for _ in range(H):
        S.append(input())

    l = [[0 for _ in range(H * W)] for _ in range(H * W)]
    for h in range(H):
        for w in range(W):
            if not S[h][w] == "#":
                if 0 <= h - 1 and S[h - 1][w] == ".":
                    l[get_index(h, w)][get_index(h - 1, w)] = 1
                if h + 1 < H and S[h + 1][w] == ".":
                    l[get_index(h, w)][get_index(h + 1, w)] = 1
                if 0 <= w - 1 and S[h][w - 1] == ".":
                    l[get_index(h, w)][get_index(h, w - 1)] = 1
                if w + 1 < W and S[h][w + 1] == ".":
                    l[get_index(h, w)][get_index(h, w + 1)] = 1

    #print(l)

    fw = floyd_warshall(l)
    #print(fw[0][3])
    ans = 0
    for i in range(H * W):
        for j in range(H * W):
            ans = max(ans, fw[i][j] if fw[i][j] < float("inf") else 0)
            # if ans == 7:
            #     print(i, j)

    print(int(ans))


main()


Measured memory_bytes: 21488
n, m = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)
g = Array.new(n + 1, true)
g[0] = false
m.times do |_|
  a, b = gets.chomp.split.map(&:to_i)
  if h[a - 1] == h[b - 1]
    g[a] = false
    g[b] = false
  elsif h[a - 1] < h[b - 1]
    g[a] = false
  else
    g[b] = false
  end
end

puts g.count(true)

Measured memory_bytes: 23564
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
    int ObjectNumber, TracKNumber, Object;
    int TotalObject = 0;
    int Max = 0;
    vector<int> List;
    
    std::cin >> ObjectNumber >> TracKNumber;
    
    List.clear();
    for(int i = 0; i < ObjectNumber; i++){
        std::cin >> Object;
        if(Max < Object)    Max = Object;
        TotalObject+= Object;
        List.push_back(Object);
    }
    
    if(TracKNumber == 1){
        cout << TotalObject << endl;
        return 0;
    }
    int Ans = ceil((double)TotalObject / TracKNumber);
    if(Max > Ans)   Ans = Max;
    
    bool IsAnswer = false;
    while(!IsAnswer){
        int Count = 0;
        TotalObject = 0;
        for(int i = 0; i < List.size(); i++){
            TotalObject += List[i];
            if(TotalObject > Ans){
                Count++;
                TotalObject = 0;
                i--;
            } else if(TotalObject <= Ans && i == List.size() - 1){
                Count++;
            }       
        }
        if(Count <= TracKNumber){
            IsAnswer = true;
        } else {
            Ans++;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 1672
// atcoder/agc020/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int k;
  while (cin >> k) {
    vec<lli> a(k);
    cin >> a;
    reverse(a.begin(), a.end());

    lli x = 2;
    each (i, a) {
      if (x % i == 0) ;
      else x = ((x / i) + 1) * i;
    }

    lli y = 4;
    each (i, a) {
      if (y % i == 0) ;
      else y = ((y / i) + 1) * i;
    }
    --y;

    reverse(a.begin(), a.end());
    bool f = (a.back() == 2);
    {
      lli z = x;
      each (i, a) z = z - z % i;
      f = f && (z == 2);
    }
    {
      lli z = y;
      each (i, a) z = z - z % i;
      f = f && (z == 2);
    }

    if (f) cout << x << ' ' << y << endl;
    else cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3976
#include <stdio.h>
#define MAX_SIZE 100000
#define SWAP(x,y,temp) ((temp) = (x),(x)=(y),(y) = (temp))

int partition(int list[], int left, int right) //p = left, r = right
{
	int i, j;
	int pivot, temp, low, high;

	pivot = list[right];
	i = left - 1;

	for (j = left; j < right; j++)
	{
		if (list[j] <= pivot)
		{
			i++;
			SWAP(list[i], list[j], temp);
		}
	}
	SWAP(list[i+1],list[j],temp);

	return i + 1;
}

int main()
{
	int i, q,n;
	int list[MAX_SIZE];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &list[i]);

	q = partition(list, 0, n - 1);

	for (int i = 0; i < n; i++)
	{
		if (i) printf(" ");
		if (i == q) printf("[");
		printf("%d", list[i]);
		if (i == q) printf("]");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i], dp[i] = 1e9;
	dp[0] = 0;
	repn(i, 1, n){
		repn(j, 1, k + 1){
			if(i - j < 0) break;
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int n,a,b;
vector<int> V[100005];
const ll MOD=1000000007;
int bio[100005];
ll dpW[100005];
ll dpB[100005];


pair<ll,ll> dfs (int a) {
    dpW[a]=1;
    dpB[a]=1;
    for (int b : V[a]) {
        if (bio[b]==1) {continue;}
        bio[b]=1;
        pair<ll,ll> ans=dfs(b);
        dpW[a]*=(ans.first+ans.second);
        dpB[a]*=ans.first;
        dpW[a]%=MOD;
        dpB[a]%=MOD;
    }
    if (dpW[a]==0) {dpW[a]++;}
    return {dpW[a],dpB[a]};

}

int main() {
    cin >> n;
    for (int i=0;i<n-1;i++) {
        cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
    }

    for (int i=1;i<=n;i++) {
        if (V[i].size()==1) {a=i;break;}
    }
    bio[a]=1;
    dfs(a);
    cout << (dpW[a]+dpB[a])%MOD << endl;
}




Measured memory_bytes: 17188
sx, sy, tx, ty = map(int, input().split())
a = ''
x = tx - sx
y = ty - sy
for i in range(y):
    a+='U'
    
for i in range(x):
    a+='R'

for i in range(y):
    a+='D'

for i in range(x+1):
    a+='L'

for i in range(y+1):
    a+='U'

for i in range(x+1):
    a+='R'

a+='D'
a+='R'
for i in range(y+1):
    a+='D'

for i in range(x+1):
    a+='L'

a+='U'
print(a)

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

            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            #define dr 0.0000004
            typedef  long long  int ll;
            const int N = ( 5e3 + 5 );
            const int mod = 998244353 ;
            ll n ,m ,dp[N][N];
            char  a[N][N];
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt ; pt %= mod;
        if(n&1)
            pt *= a , pt %= mod;
        return pt;
    }
/*
    void dfs(ll u, ll pre)
    {
        for(auto v : g[u])
        {
            if( v == pre ) continue;
            dfs(v,u);
            if( __gcd(a[u] , a[v]) != -1)
            for(auto it : dp[v])
            {
                ll gd = __gcd(it.F , a[u]);
                if(gd != 1)
                {
                    dp[u][gd] = it.S+1;
                }
            }
        }
    }
*/


    int main()
    {
         IOS;
      //     freopen("a_example (2).txt","r",stdin);
      //   freopen("c.txt","w",stdout);
        int ts =1;
        //cin>>ts;
        while( ts-- )
        {
            cin >> n >> m;
            rep(i,0,n) rep(j,0,m) cin >> a[i][j];
            for( int i= 0 ; i < n ; i++ )
            {
                for( int j =0 ; j < m ; j++ )
                {
                    if( i == 0 and j == 0 )
                    {
                        dp[i][j] = (a[i][j] == '#');
                    }
                    else
                    {
                        dp[i][j] = 1e9;
                        if( i> 0)
                        dp[i][j] = min( dp[i][j] , dp[i-1][j] + (a[i-1][j] == '.' and a[i][j] == '#'));
                        if( j> 0)
                        dp[i][j] =  min(dp[i][j] , dp[i][j-1]  + (a[i][j-1] == '.' and a[i][j] == '#'));
                    }
                }
            }
            cout << dp[n-1][m-1] << endl;
        }
        return 0;
    }


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

using namespace std;

typedef long long ll;

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

ll ulim = 1e17;
ll n, k;
vector<ll> a;
bool cond(ll x){
	ll tmp = 0ll;
	rep(i, n){
		tmp += (a[i] + x - 1) / x - 1;
	}

	return tmp <= k;
}

// condを満たす最小のxを求める(lower_bound)
// 全てのxが条件を満たさない場合はnを返す(nはとりえない値)
ll lower_bound_cond(){
	ll lb = 0, ub = ulim;

	while(ub - lb > 1){
		int mid = (lb + ub) / 2;

		if(cond(mid)) ub = mid;   // Answer is in (lb, mid]
		else lb = mid;            // Answer is in (mid, ub]
	}

	// now lb + 1 = ub
	return ub;
}



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

	cin >> n >> k;

	a.resize(n);
	rep(i, n) cin >> a[i];

	// ll mx = *max_element(a.begin(), a.end());
	cout << lower_bound_cond() << endl;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	REP(i,n){
		cin >> a[i];
	}
	REP(i,n){
		cin >> b[i];
		if(a[i]>b[i]){
			a[i]=a[i]-b[i];
			b[i]=0;
		}
		else{
			b[i]=b[i]-a[i];
			a[i]=0;
		}
	}
	int a_amari=0;
	int b_amari=0;
	int a_kazu=0;
	int b_kazu=0;
	REP(i,n){
		if(a[i]>b[i]){
			a_amari+=a[i]*2;
			a_kazu+=a[i];
		}
		else if(a[i]<b[i]){
			if(b[i]%2==1){
				b[i]--;
			}
			b_amari+=b[i]/2;
			b_kazu+=b[i]/2;
		}
	}
	if(a_amari==b_amari){
		cout << "Yes" << endl;
	}
	else if(a_amari<b_amari){
		cout << "Yes" << endl;
	}
	else if(a_amari<=b_amari+(min(a_kazu,b_kazu))){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, k; cin >> n >> k;
    set<char> no;
    rep(i,k){
        char qwertyuiop; cin >> qwertyuiop;
        no.insert(qwertyuiop);
    }
    bool can = true;
    string answer;
    n--;
    while(can){
        n++;
        string str = to_string(n);
        for(char ch : str){
            can = false;
            if(no.find(ch) != no.end()){
                can = true;
                break;
            }
            if(!can) answer = str; 
        }
    }
    cout << answer << '\n'; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

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 main() {
    ll N; cin >> N;
    ll gcd_num;
    for (int i = 0; i < N; ++i) {
        ll A; cin >> A;
        if (i == 0) gcd_num = A;
        else gcd_num = gcd(gcd_num, A);
    }
    cout << gcd_num << endl;
}

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

A = list(map(int,input().split()))
A.append(0)

S = abs(A[0])
for i in range(1,n+1):
    S +=abs(A[i]-A[i-1])

for i in range(n):
    if i == 0:
        s = S + abs(A[1]-0) - (abs(0-A[0])+abs(A[0]-A[1]))
        print(s)
    else:
        s = S + abs(A[i+1]-A[i-1]) - (abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))
        print(s)

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

int main() {
	int n;
    cin >> n;
    map<string, int> data;
    int64_t count = 0;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        string tmp = "00000000000000000000000000";
        for (int j = 0; j < s.size(); j++){
            char c = s.at(j);
            char counted = tmp.at(c - 97);
            counted++;
            tmp = tmp.substr(0, c - 97) + counted + tmp.substr(c - 97 + 1);
        }

        if(data.count(tmp)){
            count += data[tmp];
        }
        data[tmp]++;
    }

    cout << count << endl;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	int cnt=0;
	while(b<=a)
	{
		b*=2;
		cnt++;
	}
	while(c<=b)
	{
		c*=2;
		cnt++;
	}
	if(cnt<=k)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long ans = 0;
    for (int i=0; i<N; i++) cin >> A.at(i);
    for (int i=0; i<N; i++) { 
        for (int j=i; j<N; j++) {
            ans = max(ans, abs(A.at(i)-A.at(j)));
        }
    }
    cout << ans;
}

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

void Main()
{
    string s;
    cin >> s;
    vector<int> n(s.size()+1);
    for (int i = 0; i < s.size(); i++)
    {
        n[i+1] = s[i] - '0';
    }

    vector<vector<int>> dp(n.size(), vector<int>(2));
    dp[0][0] = n[0];
    dp[0][1] = n[0]+1;
    for (int i = 1; i < n.size(); i++)
    {
        dp[i][0] = min(dp[i-1][0] + n[i], dp[i-1][1] + 10-n[i]);
        dp[i][1] = min(dp[i-1][0] + n[i]+1, dp[i-1][1] + 9-n[i]);
    }
    
    cout << min(dp[n.size()-1][0], dp[n.size()-1][1]+1) << endl;

}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 62864
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<vector<int>> to;
vector<int> ord, low;
vector<bool> is_articulation;
int num = 0;

void dfs(int v, int p=-1) {
    ord[v] = num++;
    low[v] = ord[v];
    int child = 0;
    for (auto u : to[v]) {
        if (ord[u] == -1) {
            child++;
            dfs(u, v);
            low[v] = min(low[v], low[u]);
            if (p != -1 && ord[v] <= low[u]) is_articulation[v] = true;
        } else if (u != p) {
            low[v] = min(low[v], ord[u]);
        }
    }
    if (p == -1 && child >= 2) is_articulation[v] = true;
}

void lowlink(int v) {
    ord.resize(v, -1);
    low.resize(v);
    is_articulation.resize(v);
    dfs(0);
}

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

    int v, e;
    cin >> v >> e;
    to.resize(v);
    rep(i, e) {
        int s, t;
        cin >> s >> t;
        to[s].pb(t);
        to[t].pb(s);
    }
    lowlink(v);
    rep(i, v) {
        if (is_articulation[i]) cout << i << endl;
    }
}


Measured memory_bytes: 4832
import math
def readinput():
    a,b=list(map(int,input().split()))
    return a,b

def myFactorization(n):
    '''nを素因数分解する

    戻り値: factList = [[prime1, exp1], [prime2, exp2],...] 
           n=(prime1)**exp1 * (prime2)**exp2 * ...
    '''

    factList=[]
    temp=n
    cnt=0
    while(temp%2==0):
        temp=temp//2
        cnt+=1
    if(cnt>0):
        factList.append([2,cnt])

    m=int(math.sqrt(n))+1
    for i in range(3,m+1,2):
        cnt=0
        while(temp%i==0):
            temp=temp//i
            cnt+=1
        if(cnt>0):
            factList.append([i,cnt])
        if(temp==1):
            break
    if(temp>1):
        factList.append([temp,1])
    return factList

def euclid(x,y):
    if x<y:
        x,y=y,x
    
    while y>0:
        r=x%y
        x=y
        y=r
    return x

def main(a,b):
    gcd=euclid(a,b)
    factList=myFactorization(gcd)
    return len(factList)+1

if __name__=='__main__':
    a,b=readinput()
    ans=main(a,b)
    print(ans)


Measured memory_bytes: 9256