akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
#include<iomanip>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> list(N);
  int i = 0;
  for (i = 0; i < N; i++) {
    cin >> list[i].first >> list[i].second;
  }
  vector<pair<int, int>> tmp(N);
  vector<int> v(N);
  double ans = 0.0;
  iota(v.begin(), v.end(), 0);
  int t=0;
  do {
    i=0;
    for (auto x : v){
      tmp[i].first =list[x].first;
      tmp[i].second = list[x].second;
      i++;
    }
    rep(i, N-1) {
      ans += sqrt(
          (tmp[i].first - tmp[i + 1].first)*(tmp[i].first - tmp[i + 1].first) +
          (tmp[i].second - tmp[i + 1].second) *(tmp[i].second - tmp[i + 1].second)
          );
    }
    t ++;
  } while (next_permutation(v.begin(), v.end()));  // 次の順列を生成
  cout << setprecision(8) << ans / t;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc133/tasks/abc133_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a,b;
  cin >> n >> a >> b;
  if (n*a>b) {
    cout << b << endl;
  } else {
    cout << n*a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    foreach (i; 0 .. H)
    {
        auto S = aryread!string();
        foreach (j, s; S)
            if (s == "snuke")
            {
                writeln(cast(char)(j + 'A'), i + 1);
            }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 

using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 5e5 + 100;
const ll mod = 1e9 + 7;
 
int main ()
{
	data();           
	int n, k;
	cin >> n >> k;
	k *= 2;
	k += 1;
	cout << n / k + (n % k ? 1 : 0);
}     
//JUDGE_ID: 295965SY
//Tis I

Measured memory_bytes: 3596
N,M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0 for i in range(M)]
B = [0 for i in range(M)]
for i in range(M):
    A[i],B[i] = list(map(int, input().split()))
lookup_points = [True for i in range(N)]
for i in range(M):
    if H[A[i]-1] > H[B[i]-1] :
        lookup_points[B[i]-1] = False
    elif H[A[i]-1] == H[B[i]-1]:
        lookup_points[A[i]-1] = False
        lookup_points[B[i]-1] = False
    else:
        lookup_points[A[i]-1] = False
count = 0
for point in lookup_points:
    if point :
        count += 1
print(count)
        

Measured memory_bytes: 21860
n=gets.to_i
h=gets.chomp.split(" ").map(&:to_i)
cnt=0
max=-999999
(n-1).times do|i|
	if(h[i]>=h[i+1])
		cnt+=1
	else
		max=cnt if(max<cnt)	
		cnt=0
	end
end
max=cnt if(max<cnt)
puts max

Measured memory_bytes: 9604
#include <stdio.h>
int main(void){
    int N,B,C,i,j,cnt=0;
    scanf("%d%d%d",&N,&B,&C);
    int b[B],a[B];
    for(i=0;i<B;i++) scanf("%d",&b[i]);
    for(i=0;i<N;i++){
        int g=0;
        for(j=0;j<B;j++){
            scanf("%d",&a[j]);
            g+=a[j]*b[j];
        }
        if(g+C>0) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


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

int res;
int main() {

    int n,i,j;
    cin>>n;
    int a[n+1],b[n+1],c[n];
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++) cin>>b[i];
    for(i=1;i<n;i++) cin>>c[i];

    for(i=1;i<=n;i++){
        res += b[a[i]];
        if(i>1 && a[i]==a[i-1]+1) res += c[a[i-1]];
    }


    cout<<res;
    return 0;
}

Measured memory_bytes: 256
K = int(input())
if K <= 10:
    print(K)
    exit()

arr = [0] * K
for i in range(1, 10):
    arr[i - 1] = i

cur = 9
s = 0
while True:
    tmp = arr[s]
    num = tmp % 10
    
    if num > 0:
        arr[cur] = tmp * 10 + (num - 1)
        cur += 1
        if cur  == K:
            break
        
        
    arr[cur] = tmp * 10 + num
    cur += 1
    if cur == K:
        break

    if num < 9:
        arr[cur] = tmp * 10 + (num + 1)
        cur += 1
        if cur == K:
            break
    s += 1

print(arr[-1])


Measured memory_bytes: 7156
//abc147_c.cpp
//Sun Dec  8 21:05:29 2019

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

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

	vector<int> member[n];
	vector<int> shogen[n];

	for (int i=0;i<n;i++){
		int num;
		cin >> num;
		for (int j=0;j<num;j++){
			int people,flag;
			cin >> people >> flag;
			people--;
			member[i].push_back(people);
			shogen[i].push_back(flag);
		}
	}


	int ans = 0;
	for (int i=0;i<1<<n;i++){
		int okflag = 1;
		for (int j=0;j<n;j++){
			if (i&(1<<j)){
				for (int k=0;k<member[j].size();k++){
					int tempp = member[j][k];
					int tempf = shogen[j][k];
					int flagflag = (i>>tempp) & 1;
//					cout << i << "\t" << flagflag << "\t" << tempf << endl;
					if (flagflag!=tempf){
//						cout << "pass" << endl;
						okflag = 0;
						break;
					}
				}
				if (!okflag){
					break;
				}
			}
		}
		int tempans = 0;
		if (okflag){
			for (int l=0;l<n;l++){
				if (i&(1<<l)){
					tempans++;
				}
			}
		}
		ans = max(ans,tempans);
//		cout << ans << endl;
	}



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

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll X, Y, Z;
  cin >> X >> Y >> Z;

  for(ll i = 0; i < 1; i++){
    cout << Z << " " << X << " " << Y << endl;
  }

  return 0;
  
}


Measured memory_bytes: 256
num = str(input())

op=['+', '-']
siki=[]
for op1 in op:
    for op2 in op:
        for op3 in op:
            siki.append(num[0] + op1 + num[1] + op2 + num[2] + op3 + num[3])

for s in siki:
    if eval(s) ==7:
        print(s+"=7")
        break


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <complex>

using namespace std;
using Arrow = complex<long long>;

class Solution {
public:
	long double engines(vector<Arrow>& arrows) {
		const int n = arrows.size();
		sort(arrows.begin(), arrows.end(), [](const auto& a, const auto& b) { return atan2(a.imag(), a.real()) < atan2(b.imag(), b.real()); });
#if 0
		cout << "Input in sorted: " << endl;
		for (auto arrow : arrows)
			cout << arrow << endl;
		cout << endl;
#endif
		Arrow curr(0, 0);
		long long ans = 0;
		int j = 0;
		for (int i = 0; i < n * 2; i++) {
			if (j < i) {
				curr = Arrow(0, 0);
				j = i;
			}
			while (j < 2 * n && j < i + n && norm(curr + arrows[j % n]) >= norm(curr)) {
				curr += arrows[j % n];
				j++;
			}
			ans = max(ans, norm(curr));
			curr -= arrows[i % n];
		}
		return sqrt(ans);
	}
};

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

	vector<Arrow> arrows(n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		arrows[i] = Arrow(x, y);
	}

	Solution sol;
	long double ans = sol.engines(arrows);
	cout << fixed << setprecision(50) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long
#define P pair<int, int>
using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  int c,d;
  c = stoi(a);
  d = stoi(b);
  string e,f;
  rep(i,d) e += a;
  rep(i,c) f += b;
  if(a < b) cout << e << endl;
  else cout << f << endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long A = GetLong();
		long B = GetLong();
		long K = GetLong();

		long cnt = 0;
		for(long i = Min(A, B); ; i--)
		{
			if(A % i == 0 && B % i == 0)
				cnt++;

			if(cnt == K)
			{
				WriteLine(i);
				return;
			}
		}
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27340
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 100001;
bool dp[MAX];
int a[MAX];
int bin_search(int a[], int l, int r, int x, int n)
{
	int m = (l + r) / 2;
	while (l <= r)
	{
		if (a[m] == x)
			return m;
		else
		{
			if (a[m] > x)
				return bin_search(a, l, m - 1, x,n);
			else
				return bin_search(a, m + 1, r, x,n);
		}
	}
	return (m>=n ? n-1 : m);
}
int main()
{
	int n, k;
	int p;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	dp[0] = 0;
	for (int i = a[0]; i <= k; i++)
	{
		p = bin_search(a, 0, n, i,n);
		if (p >= 0)
		{
			for (int j = p; j >= 0; j--)
			{
				if (dp[i - a[j]]==0)
				{
					dp[i] = 1;
					break;
				}
			}
		}
	}
	if (dp[k] == 0)	cout << "Second";
	else			cout << "First";

	
	return 0;
}

Measured memory_bytes: 384
from math import sqrt
import itertools

N = int(input())
P = []
for i in range(N):
  P.append(list(map(int, input().split())))
  
def dist(P,Q):
  return sqrt( (P[0]-Q[0]) ** 2 + (P[1]-Q[1]) ** 2 )

def isFound(R):
  for i,j in itertools.combinations(list(range(N)),2):
    if dist(P[i], P[j]) >= 2*R:
      continue
    ### calculate cross points with 2 circles whose center us Pi, Pj
    x1,y1 = P[i]
    x2,y2 = P[j]
    PM = dist(P[i], P[j])/2
    #midP = [(P[i][0] + P[j][0])/2, (P[i][1] + P[j][1])/2]
    xm,ym = (x1+x2)/2, (y1+y2)/2
    #slope = (-1) * (P[i][0] - P[j][0]) / (P[i][1] - P[j][1])
    #slope = (x2-x1)/(y2-y1) * (-1)
    # vector = (y2-y1), (x1-x2)
    x_ev, y_ev = y2-y1, x1-x2
    norm_ev = sqrt(x_ev**2 + y_ev**2)
    x_ev, y_ev = x_ev / norm_ev, y_ev / norm_ev
    #ds = sqrt( R**2 - ((dist(P[i], P[j]))/2) ** 2)
    MM = sqrt( R**2 - PM**2 )

    P1 = [xm + x_ev * MM, ym + y_ev * MM]
    P2 = [xm - x_ev * MM, ym - y_ev * MM]
    #print(P1, P2)
    
    ### judge each point within circle which P is center, R is radius
    for v in [P1, P2]:
      flg = False
      for p in P:
        if dist(v,p) > R + 1e-7: # testcase1
          flg = True
          break
      if flg:
        continue
      else:
        return True
  
  return False


l,r = 0, 1001

for i in range(100):
  m = (l+r)/2
  #print(m)
  if isFound(m):
    r = m
  else:
    l = m
        
print(m)

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

typedef long long ll;

const ll kMod = 1e9 + 7;
const int kN = 2e5 + 5;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a % kMod;
	while(b) {
		if(b & 1) ans = ans * bas % kMod;
		bas = bas * bas % kMod;
		b >>= 1;
	}
	return ans;
}

std::vector<int> E[kN];
int n, siz[kN], fa[kN]; ll f[kN];
void Dfs1(int x) {
	f[x] = 1; siz[x] = 1;
	for(int i : E[x])
		if(!siz[i]) {
			Dfs1(i); siz[x] += siz[i]; fa[i] = x;
			f[x] = f[x] * f[i] % kMod;
		}
	f[x] = f[x] * siz[x] % kMod;
}
void Dfs2(int x) {
	for(int i : E[x])
		if(i != fa[x]) {
			f[i] = f[x] * (n - siz[i]) % kMod * QPow(siz[i], kMod - 2) % kMod;
			Dfs2(i);
		}
}

int main() {
	scanf("%d", &n);
	ll fac = 1;
	for(int i = 1; i <= n; ++i) fac = fac * i % kMod;
	for(int i = 1; i < n; ++i) {
		int a, b; scanf("%d%d", &a, &b);
		E[a].push_back(b); E[b].push_back(a);
	}
	Dfs1(1); Dfs2(1);
	for(int i = 1; i <= n; ++i)
		printf("%lld\n", fac * QPow(f[i], kMod - 2) % kMod);
	return 0;
}

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

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

    int WtoE[N], EtoW[N];
    WtoE[0] = 0;
    EtoW[N - 1] = 0;
    for (int i = 0; i < N - 1; ++i) {
        if (S[i] == 'W') WtoE[i + 1] = WtoE[i] + 1;
        else WtoE[i + 1] = WtoE[i];
    }
    for (int i = N - 1; i > 0; --i) {
        if (S[i] == 'E') EtoW[i - 1] = EtoW[i] + 1;
        else EtoW[i - 1] = EtoW[i];
    }

    int min = 300000;
    for (int i = 0; i < N; ++i) {
        if (WtoE[i] + EtoW[i] < min) min = WtoE[i] + EtoW[i];
    }

    cout << min << endl;
    
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,l;
	cin>>n>>l;
	int ans=0,mi=1000000,cab;
	for (int i = 1; i <= n; ++i)
	{
		ans+=l+i-1;
		if (mi>abs(l+i-1))
		{
			mi=abs(l+i-1);
			cab=l+i-1;
		}
	}
	cout<<ans-cab<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();
            int l = s.Length - 2;
            Console.WriteLine(s[0] + $"{l}" + s[s.Length - 1]);

            Console.Out.Flush();
        }
    }
}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  long long ans = 1001001001;
  for (int i = 0; i <= 100000; i++) {
    long long res = 2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B;
    ans = min(ans, res);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[11];
  int b[10];
  while(scanf(" %s",a) != EOF){
    for(int i = 0;i < 10;i++){
      b[i] = a[i] - '0';
    }
    for(int i = 9;i > 0;i--){
      for(int j = 0;j < i;j++){
	b[j] += b[j+1];
	b[j] %= 10;
      }
    }
    printf("%d\n",b[0]);
  }
  return 0;
}

Measured memory_bytes: 3124
int main(){
  int A[9],B[9];
  int N,i,j,num;
  int count=0;
  scanf("%d %d %d",&A[0],&A[1],&A[2]);
  scanf("%d %d %d",&A[3],&A[4],&A[5]);
  scanf("%d %d %d",&A[6],&A[7],&A[8]);
  scanf("%d",&N);
  for(i=0;i<9;i++) B[i]=0;
  for(i=0;i<N;i++){
    scanf("%d",&num);
    for(j=0;j<9;j++){
      if(num==A[j]){
        B[j]=1;
      }
    }
  }
  if(B[0]==1 && B[1]==1 && B[2]==1) count=1;
  if(B[3]==1 && B[4]==1 && B[5]==1) count=1;
  if(B[6]==1 && B[7]==1 && B[8]==1) count=1;
  if(B[0]==1 && B[3]==1 && B[6]==1) count=1;
  if(B[1]==1 && B[4]==1 && B[7]==1) count=1;
  if(B[2]==1 && B[5]==1 && B[8]==1) count=1;
  if(B[0]==1 && B[4]==1 && B[8]==1) count=1;
  if(B[2]==1 && B[4]==1 && B[6]==1) count=1;
  
  if(count==0){
	printf("No");
    return 0;
  }
  else{
    printf("Yes");
    return 0;
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
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;}

main() {
    int N; cin >> N; int A[N]; int sum=0;
    rep(i,N){
        int x; cin >> x;
        sum+=x;
        A[i]=x;
    }
    sort(A,A+N);
    for(int i=0;;i++){
        if(sum%10!=0) {cout << sum << endl; break;}
        else if(i==N) {cout << 0 << endl; break;}
        else if(A[i]%10!=0){
            cout << sum-A[i] << endl; break;
        } 
    }

    return 0;
}

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

const ll MAX = 2*1e17+5;

int main() {
  ll n;
  cin >> n;
  if (n%2) cout << 0 << endl;
  else {
    ll ans = 0;
    ll tmp = 10;
    while (1) {
      ans += n/tmp;
      if (tmp > MAX) break;
      tmp *= 5;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS
    //io_set();
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k){
        cout<<n*x<<endl;
    }
    else{
        ll ans=k*x;
        n-=k;
        ans+=(n*y);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;
struct graph {
	struct node {v n; int gid = 0;};
	vector<node> nodes;
	int gid_counter = 1;

	graph(int n) {
		nodes.resize(n);
	}
	void read(int n) {
		while (n--) {
			int s = in(), t = in();
			nodes[s].n.push_back(t);
			nodes[t].n.push_back(s);
		}
	}
	void traverse(int id, int gid) {
		node &n = nodes[id];
		if (n.gid)
			return;
		n.gid = gid ? gid : gid_counter++;
		for (int i: n.n)
			traverse(i, n.gid);
	}
	bool find(int s, int t) {
		traverse(s, nodes[s].gid);
		return nodes[s].gid == nodes[t].gid;
	}
};

int main() {
	int n = in(), m = in();
	graph g(n);
	g.read(m);
	int q = in();
	while (q--) {
		int s = in();
		out(g.find(s, in())? "yes" : "no", '\n');
	}
}



Measured memory_bytes: 10180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const long inf=1e9;
int main(){
	int X,A,B; cin>>X>>A>>B;
	cout<<(X - A) % B<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;

    int ans = 0;
    for(int n_cake = 0; n_cake <= N/4; n_cake++){
        int rest = N - (n_cake * 4);
        if(rest % 7 == 0) ans++;
    }
    if(ans > 0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int count[10][10];
    memset(count, 0, sizeof(count));
    for (int i = 1; i <= n; i++) {
        int last = i % 10;
        if (last == 0) {
            continue;
        }
        int first = to_string(i)[0] - '0';
        count[first][last]++;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int k = 0; k < 10; k++) {
            ans += count[i][k] * count[k][i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll ncr[51][51];
int n, a, b;
ll v[50];

void nCr(ll n, ll r) {
	REP(i, n + 1) {
		REP(j, i + 1) {
			if (j == 0 || j == i) ncr[i][j] = 1;
			else ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j];
		}
	}
}

int main() {
	cin >> n >> a >> b;
	REP(i, n) scanf("%lld", v + i);
	sort(v, v + n, greater<ll>());
	
	nCr(n, n);
	
	double ma = 0.0;
	REP(i, a) ma += v[i];
	ma /= a;
	printf("%.15lf\n", ma);
	
	int cnt = 0, bec = a;
	REP(i, n) if (v[i] == v[a - 1]) cnt++;
	REP(i, a) if (v[i] != v[a - 1]) bec--;
	
	ll ans = 0;
	
	if (v[a - 1] == v[0])
		FOR(i, bec, min(b, cnt) + 1) ans += ncr[cnt][i];
	else
		ans += ncr[cnt][bec];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main(){
  int x,n;
  cin>>x>>n;
  if(n==0) {
    cout<<x<<endl;
    return 0;
  }
  int a[n];
  for(int i=0;i<n;++i) cin >>a[i];
  sort(a, a + (n));
  int flag=-1;
  for(int i=0;i<n;++i) {
    if((int)a[i]==x) {
      flag=i;
      break;
    }
  }
  if(flag==-1) {
    cout<<x<<endl;
    return 0;
  }
  int k=1;
  while(1) {
    if(a[flag+k]==x+k && a[flag-k]==x-k) {
      ++k;
      continue;
    }
    if(a[flag-k]!=x-k) {
      cout<<x-k<<endl;;
      return 0;
    }
    if(a[flag+k]!=x+k) {
      cout<<x+k<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final int a = scan.nextInt();
        final String s = scan.next();

        if(a >= 3200){
            System.out.println(s);
        }
        else{
            System.out.println("red");
        }
        scan.close();
    }
  
}

Measured memory_bytes: 21844
import java.util.HashMap;
import java.util.Scanner;
import java.util.Map;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        Map<Integer, Integer> map = new HashMap<>();
        int a;
        int b;
        for (int i = 0; i < 3; i += 1) {
            a = sc.nextInt();
            b = sc.nextInt();
            
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            } else {
                map.put(a, 1);
            }
            if (map.containsKey(b)) {
                map.put(b, map.get(b) + 1);
            } else {
                map.put(b, 1);
            }
        }
        
        if (map.containsValue(3)) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }

    }

}


Measured memory_bytes: 23764
#include<stdio.h>

int main() {
    int n, s, i, h,max= 0;

    scanf("%d %d", &h, &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &s);
        max += s;
    }

    if (h <= max) printf("Yes\n");

    else printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int a;
	scanf("%d", &a);
	if (a<=15)
	{
		int b;
		b = a * 800;
		printf("%d", b);
	}
	if (a > 15)
	{
		int c;
		c = a * 800 - 200 * (a / 15);
		printf("%d", c);
	}
	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>

void printArray(std::vector<int> a) {
  int n = (int)a.size();
  for (int i = 0; i < n; i++) {
    std::cout << a[i] <<std::endl; 
  }
}

int insertionSort(std::vector<int> &a, int g) {
  int cnt = 0, n = (int)a.size();
  for (int i = g; i < n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}

int shellSort(std::vector<int> &a) {
  std::vector<int> g;
  for (int i = 1; i <= (int)a.size(); i = i * 3 + 1) {
    g.push_back(i);
  }
  int m = (int)g.size();
  std::cout << m << std::endl;

  int cnt = 0;
  for (int i = m - 1; i >= 0; i--) {
    cnt += insertionSort(a, g[i]);

    std::cout << g[i];
    if (i > 0)
      std::cout << " ";
    else
      std::cout << std::endl;
  }

  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  std::cout << shellSort(a) << std::endl;
  printArray(a);
}



Measured memory_bytes: 10816
import sys
input = sys.stdin.readline

inf = float('inf')

# dist[i][j]: iからjへのコスト,  n:頂点数
def warshall_floyd(dist,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if i == j:
                    dist[i][j] = 0
                elif dist[i][j] > dist[i][k] + dist[k][j]:
                    dist[i][j] = dist[i][k] + dist[k][j]

N,M = map(int,input().split())
edges = []
ad = [[inf]*N for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1;  b -= 1
    edges.append((a,b,c))
    ad[a][b] = c
    ad[b][a] = c

warshall_floyd(ad,N)
ans = M

for a,b,c in edges:
    if a > b:
        a,b = b,a
    for s in range(N):
        for e in range(s+1,N):
            if ad[s][a] + c + ad[b][e] == ad[s][e]:
                ans -= 1
                break
        else:
            continue
        break

print(ans)

Measured memory_bytes: 3436
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n;
    a=n%10;
    n/=10;
    b=n%10;
    if(a==9||b==9)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;

}

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

using ll=int64_t;

int main() {
  string s[3];
  string ans="";
  rep(i,0,3) {
    cin >>s[i];
    ans.push_back(s[i][0]);
  }

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


Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())

    ans = 0
    for i in range(n+1):
        i = str(i)
        i_str = i
        i = sum(list(map(int, list(i))))
        if a <= i and i <= b:
            ans += int(i_str)
    print(ans)


if __name__ == "__main__":
    main()


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        boolean no = false;
        for(int i = 1; i < 10; i++)
        {
            if(n % i == 0) {
                if(n / i < 10) no = true;
            }
        }
        if(!no) System.out.println("No");
        else System.out.println("Yes");
        br.close();
    }
}

Measured memory_bytes: 21972
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    string S;
    cin >> S;
    char c_ = ' ';
    ll ans = -1;
    for (char c : S) {
        if (c != c_) {
            c_ = c;
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  vector<string> words={"dream","dreamer","erase","eraser"};
  reverse(S.begin(),S.end());
  for(auto &word:words) reverse(word.begin(),word.end());
  
  ll N=S.size();
  int i=0;
  while(i<N){
    int judge=0;
    for(auto word:words){
      ll sz=word.size();
      if(i<=N-sz&&S.substr(i,sz)==word) {i+=sz; judge=1; break;}
    }
    if(!judge) {cout<<"NO"<<'\n'; return 0;}
  }
  cout<<"YES"<<'\n';
  return 0;
}

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

int main(){
  char A, B;
  cin >> A >> B;
  if (A < B) {
    cout << "<" << endl;
  } else if (B < A) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S[0] == 'S'){
  cout << "Cloudy" << endl;
  }else if(S[0] == 'C'){
  cout << "Rainy" << endl;
  }else {cout << "Sunny" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;


int main(void)
{
    //double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    //string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n>>a1>>a2;
    if(a1%n==0 || a2%n==0) cout<<"OK";
    else
    {
        if(a1/n!=a2/n) cout<<"OK";
        else cout<<"NG";
    }
    return 0;
}





Measured memory_bytes: 3620
// AOJ 1590: One-Time Path
// 2017.11.29 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 200000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 1000000010
typedef struct { int to[20]; int c[20]; } TBL;
TBL tbl[100002];
int len[100002];
int dist[100002];
int lastn[100002], lastc[100002]; sz;

void dijkstra(int start)
{
	int i, s, e, c, d;

	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node; c = que[0].t, deq();
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i];
			if (c <= (d = tbl[s].c[i]) && d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
}

char buf[40], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, n1, m, a, b, c, i, ans;

	fgets(bp=buf, 40, stdin);
	n = getint(), bp++, m = getint();
	n1 = n - 1;

	for (i = 0; i < m; i++) {
		fgets(bp=buf, 40, stdin);
		a = getint()-1, bp++, b = getint()-1, bp++, c = getint();
		tbl[a].to[len[a]] = b, tbl[a].c[len[a]++] = c;
		if (b == n1) lastn[sz] = a, lastc[sz++] = c;
	}

	memset(dist, 0x77, sizeof(dist));
	dijkstra(0);

	ans = 0;
	if (dist[n-1] > INF) puts("-1");
	else {
		for (i = 0; i < sz; i++) {
			a = lastn[i], c = lastc[i];
			if (dist[a] <= c && c > ans) ans = c;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 18120
#include <stdio.h>

int main(){
   int i,n,ans;
   long long x,y,d;

   scanf("%d %lld",&n,&d);
   d=d*d;
   for (ans=i=0;i<n;i++) {
      scanf("%lld %lld",&x,&y);
      if (x*x+y*y<=d) ans++;
   }
   printf("%d\n",ans);
   return 0;
}

Measured memory_bytes: 1732
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  itn n,x; cin >> n >> x;
  x--;
  if(x==0||x==2*n-2){
    cout << "No" << endl;
    return 0;
  }
  vector<itn> ans(2*n-1);
  rep(i,2*n-1){
    ans[i]=i;
  }
  if(x==n-1){
    cout << "Yes" << endl;
    rep(i,ans.size()) cout << ans[i]+1 << endl;
    return 0;
  }
  else if(x<n-1){
    swap(ans[0],ans[n-1]);
    swap(ans[x],ans[n]);
  }
  else{
    swap(ans[2*n-2],ans[n-1]);
    swap(ans[x],ans[n-2]);
  }
  cout << "Yes" << endl;
  rep(i,ans.size()) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n;
ll t,e,x[N],f[N];
ll calc(int l,int r) {
    return x[r]-x[l]+max(x[r]-x[l+1],t-(x[r]-x[l+1]))+x[r]-x[l+1];
}
struct data { int x,l,r; } q[N];
int main() {
    cin>>n>>e>>t;
    for(int i=1;i<=n;i++) x[i]=gi();
    memset(f,0x3f,sizeof(f));f[0]=0;
    int h=1,t=0;q[++t]=(data){0,1,n};
    for(int i=1;i<=n;i++) {
        while(q[h].r<i) h++;
        f[i]=f[q[h].x]+calc(q[h].x,i);
        while(h<=t&&f[q[t].x]+calc(q[t].x,q[t].l)>=f[i]+calc(i,q[t].l)) t--;
        if(h>t) q[++t]=(data){i,i+1,n};
        else {
            int l=q[t].l,r=q[t].r,ret=q[t].r+1;
            while(l<=r) {
                int mid=(l+r)>>1;
                if(f[q[t].x]+calc(q[t].x,mid)>=f[i]+calc(i,mid)) ret=mid,r=mid-1;
                else l=mid+1;
            }
            q[t].r=ret-1;if(ret<=n) q[++t]=(data){i,ret,n};
        }
    }
    /*for(int i=1;i<=n;i++) {
        f[i]=calc(0,i);int p=0;
        for(int j=1;j<i;j++) if(f[j]+calc(j,i)<f[i]) f[i]=f[j]+calc(j,i),p=j;
        }*/
    printf("%lld\n",f[n]+abs(x[n]-e));
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


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

int main(){
	string a;
	cin >> a;
	if(a=="Sunny")
		cout <<"Cloudy";
	if(a=="Cloudy")
		cout <<"Rainy";
	if(a=="Rainy")
		cout <<"Sunny";

}

//, , or .

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){

  for(int n,t,l,b,m[200]={};cin>>n>>t>>l>>b&&n!=0;){
    memset(m,0,sizeof(m));
    double dp[200][200]={},r=0;
    dp[0][0]=1.0;
    for(int i=0,a;i<l;i++){
      cin>>a;
      m[a]=1;
    }
    for(int i=0,a;i<b;i++){
      cin>>a;
      m[a]=2;
    }
    for(int i=0;i<t;i++){
      for(int j=0;j<n;j++){
	for(int k=1;k<=6;k++){
	  int how=j+k;
	  if(how>n) how=n-(how-n);
	  if(m[how]==1) dp[i+2][how]+=dp[i][j]/6.0;
	  else if(m[how]==2) dp[i+1][0]+=dp[i][j]/6.0;
	  else dp[i+1][how]+=dp[i][j]/6.0;
	}
      }
    }
    /* for(int i=0;i<=t;i++){
       for(int j=0;j<=n;j++) cout<<dp[i][j]<<" ";
       cout<<endl;
       }*/
    for(int i=1;i<=t;i++) r+=dp[i][n];
    cout<<fixed<<setprecision(12)<<r<<endl;  
  }
  return 0;
  
}

Measured memory_bytes: 3492
#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 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



int main() {
	llong N;
    cin >>N;
    llong ans =0;
    llong cm = 0;
    LV A(N);
    REP(i,N){
        cin >> A[i];
        if(A[i]<0) {
            A[i]=-1*A[i];
            cm++;
            }
        ans += A[i];
    }
    // cout << ans <<"a" << endl;
    if( (cm%2) == 0){
        
    }else{
        // cout << cm << endl;
        sort(A.begin(),A.end());
        ans = ans - A[0]*2;
    }

    cout << ans << endl;


    

    




}


Measured memory_bytes: 1024
from sys import stdin
import numpy as np

n = int(stdin.readline().strip())
abc_lst = []

for i in range(n):
  abc = [int(x) for x in stdin.readline().strip().split()]
  abc_lst.append(abc)
  
hapiness_mat = np.zeros((n, 3))
hapiness_mat[0] = abc_lst[0]

for i in range(1, n):
  hapiness_mat[i][0] = max(hapiness_mat[i-1][1],hapiness_mat[i-1][2]) + abc_lst[i][0]
  hapiness_mat[i][1] = max(hapiness_mat[i-1][0],hapiness_mat[i-1][2]) + abc_lst[i][1]
  hapiness_mat[i][2] = max(hapiness_mat[i-1][0],hapiness_mat[i-1][1]) + abc_lst[i][2]
  
print(int(max(hapiness_mat[-1])))

Measured memory_bytes: 37228
#include <bits/stdc++.h>
  #define int long long int
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
   
  
  using namespace std;
  int dp[100005];
  vi adj[100005];
  int deg[100005];
  queue<int> q;
  void dfs()
  {
      
      
      
      while(!q.empty())
      {
          int f=q.front();
          
          q.pop();
          for(int i:adj[f])
          {
             dp[i]=max(dp[i],dp[f]+1);
             deg[i]--;
             if(deg[i]==0)
               q.push(i);
          }
      }
     
  }
  void solve()
  { 
 
     int n,m;
     cin>>n>>m;
     while(m--)
     {
       int a,b;
       cin>>a>>b;
       adj[a].eb(b);
       deg[b]++;
    
     }
     for(int i=1;i<=n;i++)
     {
        if(deg[i]==0)
           q.push(i);
     }

    
         dfs();
   
    int ans=0;
    rep(n)
    {
       ans=max(ans,dp[i+1]);
    }
  cout<<ans;


   
   }

  signed main()
  {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }


Measured memory_bytes: 7296
#include <stdio.h>

int main()
{
  char s[10];
  
  scanf("%s", s);
  if(s[1] == 'S')
  {
    if((s[0] == 'R') || (s[2] == 'R'))
      printf("1\n");
    else
      printf("0\n");
  }
  else
  {
    if((s[0] == 'R') && (s[2] == 'R'))
      printf("3\n");
    else if((s[0] == 'R') || (s[2] == 'R'))
      printf("2\n");
    else
      printf("1\n");
  }
  return(0);
}


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

int main(){
    int maxr = (int)1e5;
	vector<int> pr(maxr+1,1);
    for(int i=2; i<=maxr; i++){
        if(pr[i]){
            int j = 2*i;
            while(j<=maxr){
                pr[j]=0;
                j+=i;
            }
        }
    }
    vector<ll> sum(maxr+1,0);
    for(int i=3; i<=maxr; i++){
        if(i%2==1&&pr[i]&&pr[(i+1)/2]){
            sum[i]=sum[i-1]+1;
        }
        else{
            sum[i]=sum[i-1];
        }
    }
    int q;cin>>q;
    for(int i=0; i<q; i++){
        int l,r;cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
mod = 10**9+7

def pow(x, n):
    ans = 1
    if n in dict:
        return dict[n]
    n_tmp = n
    while n:
        if n % 2:
            ans *= x
            ans %= mod
        x *= x
        n >>= 1
    dict[n_tmp] = ans
    return ans

def cmb(n, r, mod):
    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range(2, n+1):
    g1.append( (g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k):
    # print(cmb(n-k+1, i+1, mod), cmb(k-1, i, mod))
    tmp_ans = cmb(n-k+1, i+1, mod)
    tmp_ans %= mod
    tmp_ans *= cmb(k-1, i, mod)
    tmp_ans %= mod
    print(tmp_ans)


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include<set>
#include <string>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    int count=0;
    for (int i=0; i<n; i++){
        char c;
        cin >> c;
        if (c == 'R')  count++;
        else  count--;
    }
    if (count > 0)  cout << "Yes" << endl;
    else  cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

var fac, finv, inv []int

const MOD = 1000000007

func cominit(n int) {
	fac, finv, inv = make([]int, n+1), make([]int, n+1), make([]int, n+1)
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < n+1; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	if (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	// (+1, +2)の移動回数: n
	// (+2, +1)の移動回数: mとすると、
	// n + 2m = x
	// 2n + m = y
	// -> 3n + 3m = x + y
	// -> n + m = (x + y) / 3
	n, m := -1, -1
	k := (x + y) / 3
	for i := 0; i <= k; i++ {
		if i+2*(k-i) == x && 2*i+(k-i) == y {
			n, m = i, k-i
		}
	}

	if n == -1 || m == -1 {
		fmt.Println(0)
		return
	}

	cominit(n + m)
	fmt.Println(com(n+m, n))
}


Measured memory_bytes: 17024