akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var A = cin.ReadInt();
            var B = cin.ReadInt();
            var S = cin.Read();
            for (int i = 0; i < A; ++i)
                if (S[i] < '0' || '9' < S[i]) { WriteLine("No"); return; }
            if (S[A] != '-') { WriteLine("No"); return; }
            for (int i = 0; i < B; ++i)
                if (S[A + i + 1] < '0' || '9' < S[A + i + 1]) { WriteLine("No"); return; }
            WriteLine("Yes");
        }  
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}

Measured memory_bytes: 13268
import sys
import collections
import bisect


def main():
    n = int(input())
    under = 1
    for i in range(1, n + 1):
        under *= i

    xyList = [list(map(int, input().split())) for _ in range(n)]
    xyListSum = 0
    for xn in range(1, n):
        for yn in range(xn + 1, n + 1):
            leng = ((xyList[xn-1][0] - xyList[yn-1][0]) **
                    2 + (xyList[xn - 1][1] - xyList[yn - 1][1]) ** 2) ** 0.5
            xyListSum += leng * 2
    print(xyListSum / n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9672
# Your code here!
MAX_TIME = 100000

n, c = gets.chomp.split(' ').map(&:to_i)
programs = Array.new(c){[]}
n.times do 
    s, t, c = gets.chomp.split(' ').map(&:to_i)
    programs[c - 1] << [s, t]
end
programs.each(&:sort!)
array = Array.new(MAX_TIME * 2 + 2){0}

programs.each do |list|
    unless list.empty?
        array[list.reduce(0) {|acc, (a, b)|
            if a != acc 
                array[a * 2 - 1] += 1
                if acc != 0
                    array[acc * 2 + 1] -= 1
                end
            end
            b
        } * 2 + 1] -= 1
    end
end
for i in 1 ... array.size
    array[i] += array[i - 1]
end
p array.max


Measured memory_bytes: 12136
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  for (int t, i = 0; i < n; ++i) {
    cin >> t;
    nums.push_back(t);
  }
  int count = 0;
  for (auto it = nums.begin(); it != nums.end(); ++it) {
    for (auto it2 = nums.rbegin(); distance(it2, make_reverse_iterator(it)) >= 2; ++it2) {
      auto next_ = next(it2);
      if (*it2 < *next_) {
        iter_swap(it2, next_);
        ++count;
      }
    }
  }

  for (auto it = nums.begin(); it != nums.end(); ++it) {
    cout << *it;
    if (next(it) != nums.end()) {
      cout << " ";
    }
  }
  cout << endl;
  cout << count << endl;
}

Measured memory_bytes: 3128
# -*- coding: utf-8 -*-
"""
A - Security
https://atcoder.jp/contests/abc131/tasks/abc131_a

"""
import sys


import re

def solve(S):
    m = re.search(r'(.)\1', S)
    if m:
        return 'Bad'
    return 'Good'


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  int N;
  cin >> N;
  double X = N/1.08;
  int Y = int(X)+1;
  int Z = int(X);
  if(int(Y*1.08)==N){
    cout << Y << endl;
  }
  else if (int(Z*1.08)==N)
  {
    cout << Z << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
    return 0;
}

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

using namespace std;

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

    t.resize(s.size());

    if(s.compare(t)==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int a,b,ans;
		String str;
		String[] s;
		str = bf.readLine();
		s = str.split(" ");
		a = Integer.parseInt(s[0]);
		b = Integer.parseInt(s[1]);
		if(a > b) {
			ans = 2*a-1;
		} else if(a < b) {
			ans = 2*b-1;
		} else {
			ans = 2*a;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21076
import sys
from collections import deque
N,M=map(int,input().split())
s=input()
table=[]
for i in range(M):
    x,y=map(int,input().split())
    table.append((x-1,y-1))
edge=[[]for i in range(2*N)]
visit=[0]*(2*N)
for x,y in table:
    if x==y:
        edge[2*x].append(2*x+1)
        visit[2*x+1]+=1
        continue
    if s[x]==s[y]:
        edge[2*x].append(2*y+1)
        edge[2*y].append(2*x+1)
        visit[2*x+1]+=1
        visit[2*y+1]+=1
        continue
    edge[2*x+1].append(2*y)
    edge[2*y+1].append(2*x)
    visit[2*x]+=1
    visit[2*y]+=1
S=set()
L=deque()

for i in range(2*N):
    if visit[i]==0:
        L.append(i)

while L:
    x=L.pop()
    S.add(x)
    for y in edge[x]:
        visit[y]-=1
        if visit[y]==0:
            L.append(y)
if len(S)!=2*N:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 132284
#include <stdio.h>

int main(void)
{
	int n, m;
	int i;
	int a, b, cnt[50] = {0};
	
	scanf("%d%d", &n, &m);
	
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		cnt[a - 1]++;
		cnt[b - 1]++;
	}
	
	for (i = 0; i < n; i++) {
		printf("%d\n", cnt[i]);
	}
	
	return (0);
}


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

int main() {
	int H, W;
	vector<string> s;

	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		string tmp;
		cin >> tmp;
		s.push_back(tmp);
	}

	for (int i = 0; i < W+2; i++)
	{
		cout << '#' ;
	}
	cout << endl;

	for (int i = 0; i < H; i++)
	{
		cout << '#' << s.at(i) << '#' << endl;
	}

	for (int i = 0; i < W + 2; i++)
	{
		cout << '#' ;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])

def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
    if a == 0:
        return strInput[b::-1]+strInput[b+1:]
    else:
        return strInput[:a]+strInput[b:a-1:-1]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()



Measured memory_bytes: 5624
N=int(input())
A = list(map(int,input().split()))
Q=int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i]=map(int,input().split())
#print(B,C)
#print(A)
#a = 0
#for i in range(N):
    #a += A[i]
#print(a)
ls = [0]*100000
for i in A:
    ls[i-1] += 1
#print(ls)
sumA = sum(A)
#print("sumA",sumA)
for j in range(Q):
    #print(B[j]-1)
    #print(ls)
    sumA += (C[j]-B[j])*ls[B[j]-1]
    #print("j","C[j]","B[j]","ls[B[j]]",j,C[j],B[j],ls[B[j]-1])
    ls[C[j]-1] += ls[B[j]-1]
    ls[B[j]-1] = 0
    print(sumA)


Measured memory_bytes: 85596
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[2000000], ans, dp[5000][5000], a[2000000], b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL from, cost; };
vector<Edge>vec[1000000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL gcd(LL x, LL y)
{
	LL r;
	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}
int main() {
	cin >> n;
	rep(i, n) {
		LL x, y, z, w;
		cin >> x >> y >> z >> w;
		if (x < y)cout << "No" << endl;
		else {
			LL A[5];
			if (y > w)cout << "No" << endl;
			else {
				if (y - 1 <= z)
					cout << "Yes" << endl;
				else {
					x %= y;
					if (x > z)
						cout << "No" << endl;
					else {
						if (y == w) {
							if (x <= z)
								cout << "Yes" << endl;
							else	cout << "No" << endl;
						}
						else {
							A[4] = gcd(w, y);
							if (y / A[4] * A[4] - x / A[4] * A[4] +x > z
								&&y / A[4] * A[4] - x / A[4] * A[4] +x < y)
								cout << "No" << endl;
							else if (y / A[4] * (A[4]) - x/A[4]*A[4]-A[4]+x > z)
								cout << "No" << endl;
							else
								cout << "Yes" << endl;
						}
					}
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 24832
n,q = map(int, input().split())
s = "_" + input() + "_"
l, r = 0, n+1

for(t,d) in [input().split() for i in range(q)][::-1]:
    L = d == "L"
    R = d == "R"
    l += (t==s[l+1] and L) - (t==s[l] and R)
    r += (t==s[r] and L) - (t==s[r-1] and R)
print(r-l-1)


Measured memory_bytes: 40892
#include <stdio.h>

int main(void) {
	int a, b, c, d, n, ctr;
	while (scanf ("%d", &n) != EOF){
		ctr = 0;
		for (a=0; a<10; a++)
			for (b=0; b<10; b++)
				for (c=0; c<10; c++)
					for (d=0; d<10; d++)
						if (n == a+b+c+d) ctr++;
		printf ("%d\n", ctr);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100+10;

int n;
int b[maxn];
int kq;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n-1;i++) scanf("%d",&b[i]);
  kq=b[1];
  for(int i=2;i<=n-1;i++)
    kq=kq+min(b[i-1],b[i]);
  kq=kq+b[n-1];
  cout<<kq<<endl;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1e18
#define N 100005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll prod = -MAX;
	prod = max(prod,(b*d));
	prod = max(prod,(a*c));
	prod = max(prod,(a*d));
	prod = max(prod,(b*c));
	if(a<=0&&b>=0){
		prod = max(prod,0LL);
	}
	if(c<=0&&d>=0){
		prod = max(prod,0LL);
	}
	cout<<prod<<endl;


	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int X;
    cin >> X;
    int ans = 0;
    ans += (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
}


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

int main(){
        int64_t n, tmp = 1;
        cin >> n;
        vector<int64_t> a(n);
        vector<int64_t> dp;
        for(int64_t i = 0; i < n; i++) cin >> a[i];
        dp.push_back(a[0]);
        int64_t cnt = 0;
        for(int64_t i = 1; i < n; i++){
                if(dp[cnt] < a[i]){
                        cnt++;
                        dp.push_back(a[i]);
                }
                else{
                        for(int64_t j = 0; j < dp.size(); j++){
                                if(dp[j] >= a[i]){
                                        dp[j] = a[i];
                                        break;
                                }
                        }
                }
        }
        cout << dp.size() << endl;
        return 0;
}



Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int W,count=0;
     cin >> W;
     string A,B,C;
     cin >> A >> B >> C;
     for(int i=0; i<W; i++){
         if(A[i]==B[i] && A[i]!=C[i]){
             count+=1;
         }else if(A[i]==C[i] && A[i]!=B[i]){
             count += 1;
         }else if(B[i]==C[i] && A[i]!=B[i]){
             count +=1;
         }else if(A[i]!=B[i] && B[i]!=C[i] && C[i]!=A[i]){
             count +=2;
         }
     }
     cout << count << endl;
 }

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

f = [lambda x : x * 2, lambda x : x + K]

o = 1024
for i in range(2**N):
    p = 1
    for j in [(i//(2**x))%2 for x in range(N)]:
        p = (f[j])(p)
    o = min(o,p)

print(o)


Measured memory_bytes: 3060
def min(a,b) a<b ? a:b end
N,K=gets.split.map(&:to_i)
S=gets.chomp.split("")

lr = 0
rl = 0
point = 0
(N-1).times do |i|
  if S[i] == S[i+1]
    point += 1
  else
    if S[i] == "L"
      lr += 1
    else
      rl += 1
    end
  end
end
t = min(lr, rl)
if K <= t
  point += K*2
else
  if lr == rl
    point += t*2
  else
    point += (t+1)*2 - 1
  end
end

p point

Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int col[N] = {};
long long cnt[N] = {};
long long ans[N] = {};
vector<int> G[N] = {};
long long n;
long long dfs(int u, int f) {
    long long ret = 1, s = 0, tag = cnt[col[u]];
    long long intag = tag;
    for (const int &v : G[u]) {
        if (v == f) continue;
        s = dfs(v, u);
        ret += s;
        long long d = s - (cnt[col[u]] - tag);
        ans[col[u]] -= d * (d - 1) / 2;
        tag = cnt[col[u]]; 
    }
    cnt[col[u]] = intag + ret;
    return ret;
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    fill(ans + 1, ans + 1 + n, n * (n - 1) / 2);
    for (int i = 1; i <= n; i++) {
        cin >> col[i];
        ans[col[i]]++;
    }
    int u, v;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    dfs(1, 1);
    for (int i = 1; i <= n; i++) {
        long long s = n - cnt[i];
        ans[i] -= s * (s - 1) / 2;
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 37212
N = int(input())
h = list(map(int, input().split()))

def is_ok(state):
    flag = 0
    for i in range(N):
        if state[i] != h[i]:
            return False
    return True

i = 0
cnt = 0
state = [0 for _ in range(N)]
while not is_ok(state):
    if state[i] == h[i]:
        i += 1
        continue
    j = 0
    while i + j < N and state[i+j] != h[i+j]:
        j += 1
    for k in range(i, i+j):
        state[k] += 1
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
n = int(input())
if n < 3:
    print(n)
else:
    n_1 = 1
    n_2 = 1
    for i in range(2, n+1):
        n_0 = n_1 + n_2
        n_2, n_1 = n_1, n_0
    print(n_0)



Measured memory_bytes: 5600
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)
 
typedef vector<int> vi;
 
int main()
{
    int n;
    scanf("%d", &n);
    rep(i, n){
        double x1, y1, x2, y2, x3, y3;
        scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
        double a1 = 2.0*(x2-x1);
        double b1 = 2.0*(y2-y1);
        double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
        double a2 = 2.0*(x3-x1);
        double b2 = 2.0*(y3-y1);
        double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
 
        double px = (b1*c2-b2*c1)/(a1*b2-a2*b1);
        double py = (c1*a2-c2*a1)/(a1*b2-a2*b1);
        printf("%.3f %.3f %.3f\n", px, py, sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1)));
    }
 
    return 0;
}

Measured memory_bytes: 1092
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:= 1; i <= n;i++{
		x := i
		if i%3 == 0{
			fmt.Printf(" %d",i)
			continue
		}
		for x > 0 {
			if x%10==3 {
				fmt.Printf(" %d", i)
				break
			}
			x/=10
		}
	}
	fmt.Println("")
}


Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int N, M, Q;
int a[50], b[50], c[50], d[50];
vector<int> buf;

int ans = 0;
void dfs(int i, const int size, const int range_start, const int range_end)
{
    if (i == size) {
        int sum = 0;
        vector<int> S;
        for(int i = 0; i < buf.size(); i++) {
            S.push_back(buf[i]);
        }
        for (int i = 0; i < Q; i++) {
            if (S[b[i]-1] - S[a[i]-1] == c[i]) {
                sum += d[i];
            }
            if (sum > ans) {
                ans = sum;
            }
        }
    }
    else{
        for(int j = range_start; j <= range_end; j++){
            buf[i] = j;
            dfs(i + 1, size, j, range_end);
        }
    }
}

int main(void) {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    buf.resize(N);
    dfs(0, N, 1, M);
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int K,X;
int main()
{
	scanf("%d%d",&K,&X);
	for(int i=max(-1000000,X-K+1);i<=min(1000000,X+K-1);i++)
	printf("%d ",i);
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b,c;
	cin >>  a >> b >> c;
	int z = max(max(a, b),c);
	cout << a+b+c - z << "\n";	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s;
	map<char,int> m;
	cin>>s;
	bool exit=false;
	int k=s.length();
	sort(s.begin(),s.end());
	m[s[0]]=1;
	//hth -> hht
	forn(i,1,k-1){
		m[s[i]]++;
		if(s[i]!=s[i-1])
			if(m[s[i-1]]%2==1){
				m[s[i]]=0;
				cout<<"No\n";
				exit=true;
				break;
			}
	}
	if(m[s[k-1]]%2) cout<<"No\n", exit=true;
	if(!exit) cout<<"Yes\n";
	
	return 0;
}

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

int main()
{
	string C1, C2;
	cin >> C1 >> C2;

	for (int i = 0; i < 3; i++)
	{
		if (C1[i] != C2[2 - i])
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 256
def r_in_c():
    W, H, x, y, r = map(int, input().split())
    vertical = (x - r) >= 0 and (x + r) <= W
    horizontal = (y - r) >= 0 and (y + r) <= H
    if vertical and horizontal:
        print('Yes')
    else:
        print('No')
    

if __name__ == "__main__":
    r_in_c()



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin >> c;
    if (c >= 'a')
    {
        cout << "a\n";
    }
    else
    {
        cout << "A\n";
    }
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>

int main() {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
    if(W - x >= r&&H - y >= r&&x >= r&&y >= r) {
        printf("Yes\n");
        return 0;
    }
    else {
        printf("No\n");
        return 0;
    }
}


Measured memory_bytes: 2680
from math import sqrt
N, D = map(int, input().split())
X = [0]*N
Y = [0]*N
d = []

for i in range(N):
    X[i], Y[i] = map(int, input().split())
    d.append(sqrt(X[i]**2+Y[i]**2))

print(len([n for n in d if n <= D]))

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

int main() {
  int n;
  cin >> n;
  long long a[n], dp[n+1], odds[n];
  dp[0] = dp[1] = 0;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; i += 2)
    odds[i] = (i ? odds[i-2] : 0) + a[i];
  for (int i = 1; i < n; i++)
    dp[i+1] = max(a[i] + dp[i-1],i % 2 ? odds[i-1] : dp[i]);
  cout << dp[n] << '\n';
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

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

	int cnt = 0;
	int j = 0;
	vector<int>cn(n);
	for (int i = 1; i < n ; i++) {
		if (s[i] != s[i - 1]) {
			cn[i]++;
		}
	}
	

	rep(i, n)cnt+=cn[i];
	if (cnt == 0) {
		cout << 1 << endl;
		return 0;
	}

	cout << cnt + 1<< endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[3];
int main(){
    ll n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    rep(i,0,n){
        if(s[i]=='R')a[0]++;
        else if(s[i]=='G')a[1]++;
        else a[2]++;
    }
    ans+=a[0]*a[1]*a[2];

    rep(i,1,n/3+1000){
        rep(j,0,n-i*2){
            if(s[j]!=s[j+i]&&s[j]!=s[j+i*2]&&s[j+i]!=s[j+i*2])ans--;
        }
    }

    cout<<ans;
}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int cmp(int a, int b) {
    if (a == b) {
        return 0;
    }
    return a < b ? -1 : 1;
}

void solve() {
    int n;
    read(n);
    vt<int> a(n);
    read(a);
    
    int m;
    read(m);
    int sum = 0;
    FOR(n) {
        sum += a[i];
    }
    
    FOR(m) {
        int x, y;
        read(x, y);
        print(sum - a[x-1] + y);
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



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

#define M 1000000
#define L 13

char Hash[M][L];

int h1(int key){
	return key % M; 
}

int h2(int key){
	return 1 + (key % (M-1)); 
}

int getChar(char str){
	if(str == 'A') return 1;
	else if(str == 'C') return 2;
	else if(str == 'G') return 3;
	else if(str == 'T') return 4;
}

int getKey(char str[]){
	int sum = 0, p = 1;
	for(int i = 0 ; i < strlen(str) ; i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	
	return sum;
}

int insert(char str[]){
	int key, h;
	int x, y;
	key = getKey(str);
	x = h1(key);
	y = h2(key);
	for(int i = 0 ; i < M ; i++){
		h = (x + i * y) % M;
		if(strcmp(Hash[h], str) == 0) return 1;
		else if(strlen(Hash[h]) == 0){
			strcpy(Hash[h], str);
			return 0;
		}
	}
	
	return 0;
}

int find(char str[]){
	int key, h;
	int x, y;
	
	key = getKey(str);
	
	x = h1(key);
	y = h2(key);
	
	for(int i = 0 ; i < M ; i++){
		h = (x + i * y) % M;
		if(strcmp(Hash[h], str) == 0) return 1;
		else if(strlen(Hash[h]) == 0) return 0;;
	}
	
	return 0;
}

int main(){
	int n, h;
	char str[L], status[7];
	
	for(int i = 0 ; i < M ; i++){
		Hash[i][0] = '\0';
	}
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> status >> str;
		
		if(status[0] == 'i'){
			insert(str);
		}else{
			if(find(str)){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 13868
/*
sonu_verma1
*/
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	int n,i,j,k;
	cin>>n;
	double a[n][2];
	for(i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	double s=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i!=j)
			{
				double dis;
				double x1,x2;
				x1=a[i][0]-a[j][0];
				x2=a[i][1]-a[j][1];
				dis=sqrt(x1*x1+x2*x2);
				//cout<<dis<<endl;
				s+=(dis);
			}
		}
	}
	printf("%lf",s/n);

	return 0;
}

Measured memory_bytes: 256
import re
S = input()
T = input()
result=0
if(len(S)!=len(T)):
    pass
elif(re.fullmatch(r'[a-z]{1,200000}', S) and re.fullmatch(r'[a-z]{1,200000}', T)):
    for i in range(len(S)):
        if S[i]!=T[i]:
            result+=1
    print(result)

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

int main() {

  string S;
  cin >> S;
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}


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(void){
    ll A,B;
    cin >> A >> B;
    
    ll q = 4;
    ll ans = 0;
    if(A%2 ==0 && ((B-A)%4 == 1 ||(B-A)%4 == 2) ) ans++;
    if(A%2 ==1 && (B-A)%4 < 2) ans++;
    //cout << ans << endl;
    rep(i,40){
        ans += (max(A%q,q/2) + max(B%q,q/2-1)+1)%2 * q/2; 
//        cout << A%q <<" " << B%q <<endl;
//        cout << (max(A%q,q/2-1) + max(B%q,q/2-1)+1)%2 << endl;
        q = q*2;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    double L;
    cin >> L;

    double x = L/3.0;
    double ans = x*x*x;
    exout(ans);
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define M 1000000007
#define pb push_back
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



int dp[100001][5];
int a[100001];
int b[100001];
int c[100001];
int n,k;

int solve(int i,int f)
{
    if(i>n)
        return 0;
    if(dp[i][f]!=-1)
        return dp[i][f];
    int x=-9999999999,y=-999999999999,z=-99999999999;
    if(f!=1)
    x=a[i]+solve(i+1,1);
    if(f!=2)
    y=b[i]+solve(i+1,2);
    if(f!=3)
    z=c[i]+solve(i+1,3);
    dp[i][f]=max(x,max(y,z));
    return dp[i][f];
}
signed main()
{
    boost
   // #ifndef ONLINE_JUDGE 
   // NAYAN
   // #endif
   
    //int n;
    cin >> n ;
   // int a[n];
    memset(dp,-1,sizeof(dp));
    int i;
    for(i=1;i<=n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int ans=solve(1,0);
    cout << ans << endl;

}






















Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

void func(ll x, ll N, ll &sum){
  if(x <= N){
    string X = to_string(x);
    if(find(all(X),'3')!=X.end() && find(all(X),'5')!=X.end() && find(all(X),'7')!=X.end()) sum++;
    //cout << x << rt;
    func(3*round(pow(10,(ll)log10(x)+1)) + x, N, sum);
    func(5*round(pow(10,(ll)log10(x)+1)) + x, N, sum);
    func(7*round(pow(10,(ll)log10(x)+1)) + x, N, sum);
  }
}

int main(){
  fastio;
  ll N;
  cin >> N;
  ll sum{};
  func(3, N, sum);
  func(5, N, sum);
  func(7, N, sum);
  cout << sum << rt;
}

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

template <typename t>
void print(const t & v){
    for (auto i :v)
        cout << i << " ";
    cout << endl;
}

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

    string s;
    cin >> s;

    while ( n--) {
        for (ll i=0 ; i<s.size() ; i++){
            if ( s[i] == 'Z'){
                s[i] = 'A';
            }

            else {
                s[i] = char(int(s[i] +1 ));
            }
        }
    }
    cout << s << endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	double sum=0,t;
	for(int i=0;i<n;++i){
		cin>>t;
		sum=sum+(1/t);
	}
	sum=(1/sum);
	printf("%.6f\n",sum);

}


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()
{
  int N;
  cin >> N;
  // string w;
  map<string,int> mp;
  rep(i,N) {
    string w;
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  for(auto& p : mp){
    ll count = (ll) p.second;
    ans += count * (count-1) / 2;  //ACになる
 // ans +=(ll) (count * (count-1))/2;  //WAになる
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11136
#include <cstdio>
#define Int register int
const int N = 2000, mod = 1e9 + 7;
typedef long long LL;

static inline char Get_Char() {
	static char buffer[100000], *S = buffer, *T = buffer;
	if (S == T) {
		T = (S = buffer) + fread(buffer, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}

//#define Get_Char() getchar()

static inline int Read() {
	int f = 1, x = 0;
	register char sign = Get_Char();
	for (; sign > '9' || sign < '0'; sign = Get_Char())
		if (sign == '-') f = -1;
	for (; sign >= '0' && sign <= '9'; sign = Get_Char())
		x = (x << 3) + (x << 1) + (sign ^ 48);
	return x * f;
}

int a[N + 1];
LL Rec[N + 1], Ans;
int main() {
	int n = Read(), k = Read();
	for (Int i = 1; i <= n; ++ i) {
		a[i] = Read();
	}
/*
3 2
3 2 1
*/
	for (Int i = 1; i <= n; ++ i) {
		for (Int j = 1; j < i; ++ j) {
			if (a[j] > a[i])
				++Ans;
		}	
	}
	
	for (Int i = 1; i <= n; ++ i) {
		for (Int j = 1; j <= n; ++ j) {
			if (a[i] > a[j])
				++Rec[i];
		} 
	}
	
	Ans = Ans * k % mod;
	
	for (Int i = 1; i <= n; ++ i) {
		Ans = (Ans + Rec[i] * ((1ll * (1 + k - 1) * (k - 1) / 2) % mod)) % mod;
	} 
	
	printf("%lld\n", Ans); 
	return 0;
}



Measured memory_bytes: 128
#!/usr/bin/env python3

def main():
    N = int(input())
    L =  [int(s) for s in input().split()]
    most_long = 0
    other_longs = 0
    for l in L:
        if(l>most_long):
            other_longs += most_long
            most_long = l
        else:
            other_longs += l
    if(other_longs>most_long):
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var N, A, C int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A)
		if i == 0 {
			C = A
		} else {
			for {
				if A > C {
					if A%C != 0 && A%C < C {
						D := C
						C = A % C
						A = D
					} else {
						break
					}
				} else {
					if C%A != 0 && C%A < A {
						D := A
						A = C % A
						C = D
					} else {
						C = A
						break
					}
				}
			}
		}
	}
	fmt.Println(C)
}


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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

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

  int L[N];

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

  sort(L, L + N, greater<>());

  if (L[0] < (total - L[0])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
struct ddd{
	int s, b;
}num[222222];
int N;
bool cmp(struct ddd x, struct ddd y){
	return x.s < y.s;
}
int main(){
	cin>>N;
	int x, y;
	int mi = 0, ma = 1e9, mmi = 1e9, mma = 0;
	for(int i = 1;i <= N; i++){
		scanf("%d%d", &x, &y);
		num[i].s = min(x, y);
		num[i].b = max(x, y);
		mi = max(mi, min(x, y));
		ma = min(ma, max(x, y));
		mmi = min(mmi, min(x, y));
		mma = max(mma, max(x, y));
	}
	sort(num + 1, num + 1 + N, cmp);
	LL ans = 1LL * (1LL * mma - 1LL * ma) * (1LL * mi - 1LL * mmi);
	ma = mi = num[1].b;
	for(int i = 1;i < N; i++){
		ans = min(ans, 1LL * (1LL * mma - 1LL * mmi) * (1LL * max(ma, num[N].s) - 1LL * min(mi, num[i+1].s)));
		mi = min(mi, num[i+1].b);
		ma = max(ma, num[i+1].b);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>  // {{{
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()

using Int = long long;
// clang-format off
template<typename T,typename U>inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
template<typename T,typename U>inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
inline signed in(){signed x;scanf("%d",&x);return x;}
// clang-format on
// }}}

using namespace std;

signed main() {
  int n = in();
  REP(i, n) {
    Int base = 1u << 31;
    Int src = in() + base, dst = in() + base;
    Int step = 0;
    while (src != dst) {
      step += src % 2 + dst % 2;
      src = (src + 1) / 2;
      dst = (dst + 0) / 2;
    }
    cout << step << endl;
  }
  return 0;
}

Measured memory_bytes: 3188
unittest
{
	assert( [ "5", "1 1 2 2 2" ].parse.expand.solve == 2 );
	assert( [ "3", "1 2 1" ].parse.expand.solve == 0 );
	assert( [ "5", "1 1 1 1 1" ].parse.expand.solve == 2 );
	assert( [ "14", "1 2 2 3 3 3 4 4 4 4 1 2 3 4" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto bs = as.group.filter!( ( a ) => ( 2 <= a[ 1 ] ) );
	auto cs = bs.map!( ( a ) => a[ 1 ] / 2 );
	return cs.sum;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>

using namespace std;

int main(void)
{
	long long int n;
	cin >> n;
	vector<int> a(n);
	long long int i;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long int ans;
	ans = a[0] - a[n - 1];
	ans = fabs(ans);

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


Measured memory_bytes: 256
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

import sys
input = sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
 
f=bfs(0);s=bfs(n-1)
ctf=0;cts=0
for i in range(n):
  if f[i]<=s[i]:
    ctf+=1
  else:
    cts+=1
 
if ctf>cts:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 78040
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , x = 0 , y = 0;
    cin >> a;
    int b[a];
    for( int i = 0 ; i < a ; i++ ) cin >> b[i];
    sort( b , b  + a );
    for( int i = 0 ; i < a ; i++ ) {
        if( i % 2 ) y += b[i];
        else x += b[i];
    }
    cout << abs( x - y );
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdlib>
#include<map>
#include<algorithm>

using namespace std;

int main(){
  string str;
  int max_len = 0;
  int max_fac = 0;
  string max_str1;
  string max_str2;
  map<string, int> map_str;
  while(cin >> str) {
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    map_str[str]++;
  }

  map<string, int>::iterator it;
  for(it = map_str.begin(); it != map_str.end(); it++) {
    if(max_len < (it->first).size()) {
      max_len = (it->first).size();
      max_str1 = it->first;
    }
    if(max_fac < it->second) {
      max_fac = it->second;
      max_str2 = (it->first);
    }
  }

  cout << max_str2 << " " << max_str1 << endl;

  return 0;
}

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

int main()
{
    int a[10], m1, m2, m3;
    for(int i = 0; i < 10; i++) cin >> a[i];
    m1 = a[0]; m2 = a[1]; m3 = a[2];
    if(m1 < m2) swap(m1, m2);
    if(m1 < m3) swap(m1, m3);
    if(m2 < m3) swap(m2, m3);
    for(int i = 3; i < 10; i++){
        if(a[i] > m1) m3 = m2, m2 = m1, m1 = a[i];
        else if(a[i] > m2) m3 = m2, m2 = a[i];
        else if(a[i] > m3) m3 = a[i];
    }
    cout << m1 <<'\n'<<m2<<'\n'<<m3<<'\n';
    return 0;
}

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

int gcd(int x,int y){

  	if(x%y==0){
      	return y;
    }
    else {
      	return gcd(y,x%y);
    }
}
   
int main(){
  	int k;
  	int sum=0;
  	int j;
  	cin>>k;
  
for(int a=1;a<(k+1);a++){
  	for(int b=1;b<(k+1);b++){
      	for(int c=1;c<(k+1);c++){
          	j=gcd(a,gcd(b,c));
            sum=sum+j;
        }
    }
}
  
cout<<sum<<endl;
  
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
    int n[5],a[5],i,j;
    for(i = 0; i < 5; i++) scanf("%d",&n[i]);

    for(i = 0; i < 5; i++){
        for(j = i+1; j < 5; j++){
            if(n[i] < n[j]){
                a[i] = n[i];
                n[i] = n[j];
                n[j] = a[i];
            }
        }
    }

    for(i = 0; i < 5; i++){
        printf("%d",n[i]);
        if(i == 4) printf("\n");
        else printf(" ");
    }
    return 0;
}

Measured memory_bytes: 600
def main():
    N = int(input())
    H = list(map(int, input().split()))
    M = 0
    count = 0
    s = H.pop(0)
    for h in H:
        if s >= h:
            count += 1
        else:
            M = max(M, count)
            count = 0
        s = h
    print(max(M, count))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
bool a=false;
bool b=false;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C') a=true;
		if(s[i]=='F' && a) b=true;
	}
	if(a && b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256