akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<vector<int>> comb(60, vector<int>(60));

signed main() {
  int N, A, B; 
  cin >> N >> A >> B;
  int AA = A;

  REP(i, N+5){
    REP(j, i+1){
      if(j == 0 || j == i){
        comb[i][j] = 1;
      }else{
        comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
      }
    }
  }

  vector<int> v(N);
  REP(i, N) cin >> v[i];

  sort(ALL(v), greater<int>());

  map<int, int> m;
  REP(i, N) m[v[i]]++;

  int sum = 0;
  map<int, int>::reverse_iterator i = m.rbegin();
  for(; i != m.rend(); i++){
    sum += i->first*min(A, i->second);
    A -= i->second;
    B -= i->second;
    if(A <= 0){
      A += i->second;
      B += i->second;
      int ans = 0;
      if(v[0] == i->first){
        for(int j = A; j <= B; j++){
          ans += comb[i->second][j];
        }
      }else{
        ans = comb[i->second][A];
      }
      printf("%.9f\n", 1.0*sum/AA);
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

// use std::io::{stdout, Write, BufWriter};
use std::cmp::{max, min};

// use std::thread;
// use std::time::Duration;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
        q: [usize; n],
    }

    let mut f = Facto::new(n - 1).unwrap();
    let (a, b) = (lex_order(&p, &mut f, n), lex_order(&q, &mut f, n));
    println!("{}", max(a, b) - min(a, b));
}

type SomeInt = usize;

struct Facto {
    cache: Vec<SomeInt>,
}

impl Facto {
    fn facto(n: SomeInt) -> Option<SomeInt> {
        if 1 <= n {
            Some(
                (1..(n + 1)).product()
            )
        } else if n == 0 || n == 1 { Some(1) }
        else { None }
    }

    fn new(n: SomeInt) -> Option<Facto> {
        if 0 <= n {
            Some(Facto{
                cache: (0..(n + 1)).scan(1, |state, i| {
                    if i == 0 { *state = 1; }
                    else { *state *= i; }
                    Some(*state)
                }).collect()
            })
        } else { None }
    }

    fn facto_cached(&mut self, n: SomeInt) -> Option<SomeInt> {
        if n < 0 { return None }
        let l = self.cache.len() as SomeInt;
        let mut to_be_appended = (l..(n + 1))
            .scan(*((self.cache).last().unwrap()), |state, i| {
                *state *= i;
                 Some(*state)
            }).collect();
        self.cache.append(&mut to_be_appended);
        Some(*(self.cache.get(n as usize).unwrap()))
    }
}



// {1, ..., n}からなる順列の辞書式順序を求める
fn lex_order(v: &[SomeInt], f: &mut Facto, n: usize) -> SomeInt {
    let mut states: Vec<SomeInt> = vec![1; n];
    let sum: SomeInt = v.iter().enumerate().map(|(i, &x)| {
        states[x - 1] = 0;
        let s: SomeInt = states.iter().take(x).sum();
        s  * f.facto_cached(n - i - 1).unwrap()
    }).sum();
    sum + 1
}


Measured memory_bytes: 4352
#include<iostream> 
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W >>H >>x >>y >>r;
    if((x+r<=W)&&(x-r>=0)&&(y+r<=H)&&(y-r>=0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;



int main() {

	int a, b;
	string s;

	cin >> a >> b >> s;
	rep(i, 0, a) {
		if (!isdigit(s[i])) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}
	rep(i, a+1, a+b+1) {
		if (!isdigit(s[i])) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int digitsum(string s) {
  int ans = 0;
  for ( char d : s) ans += d-'0';
  return ans;
}

int main() {
  string s;
  cin>>s;
  int n = s.length();
  cout << max(digitsum(s),s[0]-'1'+9*(n-1)) << endl;

  return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var split = read.Split(' ');
            int H = int.Parse(split[0]);
            int W = int.Parse(split[1]);
            int[,] field = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                read = Console.ReadLine();
                split = read.Split(' ');
                for (int j = 0; j < W; j++)
                {

                    field[i, j] = int.Parse(split[j]);

                }
            }
            //準備完了
            List<string> output = new List<string>();
            if (W >= 2)
            {
                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W - 1; j++)
                    {
                        //偶、偶　なにもしない
                        //偶、奇　なにもしない
                        //奇、偶　左を選んで一枚
                        //奇、奇　左を選んで一枚右に

                        if (field[i, j] % 2 != 0)
                        {
                            output.Add((i+1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                            field[i, j]--;
                            field[i, j + 1]++;
                        }

                    }
                    //一番右にきました、一番左以外は偶数です
                }
                //れつの一番右だけが偶数奇数が入り交じる、ほかは全部偶数という状態が出来上がりました
            }
            for (int i = 0; i < H - 1; i++)
            {
                if (field[i, W - 1] % 2 != 0)
                {
                    output.Add((i + 1) + " " + (W) + " " +(i+2) + " " + (W));
                    field[i, W-1]--;
                    field[i + 1, W - 1]--;
                }
            }
            Console.WriteLine(output.Count);
            for (int i = 0; i < output.Count; i++)
            {
                Console.WriteLine(output[i]);
            }
        }

    }
}


Measured memory_bytes: 28568
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_X 2002
#define MAX_Y 2002
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;

    for (int i=a; i<=b; ++i) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL N, M, S, A[50];
inline LL ceil(LL d, LL n) {return (d+n-1)/n;}
inline bool ok(LL x) {
  if(M < S-x) return false;
  LL s = 0;
  for(auto i=0; i<N; ++i) s += ceil(A[i]+x+1-N, N+1);
  return s <= x;
}
int main() {
  scanf("%lld", &N);
  M=N*(N-1);
  for(auto i=0; i<N; ++i) scanf("%lld", A+i), S+=A[i];
  LL l = -1, h = 1e18;
  while(l+1 < h) {
    LL m = (l+h)>>1;
    if(ok(m)) h = m;
    else      l = m;
  }
  for(auto x=max(0ll,h-N*N); x<=h; ++x) if(ok(x)) {
    printf("%lld\n",x);
    break;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    vector<bool> dp(k+1, false);
    for(int i=0; i<=k; i++){
        for(int j=0; j<n; j++){
            if(i - a[j] >= 0){
                dp[i] = dp[i] | !dp[i-a[j]];
            }
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

ans :: Int -> Int -> Int -> Int
ans _ 0 acc = acc
ans k n acc = ans k (n `div` k) (acc + 1)

main :: IO ()
main = do
	[n, k] <- readToListN 2 <$> BS.getLine
	print $ ans k n 0


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

int main(){
	int l, r, d;
  	cin >> l >> r >> d;
  
  	int ans = 0;
  	for(int i = l; i <= r; i++){
    	if(i % d == 0) ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll> c(n);
    vector<ll> s(n);
    vector<ll> f(n);
    for(ll i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    ll total;
    for(ll i=0;i<n-1;i++){
        total = 0;
        for(ll j=i;j<n-1;j++){
            if(total<=s[j]){
                total+=abs(total-s[j]);
            }else{
                ll temp = s[j];
                while(total>temp){
                    temp+=f[j];
                }
                total+=abs(total-temp);
            }
            total+=c[j];
        }
        cout << total << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
import math
import sys
import numpy
import decimal

a, b, h, m = map(int, input().split())

sita = abs((h / 12 * 360+m/60*30) - (m / 60 * 360))

if (sita > 180):
    sita = 360-sita

ans = numpy.sqrt((a * a) + (b * b) - (2 * a * b*math.cos(math.radians(sita))))
print(decimal.Decimal(ans))


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

ll n, a, b;

bool calc(ll mid, vector<ll> h){
    for(int i=0; i<n; i++){
        h[i] -= mid*b;
    }

    ll cnt=0;
    for(int i=0; i<n; i++){
        if(h[i] > 0) cnt += (h[i] + (a - b) - 1) / (a - b);
    }

    if(cnt <= mid) return true;
    else return false;
}

int main(){
    cin>>n>>a>>b;
    vector<ll> h(n);
    for(int i=0; i<n; i++) cin>>h[i];

    ll left=0, right=1e9, mid;
    while(left + 1 < right){
        mid=(left+right)/2;

        if(calc(mid, h)) right=mid;
        else left=mid;
    }
    cout << right << endl;
}

Measured memory_bytes: 1792
X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input().split()))
P.sort(reverse=True)

for i in range(105):
    if X - i not in P:
        print(X - i)
        break
    if X + i not in P:
        print(X + i)
        break

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S,T;
    cin >> S >> T;
    bool ok = 0;
    REP(i,S.size()){
        if(S == T)ok = 1;
        S = S.substr(1) + S[0];
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
<?php 
  $n = trim(fgets(STDIN));
  $a = explode(' ', trim(fgets(STDIN)));
  $cnt = 0;
  for ($i=0; $i < $n; $i++) {
    // code...
    $num = $i+1;
    if($num % 2 != 0){
      if($a[$i] % 2 != 0){
      	$cnt += 1;
      }
    }
  }
  echo $cnt;


Measured memory_bytes: 16080
H, N = [int(i) for i in input().split()]

md = {}
max_d = 0
for _ in range(N):
    d, m = [int(i) for i in input().split()]
    if m not in md:
        md[m] = 0
    md[m] = max(md[m], d)
    max_d = max(max_d, d)

dp = [float("inf")] * (H + max_d + 1)
dp[0] = 0

for i in range(1, H + max_d + 1):
    for m, d in md.items():
        if 0 <= i - d <= H + max_d:
            dp[i] = min(dp[i], dp[i-d] + m)
ans = min(dp[H:])
print(ans)

Measured memory_bytes: 43100
import java.util.*;
public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void run() {
		Scanner sc = new Scanner(System.in);
		
		char digit[] = {'0', '1', '2', '3', '5', '7', '8', '9'};
		for(;;) {
			int N = sc.nextInt();
			if( N == 0 ) break;
			
			StringBuilder sb = new StringBuilder();
			while( N > 0 ) {
				sb.append( digit[ N % 8] );
				N /= 8;
			}
			sb.reverse();
			System.out.println( sb.toString());
		}
	}
}

Measured memory_bytes: 12000
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 h,n,i;
		cin>>h>>n;
		for(i=0;i<n;i++)
		{
			int64 tem;
			cin>>tem;
			h-=tem;
		}
		if(h<=0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;

	}	

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Main main = new Main();
        main.main();
    }
    int[] factorial;
    boolean[] flag;
    int n;
    void main(){
        Scanner sc = new Scanner(System.in);
        n= sc.nextInt();
        int[] p = new int[n+1];
        int[] q = new int[n+1];
        for(int i = 1; i<=n ; i++){
            p[i] = sc.nextInt();
        }
        for(int i = 1; i<=n ; i++){
            q[i] = sc.nextInt();
        }
        factorial = new int[n+1];
        factorial[0] = 1;
        for(int i = 1; i<=n ; i++){
            factorial[i] = i* factorial[i-1];
        }
        flag= new boolean[n+1];
        int rankP = rank(p);
        int rankQ = rank(q);
        System.out.println(Math.abs(rankP - rankQ));
    }

    int rank(int[] array){
        for( int i=1; i <=n; i++){
            flag[i]= false;
        }
        int rank=0;
        for(int j=1; j<=n; j++) {
            int counter=0;
            for (int i = 1; i < array[j]; i++) {
                if (flag[i] == false) {
                    counter++;
                }
            }
            rank += factorial[n-j]*counter;
            flag[array[j]]= true;
        }
        return rank;
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {

  int N;
  std::cin >> N;

  std::vector<int> t(N), x(N), y(N);
  for(int i=0; i<N; i++){
    std::cin >> t[i] >> x[i] >> y[i];
  }

  bool flag = false;
  int bef_t = 0;
  int bef_x = 0;
  int bef_y = 0;
  for(int i=0; i<N; i++){
    int tdiff = t[i] - bef_t;
    int dis = std::abs(x[i] - bef_x) + std::abs(y[i]-bef_y);
    if ( dis > tdiff ) flag = true; 
    else if ( (tdiff - dis) % 2 != 0 ) flag = true;

    bef_t = t[i];
    bef_x = x[i];
    bef_y = y[i];
  }
  if ( flag ) std::cout << "No" << std::endl;
  else std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int a[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,k,ans=1<<30;
    cin>>n>>k;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=1;i+k-1<=n;i++)
	ans=min(ans,min(abs(a[i]),abs(a[i+k-1]))+a[i+k-1]-a[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<KeyValuePair<int, int>> dic = new List<KeyValuePair<int, int>>();
            int a = int.Parse(Console.ReadLine());
            for (int i=0; i < a; i++){
                string[] b = (Console.ReadLine().Split(' '));
                dic.Add(new KeyValuePair<int, int> (int.Parse(b[1]), int.Parse(b[0])));
            }
            int sum = 0;
            dic.Sort(new Comparison<KeyValuePair<int, int>>(comp));
            foreach(KeyValuePair<int,int>buf in dic)
            {
                sum += buf.Value;
                if(sum > buf.Key)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            
            Console.Write("Yes");
        }
        static int comp (KeyValuePair<int,int> a, KeyValuePair<int, int> b)
        {
            return a.Key - b.Key;
        }
    }
}

Measured memory_bytes: 21160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085B_KagamiMochi
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            HashSet<int> hs = new HashSet<int>();
            for(int i = 0; i < n; i++)
            {
                int input = int.Parse(Console.ReadLine());
                hs.Add(input);
            }
            Console.WriteLine(hs.Count);
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <cstdlib>
using namespace std;
#define MAX_N 100
#define MAX_T 40000

int t[MAX_N];
double v[MAX_N], f[MAX_T];

double min(double a, double b)
{
    return a < b? a: b;
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &t[i]);
    for (int i = 0; i < n; i++)
        scanf("%lf", &v[i]);
    for (int i = 0; i < MAX_T; i++)
        f[i] = 1.E8;
    int tot = 0;
    for (int i = 0; i < n; i++) {
        t[i] *= 2;
        for (int j = tot; j <= tot + t[i]; j++)
            f[j] = min(f[j], v[i]);
        tot += t[i];
    }
    f[0] = f[tot] = 0.;
    for (int i = 1; i <= tot; i++)
        f[i] = min(f[i], f[i - 1] + .5);
    for (int i = tot - 1; i >= 0; i--)
        f[i] = min(f[i], f[i + 1] + .5);
    double ans = 0.;
    for (int i = 0; i < tot; i++)
        ans += .25 * (f[i] + f[i + 1]);
    printf("%.15f\n", ans);
    system("pause");
    return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;

    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll now = a, res = 1;

    while (1) {
        if (now >= b) break;
        res++;
        now += a - 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

int h, w, n;
vector<vector<char>> maze(1005, vector<char>(1005));
vector<vector<int>> dist(1005, vector<int>(1005));

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


int bfs(int sy, int sx, int gy, int gx) {
    rep(i, h) {
        rep(j, w) {
            dist[i][j] = -1;
        }
    }

    dist[sy][sx] = 0;
    queue<P> q;
    q.push(make_pair(sy, sx));

    while (!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();
        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if (dist[ny][nx] != -1) continue;
            if (ny == gy && nx == gx) {
                dist[ny][nx] = dist[y][x] + 1;
                break;
            }
            if (maze[ny][nx] != 'X') {
                q.push(make_pair(ny, nx));
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }
    return dist[gy][gx];
}

void solve() {
    cin >> h >> w >> n;

    vector<P> S(n+1);
    rep(i, h) {
        rep(j, w) {
            cin >> maze[i][j];
            if (maze[i][j] == 'S') {
                S[0] = make_pair(i, j);
            } if(isdigit(maze[i][j])) {
                int num = maze[i][j] - '0';
                S[num] = make_pair(i, j);
            }
        }
    }


    int ans = 0;
    rep(i, n) {
        ans += bfs(S[i].first, S[i].second, S[i+1].first, S[i+1].second);
    }
    cout << ans << endl;
 
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7728
#include<bits/stdc++.h>
#define maxn 505

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
int ans,a[maxn],b[maxn],c[maxn],d[maxn],n,f[maxn][maxn],to[maxn];
bool vis[maxn];

bool dfs(int x)
{
    for (int i=0;i<n;i++)
        if (f[x][i]&&!vis[i]){
            vis[i]=true;
            if (to[i]==-1||dfs(to[i])) {to[i]=x;return true;}
        }
    return false;
}

int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d%d",&a[i],&b[i]);
    for (int i=0;i<n;i++) scanf("%d%d",&c[i],&d[i]);
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            if (a[i]<c[j]&&b[i]<d[j]) f[i][j]=true;
    memset(to,-1,sizeof(to));
    for (int i=0;i<n;i++)
    {
        memset(vis,0,sizeof(vis));
        if (dfs(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll a;
  scanf("%lld", &a);
  cout << (a * 3.1415 * 2.0) << endl;
}


Measured memory_bytes: 3848
#include <stdio.h>

int main(void){
	int a, b, k, i, count;
	scanf("%d %d %d", &a, &b, &k);

	count=0;
	for(i=a; i<=b; i++){
		if((count<k)||(b-a-count<k)){
			printf("%d\n", i);
		}
		count++;
	}

	return 0;
}


Measured memory_bytes: 128
A, B = map(int, input().split())
k = 50
d = [["." if i < k else "#" for j in range(2 * k)] for i in range(2 * k)]
A -= 1
B -= 1
for i in range(0, 50, 2):
    for j in range(0, 100, 2):
        if B > 0:
            d[i][j] = "#"
            B -= 1

for i in range(51, 100, 2):
    for j in range(0, 100, 2):
        if A > 0:
            d[i][j] = "."
            A -= 1

print(2 * k, 2 * k)
for s in d:
    print("".join(s))


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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int c=0;
  for(int i=0;i<N;i++){
    if(s.at(i) == 'R') c++;
  }
  if(c>N/2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
    int A,B,C,D,L,R;
    cin>> A >> B >> C >> D;
    L=A+B;
    R=C+D;
    if(L>R){
        cout << "Left" << endl;
    }
    else if(L<R){
        cout << "Right" << endl;
    }
    else {
       cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
int main()
{
	vii a;
	int n; cin>>n;
	for(int i =1; i<=n ;i++)
	{
		int k; cin>>k;
		a.push_back(make_pair(k,i));
	}
	sort(a.begin(), a.end());
	for(ii x : a)
		cout<<x.second<<" ";
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 2544
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int i1 = scanner.nextInt();
        int max = Integer.MIN_VALUE;
        int j = 0;
        for (int i = 0;i < i1;++i){
            int k = scanner.nextInt();
            if(k > max){
                max = k;
                j = k + scanner.nextInt();
                continue;
            }
            scanner.next();
        }
        System.out.println(j);
    }





}


Measured memory_bytes: 65820
#include <bits/stdc++.h>
 
using namespace std;
 
int toint(string &str, int &i){
    int j = 0;
    while('0' <= str[i+j] && str[i+j] <= '9'){
        j++;
    }
    int ret = stoi(str.substr(i,j));
    ret = (ret+1)/2;
    i+=j;
    return ret;
}
 
int calc(string &str, int &i, int end){
    vector<int> v;
    int ret = 0;
    for(;i < end;i++){
        if(str[i] == '['){
            int idx = i+1;
            i++;
            int d = 1;
            while(1){
                if(str[idx] == ']') d--;
                else if(str[idx] == '[')d++;
 
                if(d == 0) break;
                idx++;
            }
            v.push_back(calc(str, i, idx));
            i = idx;
        }
        else if(str[i] == ']'){
            continue;
        }
        else{
            //cout << str[i] << endl;
            v.push_back(toint(str,i));
        }
    }
    sort(v.begin(), v.end());
    for(int j = 0; j < (v.size()+1)/2; j++){
        ret += v[j];
    }
    //for(int j = 0; j < v.size(); j++){
    return ret;
}
 
 
int main(){
    int nn; cin >> nn;
    for(int z = 0; z < nn; z++){
        string str;cin >> str;
        int i = 1;
        cout << calc(str, i, str.size()) << endl;
    }
 
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	multiset<ldbl> s;

	cin >> N;
	ldbl v;
	for (int i = 0; i < N; ++i) {
		cin >> v;
		s.insert(ldbl(v));
	}

	while (s.size() > 1) {
		ldbl fst = *s.begin();
		s.erase(s.begin());
		ldbl scd = *s.begin();
		s.erase(s.begin());

		s.insert((fst + scd) / 2.0);
	}

	cout << fixed << setprecision(20) << *s.begin() << endl;

	return 0;
}

Measured memory_bytes: 256
//ABC118C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include<stdio.h>
using namespace std;

int main(){
	int s;
	cin >> s;
	vector<int> a(1000001);
	a.at(0) = s;
	for(int i=0;i<1000000;i++){
		if(a.at(i) == 4 || a.at(i) == 2 || a.at(i) == 1){
			cout << i+4 << endl;
			return 0;
		}else{
			if(a.at(i)%2 == 0){
				a.at(i+1) = a.at(i)/2;
			}else{
				a.at(i+1) = 3*a.at(i)+1;
			}
		}
	}
}

Measured memory_bytes: 4096
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n; scan(n);
  vll c(n-1), s(n, 0), f(n, 1);
  rep (i, n-1) {
    scan(c[i], s[i], f[i]);
  }
  vll ans(n, 0);
  rep (i, n-1) {
    ll t = 0;
    FOR (j, i, n-1) {
      ll wait = max(s[j] - t, (f[j] - t % f[j]) % f[j]);
      t += wait + c[j];
    }
    ans[i] = t;
  }
  rep (i, n) {
    print(ans[i]);
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < n; i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }
ll cntd(ll n){
    ll an=0;
    while(n){
        an+=(n%10);
        n/=10;
    }
    return an;
}
mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<m.size();i++)prv(m[i]);
}

ll n, k, m, l, r, x, y, ans=0;
ll t, t1, t2;

ll i, j;
ll a, b;
ll mod = 1000000007;

ll cntblk(vector<string> ar,ll row, ll col){
    bitset<32> b1(row), b2(col);
    string r=b1.to_string();
    string c=b2.to_string();
    reverse(r.begin(),r.end());
    reverse(c.begin(),c.end());
    ll ck=0;
    F(i,m){
        F(j,n){
            if((r[i]!='1') && (c[j]!='1') && (ar[i][j]=='#'))ck++;
        }
    }
    return ck;

}

void solve()
{
    cin>>m>>n>>k;
    ans=0;
    vector<string>ar(m);
    F(i,m)cin>>ar[i];



    for(a=0;a<=(pow(2,m)-1);a++){
        for(b=0;b<=(pow(2,n)-1);b++){
            ll rjb=cntblk(ar,a,b);
            if(rjb==k)ans++;
        }
    }
    prn(ans);
}

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


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll dp[3030][3030];
string dp2[3030][3030];

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

    rep(i, s.size()) {
        rep(j, t.size()) {
            if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    int n = s.size(), m = t.size();
    string ans = "";
    while (n > 0 and m > 0) {
        if (dp[n][m] == dp[n-1][m]) {
            n--;
        }
        else if (dp[n][m] == dp[n][m-1]) {
            m--;
        }
        else {
            n--;
            m--;
            ans += s[n];
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

int main(){
    int a,b,t;
    cin>>a>>b>>t;
    
    int cookies = 0;
    REP(i,t){
        if((i+1)%a == 0) cookies+=b;
    }

    cout<<cookies<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

string ans[200000];
char s[20];
signed main(){
	int n,m;cin>>n>>m;
	map<int,vector<P>>mp;
	rep(i,m){
		int p,y;scanf("%d%d",&p,&y);
		mp[p].push_back(P(y,i));
	}
	for(auto&p:mp){
		auto&v=p.second;
		sort(v.begin(),v.end(),[](auto&a,auto&b){return a.first<b.first;});
		sprintf(s,"%06d",p.first);
		string S;S+=s;
		rep(i,v.size()){
			sprintf(s,"%06d",i+1);
			ans[v[i].second]=S+s;
		}
	}
	rep(i,m){
		printf("%s\n",ans[i].data());
	}
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
string moji(long n){
  if(n==1)return "b";
  if(n==2)return "c";
  if(n==3)return "d";
  if(n==4)return "e";
  if(n==5)return "f";
  if(n==6)return "g";
  if(n==7)return "h";
  if(n==8)return "i";
  if(n==9)return "j";
  if(n==10)return "k";
  if(n==11)return "l";
  if(n==12)return "m";
  if(n==13)return "n";
  if(n==14)return "o";
  if(n==15)return "p";
  if(n==16)return "q";
  if(n==17)return "r";
  if(n==18)return "s";
  if(n==19)return "t";
  if(n==20)return "u";
  if(n==21)return "v";
  if(n==22)return "w";
  if(n==23)return "x";
  if(n==24)return "y";
  if(n==25)return "z";
  if(n==0)return "a";
  else return "";
}
  
int main(){
  long n;
  cin>>n;
  long m=n-1;
  
  vector<long>ex(20,-1);
  for(int i=0;i<20;i++){
    if(m>=26){
      long a=m%26;
      ex[i]=a;
      m-=a;
      m=m/26;
      m--;
    }else{
      ex[i]=m;
      break;
    }
  }
  reverse(ex.begin(),ex.end());
  string ans;
  for(int i=0;i<20;i++){
    ans+=moji(ex[i]);
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); 
		String s = bf.readLine();
		long suma = 0L;
		int bs = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'B')
				bs++;
			else
				suma += bs;
		}
		System.out.println(suma);
	}
}


Measured memory_bytes: 27184
import java.util.*;
import java.io.*;

public class Main 
{
	static int a;static int b;static int c;static int n;
	static int[]bamboos;
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s = new Scanner(System.in);
		 n=s.nextInt();
		 a=s.nextInt();
		 b=s.nextInt();
		 c=s.nextInt();
		 bamboos=new int[n];
		for(int i=0;i<n;i++)
			bamboos[i]=s.nextInt();
		System.out.println(syntheticBamboos(0,0,0,0));
	}
	private static long syntheticBamboos(int x, int y, int z, int i) {
		if(i==n) {
			if(x<=0 ||y<=0 ||z<=0)return Integer.MAX_VALUE;
			return Math.abs(x-a)+Math.abs(y-b)+Math.abs(z-c);
		}
		
		long op1=syntheticBamboos(x, y, z, i+1);
		long op2=syntheticBamboos(x+bamboos[i], y, z, i+1)+((x>0)?10:0);
		long op3=syntheticBamboos(x, y+bamboos[i], z, i+1)+ ((y>0)?10:0);
		long op4=syntheticBamboos(x, y, z+bamboos[i], i+1)+ ((z>0)?10:0);
		
		return Math.min(op1, Math.min(op2,Math.min(op3, op4)));
	}
	
}


Measured memory_bytes: 37764
use io::*;

fn main() {

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let mut s: Vec<i64> = sc.next_vec(n);

    s.sort_by(|x, y| y.cmp(x));

    let mut count = 1;
    for i in 1..n {
        if s[i as usize] < s[(i - 1) as usize] {
            count += 1;
        }
    }
    println!("{}", count);
}

pub mod io {

    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int q;
  cin>>s>>q;
  int a,b;
  char c;
  string up,down; 
  
  int count=0,rev=0;
  while(count<q){
    count++;
  	cin>>a;
    if(a==1){
      rev++;
      continue;
    }
    else{
    	cin>>b>>c;
      if((b==1&&rev%2==0)||b==2&&rev%2==1){
      	up=c+up;
      }
      else{
      	down+=c;
      }
    }
  }
  s=up+s+down;
  if(rev%2==1) reverse(s.begin(),s.end());
  cout<<s<<endl;
  
}

Measured memory_bytes: 1360
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,ans=0,l[2000][2000]={},r[2000][2000]={},u[2000][2000]={},d[2000][2000]={};
  char c[2000][2000]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> c[i][j];
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      if(c[i][j]=='.') {
        if(j==0) {
          l[i][j]=1;
        }
        else {
          l[i][j]=l[i][j-1]+1;
        }
      }
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=m-1; j>=0; j--) {
      if(c[i][j]=='.') {
        if(j==m-1) {
          r[i][j]=1;
        }
        else {
          r[i][j]=r[i][j+1]+1;
        }
      }
    }
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<n; j++) {
      if(c[j][i]=='.') {
        if(j==0) {
          u[j][i]=1;
        }
        else {
          u[j][i]=u[j-1][i]+1;
        }
      }
    }
  }
  for(int i=0; i<m; i++) {
    for(int j=n-1; j>=0; j--) {
      if(c[j][i]=='.') {
        if(j==n-1) {
          d[j][i]=1;
        }
        else {
          d[j][i]=d[j+1][i]+1;
        }
      }
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      if(c[i][j]=='.') {
        ans=max(ans,r[i][j]+l[i][j]+u[i][j]+d[i][j]-3);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 66688
def solve():
    
    N = int(input())

    all = 10 ** N
    n9 = 9 ** N
    n0 = 9 ** N
    n0_9 = 8 ** N

    tmp_ans = all -(n9 + n0 - n0_9)

    ans = tmp_ans % ((10**9) + 7)

    print(ans)

if __name__ == "__main__":
    solve()



Measured memory_bytes: 11576
#include<stdio.h>
#include<string.h>
int main()
{
    char str[7];
    gets(str);
    if((str[2]==str[3]) && str[4]==str[5])
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");

    }
    return 0;

}


Measured memory_bytes: 128