akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    static long mod = (int)Math.pow(10,9)+7;
    static int n, max = 100000000 , a[][], memo[][];
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		a = new int[n][2];
		memo = new int[51][1 << n];
		for (int[] x : memo){
		    Arrays.fill(x, -1);
		}
		for (int j = 0; j < 2; j++){
		    for (int i = 0; i < n; i++){
		        a[i][j] = sc.nextInt();
		    }
		}
		int ans = dp(0,0,0);
		pw.println(ans >= max ? -1 : ans);
		pw.close();
	}
	    /*
	        msk = 既に使用したかどうかの判定
	        memo[last][msk] = mskのbitを使用した状態で一番最後の数字がlastになる最小の転倒数
	        last <= valの未使用bitが存在する場合、dp(使用した値のbit+msk,idx++,val)を呼び出す(そうでない場合はそのままreturn)
	        newPosは値の位置 + i < jであるものの内、既に使用されている(mskに追加されている)値の数
	        
	    */
		static int dp(int msk, int idx, int last) {
		if (idx == n)
			return 0;
		if (memo[last][msk] != -1)
			return memo[last][msk];
		int ans = max;
		for (int put = 0; put < n; put++) {
			if ((msk & 1 << put) != 0){ 
			    continue;
			}
			int all = (1 << (put + 1)) - 1; //これまで適用したビット
			int newPos = put + Integer.bitCount(msk&~all);
			int val = a[put][Math.abs(put - idx) % 2]; //Math.abs(put - idx) % 2 == 0 ? 表 : 裏
			//System.out.println(idx+" "+last+" "+msk+" "+ put+" "+all+" "+newPos+" "+val + " " + Integer.bitCount(msk&~all));
			if (val >= last) {
				ans = Math.min(ans, dp(msk | 1 << put, idx + 1, val) + Math.abs(newPos - idx));
			}
		}
		return memo[last][msk] = ans;
 
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}



Measured memory_bytes: 88780
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i)

a.select! { |e| e.even? }
if a.all? { |e| e % 3 == 0 || e % 5 == 0}
  puts 'APPROVED'
else
  puts 'DENIED'
end


Measured memory_bytes: 1788
import Control.Monad
import Data.List
import Data.Bool

main = do
  [n,m]<-map read.words<$>getLine
  kss<-replicateM m$map read.words<$>getLine
  ps<-map read.words<$>getLine
  print $ solve n m kss ps

solve :: Int->Int->[[Int]]->[Int]->Int
solve n m kss ps = length ans
  where
  ans = filter and cs
  cs = map g sws
  sws = replicateM n [True,False] :: [[Bool]]
  g sw = map ($ sw) evs
  evs = zipWith (.) eqs cts
  eqs = map (\a->(==a)) ps
  cts = map h kss
  h :: [Int] -> ([Bool] -> Int)
  h ks = bool 0 1 . go 1 ss
    where
    go :: Int -> [Int] -> [Bool] -> Bool
    go _ _ [] = False
    go _ [] _ = False
    go n (s:ss) (l:ls)
      | n == s = l ^^ go (n+1) ss ls
      | otherwise = go (n+1) (s:ss) ls
    ss = sort $ tail ks
    True ^^ True = False
    True ^^ False = True
    False ^^ True = True
    False ^^ False = False


Measured memory_bytes: 1020
N = int(input())
a = list(input().split())
counter = 1
old_a = 0
ref = 0
for i in range(len(a)):
    if i == 0:
        old_a = a[i]
    elif old_a == a[i]:
        counter +=1
        if i == len(a)-1:
            ref += int(counter /2)
    else:
        ref += int(counter /2)
        counter = 1
    old_a = a[i]
print(ref)

Measured memory_bytes: 3064
N,M=map(int,input().split())
P=[[] for i in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  P[a].append(b)
  P[b].append(a)
#AB=[list(map(int,input().split())) for i in range(M)]
ans=[0]*N
con=set()
now=[1]
while now!=[]:
  _now=[]
  for n in now:
    for p in P[n]:
      if p in con:
        continue
      ans[p-1]=n
      _now.append(p)
      con.add(p)
    #con.add(n)
  now=_now
print('Yes')
for a in ans[1:]:
  print(a)




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

typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main()
{
	
	ll n, num, den = 0, i;
	
	scanf("%lld", &n);
	vll nums(n);
	for (i = 0; i < n; i++) {
		scanf("%lld", &nums[i]);
		if (i == 0)
			num = nums[i];
		else
			num = lcm(num, nums[i]);
	}
	for (i = 0; i < n; i++)
		den += (num / nums[i]);
	printf("%.6lf\n", num / (1.0 * den));
	return 0;
}

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

struct P{
	double x,y;
};
const double th=M_PI*60.0/180.0;

void koch(int n,P a,P b){
	if(n==0)
		return ;
	P s,t,u;
	s.x=(2*a.x+b.x)/3;
	s.y=(2*a.y+b.y)/3;
	t.x=(a.x+2*b.x)/3;
	t.y=(a.y+2*b.y)/3;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.y-s.y)*cos(th)+(t.x-s.x)*sin(th)+s.y;
	koch(n-1,a,s);
	printf("%.5f %.5f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.5f %.5f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.5f %.5f\n",t.x,t.y);
	koch(n-1,t,b);
}

int main(){
	int n;
	scanf("%d",&n);
	P a={0,0},b={100.0,0};
	printf("%.5f %.5f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.5f %.5f\n",b.x,b.y);
	return 0;
}

Measured memory_bytes: 2748
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;

const int maxn=1e5+10;
int n,a[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		if(a[i+1]<i+1){
			if((a[i]-i)&1){
				puts("First");
				return 0;
			}
			int j=i;
			while(a[j+1]==i)
				++j;
			if((j-i)&1){
				puts("First");
				return 0;
			}
			puts("Second");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 640
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001];
	ll now=1;
	scan(N);
	int flag=0;
	rep(i,N){
		scan(A[i]);
		if(A[i]==0) flag=1;
	}
	if(flag){
		prin(0);
		return 0;
	}
	rep(i,N){
		if((double)now*A[i]>=2e+18){
			prin(-1);
			return 0;
		}
		else if(now*A[i]>=INFl){
			prin(-1);
			return 0;
		}
		now*=A[i];
	}
	prin(now);
	return 0;
}


Measured memory_bytes: 4404
#temprate
from sys import setrecursionlimit
setrecursionlimit(10**6)
from collections import Counter
def inputlist(): return [int(i) for i in input().split()]
#temprate

S = list(input())
c = Counter(S)
if 0<=c['x']<=7:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            long a = cin.ReadLong;
            long b = cin.ReadLong;
            long x = cin.ReadLong;

            long m = a == 0 ? -1 : (a - 1) / x;
            long sum = (b / x) - m ;

            Console.WriteLine(sum);
        }
    }

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

Measured memory_bytes: 13268
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll Max(ll a,ll b,ll c){
    if(a<0){
        a=-inf;
    }
    if(b<0){
        b=-inf;
    }
    if(c<0){
        c=-inf;
    }
    ll ans=max(max(a,b),c);
    if(ans<0){
        return -2;
    }else{
        return ans;
    }
}

int main(){
    ll q;cin>>q;
    string x,y;
    ll ans[q];
    ll dp[2000][2000];  //xのi文字目までと、yのj文字目までの最長の長さ
    rep(ii,0,q-1){
        cin>>x>>y;
        rep(i,0,y.size()){
            dp[0][i]=0;
        }
        rep(i,0,x.size()-1){
            rep(j,0,y.size()-1){
                if(x[i]==y[j]){
                    dp[i+1][j+1]=Max(dp[i][j]+1,dp[i+1][j],dp[i][j+1]);
                }else{
                    dp[i+1][j+1]=Max(dp[i][j],dp[i+1][j],dp[i][j+1]);
                }
                //cout<<dp[i+1][j+1]<<' ';
            }
            //cout<<endl;
        }
        ans[ii]=dp[x.size()][y.size()];
    }
    rep(i,0,q-1){
        cout<<ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 15080
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Storable         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    B.PS p 0 l <- C.hGetNonBlocking IO.stdin (h*(w+1))
    let mat = U.unsafeFromForeignPtr0 p l
    print $ solve h (w+1) mat

solve :: Int -> Int -> U.Vector Word8 -> Int
solve h w mat = subtract 1 . U.maximum $ U.zipWith (+) lr ud
  where
    forward :: Int -> Int -> Int
    forward acc x
        | x == 0 = 0
        | otherwise = max acc x

    backward :: Word8 -> Int -> Int
    backward x acc
        | x /= B.c2w '.' = 0
        | otherwise = acc + 1

    lr :: U.Vector Int
    lr = U.concatMap (\i ->
          U.scanl1' forward
            . U.postscanr' backward 0
            $ U.unsafeSlice (i * w) w mat
        )
        $ U.generate h id

    ud :: U.Vector Int
    ud = V.convert
        . V.concatMap U.convert
        . V.scanl1' (U.zipWith forward)
        . V.postscanr' (U.zipWith backward) (U.replicate w 0)
        $ V.generate h (\i -> U.unsafeSlice (i * w) w mat)



Measured memory_bytes: 49404
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int s1 = A * B, s2 = C * D;
	if (s1 > s2) cout << s1 << endl;
	else cout << s2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<complex>
#include<cmath>

using namespace std;

typedef complex<double> xy_t;
double cross(xy_t a,xy_t b);
xy_t P[110];



int main(){
  
  int N;

  double x,y;
  
  cin >> N;
  
  for(int i=0;i<N;i++){
    cin >> x >> y;
    P[i] = xy_t(x,y);
  
  }
  
 
  double ans=0;
  for(int j=1;j<N-1;j++){
    ans+=cross(P[j]-P[0],P[j+1]-P[0]);
  }

  ans=abs(ans)/2;
  cout.precision(1);
  cout << fixed << ans << endl;
  
}
double cross(xy_t a, xy_t b){return (conj(a)*b).imag();}

Measured memory_bytes: 1296
#include <iostream>

using namespace std;

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

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

  int min = m[0];
  int sum = 0;
  for(i = 0;i < N;i++){
    if(min > m[i]) min = m[i];
    sum += m[i];
  }

  int nokori = 0;
  nokori = X - sum;
  int count = N ;


  while(nokori >= min){
    nokori -= min;
    count++;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self,num):
        self.num = num.copy()
        
    def east(self):
        temp = self.num.copy()
        self.num[1-1] = temp[4-1]
        self.num[4-1] = temp[6-1]
        self.num[6-1] = temp[3-1]
        self.num[3-1] = temp[1-1]

    def north(self):
        temp = self.num.copy()
        self.num[1-1] = temp[2-1]
        self.num[2-1] = temp[6-1]
        self.num[6-1] = temp[5-1]
        self.num[5-1] = temp[1-1]

    def south(self):
        temp = self.num.copy()
        self.num[1-1] = temp[5-1]
        self.num[5-1] = temp[6-1]
        self.num[6-1] = temp[2-1]
        self.num[2-1] = temp[1-1]

    def west(self):
        temp = self.num.copy()
        self.num[1-1] = temp[3-1]
        self.num[3-1] = temp[6-1]
        self.num[6-1] = temp[4-1]
        self.num[4-1] = temp[1-1]

    def right(self):
        temp = self.num.copy()
        self.num[2-1] = temp[4-1]
        self.num[4-1] = temp[5-1]
        self.num[5-1] = temp[3-1]
        self.num[3-1] = temp[2-1]

num1 = list(map(int,input().split()))
num2 = list(map(int,input().split()))
dice1,dice2 = Dice(num1),Dice(num2)
if num1.sort() != num2.sort(): print('No')
else:
    flag = False
    for i in range(20):
        if flag == True: break
        dice2.north()
        for _ in range(20):
            if flag == True:
                break
            dice2.east()
            for _ in range(20):
                dice2.right()
                if dice1.num == dice2.num:
                    flag = True
                    break
    if flag: print("Yes")
    else: print("No")
            
    



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
 
 
void solve(){
    int n,tw;
    cin>>n>>tw;

    vector<int> w(n),v(n);
    for(int i=0;i<n;i++)cin>>w[i]>>v[i];

    vector<vector<ll>> dp(n+1,vector<ll>(tw+1));

    for(int i=0;i<=n;i++){
        for(int j=0;j<=tw;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }

            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

            if(j-w[i-1]<0)continue;
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }

    cout<<dp.back().back()<<endl;
}


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

    // while(n--)
    solve();

    return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>
int main(void) {
   int i,n;
   float ax,ay,bx,by,cx,cy,dx,dy,ab,cd;
   scanf("%d",&n);
   for(i=0;i<n;i++){
	   scanf("%f %f %f %f %f %f %f %f",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
	   ab=(by-ay)/(bx-ax);
	   cd=(dy-cy)/(dx-cx);
	  if(ab==cd){printf("YES\n");}else{printf("NO\n");}
   }
   return 0;
}



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

typedef pair <int, int> p;
vector <p> vn,vm;
vector <int> ans;

int main(){
  int n,m;
  int a,b;

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

  REP (i, n) {
    scanf("%d %d",&a,&b);
    vn.push_back(make_pair(a, b));
  }

  REP (i, m) {
    scanf("%d %d",&a, &b);
    vm.push_back(make_pair(a, b));
  }

  REP (i, n) {
    vector <p> v;
    REP (j, m) {
      int dis = abs(vn.at(i).first - vm.at(j).first) + abs(vn.at(i).second - vm.at(j).second);
      v.push_back(make_pair(dis, j + 1));
    }
    stable_sort(v.begin(), v.end());
    ans.push_back(v.front().second);
  }

  REP (i, n) {
    printf("%d\n",int(ans.at(i)));
  }
}


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

int main()
{
	int a[10000], n, max, min;
	long long int sum;

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

	max = a[0];
	min = a[0];
	sum = a[0];

	for (int i = 1;i < n;i++) {
		if (max < a[i]) { max = a[i]; }
		if (min > a[i]) { min = a[i]; }
		sum += a[i];
	}

	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1200
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n, K = na()
lr = []
for i in range(K):
    lr.append(na())

mod = 998244353
dp = [0] * (n+1)
cum = [0] * (n+1)

dp[1] = cum[1] = 1
for i in range(2, n+1):
    v = 0
    for u in lr:
        l = max(1, i-u[1])
        r = i-u[0]
        if l <= r:
            v += cum[r] - cum[l-1] + mod
    dp[i] = v % mod
    cum[i] = cum[i-1] + dp[i]
    if cum[i] >= mod:
        cum[i] -= mod
print(dp[n])


Measured memory_bytes: 71292
#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
using namespace std;

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

	vector <int> X,X_sorted;
	X.push_back(0);
	X_sorted.push_back(0);

	for (int i = 1; i <= N; i++) {
		int tmp;
		cin >> tmp;
		X.push_back(tmp);
		X_sorted.push_back(tmp);
	}

	sort(X_sorted.begin(), X_sorted.end());

	for (int i = 1; i <= N; i++) {
		if (X[i] <= X_sorted[N/2]) cout << X_sorted[N / 2 + 1] << endl;
		else cout << X_sorted[N / 2] << endl;
	}

	return 0;
}

Measured memory_bytes: 3948
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
C = Counter(A)

tmp = 0
for x in C.values():
	tmp += x*(x-1)//2

for x in A:
	print(tmp - (C[x]-1))

Measured memory_bytes: 35012
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    int i,ans = 0;

    for(  i = 0; i < s.length(); i++ )
        if( s[ i ] != t[ i ] )
            ans++;
    
    cout << ans << "\n";
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
void add(ll &a,ll b){
	a+=b;
	if(a>=mod)a-=mod;
}
int main(void){
	int H,W,K;
	cin >> H >> W >> K;
	--K;
	vector<vector<ll>> dp(H+1,vector<ll>(W,0));
	dp[0][0] =1;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int bit=0;bit < 1<<(W-1);bit++){
				bool ok = true;
				for(int k=0;k<W-2;k++){
					if((bit&(1<<k)&&(bit&(1<<(k+1)))))ok=false;
				}
				if(!ok)continue;
				int nj = j;
				if(bit&(1<<j))nj=j+1;
				else if(j>0 &&(bit&(1<<(j-1))))nj=j-1;
				add(dp[i+1][nj],dp[i][j]);
			}
		}
	}
	cout << dp[H][K] << endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
count = 3000000

left_count = 0 # 先頭から
right_count = s.count('E') # 最初は向く方向が代わるEをカウント

n.times do |i|
  if s[i] == 'W'
    ans = left_count + right_count
    left_count += 1
  else
    right_count -= 1
    ans = left_count + right_count
  end
  count = ans if ans < count
end

puts count

Measured memory_bytes: 2564
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()



int main(){

    fast;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>b)
    swap(a,b);
    if(c>b)
    swap(c,d);
    ll ans=-1*1e18;
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;

    

}

Measured memory_bytes: 3644
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    char x[3];
    char *s1 = "SSS";
    char *s2 = "SSR";
    char *s3 = "SRS";
    char *s4 = "RSS";
    char *s5 = "RRS";
    char *s6 = "RSR";
    char *s7 = "SRR";
    char *s8 = "RRR";

    int ans = 1;
    scanf("%s", x);

    if (strcmp(s1, x) == 0) {
        ans = 0;
    } else if (strcmp(s5, x) == 0 || strcmp(s7, x) == 0) {
        ans = 2;
    } else if (strcmp(s8, x) == 0) {
        ans = 3;
    } else {
        ans = 1;
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 100050;
int a[MAX_N], b[MAX_N];
int N;
int parent[MAX_N];
std::vector<int> adj[MAX_N];
 
int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N - 1; i++) {
        std::cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= N - 1; i++) {
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }

    for (int i = 1; i <= N; i++) {
        parent[i] = -1;
    }

    std::queue<int> que;
    que.push(1);
    parent[1] = 1;

    while (!que.empty()) {
        int tmp = que.front();
        que.pop();
        for (auto ad : adj[tmp]) {
            if (parent[ad] == -1) {
                parent[ad] = tmp;
                que.push(ad);
            }
        }
    }

    std::vector<int> path;
    int tmp = N;
    while (true) {
        path.push_back(tmp);
        if (tmp == 1) {
            break;
        }
        tmp = parent[tmp];
    }

    int center = path.size() / 2;
    int e1 = path[center];
    int e2 = path[center-1];

    int bridge = -1;
    for (int i = 1; i <= N - 1; i++) {
        if ((a[i] == e1 && b[i] == e2) ||
            (a[i] == e2 && b[i] == e1)
        ) {
            bridge = i;
            break;
        }
    }

    for (int i = 1; i <= N; i++) {
        parent[i] = -1;
    }

    int num = 0;
    que.push(1);
    parent[1] = 1;
    num++;

    while (!que.empty()) {
        int tmp = que.front();
        que.pop();
        for (auto ad : adj[tmp]) {
            if ((a[bridge] == tmp && b[bridge] == ad) ||
                (b[bridge] == tmp && a[bridge] == ad)
            ) {
                continue;
            }
            if (parent[ad] == -1) {
                parent[ad] = tmp;
                que.push(ad);
                num++;
            }
        }
    }

    if (N - num < num) {
        std::cout << "Fennec" << std::endl;
    } else {
        std::cout << "Snuke" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 7548
package main

import "fmt"

type Music struct {
	name string
	time int
}

func main() {
	var n int
	fmt.Scan(&n)

	var pl []Music
	for i := 0; i < n; i++ {
		var name string
		var time int
		fmt.Scan(&name, &time)
		pl = append(pl, Music{name: name, time: time})
	}
	var last string
	fmt.Scan(&last)
	var flag bool
	var ans int
	for _, m := range pl {
		if flag {
			ans += m.time
		} else {
			if m.name == last {
				flag = true
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#include <iomanip>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n,m,d;
int main(int argc,char const* argv[])
{
  double ans=0.0;
  int n,m,d;
  cin >> n >> m >> d;
  if(d==0)
    {
      ans=1.0*(m-1)/n;
    }
  else
    {
      ans=2.0*(n-d)*(m-1)/n/n;
    }
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool c[4];

int main()
{
	string S;
	cin >> S;
	REP(i, S.length())
	{
		if (S[i] == 'N')
		{
			c[0] = true;
		}
		else if (S[i] == 'S')
		{
			c[1] = true;
		}
		else if (S[i] == 'W')
		{
			c[2] = true;
		}
		else
		{
			c[3] = true;
		}
	}

	if (c[0] == c[1] && c[2] == c[3])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 500000 + 5
#define M 5
#define base 1331
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
char s[N];
int n, f, ans, bp[M][N], pre[N], suf[N], Mod[M], Hash[M][N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b, int p){
    return (a += b) >= Mod[p] ? a - Mod[p] : a;
}
int Dec(int a, int b, int p){
    return (a -= b) < 0 ? a + Mod[p] : a;
}
int Mul(int a, int b, int p){
    return 1ll * a * b % Mod[p];
}
int Get(int l, int r, int p){
    return Dec(Hash[p][r], Mul(Hash[p][l - 1], bp[p][r - l + 1], p), p);
}
int main(){
    scanf("%s", s + 1), n = strlen(s + 1);
    rep(i, 2, n) if(s[i] != s[i - 1]){ f = 1; break;}
    if(!f){ printf("%d\n%d", n, 1); return 0;}
    Mod[1] = 19260817, Mod[2] = 1000000007;
    bp[1][0] = bp[2][0] = 1;
    rep(i, 1, n) rep(j, 1, 2) bp[j][i] = Mul(bp[j][i - 1], base, j);
    rep(i, 1, n) rep(j, 1, 2) Hash[j][i] = Inc(Mul(Hash[j][i - 1], base, j), s[i] - 'a' + 1, j);
    rep(i, 1, n / 2) if(n % i == 0){
        if((Get(1, n - i, 1) == Get(i + 1, n, 1)) && (Get(1, n - i, 2) == Get(i + 1, n, 2))){ f = 0; break;}
    }
    if(f){ printf("%d\n%d", 1, 1); return 0;}
    rep(i, 1, n / 2) for(int j = i + i; j <= n; j += i){
        if((Get(1, j - i, 1) == Get(i + 1, j, 1)) && (Get(1, j - i, 2) == Get(i + 1, j, 2))) pre[j] = 1;
    }
    rep(i, 1, n) rep(j, 1, 2) Hash[j][i] = Inc(Mul(Hash[j][i - 1], base, j), s[n - i + 1] - 'a' + 1, j);
    rep(i, 1, n / 2) for(int j = i + i; j <= n; j += i){ 
        if((Get(1, j - i, 1) == Get(i + 1, j, 1)) && (Get(1, j - i, 2) == Get(i + 1, j, 2))) suf[n - j + 1] = 1;
    }
    rep(i, 1, n - 1) if(!pre[i] && !suf[i + 1]) ++ans;
    printf("%d\n%d\n", 2, ans);
    return 0;
}

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


#define pb push_back 
#define rep(i, n, a) for(int i = a;i< n;i++)
#define all(x) (x).begin(), (x).end()
#define so(x) sort(x.begin(), x.end());
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>>vii;
typedef vector<ll> vl;
typedef vector<vector<ll>>vll;
typedef pair <int, int> pii;
typedef pair<ll, ll> pll;

void printVec(vector<int> &A){
    for(int i=0;i< A.size();i++){
        cout<<A[i]<<' ';
    }
    cout <<endl;
}

void printArr(int arr[], int n){
    for(int i =0;i< n;i++){
        cout<<arr[i]<<' ';
    }
    cout <<endl;
}

vector<vll> dp;
vi rs;
vi gs;
vi bs;


ll getAns(int r, int g, int b){
    if(r < 0 || g < 0 || b < 0)return 0;
    if(dp[r][g][b] >= 0) return dp[r][g][b];
    if(r == 0 && g == 0 && b == 0)return 0;
    if(r == 0){
        if(g == 0 || b == 0)return 0;
        dp[r][g][b] = gs[g-1]*bs[b-1] + getAns(r, g-1, b-1);
        return dp[r][g][b];
    }
    if(g == 0){
        if(r == 0 || b == 0)return 0;
        dp[r][g][b] = rs[r-1]*bs[b-1] + getAns(r-1, g, b-1);
        return dp[r][g][b];
    }
    if( b == 0){
        if(r == 0 || g == 0)return 0;
        dp[r][g][b] = rs[r-1]*gs[g-1] + getAns(r-1, g-1, b);
        return dp[r][g][b];
    }
    dp[r][g][b] = rs[r-1]*gs[g-1] + getAns(r-1, g-1, b);
    dp[r][g][b] = max(dp[r][g][b],rs[r-1]*bs[b-1] +getAns(r-1, g, b-1));
    dp[r][g][b] = max(dp[r][g][b], bs[b-1]*gs[g-1] + getAns(r, g-1, b-1));
    return dp[r][g][b];
}


void solve(){
    string a;
    cin>>a;
    if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R'){
        cout<<3<<endl;
        return ;
    }
    if(a[0] == 'R' && a[1] == 'R'){
        cout<<2<<endl;
        return ;
    }
    if( a[1] == 'R' && a[2] == 'R'){
        cout<<2<<endl;
        return ;
    }
    if(a[1] == 'R' || a[2] == 'R' || a[0] == 'R'){
        cout<<1<<endl; 
        return ;
    }
    cout<<0<<endl;
    return  ;
}

int main(){
    int t;
    // cin>>t;
    t = 1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int dx = x1-x2;
	int dy = y1-y2;	
	cout<<x2+dy<<" "<<y2-dx<<" "<<x1+dy<<" "<<y1-dx;
}


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

class Color
{
  public:
    Color();
  public:
    void ChangeColor(int i);
    void PlusColor(int c);
    int isColor();

  private:
    int m_color;
};

Color::Color()
{
  m_color = 1;
}

inline void Color::PlusColor(int i)
{
  m_color = (m_color + i - 1) % 3 + 1;
}

inline void Color::ChangeColor(int c)
{
  m_color = c;
}

inline int Color::isColor()
{
  return m_color;
}

int main(void)
{
  int wh;
  int k;
  int x, y;
  cin >> wh;
  int centre = wh / 2;
  cin >> k;
  for (int i = 0; i < k; ++i)
  {
    cin >> x >> y;
    if (centre < x) x = wh - x + 1;
    if (centre < y) y = wh - y + 1;

    Color color;
    if (y >= x)
    {
      color.ChangeColor( x % 3 == 0 ? 3 : x % 3);
    }
    else
    {
      color.PlusColor(y - 1);
    }

    cout << color.isColor() << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/*
*  Problem Link: https://atcoder.jp/contests/abc172/tasks/abc172_b
*  Author: Raunak Sett
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long 
#define vi vector<int>
int main() {
    IOS
    // Code Here
    string s, t;
    cin>>s>>t;
    int c = 0;
    for (int i=0; i < s.length(); i++) {
        if (t[i] != s[i]) c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3880
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
}

int main() {
    cpp();
    ll a, b, n;
    cin>>a>>b>>n;
    ll z = min(b-1, n);
    ll ans = (a*z - (a%b*z)%b)/b;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int k, n;
    cin >> k >> n;
    vi a(n);
    for(int i = 0; i < n ; i++){
        cin >> a[i];
    }
    int min_distance = a[n-1];
    for(int i = 0 ; i < n ; i++){
        int start = a[i];
        int end1 = a [ ( n - 1 + i) % n];
        int end2 = a[ ( i + 1 ) % n];
        int dist1 = (end1 - start);
        int dist2 = start - end2;
        //cout << dist1 << " " << dist2 << endl;
        if( dist1 < 0){
            dist1 = dist1 + k;
        }
        if(dist2 < 0){
            dist2 = dist2 + k;
        }
        if( min_distance > min(dist1, dist2)){
            min_distance = min(dist1, dist2);
        }
    }
    cout << min_distance << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}



Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	float c=float(a[0]+a[1])/2;
	for(int i=2;i<n;i++)
		c=(a[i]+c)/2;
	 cout<<c<<endl;
	 return 0;
}

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

int main() {
  int a, b, x;
  cin >> a;
  
  for(int i = 0;i < 7;i++) {
    b = pow(2, i);
    if(b <= a) {
      x = b;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define rep(i,l,r) for (ll i=l;i<=r;i++)
using namespace std;
typedef long long ll;
int la[500007],yes[5000007],dp[5000007];
char s[500007],t[500007];
int main(){
	scanf("%s",t+1); scanf("%s",s+1);
	int ls=strlen(s+1),lt=strlen(t+1);
	rep(i,2,ls+1){
		int p=la[i-1];
		while (p>0&&s[p]!=s[i-1]) p=la[p];
		la[i]=p+1;
	}
	int p=1,nn=max((ls*5+lt-1)/lt,5);
	rep(kk,0,nn-1) rep(i,1,lt){
		while (p>0&&t[i]!=s[p]) p=la[p];
		p++;
		if (p==ls+1) yes[i+lt*kk]=1;
	}
	int ans=0;
	rep(i,1,lt*nn){
		if (yes[i]) dp[i]=dp[i-ls]+1; 
		ans=max(ans,dp[i]);
	}
	if (ans*ls>max(ls,lt)*2) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 28928
import Foundation
let main: () = {
    let R = nextDouble()
    let ans = Double.pi * 2.0 * R
    print(ans)
}()
@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func nextDouble() -> Double { Double(next())! }

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

#define debug(x) cerr<<#x<<'='<<x<<'\n'

int main(void) {
	int n;
	int a[20];
	int j[20], o[20];
	cin>>n;
	for (int i=1; i<=n; i++) {
		cin>>a[i];
	}
	for (int i=1; i<=n; i++) {
		if (a[i]&1) {
			o[i]=2;
			j[i]=1;
		} else {
			o[i]=1;
			j[i]=2;
		}
	}
	int ans=0;
	for (int i=1; i<=n; i++) {
		int tmp=1;
		for (int k=1; k<=n; k++) {
			if (i==k) {
				tmp*=o[k];
			} else {
				if (i<k) tmp*=j[k];
				else tmp*=(j[k]+o[k]);
			}
		}
		ans+=tmp;
	}
	cout<<ans;
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0;
		return 0;
	}
	if (a == b) {
		cout << 1;
		return 0;
	}
	if (n == 1) {
		cout << 0;
	} else if (n == 2) {
		cout << 1;
	} else {
		cout << 1LL * (n - 2) * (b - a) + 1;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  vector <int> ans(n, s == 1e9 ? s - 1 : s + 1);
  REP(i, k) {
	ans[i] = s;
  }
  REP(i, n - 1) {
	cout << ans[i] << " ";
  }
  cout << ans[n - 1] << endl;
  return 0;
}


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

int main()
{
  int n; cin >> n ;
  int F[50];
  F[0] = F[1] = 1;
  for (int i = 2 ; i <= n; ++i)
  {
    F[i] = F[i-1] + F[i-2];
  }

  cout << F[n] << endl;

  return 0;
}

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

int N,sum;

int main()
{
	ios::sync_with_stdio(0);
	cin>>N;
	for (int i=1; i<=N; i++)
	{
		int temp;
		cin>>temp;
		sum+=temp;
	}
	if (sum%2)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream input = System.in;
      	OutputStream output = System.out;
      	Scanner sc = new Scanner(input);
      	PrintWriter out = new PrintWriter(output);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int C = sc.nextInt();
      	int X = sc.nextInt();
      	int count = 0;
      	for(int i = 0; i <= A; i++){
        	for(int j = 0; j <= B; j++){
            	for(int l = 0; l <= C; l++){
                	if((500 * i) + (100 * j) + (50 * l) == X){
                    	count++;
                    }
                }
            }
        }
      	out.println(count);
      	out.close();
    }
}

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

int main(){
	int n[5], num[14], pair[3],i;
	while (scanf("%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4]) != EOF){
		i = 0;
		for (int i = 0; i < 14; i++) num[i] = 0;
		for (int i = 0; i < 3; i++) pair[i] = 0;
		for (int i = 0; i < 5; i++) num[n[i] - 1]++;
		for (int i = 0; i < 13; i++){
			if (num[i] > 1) pair[num[i] - 2]++;
		}
		if (pair[2]) cout << "four card" << endl;
		else if (pair[0] && pair[1]) cout << "full house" << endl;
		else if (pair[1]) cout << "three card" << endl;
		else if (pair[0] == 2) cout << "two pair" << endl;
		else if (pair[0]) cout << "one pair" << endl;
		else{
			num[13] = num[0];
			for (i = 0; i < 10; i++){
				if (num[i] == 1 && num[i] == num[i + 1] && num[i + 1] == num[i + 2] && num[i + 2] == num[i + 3] && num[i + 3] == num[i + 4]) {
					cout << "straight" << endl;
					break;
				}
			}
		}
		if (i == 10)  cout << "null" << endl;
	}
	return 0;
}

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

using namespace std;

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

pii loc[100000];
ll dp[100000];

int r, c, d;

int main() {
	scanf("%d%d%d", &r, &c, &d);
	for(int i = 0; i < r; i++) {
		for(int j = 0; j < c; j++) {
			int t;
			scanf("%d", &t);
			loc[t] = pii(i, j);
		}
	}
	for(int i = 1; i <= r*c; i++) {
		dp[i] = dp[max(0, i-d)];
		if(i > d) {
			dp[i] += abs(loc[i].first - loc[i-d].first) + abs(loc[i].second - loc[i-d].second);
		}
	}
	int q;
	scanf("%d", &q);
	while(q--) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%lld\n", dp[b] - dp[a]);
	}
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      String original = sc.nextLine();
      int n = Integer.parseInt(sc.nextLine());
      
      
      
      for(int i = 0; i < n; i ++){
         String command = sc.next();
         if(command.equals("print")){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            
            print(original,a,b);
         
         }else if(command.equals("replace")){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            String str = sc.next();
            
            original = replace(original, a,b,str);
            
         }else{ //reverse
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            
            original = reverse(original, a,b);
            
         }
      }// end for
         
   }//main
   
   /**
   *print(String, int, int) method
   *@ param str : the original string
   *@ param a        : the beginning index
   *@ param b        : the ending index
   *@ print a string from index a to index b
   */
   
   public static void print(String str, int a, int b){
      System.out.println(str.substring(a,b+1));
   }
   
   /**
   *replace(String,int,int,String) method
   *@ param original : The original string
   *@ param a        : The biginning index to be replaced
   *@ param b        : The ending index to be replaced
   *@ param str      : The string to be replaced into the original
   *@ return a string with string inserted from a to b
   */
   public static String replace(String original, int a, int b, String str){
      String s = "";
      s += original.substring(0,a);
      s += str;
      s += original.substring(b+1);
      
      return s;
   }
   
   /**
   *reverse(String,int,int) method
   *@ param str   : The original string
   *@ param a     : The biginning index to be reversed
   *@ param b     : The last index to be replaced
   *@ return a string 
   */
   
   public static String reverse(String str, int a, int b){
      String s = "";
      s += str.substring(0,a);
      for(int i = b; i >= a; i--){
         s += str.substring(i,i + 1);
      }
      s += str.substring(b + 1);
      
      return s;
      
   }
      
}//class


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int bingo[3][3] = {};
  bool ok[3][3] = {};
  rep(i,3) rep(j,3) cin >> bingo[i][j];

  int N; cin >> N;
  rep(i,N) {
    int b; cin >> b;
    rep(i,3) rep(j,3) if (bingo[i][j]==b) ok[i][j] = true;
  }

  string result = "No";
  rep(i,3) if (ok[i][0]&&ok[i][1]&&ok[i][2]) result = "Yes";
  rep(i,3) if (ok[0][i]&&ok[1][i]&&ok[2][i]) result = "Yes";
  if (ok[0][0]&&ok[1][1]&&ok[2][2]) result = "Yes";
  if (ok[0][2]&&ok[1][1]&&ok[2][0]) result = "Yes";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256