akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
#define N 500050
#define mod 998244353
int fr[N],ifr[N],n,m,as;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	fr[0]=ifr[0]=1;for(int i=1;i<=5e5;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n&&i<=m;i++)as=(as+1ll*(i&1?mod-1:1)*fr[n]%mod*ifr[i]%mod*ifr[n-i]%mod*fr[m]%mod*ifr[m-i]%mod*pw(m+1,n-i)%mod*pw(n+1,m-i))%mod;
	printf("%d\n",as);
}

Measured memory_bytes: 4096
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
		int [] Array = new int [50];
		int counter = 0;
		for(int i = 1; i <= a && i <= b; i++) {
			if(a % i == 0 && b % i == 0) {
				Array[counter] = i;
				counter++;
			}
		}
		System.out.println(Array[counter - k]);
		sc.close();
	}

}


Measured memory_bytes: 21332
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

n = int(input())
ans = []

def dfs(arr, max_val):
    if len(arr) == n:
        ans.append(arr)
        return
    for i in range(max_val + 2):
        next_arr = arr[:]
        next_arr.append(i)
        dfs(next_arr, max(max_val, i))

dfs([0], 0)

ans.sort()
orda = ord("a")
for line in ans:
    print("".join([chr(orda + item) for item in line]))

Measured memory_bytes: 28972
n,m = list(map(int,input().split()))
mod = 10**9 + 7

maxn = 5*(10**5) 
maxn+=10
fac = [0 for i in range(maxn)]
fac[0] = 1
for i in range(1,maxn):
    fac[i] = (fac[i-1]*i)%mod

def inv(n):
    return pow(n,mod-2,mod)

def func(n,r):
    ans = fac[n]
    ans = (ans*inv(fac[n-r]))%mod
    ans = (ans*inv(fac[r]))%mod
    return ans


# inv = [0 for i in range(maxn)]
# inv(maxn-1] = pow(fac[n],mod-2,mod)
# for i in range(maxn-2,-1,-1):
#     inv(i] = (inv(i+1]*(i+1))%mod

ans = 0
for i in range(n+1):
    if i%2==0:
        t = 1
    else:
        t = -1
    p = func(n,i)
    q = (fac[m]*inv(fac[m-i]))%mod
    r = func(m-i,n-i)
    s = fac[n-i]
    temp = (r*s)%mod
    temp = pow(temp,2,mod)

    h = (((p*q)%mod)*temp)%mod
    h = (h*t)
    ans = (ans+h)%mod
print(ans)

Measured memory_bytes: 103684
S = input()
n = 0
i = 0
while i < len(S):
    # print(S)
    if len(set(S[i:i+2])) == 2:
        S = S[:i]+S[i+2:]
        n += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(n)

Measured memory_bytes: 9204
import sys
def input():
	return sys.stdin.readline().strip()


N, M = list(map(int, input().split()))

LRC = []
for _ in range(M):
	LRC.append(tuple(map(int, input().split())))

LRC.sort()


class seg_tree():
	def __init__(self, N):
		# N: 処理する区間の長さ
		self.N0 = 2 ** (N - 1).bit_length()
		self.INF = 2 ** 100 - 1 #単位限的なもの(最小値なので、非常に大きい値を置いておく)
		self.data = [self.INF] * (2 * self.N0)

	# a_k の値を x に更新
	def update(self, k, x):
		#値は0始まり
		k += self.N0 - 1
		self.data[k] = x
		while k >= 0:
			k = (k - 1) // 2
			self.data[k] = min(self.data[2 * k + 1], self.data[2 * k + 2])

	# 区間[l, r)の最小値
	def query(self, l, r):
		L = l + self.N0
		R = r + self.N0
		s = self.INF
		while L < R:
			if R & 1:
				R -= 1
				s = min(s, self.data[R - 1])

			if L & 1:
				s = min(s, self.data[L - 1])
				L += 1
			L >>= 1
			R >>= 1
		return s

dist = seg_tree(N)
dist.update(0, 0)

for i in range(M):
	L, R, C = LRC[i]
	L -= 1
	R -= 1
	dist_start = dist.query(L, N)
	target_dist = dist.query(R, N)
	if dist_start + C < target_dist:
		dist.update(R, dist_start + C)


ans = dist.query(N - 1, N)
if ans == dist.INF:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 95452
a,b,c,k = map(int,input().split())
ans = 0
if k<=a:
  ans += k
elif k>a and k<=(a+b):
  ans += a
elif k>a and 0<(k-a-b)<c:
  ans += a + (k-a-b)*(-1)
elif k>a and (k-a-b)>=c:
  ans += a + c*(-1)
  
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string a, b, c; cin >> a >> b >> c;
    int ans = 0;
    rep(i,n) {
        set<char> st;
        for (string s : vector<string>{a,b,c}) {
            st.insert(s[i]);
        }
        if (st.size() == 2) ans += 1;
        if (st.size() == 3) ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define BPhuong "Knapsack 2"
#define maxn 100003
#define maxm
#define fi(i,a,b) for(int i = a; i<= b; i++)
#define fid(i,a,b) for(int i = a; i>= b; i--)
#define se second
#define f first
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define bit(x, i) ((x>>i)&1)
#define oo 1e9
struct data{
    int x, y, z;
};
using namespace std;
int n, W, cl[109][maxn], w[maxn], v[maxn], f[109][maxn];
long long solve(int i, int V)
{
    if(i == n+1)
    {
        if(V == 0) return 0;
        else if(V > 0 ) return 1e13;
    }
    if(V < 0) return 1e13;
    if (cl[i][V]) return f[i][V];
    cl[i][V] = 1;
    f[i][V] = min(w[i] + solve(i+1, V-v[i]), solve(i+1, V));
    return f[i][V];
}
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //freopen(BPhuong".inp","r",stdin);
    //freopen(BPhuong".out","w",stdout);
    cin >> n  >> W;
    fi(i, 1, n) cin >> w[i] >> v[i];
}

void xuli(){
    fid(i, 100000, 0)
    {
        if(solve(1, i) <= W)
        {
            cout << i;
            exit(0);
        }
    }
}

int main(){
    nhap();
    xuli();
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


ll ndigit(ll n)
{
    ll c = 0;
    while(n > 0) {
        n /= 10;
        ++c;
    }
    return c;
}


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

    vec D;
    D.pb(1);
    for(ll i=2; i*i<=N; ++i) {
        if(N % i == 0) D.pb(i);
    }

    ll m = INF, f;
    FORR(d,D) {
        ll a, b;
        a = ndigit(d);
        b = ndigit(N/d);
        f = MAX(a,b);
        m = MIN(m,f);
    }
    PR(m);


    return 0;
}

/*



*/

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

int main() {
    int N; cin >> N;
    vector<int> A(N+1);
    int tmp;
    rep(i, N-1) {
        cin >> tmp;
        A[tmp]++;
    }
    rep2(i, 1, N+1) cout << A[i] << endl;
}


Measured memory_bytes: 4052
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<cctype>
using namespace std;

int mkans(int x,int y,int z){
  int wa=0; 
  if(x%(z-1)){
    wa+=x/(z-1)+1;
  }
  else{
    wa+=x/(z-1);
  }
  if(y%(z-1)){
    wa+=y/(z-1)+1;
  }
  else{
    wa+=y/(z-1);
  }
  return wa;
}

int main(void)
{
  int n,k;
  cin>>n>>k;
  int a[100100];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int iti=0,ans;
  while(a[iti]!=1){
    iti++;
  }
  int sa1=iti;
  int sa2=n-iti-1;
  int amari1=sa1%(k-1);
  int amari2=sa2%(k-1);
  if(amari1==0&&amari2==0){
    ans=mkans(sa1,sa2,k);
  }
  else{
    if(n==k){
      ans=1;
    }
    else {
      ans=mkans(sa1-amari1,sa2+amari1+1-k,k)+1;   
      int ansl=mkans(sa1+amari2+1-k,sa2-amari2,k)+1;
      if(ansl<ans)ans=ansl;
    }
  }

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



Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vint a(n);
    vint b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    double med_a, med_b;
    ll ans;
    if(n&1){
        med_a = a[(n-1)/2];
        med_b = b[(n-1)/2];
        ans = med_b - med_a + 1;

    }else{
        med_a = (double)(a[n/2] + a[n/2-1]) / 2;
        med_b = (double)(b[n/2] + b[n/2-1]) / 2;
        ans = med_b*2 - med_a*2 + 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4780
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC131_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var AB = new List<Tuple<int, int>>();

            for (int i = 0; i < N; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                AB.Add(new Tuple<int, int>(line[0], line[1]));
            }

            AB = AB.OrderBy(x => x.Item2).ToList();
            var ans = true;
            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += AB[i].Item1;
                if (sum > AB[i].Item2)
                {
                    ans = false;
                }
            }

            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 34324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  int A, B, C;
  
  int now_tower = 0;
  bool isChecked = true;
  int count = 0;
  
  vector<pair<int, bool>> tower;
  set<pair<int, int>> path;
  
  cin >> N >> M;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    tower.push_back(make_pair(A, false));
  }  
  
  for (int i = 0; i < M; i++) {
    cin >> B >> C;
    path.insert(make_pair(B, C)); 
    path.insert(make_pair(C, B)); 
  }    


  for (auto p : path) {
    if (now_tower != p.first) {
      if (!isChecked) {
        count++;
      }
      
      now_tower = p.first;
      isChecked = false;
    }
    
    if (tower[p.first - 1].first <= tower[p.second - 1].first ) {
      isChecked = true;
    }  
    
    tower[p.first - 1].second = true;
  }      
  
  if (!isChecked) {
    count++;
  }
  
  for (auto t : tower) {
    if (t.second == false) {
      count++;
    }  
  }  
  
  cout << count << endl;
}

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

#define LL long long

//5: 2^0, 6: 2^1, ..., 35: 2^30

struct Node
{
	char op;
	int a, b, c;
	Node(char C = 0, int X = 0, int Y = 0, int Z = 0) { op = C; a = X; b = Y; c = Z; }
};

int id[65];
LL v[200005];

vector<Node> ans;

inline void add(int a, int b, int c) { ans.push_back( Node('+', a, b, c) ); v[c] = v[a] + v[b]; }

inline void cmp(int a, int b, int c) { ans.push_back( Node('<', a, b, c) ); v[c] = (v[a] < v[b]); }

int main()
{
	add(0, 1, 3); cmp(5, 3, 5);

	id[0] = 5;
	for(int i = 6; i <= 35; i++)
	{
		int x = i - 5;
		add(5, i, i);
		for(int j = 1; j <= x; j++) add(i, i, i);
		id[x] = i;
	}

	//36 ~ 65: A, 66 ~ 95: B, 96 ~ 155: C
	add(0, 5, 500);
	for(int i = 65; i >= 36; i--)
	{
		int x = i - 36;
		add(id[x], 200, 201); 
		cmp(201, 500, 202); add(4, 202, i);
		for(int j = 1; j <= x; j++) add(202, 202, 202);
		add(200, 202, 200);
	}
	add(1, 5, 500); add(4, 4, 200);
	for(int i = 95; i >= 66; i--)
	{
		int x = i - 66;
		add(id[x], 200, 201);
		cmp(201, 500, 202); add(4, 202, i);
		for(int j = 1; j <= x; j++) add(202, 202, 202);
		add(200, 202, 200);
	}
	for(int i = 36; i <= 65; i++)
		for(int j = 66; j <= 95; j++)
		{
			int x = i - 36, y = j - 66, p = 96 + x + y;
			add(i, j, 200);
			cmp(5, 200, 201);
			add(p, 201, p);
		}
	for(int i = 96; i <= 155; i++)
	{
		int x = i - 96;
		for(int j = 1; j <= x; j++) add(i, i, i);
		add(2, i, 2);
	}

	printf("%lu\n", ans.size());
	for(int i = 0; i < ans.size(); i++) printf("%c %d %d %d\n", ans[i].op, ans[i].a, ans[i].b, ans[i].c);
	return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans = 0,m;
    cin >> n;
    m = n;
    rep(i,2,sqrt(n)+1){
        ll cnt = 0;
        if (m%i == 0){
            while(m%i == 0){
                m /= i;
                cnt++;
            }
        }
        ll b = sqrt(cnt);
        while((b+1)*(b+2)/2 <= cnt){
            b++;
        }
        ans += b;
    }
    if (m > 1) ans++;
    PRINT(ans);
}


Measured memory_bytes: 3692
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n;
    while ((n = readint) > 0) {
        int[] ids;
        long[int] m;
        for (int i = 0; i < n; i++) {
            auto xs = readints;
            int no = xs[0];
            long a = xs[1];
            long b = xs[2];
            m[no] += a * b;
            if (!ids.canFind(no)) {
                ids ~= no;
            }
        }

        bool none = true;
        foreach (id; ids) {
            if (m[id] >= 1_000_000) {
                writeln(id);
                none = false;
            }
        }
        if (none)
            writeln("NA");
    }
}

Measured memory_bytes: 2516
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] mat = new int[H][W];
		for(int i = 0;i < H;++i) {
			String cap = sc.next();
			for(int j = 0;j < W;++j) {
				mat[i][j] = ((cap.charAt(j) == '.') ? 0 : 1);
			}
		}
		sc.close();
		for(int i = 0;i < H;++i) {
			boolean flag = true;
			for(int j = 0;j < W;++j)
				if(mat[i][j] == 1)
					flag = false;
			if(flag) {
				for(int j = 0;j < W;++j)
					mat[i][j] = 2;
			}
		}
		for(int i = 0;i < W;++i) {
			boolean flag = true;
			for(int j = 0;j < H;++j)
				if(mat[j][i] == 1)
					flag = false;
			if(flag) {
				for(int j = 0;j < H;++j)
					mat[j][i] = 2;
			}
		}
		
		for(int i = 0;i < H;++i) {
			boolean flag = false;
			for(int j = 0;j < W;++j) {
				if(mat[i][j] == 0) {
					System.out.print('.');
					flag = true;
				}else if(mat[i][j] == 1) {
					System.out.print('#');
					flag = true;
				}
			}
			if(flag)
				System.out.println();
		}
	}
}


Measured memory_bytes: 25456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      s: chars,
    }

    const MOD: usize = 998244353;
    let mut ans = 1;

    let mut cnt = vec![0; 3];
    for c in s {
        let idx = match c {
            'R' => 0,
            'G' => 1,
            'B' => 2,
            _  => unreachable!()
        };

        let o1 = (idx+1) % 3;
        let o2 = (idx+2) % 3;
        if min(cnt[o1], cnt[o2]) > 0 {
            ans *= min(cnt[o1], cnt[o2]);
            ans %= MOD;
            cnt[o1] -= 1;
            cnt[o2] -= 1;
        } else if max(cnt[o1], cnt[o2]) > cnt[idx] {
            ans *= max(cnt[o1], cnt[o2]) - cnt[idx];
            ans %= MOD;
            cnt[idx] += 1;
        } else {
            cnt[idx] += 1;
        }
    }

    for i in 0..n {
        ans *= i+1;
        ans %= MOD;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
 
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        mp[A[i]] = i;
    }
    sort(A.begin(), A.end());
    ll OtoE = 0;
    ll EtoO = 0;
    rep(i,N){
        if((mp[A[i]] - i) % 2 != 0){
            if(mp[A[i]]%2 == 0){
                EtoO++;
            }else{
                OtoE++;
            }
        }
    }
    cout << OtoE << endl;
}

Measured memory_bytes: 10332
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
const int MYINF = 1e9+7;

#define NSIZE 100010
#define QSIZE 50000

int S[NSIZE];
int n;

int cmp(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int binsearch_h(int x, int left, int right) {
	int m;
	if (left == right) {
		return S[left] == x;
	} else if (left > right) {
		return 0;
	}
	m = (right + left)  / 2;
	if (x < S[m]) {
		return binsearch_h(x, left, m - 1);
	} else if (x > S[m]) {
		return binsearch_h(x, m + 1, right);
	} else {
		return 1;
	}
}

int binsearch(int x) {
	return binsearch_h(x, 0, n - 1);
}

int main(int argc, char **argv)
{
	int q, i, x, count;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	qsort(S, n, sizeof(int), cmp);

	scanf("%d", &q);
	count = 0;
	for (i = 0; i < q; i++) {
		scanf("%d", &x);
		count += binsearch(x);
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 1036
# from collections import deque
H, W = list(map(int, input().split()))
# dp = [[1000 for _ in range(W)] for _ in range(H)]

S = [['#']*(W+2)] + [['#']+list(input())+['#'] for h in range(H)] + [['#']*(W+2)]
# S = (H+2, W+2)
# S =  [input().split() for h in range(H)]
max_n = 0

for h1 in range(1,H+1):
  for w1 in range(1,W+1):
    if S[h1][w1] == '#':
      continue
    distance = [[1000 for _ in range(W+2)] for _ in range(H+2)]
    done_que = [[0 for _ in range(W+2)] for _ in range(H+2)]
    distance[h1][w1] = 0
    que = []
    que.append([h1,w1])
    que_i = 0
    while que_i < len(que):
      h, w = que[que_i]
      if S[h-1][w] == '.' and done_que[h-1][w] == 0:
        done_que[h-1][w] = 1
        que.append([h-1,w])
        distance[h-1][w] = min(distance[h][w] + 1, distance[h-1][w])
      if S[h+1][w] == '.' and done_que[h+1][w] == 0:
        done_que[h+1][w] = 1
        que.append([h+1,w])
        distance[h+1][w] = min(distance[h][w] + 1, distance[h+1][w])
      if S[h][w-1] == '.' and done_que[h][w-1] == 0:
        done_que[h][w-1] = 1
        que.append([h,w-1])
        distance[h][w-1] = min(distance[h][w] + 1, distance[h][w-1])
      if S[h][w+1] == '.' and done_que[h][w+1] == 0:
        done_que[h][w+1] = 1
        que.append([h,w+1])
        distance[h][w+1] = min(distance[h][w] + 1, distance[h][w+1])
      que_i += 1
    hw_max_n = 0
    for h2 in range(1,H+1):
      for w2 in range(1,W+1):
        if distance[h2][w2] != 1000:
          hw_max_n = max(hw_max_n, distance[h2][w2])
    max_n = max(max_n, hw_max_n)
print(max_n)

Measured memory_bytes: 3192
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_permutation(l: list) -> bool:
    n = len(l)
    i = n - 2
    while i >= 0 and l[i] >= l[i + 1]:
        i -= 1

    if i == -1:
        return False

    j = i + 1
    while j < n and l[j] > l[i]:
        j += 1
    j -= 1

    l[i], l[j] = l[j], l[i]

    left = i + 1
    right = n - 1

    while left < right:
        l[left], l[right] = l[right], l[left]
        left += 1
        right -= 1

    return True


def main() -> None:
    s = next_str()
    t = [a for a in s]

    for v in range(ord('a'), ord('z') + 1):
        if chr(v) not in s:
            print(s + chr(v))
            return

    if not next_permutation(t):
        print(-1)
    else:
        i = 0
        while s[i] == t[i]:
            print(s[i], end="")
            i += 1
        print(t[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import math
a,b,h,m=map(int,input().split())
degB=m*math.pi/30
degA=(60*h+m)*math.pi/360
degAB=max(degA,degB)-min(degA,degB)

ans=math.sqrt(a**2+b**2-2*a*b*math.cos(degAB))
print(ans)



Measured memory_bytes: 9564
#include <stdio.h>

int main(void)
{
	int x, y, z,temp;

	scanf("%d%d%d", &x, &y, &z);

	if (x > y)
	{
		temp = x;
		x = y;
		y = temp;
	}
	if (y > z)
	{
		temp = y;
		y = z;
		z = temp;
		if (x > y)
		{
			temp = x;
			x = y;
			y = temp;
		}
	}

	printf("%d %d %d\n", x, y, z);

	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String s = sc.next();
    
		// 出力
		System.out.println(s.substring(0,4) + " " + s.substring(4, 12));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}

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

   int k;
   cin >> k;
   int ans = 0;
   rep(a, 1, k + 1) rep(b, 1, k + 1) rep(c, 1, k + 1) {
      ans += gcd(gcd(a, b), c);
   }
   cout << ans << endl;
   return 0;
}

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


int main(){
    int a[10], b[10];
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++ ){
        scanf("%d %d", &a[i], &b[i]);
    }
    double f = 0;
    for(int i = 0; i < n; i ++ ){
        for(int j = i + 1; j < n; j ++ ){
            int x = a[j] - a[i];
            int y = b[j] - b[i];
            f += sqrt(x * x + y * y);
        }
    }
    /*int o = 1;
    for(int i = 2; i <= n - 1; i ++ ){
        o *= i;
    }
    double ans = 2 * o * f / n / ;*/
    printf("%.9lf", f * 2 / n);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=2e5+5;

int pw(int a,int p=M-2,int MOD=M){
	int result = 1;
	while (p > 0) {
		if (p & 1)
			result = a * result % MOD;
		a = a * a % MOD;
		p >>= 1;
	}
	return result;
}


int f(int n){
	if(n==0) return 0;
	int pc = ppc(n);
	return 1 + f(n%pc);
}

int rem[N];
int x[N];

void solve(){
	int n;
	string s;
	cin>>n>>s;
	
	
	int pc = 0;
	
	
	rep(i,0,n){
		x[i] = s.back() - '0';
		s.ppb();
		pc += x[i];
	}
	
	rep(p,pc-1,pc+2){
		if(p<=0) continue;
		int ans = 0;
		rep(i,0,n){
			if(x[i]) ans += pw(2,i,p);
			ans %= p;
		}
		rem[p] = ans;
	}
	
	
	for(int i = n-1 ; i>=0 ; i--){
		if(x[i]){
			if(pc == 1){
				cout<<0<<"\n";
				continue;
			}
			int k = (rem[pc-1] - pw(2,i,pc-1) + pc-1)%(pc-1);
			cout<<1+f(k)<<"\n";
		}
		else{
			int k = (rem[pc+1] + pw(2,i,pc+1))%(pc+1);
			cout<<1+f(k)<<"\n";
		}
	}
	
	
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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

typedef pair<string,int> p;
int n;

int main(void){
    string x;
    int y;
    cin >> n;
    map<p,int> sp;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        sp[p(x,y*-1)] = i+1;
    }
    for(pair<p,int> itr: sp){
        cout << itr.second << endl;
    }
}



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

a = list(map(int,input().split())) 

b0=0
b2=0
b4=0

for i in range(N):
    if a[i]%4==0:
        b4+=1
    elif a[i]%2==0:
        b2+=1
    else:
        b0+=1
        
#print(b0,b2,b4)        
        
if b0<=b4:
    print("Yes")
elif b0==b4+1 and b0+b4==N:
    print("Yes")
else:
    print("No")


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

int main()
{
	int n,m,j,y,p=0;
	cin>>n>>m;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=0;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>j>>y;
		if(a[j]>a[y])
		swap(j,y);
		else if
		(a[j]==a[y])
		b[y]++;
		b[j]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==0)
		p++;
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int x, y; cin >> x >> y;
    int ans = INF;
    if(y >= x) ans = min(ans, y - x);
    if(y >= -1 * x) ans = min(ans, 1 + y + x);
    if(-1 * y >= x) ans = min(ans, - 1 * y - x + 1);
    if(-1 * y >= -1 * x) ans = min(ans, -1 * y + x + 2);
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{/*???????????????*/
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer p;
  int i;
  p=nil->next;
 
  while((p != nil) && (p->key!=key)){
    p=p->next;
  }
    return p;
 
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  /*node ????¶????*/
  t->prev->next=t->next;
  t->next->prev=t->prev;
}
 
void deleteFirst(){
  /*???????????????????????????*/
  NodePointer t = nil->next;
  if ( t == nil )return;
  deleteNode(t);
}
 
void deleteLast(){
  /*????????????????????????*/
  NodePointer t=nil->prev;
  if(t==nil)return;
  deleteNode(t);
 
}
 
void delete(int key){
 
  NodePointer tea;
  if((tea=listSearch(key))!= NULL){
    if(tea == nil) return;
    deleteNode(tea);
    }
}
 
 
void insert(int key){
  /*?????\*/
  NodePointer new;
  new = malloc(sizeof(struct node));
  new->key = key;
  new->next=nil->next;
   
  nil->next->prev=new;
 
  nil->next=new;
 
  new->prev=nil;
}
 
 
 
int main(void){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) {
deleteFirst();
}
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++; 
      }
      size--;
    }
  }
 
  printList();
  return 0;
}

Measured memory_bytes: 34976
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	double R;
	cin >> R;
	double ans = 2 * R * PI;
	printf("%.10f", ans);
}

Measured memory_bytes: 3788
#include <iostream>

int main() {
  unsigned long long N;
  unsigned long long result = 0, temp, sum = 0;

  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> temp;
    result += temp * sum;
    result %= 1000000007;
    sum += temp;
    sum %= 1000000007;
  }

  std::cout << result << std::endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  vi h(n);
  for (int &i : h)
    cin >> i;
  vi dp(n, 1);
  for (int i = 1; i < n; i++) {
    if (h[i] <= h[i - 1])
      dp[i] = dp[i - 1] + 1;
  }
  cout << *max_element(all(dp)) - 1 << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    for(char c='a';c<='z';c++){
        if(count(ALL(s),c)==0){
            cout<<c<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

Int N, K;


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

 
  cin>>N>>K;
  Int ans = 0;
  for(Int a = 1;a <= N; a++){
    int b = K - a % K;
    Int c1 = K - b%K;
    Int c2 = K - a%K;
    if(c1 != c2) continue;
    ans += (((N-b)/K)+1) * (((N-c1)/K) + 1);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, l[100], s = 0;
    cin >> n;
    int maxx = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> l[i];
        if(maxx < l[i])
        {
            maxx = l[i];
        }
        s = s + l[i];
    }
    if(maxx + maxx < s)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

int main(){
    int N;
    long long r=0;
    cin >> N;
    vector<int> v(N+1,0),v2(N+1,0);
    for (int i=1;i<N+1;i++){
        cin >> v[i];
        r += abs(v[i]-v[i-1]);
        if (i>=2) v2[i] = abs(v[i]-v[i-2]);
        }
    r += abs(v[N]);
    v2[0] = abs(v[N-1]);

    for (int i=1;i<N;i++){
        cout << r - abs(v[i+1]-v[i]) -abs(v[i]-v[i-1]) + v2[i+1] << endl;
    }
    cout << r - abs(v[0]-v[N]) -abs(v[N]-v[N-1]) + v2[0] << endl;
}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 2048
from queue import deque

n = int(input())
edges = [set() for _ in range(n + 1)]
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    edges[a].add((c, b))
    edges[b].add((c, a))

q, k = map(int, input().split())
stack = deque([(0, k)])
costs = [0] * (n + 1)
visited = set()
while stack:
    c, p = stack.popleft()
    costs[p] = c
    visited.add(p)
    stack.extend((c + c2, p2) for c2, p2 in edges[p] if p2 not in visited)

ans = []
for _ in range(q):
    x, y = map(int, input().split())
    ans.append(costs[x] + costs[y])
print('\n'.join(map(str, ans)))

Measured memory_bytes: 71960
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = 0
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
    elif b[i] > a[i] and b[i] <= a[i] + a[i+1]:
        ans += b[i]
        a[i+1] = a[i+1] - b[i] + a[i]
    else:
        ans += a[i] + a[i+1]
        a[i+1] = 0
print(ans)


Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long Long;
const Long mod = 1000000007LL;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	string grid[h];
	for (int i = 0; i < h; i++) cin >> grid[i];
	Long dp[h + 1][w + 1];
	for (int i = 0; i <= h; i++) dp[i][0] = 0LL;
	for (int j = 0; j <= w; j++) dp[0][j] = 0LL;
	if (grid[0][0] == '.') dp[1][1] = 1LL;
	for (int row = 1; row <= h; row++) {
		for (int col = 1; col <= w; col++) {
			if (row == 1 and col == 1) continue;
			dp[row][col] = (dp[row][col - 1] + dp[row - 1][col]) % mod;
			if (grid[row - 1][col - 1] == '#') dp[row][col] = 0LL;
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int i=0;
  int b=0;
  int c=0;
  cin >> N;
  vector<int> B(N);
  for(i=0; i < N; ++i){
    cin >> B[i];
    if (b <= B[i]){
      b = B[i];
      c += 1;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
cnt = 1
N = int(input())
H = list(map(int, input().split(' ')))
for i in range(1,N,1):
  _cnt=0
  for j in range(0,i,1):
    if H[i]>=H[j]:
      _cnt+=1
  if _cnt==i:
    cnt+=1
print(cnt)

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int t1 = a * x + b * y;
  int t2 = c * max(x, y) * 2;
  int t3 = a * (x - min(x, y)) + b * (y - min(x, y)) + c * min(x, y) * 2;
  cout << min(t1, min(t2, t3)) << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
m = 0
s = 0
M = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        s += 1
        m = max(m,s)
    else:
        m = max(m,s)
        s = 0
    # print(s)
print(m)

Measured memory_bytes: 20496
import java.util.Scanner;

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

        int minP = 0;
        int maxP = (int) 1E9;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }

        // f(p) が初めてn以上になるpを求める。
        int midP = 0;
        while (maxP > minP) {
            midP = (maxP + minP) / 2;
            int m = f(midP);
            
            if (m >= n) 
                maxP = midP;
            else
                minP = midP + 1;
        }
        System.out.println(maxP);
    }
    
    // 最大積載量pのトラックk台に、wの要素はいくつ載せられるか?
    static int f(int p) {
        int i = 0;
        for (int iK = 0; iK < k; iK++) {
            int pK = 0;
            while (pK + w[i] <= p) {
                pK += w[i];
                i++;
                if (i == w.length) return w.length;
            }
        }
        return i;
    }
}


Measured memory_bytes: 70936
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,n;
    cin >> n;
    int max = 0;
    
    string s,str[n];
    map<string, int> dict;
    for(i=0; i<n; i++){
        cin >> s;
        dict[s] += 1;
        if(dict[s]==1){
            str[i] = s;
        }
        if(dict[s]>max){
            max = dict[s];
        }
    }
    
    sort(str, str+n);
    for(i=0; i<n; i++){
        if(dict[str[i]] == max){
            cout << str[i] << endl;
        }
    }   
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 a,b, c,d, n;
void solve(){
	cin >> a >> b >> c >> d >> n;
	
	if(abs(a-c) > (b-d)*n){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3648
ls = []

for i in range(5):
    ls.append(int(input()))
sum = 0
ls1 = []
for i in range(5):
    if ls[i] % 10 == 0:
        sum += ls[i]
    else:
        ls1.append(10 - ls[i] % 10)
        sum += ((ls[i] // 10) + 1)* 10
#print(ls1)
if len(ls1) != 0:
    print(sum - max(ls1))
else:
    print(sum)


Measured memory_bytes: 3060
N, M = map(int, input().split())
submit_list = []
for i in range(M):
  input_val = input().split()
  p = int(input_val[0])
  s = input_val[1]
  submit_list.append([p, s])

INDEX_ANS_NUM = 0
INDEX_ANS_RES = 1

data_list = [[False, 0] for _ in range(N)]
IDX_IS_AC_DONE = 0
IDX_COUNT_WA = 1

for submit_index, submit in enumerate(submit_list):
  submit_prob_num = submit[INDEX_ANS_NUM]
  submit_result = submit[INDEX_ANS_RES]
  data_index = submit_prob_num - 1
  if (data_list[data_index][IDX_IS_AC_DONE] == True):
    continue
  else:
    if (submit_result == 'AC'):
      data_list[data_index][IDX_IS_AC_DONE] = True
    else:
      data_list[data_index][IDX_COUNT_WA] += 1

count_AC = 0
sum_WA = 0
for _, data in enumerate(data_list):
  if (data[IDX_IS_AC_DONE] == True):
    count_AC += 1
    sum_WA += data[IDX_COUNT_WA]

print(count_AC, sum_WA)


Measured memory_bytes: 80728
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ');
        var T = int.Parse(inputs[0]);
        var A = int.Parse(inputs[1]);
        var H = new int[N];
        inputs = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            H[i] = int.Parse(inputs[i]);
        }

        var minIndex = 0;
        double min = 1000000;
        for (int i = 0; i < N; i++)
        {
            double t = T - H[i] * 0.006;
            double diff = Math.Abs(A - t);
            if (min > diff)
            {
                minIndex = i;
                min = diff;
            }
        }

        Console.WriteLine(minIndex + 1);
    }

}



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

int main()
{
    int N, X, T;
    std::cin >> N >> X >> T;

    int ans;
    ans = (N/X)*T;

    if((N/X)*X != N)
    {
        ans+=T;
    }

    std::cout << ans << std::endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
#define int long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const long double PI = 2*acos(0.0);

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r; cin >> r;
	cout << 2*r*PI;
}

Measured memory_bytes: 3808
fn main() {
    let count = get_string().trim().to_string().chars().filter(|c| c.eq(&'1')).count();
    println!("{}", count);
}

fn get_string() -> String {
    let mut ret_str = String::new();
    std::io::stdin().read_line(&mut ret_str).unwrap();
    ret_str
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#define LIMIT 1000

int main(void) {
  int a, b, i;
  char A[LIMIT];
  char B[LIMIT];

  scanf("%s",A);
  scanf("%s",B);

  a = strlen(A);
  b = strlen(B);
  for(i = 0 ; i <= a-b ; i++) {
    if(strncmp(&A[i], B, b) == 0)
      printf("%d\n", i);
  }
  return 0;
}


Measured memory_bytes: 2120