akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  
  int N; string S;
  cin >> N;
  cin >> S;
  
  //累積和
  int R[N+1]; int G[N+1]; int B[N+1];
  R[0]=0; G[0]=0; B[0]=0;
  for(int i=0;i<N;i++){
    R[i+1]=R[i]; 
    G[i+1]=G[i]; 
    B[i+1]=B[i];
    if(S[i]=='R') R[i+1]++;
    if(S[i]=='G') G[i+1]++;
    if(S[i]=='B') B[i+1]++;
  }
  
  long long Total=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S[i]==S[j])continue;
      if((S[i]!='R') && (S[j]!='R')){
        Total += R[N]-R[j+1];
        if(2*j-i < N){
          if (S[2*j-i]=='R'){
            Total -= 1;
          }
        }
      }
      if((S[i]!='G') && (S[j]!='G')){
        Total += G[N]-G[j+1];
        if(2*j-i < N){
          if (S[2*j-i]=='G'){
            Total -= 1;
          }
        }
      }
      if((S[i]!='B') && (S[j]!='B')){
        Total += B[N]-B[j+1];
        if(2*j-i < N){
          if (S[2*j-i]=='B'){
            Total -= 1;
          }
        }
      }
    }
  }
  
  cout << Total <<endl;
  
}

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

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 1; i <= m; i++) {
        int temp;
        cin >> temp;
        sum += temp;
    }
    if (n >= sum) {
        cout << n - sum << "\n";
    } else {
        cout << -1 << "\n";
    }

}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  char s_i, s_prev;
  int cntEven=0; int cntOdd=0;
  int holeEven, holeOdd;
  vector<int> ans; ans.reserve(100001); FILL(ans, 0);
  int i=0;
  while (cin >> s_i)
  {
    if (i != 0)
    {
      if (s_prev=='R' and s_i=='L')
      {
        if (i%2==0) { holeEven=i; holeOdd =i-1; }
        else        { holeOdd =i; holeEven=i-1; }
      }
      if (s_prev=='L' and s_i=='R')
      {
        ans[holeEven] = cntEven;
        ans[holeOdd] = cntOdd;
        cntEven = cntOdd = 0;
      }
    }
    (i%2==0) ? cntEven++ : cntOdd++;
    s_prev = s_i;
    i++;
  }
  ans[holeEven] = cntEven;
  ans[holeOdd] = cntOdd;
  REP0(j, i) cout << ans[j] << ((j==i-1) ?  "" : " ");
  cout << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int N;
    cin >> N;
    int a[N+1];
    int count =0;
    for(int i=1;i<=N;i++){
        cin >> a[i];
        if(i%2==1){
            if(a[i]%2==1)count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3568
import numpy as np
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]

positions = np.array(x)
tmp_index = np.arange(positions.shape[0])
xx, yy = np.meshgrid(tmp_index, tmp_index)
distances = np.linalg.norm(positions[xx]-positions[yy], axis=2)

num = np.sum(distances)
print(num/n)

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

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main() {

    ll N;
    cin >> N;

    ll ans = 0;

    for (ll a = 1; a < N; a++)
    {
        ans += (N-1) / a;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, m;
vector< set<int> > graph(100100, set<int>());
vector<int> H(100100, 0);

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; ++i) cin >> H.at(i);
    for(int i = 0; i < m; ++i) {
        int aa, bb;
        cin >> aa >> bb;
        aa--; bb--;
        graph.at(aa).insert(bb);
        graph.at(bb).insert(aa);
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        bool flg = true;
        for(auto x : graph.at(i)) {
            if(H.at(i) <= H.at(x)) {
                flg = false;
                break;
            }
        }
        if(flg) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

using namespace std;

#define MAX_N 23
#define MAX_FLG 8388610
#define MOD 1000000007

int n, dp[MAX_N][MAX_FLG];
vector<int> adh[MAX_N];

int f_imp(int, int);

int f(int p, int flgs)
{
	if (dp[p][flgs] == 0)
		dp[p][flgs] = f_imp(p, flgs) + 1;
	return dp[p][flgs] - 1;
}

int f_imp(int p, int flgs)
{
	if (p == n)
		return 1;
	int r = 0;
	for (auto &i: adh[p])
	{
		if (((flgs>>i) & 1) == 1)
			continue;
		r = (r + f(p + 1, flgs | (1 << i)))%MOD;
	}
	return r;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int c = 0; c < n; c++)
		{
			int t;
			scanf("%d", &t);
			if (t)
				adh[i].push_back(c);
		}
	}
	printf("%d\n", f(0, 0));
}


Measured memory_bytes: 180480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int e = Integer.parseInt(br.readLine());

			if (e == 0)
				break;

			int m = Integer.MAX_VALUE;
			for (int z = 0; z * z * z <= e; z++) {
				for (int y = 0; y * y <= e - z * z * z; y++) {
					int x = e - y * y - z * z * z;
					m = Math.min(m, x + y + z);
				}
			}
			System.out.println(m);
		}
	}
}


Measured memory_bytes: 29532
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (t > s) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 256
while true do
   n = gets.chomp.to_f
   break if n == 0
   data_set = gets.chomp.split.map(&:to_f)

   sum = 0
   data_set.each do |data|
      sum += data
   end
   average = sum / n
   temp = 0
   data_set.each do |data|
      temp += (data - average) ** 2
   end
   var = temp / n
   puts (var ** 0.5)
end

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    LL a,b,c,k;
    cin >> a >> b >> c >> k;

    if (abs(b-a) > pow(10,18)) {
        cout << "Unfair" << endl;
    }else{
        if (k & 1) {
            cout << b-a << endl;
        }else{
            cout << a-b << endl;
        }
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }


Measured memory_bytes: 256
x, k, d = map(int,input().split())
x = abs(x)

if k*d <= x:
    res = x - k*d
else:
    temp = x // d
    temp_x = x - temp*d
    temp_k = k - temp
    
    if temp_k%2 == 0:
        res = temp_x
    else:
        res = abs(temp_x - d)
print(res)

Measured memory_bytes: 9180
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pi pair<int, int>
#define endl "\n"

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;

ll mod = 1e8;

ll add(ll a, ll b) { return (a % mod + b % mod) % mod; }
ll mul(ll a, ll b) { return (a % mod * b % mod) % mod; }
void debug(vector<int> a) {
    for(int i: a) cout << i << " ";
    cout << "\n";
}
// abc abc

int main() {
    fastio
    int n; cin >> n;
    string s;
    cin >> s;
    int len = n/2;
    if(n%2 != 0) {
        cout << "No";
        return 0;
   }
    string a="", b="";
    for(int i=0; i<len; i++) a = a + s[i];
    for(int i=len; i<s.length(); i++) b = b+s[i];
    if(a == b) cout << "Yes" ;
    else cout << "No";
     

}

Measured memory_bytes: 256
n = int(input())
maxx = 1000000000000001
leng = 1
h = 0
while True:
	h += pow(26,leng)
	if h >= n: break
	leng+=1
#print(leng)
s = ""
for i in range(leng):
	#print(i)
	x = (n-1)%26
	#print(n,x)
	s += chr(x+ord('a'))
	#print(chr(n%26+ord('a')-1))
	#n = n%pow(26,i)
	#print(n)
	#n = (n-pow(26,leng))//26
	#print(n)
	n = n//26
	if x==25: n -= 1
for i in range(leng-1,-1,-1):
	print(s[i],end="")
print()


Measured memory_bytes: 61816
N = int(input())
s = sorted(list(map(int, input().split())))
out = 0

d = {}
for x in s:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

s = sorted(list(set(s)))
count = 0
l = 0
for x in s:
    if l != 0:
        out += x-l
        break
    else:
        count += d[x]
        if count == N/2:
            l = x
print(out)

Measured memory_bytes: 14700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin >> n;
    n%=10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout << "hon\n";
    else if(n==0 || n==1 || n==6 || n==8)
        cout << "pon\n";
    else
        cout << "bon\n";
    return 0;
}


Measured memory_bytes: 3584
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	int a[4][4];
	rep(i, 3) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}

	int n;
	int b[12];
	cin >> n;

	rep(i, n) {
		cin >> b[i];
	}

	bool res[4][4];

	rep(i,3){
		 rep(j,3){
			 res[i][j] = false;
			 rep(k,n){
				 if (a[i][j] == b[k]) 
					 res[i][j] = true;
			 }
			
		}
		
	}
	bool bingo = false;

	rep(i, 3) {
		if (res[i][0] && res[i][1] && res[i][2]) bingo = true;
	}
	rep(i, 3) {
		if (res[0][i] && res[1][i] && res[2][i]) bingo = true;
	}
	if (res[0][0] && res[1][1] && res[2][2]) bingo = true;
	if (res[0][2] && res[1][1] && res[2][0]) bingo = true;

	cout << (bingo ? "Yes" : "No") << endl;
}

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

int main(){
  int k,s;
  cin >> k >> s;
  int ans=0;
  for (int i=0;i<=k;i++){
    for (int j=0;j<=k;j++){
      if(0<=s-i-j && s-i-j<=k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n, m;
  cin >> n >> m;

  vector<ull> a;
  each(i, m) {
    ull tmp;
    cin >> tmp;
    a.push(tmp);
  }

  vector<ull> dp(n+1, 0); // N個と、何も選んでない状態の +1
  // f(n) = f(n-1) + f(n-2)

  // d[i] i段目に行到達する方法は何通りあるか？

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

    if ((index < a.size()) && (i == a[index])) {
      dp[i] = 0;
      index++;
    } else {

      if (i == 1) {
        dp[1] = 1; // 1段目は 1 の1通り
      } else if (i == 2) {
        if (dp[1] == 0) {
          dp[2] = 1; // 1段目が壊れてる場合は2段目は 2 の1通り
        } else {
          dp[2] = 2; // 2段目は 1+1 と 2 の2通り
        }
      } else {
        dp[i] = (dp[i-1] % mod) + (dp[i-2] % mod);
      }
    }
  }

  cout << dp[n] % mod << endl;

  return 0;
}


Measured memory_bytes: 1908
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

static class Program
{
    static void Main()
    {
        int[] input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Tyoten[] tyotens = new Tyoten[input[0]];
        for (int i = 0; i < tyotens.Length; i++)
        {
            tyotens[i] = new Tyoten((i + 1).ToString());
        }

        for (int i = 0; i < input[1]; i++)
        {
            int[] hen = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Tyoten.Connect(tyotens[hen[0] - 1], tyotens[hen[1] - 1]);
        }

        int count = 0;

        List<Route> routes = new List<Route>();
        routes.Add(new Route(tyotens[0]));
        while (routes.Count > 0)
        {
            if (routes[0].UsedTyotens.Count == tyotens.Length)
            {
                ++count;
                routes.RemoveAt(0);
            }
            else
            {
                IEnumerable<Route> route = routes[0].GetNextRoutes();
                if (route.Count() == 0)
                {
                    routes.RemoveAt(0);
                }
                else
                {
                    routes.RemoveAt(0);
                    routes.AddRange(route);
                }
            }
        }

        WriteLine(count);
        ReadKey();
    }
}

public class Tyoten
{
    public string Name { get; set; }
    public List<Tyoten> ConnentedTyoten { get; private set; }

    public Tyoten()
    {
        ConnentedTyoten = new List<Tyoten>();
    }

    public Tyoten(string name)
    {
        ConnentedTyoten = new List<Tyoten>();
        Name = name;
    }

    public static void Connect(Tyoten a, Tyoten b)
    {
        a.ConnentedTyoten.Add(b);
        b.ConnentedTyoten.Add(a);
    }
}

public class Route
{
    public List<Tyoten> UsedTyotens { get; private set; }
    public Tyoten NowPoint { get; set; }

    public Route(Tyoten NowPoint)
    {
        UsedTyotens = new List<Tyoten>();
        UsedTyotens.Add(NowPoint);
        this.NowPoint = NowPoint;
    }

    public Route(Route route, Tyoten NextPoint)
    {
        UsedTyotens = new List<Tyoten>(route.UsedTyotens);
        NowPoint = NextPoint;
        UsedTyotens.Add(NextPoint);
    }

    public IEnumerable<Route> GetNextRoutes()
    {
        foreach (Tyoten tyoten in NowPoint.ConnentedTyoten)
        {
            if (!UsedTyotens.Contains(tyoten))
            {
                yield return new Route(this, tyoten);
            }
        }
    }
}

Measured memory_bytes: 17980
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
using ll = long long;
using namespace std;
const ll mod = 1000000007;

const int bound = 3000000;
ll fact[bound], fact_inv[bound];

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

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = power(fact[b], mod-2);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

ll seq( ll x, ll y ){
	ll sum = 0;
	for( int k = 0; k <= x; ++k ){
		sum += comb(k+y+1, y);
		sum %= mod;
	}
	return sum;
}

int main(){
	init();
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << ( seq(c, d) - seq(a-1, d) - seq(c, b-1) + seq(a-1, b-1) + 10*mod ) % mod << endl;
}

Measured memory_bytes: 47104
n = int(input())
h = list(map(int, input().split()))

c = 0
a = 0   
for i in range(n-1):
  if h[i] >= h[i+1]:
    c += 1
  else:
    a = max(c, a)
    c = 0
    
#最後のcはelseで引っかからない
a = max(c, a)    
        
print(a)

Measured memory_bytes: 14252
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    let [N] = r.nn()

    let sum = 0
    let i = 0

    while (N > 1) {
      N = Math.floor(N / 2)

      sum += 2 ** i
      i++
    }

    sum += N * 2 ** i
    return sum
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 7500
#include <stdio.h>

int main()
{
	int x,y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x==0&&y==0){
			break;
		}
		if(x<y){
			printf("%d %d\n", x, y);
		}
		else{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
 // #define forn(i, n) for (int i = 0; i < int(n); i++)
  
  int32_t main()
  { 
     #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
     #endif
    
    IOS
    int t;
    cin >> t;
    const double pi=3.141592653589;
    cout<<fixed<<setprecision(12)<<2*pi*t;
    return 0;
   
}



Measured memory_bytes: 3828
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < (limit); counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  int n,m;
  cin>>n>>m;
  vector<int> h(n),a(m),b(m);
  vector<bool> hishigh(n,true);
  rep(i,n)cin>>h[i];
  rep(i,m){
    cin>>a[i]>>b[i];
    if(h[a[i]-1] >= h[b[i]-1]){
      hishigh[b[i]-1]=false;
    }
    if(h[a[i]-1] <= h[b[i]-1]){
      hishigh[a[i]-1]=false;
    }
  }
  int ans=0;
  rep(i,hishigh.size()){
    if(hishigh[i])ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 4524
#include<stdio.h>

#define max(x,y)  (((x)>(y))? (x) : (y))

int main()
{
	int arr[100][100] = { 0 };
	int i,j,k,row = 0, col = 0;
	
	while (scanf("%d", &arr[row][col]) != EOF)
	{
		++col;
		if (getchar() == '\n')
		{
			col = 0;
			++row;
		}
	}
	//printf("row=%d\n",row);
	row = (row + 1) / 2;
	
	for (i = 1; i < row; i++)
	{
		arr[i][0] += arr[i - 1][0];
		for (j = 1; j < i+1; j++)
		{
			arr[i][j] += max(arr[i - 1][j - 1], arr[i - 1][j]);
		}
	}

	k=row;
	for (; i < row*2-1; i++,k--)
	{
		for (j = 0; j < k; j++)
		{
			arr[i][j] += max(arr[i - 1][j], arr[i - 1][j+1]);
		}
	}

	printf("%d\n", arr[i-1][0]);

	return 0;
}


Measured memory_bytes: 648
#include<stdio.h>
#include<string.h> 
int main()
{
	int a,b,i;
	scanf("%d", &a);
	scanf("%d", &b);

  	if(a<=b)
    {
	for(i=1; i<=b; i++)
		printf("%d", a);
    }
  	else
     for(i=1; i<=a; i++){
		printf("%d", b);
     }
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main() {
	int n, m, a, b, s[200005] = {}, t[200000][2] = {}, max = 0, max2 = 0, smax = 0, smax2 = 0, memo = 0,memo2=0;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		scanf("%d", &s[i]);
		if (i % 2 == 1) {
			t[s[i]][0]++;
		}
		else {
			t[s[i]][1]++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (t[i][0] >= max) {
			
			max = t[i][0];
			memo = i;
		}
		
		if (t[i][1] >= max2) {
			
			max2 = t[i][1];
			memo2 = i;
			
		}
	}
	t[memo][0] = 0;
	t[memo2][1] = 0;
	for (int i = 1; i <= 100000; i++) {
		if (t[i][0] >= smax) {
			
			smax = t[i][0];
			
		}

		if (t[i][1] >= smax2) {
			
			smax2 = t[i][1];
			

		}
	}
	if (memo != memo2) {
		printf("%d", n - max - max2);
	}
	else {
		if (smax >= smax2) {
			printf("%d", n - smax - max2);
		}
		else {
			printf("%d", n - max - smax2);
		}
	}
}

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

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define NL              pf("\n")
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       (((a)/gcd(a,b))*b)
#define mx              1234567899
#define TC              int t;scin(t);while(t--)
#define PI              2*acos(0.0)
#define rep(i,a,b)      for( i=a; i<=b; i++)
#define rev(i,a,b)      for( i=a; i>=b; i--)
#define file            freopen("E:\\file.txt", "r", stdin);ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x)          x.begin(),x.end()
#define DEBUG(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
using namespace std;
int get(int n,int p){int res = 0;while(n>=p) res+=n/p,n/=p;return res;}
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1); }
void VC(vector<ll> &v){for(int i=0;i<v.size();i++) printf("%lld ", v[i]);printf("\n");}

template< typename T > void print(const T& v) {    cerr << v << ' ' ;}
template< typename T1, typename... T2 >
void print( const T1& first, const T2&... rest ){
    print(first);
    print(rest...) ;
}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

long long BigMod(long long int a, long long int b, int M) { long long remainder, answer = 1;remainder = a%M; while(b!=0){if(b%2==1) answer = (answer*remainder)%M;remainder = (remainder*remainder)%M;b/=2;}return answer;}
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    ll n,ans;
    cin >> n;n--;
    ans = (n*(n+1))/2;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAX_VALUE = 200000;
int R[MAX_VALUE];

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

  int min_val = R[0];
  int max_val = -1000000001;
  for (int j = 1; j < n; j++) {
    max_val = max(max_val, R[j] - min_val);
    min_val = min(min_val, R[j]);
  }
  printf("%d\n", max_val);
}

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

int main()
{
	bool A=0,B=0;
	char a;
	while ((a=getchar())!='\n')
	{
		if(a=='C') A=1;
		if(A==1 && a=='F') B=1;
	}
	if(A && B) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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

  vector<vector<int> > G(n, vector<int>(n, 0));
  for ( int i = 0; i < n; i++ ) {
    int u, k;
    cin >> u >> k;
    u--;
    for ( int i = 0; i < k; i++ ) {
      int v;
      cin >> v;
      v--;
      G[u][v] = 1;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      if ( j ) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3148
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int time = (h2-h1)*60 + (m2-m1) - k;
  cout << time << endl;
}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  //cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



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

int main() {
    string s;
    ll k,count=0,res;
    cin>>s>>k;
    bool flag = false;
    if(s[0] == '1') flag = true;
    for(int i=0; i<k; i++) {
        if(s[i] == '1') count++;
        else {
            res = i;
            break;
        }
    }
    if(count >= k && flag) cout<<1<<"\n";
    else cout<<s[res];
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG 
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#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 Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

int main() {
  int n, m;
  cin >> n >> m;
  int count = 0;
  if (n>1) {
    count += n*(n-1)/2;
  }
  if (m>1) {
    count += m*(m-1)/2;
  }
  cout << count << endl;
}
    


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


int main() {
    int A,B;cin >> A >> B;
    if (A == B){
        cout << "Draw" << endl;
    }else if(A == 1){
        cout << "Alice" << endl;
    }else if(B == 1){
        cout << "Bob" << endl;
    }else{
        if (A > B){
            cout << "Alice" << endl;
        }else{
            cout << "Bob" << endl;
        }
    }


}       

Measured memory_bytes: 256
n = gets.to_i
t = [0] * n
(n*(n-1)/2).times {
  a,b,x,y = gets.split.map(&:to_i)
  if x == y
    t[a-1] += 1
    t[b-1] += 1
  elsif x > y
    t[a-1] += 3
  else
    t[b-1] += 3
  end
}
result = t.map.with_index.to_a.sort_by{|item| -item[0]}
rank = []

r = 0
last = nil
result.each.with_index {|item, i|
  score, _ = item
  if last == score
    rank << r
  else
    rank << i + 1
    r = i + 1
  end
  last = score
}

result.zip(rank).map {|item| [item[0][1], item[1]]}.sort_by{|item| item[0]}.to_a.each{|item|
  p item[1]
}



Measured memory_bytes: 7116
#include<iostream>
#include<stack>
#include<string>

using namespace std;

int main()
{
	string str;
	stack<int> operand;
	getline(cin, str);
	
	
	for (int i = 0; i < str.size(); i++)
	{
		if ((str[i] == ' '))
			continue;
		else if (isdigit(str[i]))
		{
			int value = 0;
			while (isdigit(str[i]))
			{
				value = value * 10 +  str[i] - '0';
				i++;
			}
			operand.push(value);
		}
		else if (str[i] == '-')
		{
			if (isdigit(str[i+1]))
			{
				i++;
				int value = 0;
				while (isdigit(str[i]))
				{
					value = value * 10 +  str[i] - '0';
					i++;
				}
				operand.push(-value);
			}
			else
			{
				int a = operand.top();
				operand.pop();
				int b = operand.top();
				operand.pop();
				operand.push(b - a);
			}
		}
		else 
		{
			int a = operand.top();
			operand.pop();
			int b = operand.top();
			operand.pop();
			
			switch(str[i])
			{
				case '+' : 
					operand.push(a + b);
					break;
				case '*' : 
					operand.push(a * b);
					break; 
			}
		}
	} 
	cout << operand.top() << endl;	
	return 0;
}


Measured memory_bytes: 3220
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
a;*c;f;*i;j;m;n;s;u;v;w;C[42000];D[3001][3001];M[3001];
main(){
  for(c=C;++n,~scanf("%d",&w)||n%3-!(w=0);a=u,u=v,v=w,w=a)
    if(n%3<1)
      if(n<4)M[v]=M[w]=D[v][w]=D[w][v]=m=1e7;
      else{
        for(s=0;s++<2e3;)for(j=3;a=u,u=v,v=w,w=a,j--;)
          u-v|v-w?
            *++c=u,*++c=s,*++c=fmax(v-w?:D[s][v]+1,M[s]),
            *++c=u,*++c=v,*++c=fmax(D[w][w]+1,m)
          :++f;
        for(;c>C;)
          w=*c--,v=*c--,u=*c--,
          D[u][v]>w||(D[u][v]=D[v][u]=w),M[u]>w||(M[u]=w),M[v]>w||(M[v]=w),m=m>w?m:w;
      }
  printf("%d",m+=f/6e3-1e7);
}


Measured memory_bytes: 25736
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    for _ in 0..n {
        let x: String = read();
        let y: String = read();
        let x: Vec<char> = x.chars().collect();
        let y: Vec<char> = y.chars().collect();

        let mut dp = vec![vec![0; y.len() + 1]; x.len() + 1];
        for i in 0..x.len() {
            for j in 0..y.len() {
                if x[i] == y[j] {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
                }
            }
        }
        println!("{}", dp[x.len()][y.len()]);
    }
}



Measured memory_bytes: 9092
#141
s = input()
a = True

for i in range(len(s)):
    if (i+1)%2==0:
        if s[i]!='L' and s[i]!='U' and s[i]!='D':
            a = False
            break
    else:
        if s[i]!='R' and s[i]!='U' and s[i]!='D':
            a = False
            break

if a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
l = []
for i in range(3):
    a,b = iim()
    l.append(a)
    l.append(b)

for i in range(1,5):
    if l.count(i) == 3:
        print('NO')
        exit()
print('YES')



Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC101 {
    class B {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadString();
            var total = 0;
            for (int i = 0; i < n.Length; i++) {
                total += int.Parse(n[i].ToString());
            }

            if (int.Parse(n) % total == 0) {
                WriteAnswer("Yes");
            } else {
                WriteAnswer("No");
            }
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
n = int(input())
ans = 0
if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(9 + n - 99)
elif n < 10000:
  print(9 + 900)
elif n < 100000:
  print(9 + 900 + n - 9999)
else:
  print(9 + 900 + 90000)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int n1[5]={},n2[5]={},m1,m2,m3,m4,S=0,T=0;
cin>>m1>>m2>>m3>>m4;
S=m1+m2+m3+m4;
cin>>m1>>m2>>m3>>m4;
T=m1+m2+m3+m4;
if(S<T)S=T;
cout<<S<<endl;
return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();
        int right = 0;

        for (final char c : s.toCharArray()) {
            if (c == 'E') {
                right++;
            }
        }

        int answer = Integer.MAX_VALUE;
        int left = 0;
        for (int i = 0; i < n; i++) {
            final boolean isLeft = s.charAt(i) == 'W';
            if (!isLeft) {
                right--;
            }

            answer = Math.min(answer, right + left);

            if (isLeft) {
                left++;
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 30176
def main():
    N, M = map(int, input().split())
    commit = [list() for i in range(N)]

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        WA = 0
        if len(commit[i]) == 0:
                continue
        else:
            for j in range(len(commit[i])):
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC_total += 1
                    WA_total += WA
                    break
    print(AC_total, WA_total)
if __name__ == "__main__":
    main()

Measured memory_bytes: 20272
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    string s; cin>>s;
    int n=s.size();
    if(s[n-1]=='s'){
        s+="es";
    }else{
        s+='s';
    }
    cout<< s <<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int x[N];
    for(int i=0; i<N; i++){
        cin >> x[i];
    }

    int result = 0;

    for(int i=0; i<N; i++){
        if(abs(x[i]) <= abs(K-x[i])){
            result += abs(x[i]) * 2;
        }else{
            result += abs(K-x[i]) * 2;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define MAX 1000
#define TRUE '.'
#define BLOCK '*'

using namespace std;

char buff[MAX][MAX];
int size;
int T[MAX][MAX];

int getLangestRectangle(){
	for(int i=0;i<size;i++){
		T[0][i]=(buff[0][i]==BLOCK)?0:1;
		T[i][0]=(buff[i][0]==BLOCK)?0:1;
	}
	int maxwidth=0;
	for(int i=0;i<size;i++){//ツ債カツ、ツ湘」ツづ可つ「ツつュツづァツ行ツつッツづゥツつゥツづーツ記ツ録
		for(int j=0;j<size;j++){
			if(buff[i][j]==BLOCK){
				T[i][j]=0;
			}else{
				T[i][j]=min(T[i-1][j-1],min(T[i][j-1],T[i-1][j]))+1;
				maxwidth=max(maxwidth,T[i][j]);
			}
		}
	}
	/*
	for(int i=0;i<size;i++){
		for(int j=0;j<size;j++){
			cout<<T[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	return maxwidth;
}
int main(){
	while(cin>>size){
		if(size==0)return 0;
		for(int i=0;i<size;i++){
			for(int j=0;j<size;j++){
				cin>>buff[i][j];
			}
		}
		cout<<getLangestRectangle()<<endl;
	}	
	return 0;
}

Measured memory_bytes: 4660
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << S.substr(0, 3) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<ll>;
using m = map<int,int>;
using vv = vector<v>;


int main(){
    int n,m;
    cin >> n >> m;
    ll x =  100*(n-m)+1900*m;
    ll y = x*(ll)pow(2,m);
    cout << y;
}


Measured memory_bytes: 256
def resolve():
    H, W = map(int, input().split())  

    if H == 1 or W == 1:
        print(1)
        return

    W_odd = int(W / 2)
    W_even = W - W_odd

    H_odd = int(H / 2)
    H_even = H - H_odd

    sum_number = (W_odd * H_odd + W_even * H_even)

    print(sum_number)

if __name__ == "__main__":
    resolve()

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

void Main()
{
	vector<int> arr(5);
	rep(i,5) cin >> arr[i];
	int k; cin >> k;
	for (auto v1 : arr) {
		for (auto v2 : arr) {
			if (abs(v2 - v1) > k) {
				cout << ":(" << endl;
				return;
			}
		}
	}
	cout << "Yay!" << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	bool a[100005] = {false};
	for (int i = 0; i < m; i++) {
		int ai;
		cin >> ai;
		a[ai] = true;
	}
	long long dp1 = 1, dp2 = 0;
	for (int i = 0; i < n; i++) {
		long long dp3 = 0;
		if (!a[i+1]) dp2 = (dp2 + dp1)%MOD;
		if (!a[i+2]) dp3 = (dp3 + dp1)%MOD;
		dp1 = dp2;
		dp2 = dp3;
	}
	long long ans = dp1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	string s;
	cin >> s;
	if(s.size()<4) cout << "No\n";
	else if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_H=1e5+5;
const int MAX_N=3e3+3;
const int MOD=1000000007;

int h,w;
int n;
pii p[MAX_N];
ll ans;
ll dp[MAX_N];

ll fac[2*MAX_H], inv[2*MAX_H];
ll fpw(ll x, ll y)
{
	ll rtn=1;
	while(y)
	{
		if(y&1) rtn=(rtn*x)%MOD;
		y>>=1;
		x=(x*x)%MOD;
	}
	return rtn;
}
void pre_fac()
{
	fac[0]=1, inv[0]=1;
	for(int i=1;i<2*MAX_H;i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		inv[i]=fpw(fac[i],MOD-2);
	}
}
ll C(ll x, ll y)
{ return fac[x]*inv[y]%MOD*inv[x-y]%MOD; }

int main()
{
	pre_fac();
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++) scanf("%d%d",&p[i].F,&p[i].S);
	sort(p,p+n);
	ans=C(h+w-2,h-1);
	for(int i=0;i<n;i++)
	{
		int x2,y2;
		tie(x2,y2)=p[i];
		dp[i]=C(x2+y2-2,x2-1);
		for(int j=0;j<i;j++)
		{
			int x1,y1;
			tie(x1,y1)=p[j];
			if(x1>x2||y1>y2) continue;
			dp[i]=(dp[i]-dp[j]*C(x2+y2-x1-y1,x2-x1)%MOD)%MOD;
		}
		dp[i]=(dp[i]+MOD)%MOD;
		ans=(ans-dp[i]*C(h+w-x2-y2,h-x2)%MOD)%MOD;
	}
	ans=(ans+MOD)%MOD;
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 3456