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

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

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int a = cin.ReadInt;
            int b = cin.ReadInt;

            int ans = Min(a * n, b);

            Console.WriteLine(ans);
        }
    }

    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 N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int x = s.nextInt(), n = s.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < n; i++) {
			set.add(s.nextInt());
		}
		int ans = -1, diff = 0;
		while(true) {
			if(!set.contains(x - diff)) {
				ans = x - diff;
				break;
			}
			if(!set.contains(x + diff)) {
				ans = x + diff;
				break;
			}
			diff++;
			//System.out.println(diff);
		}
		out.print(ans);
		out.flush();
		out.close();
	}

}


Measured memory_bytes: 35980
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    int N;
    cin >> N;
    vector<int> A(N), B(N-1);
    rep(i, N-1) cin >> B[i];

    A[0] = B[0];
    rep(i, N-1) {
        if (A[i] <= B[i]) {
            A[i+1] = B[i];
        }
        if (A[i] > B[i]) {
            A[i] = B[i];
            A[i+1] = B[i]; 
        }
    }

    int sum = 0;
    rep(i, N) sum += A[i];
    cout << sum << endl;; 
}

Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=1;r<=3500;r++)for(var n=1;n<=3500;n++){var i=e*r*n/(4*r*n-e*(r+n));if(i%1==0&&0<i&&i<=3500)return void console.log(`${r} ${n} ${i}`)}}}]);

Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Node;
vector<vector<Node>> V;
struct Node {
  lint cost = 1e15;
  vector<int> nbr_idx1;
  vector<int> nbr_idx2;
  vector<lint> nbr_cost;
  bool operator>(const Node& rhs) const{
      return cost > rhs.cost;
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, M, S;
  cin >> N >> M >> S;
  V = vector<vector<Node>>(N, vector<Node>(2500));
  REP(i, M) {
    int u, v, A, B;
    cin >> u >> v >> A >> B;
    u--; v--;
    FOR(k, A, 2500) {
      V[u][k].nbr_idx1.push_back(v);
      V[u][k].nbr_idx2.push_back(k-A);
      V[u][k].nbr_cost.push_back(B);
      V[v][k].nbr_idx1.push_back(u);
      V[v][k].nbr_idx2.push_back(k-A);
      V[v][k].nbr_cost.push_back(B);
    }
  }
  REP(i, N) {
    int C, D;
    cin >> C >> D;
    REP(k, 2499) {
      V[i][k].nbr_idx1.push_back(i);
      V[i][k].nbr_idx2.push_back(min(k+C, 2499));
      V[i][k].nbr_cost.push_back(D);
    }
  }
  priority_queue<Node, vector<Node>, greater<Node>> pq;
  V[0][min(S, 2499LL)].cost = 0;
  pq.push(V[0][min(S, 2499LL)]);
  while(!pq.empty()) {
    Node e = pq.top();
    pq.pop();
    REP(i, e.nbr_cost.size()) {
      if(e.cost + e.nbr_cost[i] < V[e.nbr_idx1[i]][e.nbr_idx2[i]].cost) {
        V[e.nbr_idx1[i]][e.nbr_idx2[i]].cost = e.cost + e.nbr_cost[i];
        pq.push(V[e.nbr_idx1[i]][e.nbr_idx2[i]]);
      }
    }
  }
  FOR(i, 1, N) {
    lint ans = 1e15;
    REP(j, 2500) {
      if(V[i][j].cost < ans) ans = V[i][j].cost;
    }
    cout << ans << "\n";
  }
}

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

int n, a[21];

bool solve(int sum, int count){
    if(sum == 0){
        return true;
    }
    if(sum < 0 || count > n){
        return false;
    }
    bool res = solve(sum-a[count], count + 1) || solve(sum, count + 1);
    return res;
}

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

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

    for(int i = 0; i < q; i++){
        if(solve(m[i], 0)){
            cout << "yes" << endl;
        }
        else{
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main(){

    int dataSetNum;
    std::cin >> dataSetNum;

    std::vector< std::string > str;
    str.resize(dataSetNum);
    std::cin.ignore();

    //input 
    for(int i = 0; i < dataSetNum; ++i){
        //input
        std::string tmp;
        getline(std::cin, tmp);
        str[i] = tmp;
    }

    //replace
    for(int i = 0; i < dataSetNum; ++i){
    	const std::string tmp("Hoshino");
        auto pos = str[i].find(tmp);
        while(pos != std::string::npos){
        	str[i].replace( pos, 7, "Hoshina" );
        	pos = str[i].find(tmp, pos + 7);
        }
    }
    
    //output
    	std::for_each(str.begin() , str.end(),
    [](std::string x) { std::cout << x << std::endl; } );

    return 0;
}

Measured memory_bytes: 1224
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<std::vector<int>> inp,dp;
int main(){
	int n;cin>>n;
	inp.resize(n,std::vector<int>(3));
	dp.resize(n,std::vector<int>(3,0));
	REP(i,0,n-1)
	{
		cin>>inp[i][0]>>inp[i][1]>>inp[i][2];
	}
	dp[0][0]=inp[0][0];dp[0][1]=inp[0][1];dp[0][2]=inp[0][2];
	REP(i,1,n-1)
	{
		REP(j,0,2)
		{
			REP(k,0,2)
			{
				if(k==j){continue;}
				dp[i][j]=MAX(dp[i][j],(dp[i-1][k]+inp[i][j]));
			}
		}
	}
	cout<<MAX(dp[n-1][0],MAX(dp[n-1][1],dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 11136
x,y = map(int,input().split())
if x > y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x))+2)
    if x >= 0 and y < 0:
        print(abs(abs(y)-abs(x))+1)
    if x >= 0 and y >= 0:
        if y == 0:
            print(abs(abs(y)-abs(x))+1)
        else:
            print(abs(abs(y)-abs(x))+2)
elif x < y:
    if x < 0 and y < 0:
        print(abs(abs(y)-abs(x)))
    if x < 0 and y >= 0:
        if y == 0:
            print(abs(abs(y)-abs(x)))
        else:
            print(abs(abs(y)-abs(x))+1)
    if x >= 0 and y >= 0:
        print(abs(abs(y)-abs(x)))

Measured memory_bytes: 9232
def ceasar(sentence, n):
    sentence = list(sentence)
    for i in range(len(sentence)):
        if sentence[i] in alphabets:
            sentence[i] = alphabets[(alphabets.index(sentence[i]) + n) % 26]
    return ''.join(sentence)
def is_right(sentence):
    words = '.'.join(sentence.split(' ')).split('.')
    return 'the' in words or 'this' in words or 'that' in words
alphabets = 'abcdefghijklmnopqrstuvwxyz'
while True:
    try:
        line = input()
        if line == '*':
            break
    except:
        break
    for i in range(26):
        if is_right(ceasar(line, i)):
            print(ceasar(line, i))
            break

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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair

struct path
{
    ll n1;
    ll n2;
};

//mapのキーに利用するのに必要
bool operator <(const path& p1, const path& p2)
{
    return p1.n1 == p2.n1 ? p1.n2 < p2.n2 : p1.n1 < p2.n1;
}

struct room
{
    vector<path> neibs;
    ll sirube;
    ll step;
};

int main()
{
    ll N, M;
    cin >> N >> M;

    vector<room> rms(N);
    map<path, bool> pathchecked;
    for (ll i = 0; i < M; i++)
    {
        path tmp;
        cin >> tmp.n1 >> tmp.n2;
        if(tmp.n1 > tmp.n2)
        {
            swap(tmp.n1, tmp.n2);
        }

        rms[tmp.n1 - 1].neibs.ADD(tmp);
        rms[tmp.n2 - 1].neibs.ADD(tmp);

        pathchecked.insert(MP(tmp, false));
    }
    
    for (ll i = 0; i < N; i++)
    {
        if(rms[i].neibs.size() == 0)
        {
            OUTX("No");
            return 0;
        }
        rms[i].step = 100001;
    }
    OUTX("Yes");

    queue<ll> q;
    q.push(1);
    rms[0].step = 0;
    while(q.size() > 0)
    {
        ll current = q.front();
        room &cr = rms[current - 1];
        for(ll i = 0; i < cr.neibs.size(); i++)
        {
            path &p = cr.neibs[i];
            if(pathchecked[p])
            {
                continue;
            }

            ll n = (current == p.n1 ? p.n2 : p.n1);
            room &nr = rms[n - 1];
            if(nr.step > cr.step + 1)
            {
                nr.step = cr.step + 1;
                nr.sirube = current;
                q.push(n);
            }

            pathchecked[p] = true;
        }

        q.pop();
    }
    
    for(ll i = 1; i < N; i++)
    {
        OUTX(rms[i].sirube);
    }


    return 0;
}


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

int main() {
  int i, N;
  long long sum=1;
  
  cin >> N;
  
  for(i=1; i<=N; i++) {
    sum *= i;
    sum %= (long long)(pow(10,9)+7);
    //cout << sum << endl;
  }
  
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3612
# cf16-finalA - Where's Snuke?
from string import ascii_uppercase


def main():
    H, W, *S = open(0).read().split()
    H, W, abc = int(H), int(W), ascii_uppercase
    for i, s in enumerate(S):
        if s == "snuke":
            print(abc[i % W], i // W + 1, sep="")
            return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3764
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    t, x = nm()
    print(t / x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
def permutation(lst): 
  
    # If lst is empty then there are no permutations 
    if len(lst) == 0: 
        return [] 
  
    # If there is only one element in lst then, only 
    # one permuatation is possible 
    if len(lst) == 1: 
        return [lst] 
  
    # Find the permutations for lst if there are 
    # more than 1 characters 
  
    l = [] # empty list that will store current permutation 
  
    # Iterate the input(lst) and calculate the permutation 
    for i in range(len(lst)): 
       m = lst[i] 
  
       # Extract lst[i] or m from the list.  remLst is 
       # remaining list 
       remLst = lst[:i] + lst[i+1:] 
  
       # Generating all permutations where m is first 
       # element 
       for p in permutation(remLst): 
           l.append([m] + p) 
    return l 

N = input()
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]

NN = list(range(1,int(N)+1))
P = permutation(NN)

xx = P.index(x)
yy = P.index(y)
print(abs(xx-yy))

Measured memory_bytes: 9716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func NewScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func NewWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func ScanString(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan string failed")
	}
	return s.Text()
}

func ScanInt(s *bufio.Scanner) int {
	return int(ScanInt64(s))
}

func ScanInts(s *bufio.Scanner, n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = ScanInt(s)
	}
	return ints
}

func Scan2DInts(s *bufio.Scanner, x, y int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = ScanInts(s, x)
	}
	return ints
}

func ScanInt64(s *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(ScanString(s), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	s := NewScanner()
	w := NewWriter()
	defer w.Flush()

	n := ScanInt(s)
	times := ScanInts(s, n)
	m := ScanInt(s)
	drinks := Scan2DInts(s, 2, m)
	
	for _, d := range drinks {
		var total int
		for i, t := range times {
			if i+1 == d[0] {
				total += d[1]
				continue
			}
			total += t
		}
		fmt.Fprintln(w, total)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(){
  COMinit();
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  ll ans=1;
  ans*=COM(h-a-1+b,b);
  ans%=mod;
  ans*=COM(w+a-2-b,a-1);
  ans%=mod;
  for(int i=b+2;i<=w;i++){
    ll temp=1;
    temp*=COM(i-1+h-a-1,i-1);
    temp%=mod;
    temp*=COM(w-i+a-1,a-1);
    temp%=mod;
    ans+=temp;
    ans%=mod;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 12160
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] a = new char[n][n];
		char[][] b = new char[m][m];
		for(int i = 0; i < n; i++) {
			a[i] = sc.next().toCharArray();
		}
		for(int i = 0; i < m; i++) {
			b[i] = sc.next().toCharArray();
		}
		sc.close();
		int count = 0;
		for(int i = 0; i <= n-m; i++) {
			for(int j = 0; j <= n-m; j++) {
				if(a[i][j] == b[0][0]) {
					for(int k = 0; k < m; k++) {
						for(int p = 0; p < m; p++) {
							if(a[i+k][j+p] == b[k][p]) {
								count++;
							}
						}
					}
					if(m*m == count) {
						System.out.println("Yes");
						return;
					}
					count = 0;
				}
			}
		}
		System.out.println("No");
		}
}

Measured memory_bytes: 21844
k = int(input())
if k >= 400 and k <= 599:
  print(8)
elif 600 <= k <= 799:
  print(7)
elif 800 <= k <= 999:
  print(6)
elif 1000 <= k <= 1199:
  print(5)
elif 1200 <= k <= 1399:
  print(4)
elif 1400 <= k <= 1599:
  print(3)
elif 1600 <= k <= 1799:
  print(2)
elif 1800 <= k <= 1999:
  print(1)

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define dep(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b; cin>>a>>b;
  int x=in();
  x-=a;
  if(0<=x&&x<=b) print("YES");
  else print("NO");


  return 0;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
X = list(map(int, sys.stdin.readline().split()))

X = np.array(X)
X.sort()
diffs = np.diff(X)
diffs.sort()
print(diffs[:max(0, M - N)].sum())


Measured memory_bytes: 23236
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    for(int i = 1; i <= b; i++){
        if(i % 100 == 0) b++;
    }
    cout << (int)pow(100,a) * b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e12;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define mk make_pair
#define pb push_back
#define P pair<int,int>
#define fi first
#define se second
#define F(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
struct E{int v,nxt;};
int n,a[2000005],l,s[2000005][2],tmp[4];
bool comp(int x,int y){return a[x]>a[y];}
int main(){
	n=read();l=1<<n;
	for(int i=0;i<l;++i)a[i]=read();
	a[l]=-0x3f3f3f3f;
	for(int i=0;i<l;++i){
		memset(tmp,0,sizeof tmp);
		s[i][0]=i,s[i][1]=l;
		for(int j=0;j<n;++j)
			if(i&(1<<j)){
				int f=i^(1<<j);
				tmp[0]=s[i][0];tmp[1]=s[i][1];tmp[2]=s[f][0];tmp[3]=s[f][1];
				sort(tmp,tmp+4,comp);
				s[i][0]=tmp[0];
				if(tmp[0]!=tmp[1])s[i][1]=tmp[1];
				else s[i][1]=tmp[2];
			}
	}
	int ans=0;
	for(int i=1;i<l;++i){
		ans=max(a[s[i][0]]+a[s[i][1]],ans);
		printf("%d\n",ans);
	}
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int debt = 100000;
		
		int n = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n; i++) {
			debt *= 1.05;
			if ((debt - ((debt/1000) * 1000))!=0) {
				debt = (debt/1000) * 1000 + 1000;
			} else {
				debt = (debt/1000) * 1000;
			}
		}
		
		System.out.println(debt);
	}

}

Measured memory_bytes: 24340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

ll gcd(ll a,ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b-a+1;
  ans -= b/c - a/c;
  if (a % c == 0) ans--;
  ans -= b/d - a/d;
  if (a % d == 0) ans--;
  ll lcmcd = c * d / gcd(c, d);
  ans += b/lcmcd - a/lcmcd;
  if (a % lcmcd == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cassert>
#include<vector>

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

using namespace std;

const double EPS=1e-6;
const double INF=1e77;
const double PI=acos(-1);

template<class T>
struct point{
	T x,y;
	point operator+(const point &a)const{ return (point){x+a.x,y+a.y}; }
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
point<T> operator*(T c,const point<T> &a){ return (point<T>){c*a.x,c*a.y}; }

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

template<class T>
double abs(const point<T> &a){ return sqrt(a.x*a.x+a.y*a.y); }

point<double> rot(const point<double> &a,double theta){
	return (point<double>){a.x*cos(theta)-a.y*sin(theta),a.x*sin(theta)+a.y*cos(theta)};
}

template<class T>
double arg(const point<T> &a){
	double t=atan2(a.y,a.x);
	return t<0?t+2*PI:t;
}

template<class T>
struct polygon:vector< point<T> >{
	polygon(){}
	polygon(int n):vector< point<T> >(n){}
};

template<class T>
struct circle{
	point<T> c;
	T r;
};

enum {CCW=1,CW=-1,ON=0};
int ccw(const point<double> &a,const point<double> &b,const point<double> &c){
	double rdir=cross(b-a,c-a);
	if(rdir> EPS) return CCW;
	if(rdir<-EPS) return CW;
	return ON;
}

int get_intersect(const circle<double> &C1,const circle<double> &C2,vector< point<double> > &res){
	double r1=C1.r,r2=C2.r;
	point<double> p1=C1.c,p2=C2.c;

	double d=abs(p1-p2);
	if(d<EPS && abs(r1-r2)<EPS){ // C1==C2
		return -1;
	}
	else if(r1+r2<d-EPS || d+EPS<abs(r1-r2)){
		return 0;
	}
	else{
		double a=(r1*r1-r2*r2+d*d)/(2*d);
		double h=sqrt(max(r1*r1-a*a,0.0));
		point<double> tmp1=p1+a/d*(p2-p1);
		point<double> tmp2=h/d*(p2-p1);
		if(abs(tmp2)<EPS){
			res.push_back(tmp1);
			return 1;
		}
		else{
			res.push_back((point<double>){tmp1.x-tmp2.y,tmp1.y+tmp2.x});
			res.push_back((point<double>){tmp1.x+tmp2.y,tmp1.y-tmp2.x});
			return 2;
		}
	}
}

int main(){
	for(int n,r,q;scanf("%d%d%d",&n,&r,&q),n;){
		point<double> O={0,0};
		circle<double> C={O,r};

		polygon<double> F(n);
		rep(i,n) scanf("%lf%lf",&F[i].x,&F[i].y);

		int u=-1;
		for(u=0;abs(abs(F[u])-r)>EPS;u++);
		// assert(u!=-1);
		while(q--){
			int u_next=-1;
			double phi_next=INF;
			point<double> p_next;
			rep(v,n) if(u!=v) {
				vector< point<double> > Q;
				get_intersect(C,(circle<double>){F[u],abs(F[v]-F[u])},Q);

				point<double> p=(ccw(F[u],F[v],Q[0])==CCW?Q[0]:Q[1]);
				double phi=arg(p-F[u])-arg(F[v]-F[u]);
				if(phi<-EPS) phi+=2*PI;
				if(phi<phi_next-EPS || abs(phi-phi_next)<EPS && abs(p-F[u])>abs(p_next-F[u])){
					phi_next=phi;
					p_next=p;
					u_next=v;
				}
			}
			// assert(u_next!=-1);

			rep(v,n) F[v]=F[u]+rot(F[v]-F[u],phi_next);

			u=u_next;
			printf("%.9f %.9f\n",p_next.x,p_next.y);

			// assert(abs(abs(F[u])-r)<EPS);
			rep(v,n) assert(abs(F[v])<r+EPS);
		}
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    in(vec);
    ll ans=1000;
    ll kabu=0;
    vector<vector<int>> vec2(n);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            vec2[i].push_back(vec[j]-vec[i]);
        }
    }
    int day=0;
    for(int i=0;i<n;i++){
        if(i<day)continue;
        for(int j=0;j<vec2[i].size();j++){
            if(vec2[i][j]<0)break;
            if(vec2[i][j]>0){
                kabu=ans/vec[i];
                ans+=(ll)vec2[i][j]*kabu;
                day=i+j+1;
                //debug(ans);
                break;
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n, k;
	scanf("%lld%lld", &n, &k);
	ll Ans = 0;
	ll x = n / k;
	Ans += x * (x - 1) * (x - 2);
	Ans += x * (x - 1) * 3;
	Ans += x;
	if(k % 2 == 0)
	{
		ll x = (n + k / 2) / k;
		Ans += x * (x - 1) * (x - 2);
		Ans += x * (x - 1) * 3;
		Ans += x;
	}
	printf("%lld", Ans);
	return 0;
}

Measured memory_bytes: 256
s = list(input())
slen = len(s)
t = list(input())
tlen = len(t)
box = []


def check(wh, phase=0):
    if wh + phase >= slen:
        return False
    if s[wh + phase] == "?" or s[wh + phase] == t[phase]:
        if phase + 1 == tlen:
            return True
        return check(wh, phase + 1)
    return False


def ume(arr):
    tmp = [e for e in arr]
    for i, e in enumerate(arr):
        if e == "?":
            tmp[i] = "a"
    return tmp



for i, e in enumerate(s):
    if check(i):
        box.append(ume(s[:i] + t + s[i + tlen:]))

if not box:
    print("UNRESTORABLE")
else:
    box.sort
    print("".join(box[-1]))


Measured memory_bytes: 3064
n, m = gets.chomp.split(' ').map(&:to_i)

ary = []
(0...n).each do |i|
  ary[i] = gets.chomp.split(' ').map(&:to_i)
end

inv_ary = []
(0...n).each do |i|
  inv_ary[i] = ary[i].map {|n| n * -1 }
end

sum_ary = []
(0...8).each do |i|
  sum_ary[i] = []
end
  
(0...n).each do |i|
  sum_ary[0][i] = ary[i][0] + ary[i][1] + ary[i][2]
  sum_ary[1][i] = ary[i][0] + ary[i][1] - ary[i][2]
  sum_ary[2][i] = ary[i][0] - ary[i][1] + ary[i][2]
  sum_ary[3][i] = ary[i][0] - ary[i][1] - ary[i][2]
  sum_ary[4][i] = - ary[i][0] + ary[i][1] + ary[i][2]
  sum_ary[5][i] = - ary[i][0] + ary[i][1] - ary[i][2]
  sum_ary[6][i] = - ary[i][0] - ary[i][1] + ary[i][2]
  sum_ary[7][i] = - ary[i][0] - ary[i][1] - ary[i][2]
end

ans = []

sum_ary.each do |sub_ary|
  now_ans = 0
  sub_ary.sort!

  (0...m).each do |i|
    now_ans += sub_ary[n-i-1]
  end

  ans.push(now_ans)
end

p ans.max


Measured memory_bytes: 2168
def is_ok(mid, array, k):
    if mid == 0:
        return False

    n = len(array)
    for i in range(n):
        if k - array[i] // mid >= 0:
            k -= array[i] // mid if array[i] % mid != 0 else array[i] // mid - 1
        else:
            return False

    return True


def bin_search(ng, ok, array, k):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid, array, k):
            ok = mid
        else:
            ng = mid
    return ok


n, k = map(int, input().split())
a = list(map(int, input().split()))

max_len = max(a)

print(bin_search(0, max_len, a, k))


Measured memory_bytes: 104236
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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


	vector<int> vec(5);
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}

	int k;
	cin >> k;

	bool ans = true;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (abs(vec[i] - vec[j]) > k) {
				ans = false;
			}
		}
	}

	cout << (ans ? "Yay!" : ":(") << endl;
	return 0;
}


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

int main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    int count=0;
    for(int i=0;i<N-1;i++){
        if(S[i] == S[i+1])count++;
    }
    cout << min(count+2*K,N-1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1 = 1e5 + 5;
const int MX2 = 1e6 + 5;
const li inf = 4e18;
const li mod = 1e9 + 7;

li power(li a, li b) { li res = 1; while (b) { if (b % 2) res = (res * a) % mod;
a = (a * a) % mod; b /= 2; } return res; }

li mmi(li a) { return power(a, mod - 2); }

li cntbit(li n) { li cnt = 0; while (n) { n &= (n - 1); cnt++; } return cnt; }

void solve() {
	int n;
	cin >> n;
	li ans = 0;
	for (int i = 1; i <= n; i++) {
		li x;
		cin >> x;
		ans += x - 1;
	}
	cout << ans;
}

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

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		String S = sc.next();
	
		if(S.length() == 2){
			System.out.println(S);
		}
		else{
			String printS = String.valueOf(S.charAt(2)) + String.valueOf(S.charAt(1)) + String.valueOf(S.charAt(0));
			System.out.println(printS);
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string S; cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy" << endl;
		return;
	} else if (S == "Cloudy") {
		cout << "Rainy" << endl;
		return;
	}
	cout << "Sunny" << endl;
}

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
from functools import reduce
from operator import add
if __name__ == '__main__':
    n = int(input())
    a = [0]
    ans = 0
    for i in range(n):
        tmp = int(input())
        a.append(tmp)
        if tmp == 0:
            ans += math.floor(reduce(add, a) // 2)
            a.clear()
            a.append(0)
    ans += math.floor(reduce(add, a) // 2)
    print(ans)


Measured memory_bytes: 7716
n = int(input())

x_plus_y = []
x_minus_y = []

for i in range(n):
    x, y = [int(_) for _ in input().split()]
    x_plus_y.append(x+y)
    x_minus_y.append(x-y)

x_plus_y.sort()
x_minus_y.sort()

print(max(x_plus_y[-1] - x_plus_y[0], x_minus_y[-1] - x_minus_y[0]))

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

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

    int a,b;
    cin >> a >>b ;
    if(a == b){
        cout << a * 2 << endl;
        return 0;
    }
    int c = max(a,b);

    cout << c+c-1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double


 
void solve()  
{
	ll n; cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++) cin>>a[i];
	ll c=0, mx=0;
	for(ll i=0; i<n-1; i++)
	{
		if(a[i] >= a[i+1])
		{
			c++;
		}
		else 
		{
			mx=max(mx, c);
			c=0;
		}
	}
	mx=max(mx, c);
	cout<<mx<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, l;
    string si;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        cout << s[i];
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
     
    int main(){
      int a;
      int b;
      scanf("%d%d", &a, &b);
      if(a == b){
        printf("%d\n", a);
      }else if(a > b){
        printf("%d\n", a-1);
      }else if(a < b){
        printf("%d\n",a);
      }
     
    }

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from collections import deque

mod = 10 ** 9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

##### Settings
unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i: a * inv(SIZE[i]) % mod
adj_td = lambda a, i, p: a * inv(N-SIZE[i]) % mod
adj_fin = lambda a, i: a * fa[N-1] % mod
#####

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

inv = lambda i: fainv[i] * fa[i-1] % mod

SIZE = [1] * N
for i in R[1:][::-1]:
    SIZE[P[i]] += SIZE[i]

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_fin(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])
    ac = unit
    for j in X[i][::-1]:
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_fin(merge(ME[j], TD[j]), j)

print(*XX, sep = "\n")

Measured memory_bytes: 111420
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int a[3];
    rep(i, 3) cin >> a[i];
    if(a[0]+a[1]+a[2] >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if(a == b && b == c) cout << 1 << endl;
  else if (a == b || b == c || c == a) cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,K = map(int,input().split())
S = str(input())

count_RL, count_LR = S.count("RL"), S.count("LR")


if max(count_LR, count_RL) <= K:
    print(N-1)
elif max(count_LR, count_RL) > K:
    if count_RL == count_LR:
        happy = N-1-2*(count_LR-K)
    elif not count_RL == count_LR:
        happy = N-1-2*(min(count_LR, count_RL)-K)-1
    print(happy)


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

using namespace std;

const int maxn=2e5+5;

typedef long long ll;

//string s[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	ll k;
	cin>>k;
	int l=s.length();
	string tmp=s;
	ll ans1=0;
	for(int i=1;i<l;i++){
		if(tmp[i]==tmp[i-1]){
			tmp[i]='#';ans1++;
		}
	}
	tmp=s;
	tmp+=tmp;
	ll ans2=0;
	for(int i=1;i<2*l;i++){
		if(tmp[i]==tmp[i-1]){
			ans2++;tmp[i]='#';
		}
	}
	tmp=s;
	tmp+=tmp;tmp+=tmp;
	ll ans3=0;
	for(int i=1;i<3*l;i++){
		if(tmp[i]==tmp[i-1]){
			tmp[i]='#';ans3++;
		}
	} 
	if(k==1)printf("%lld\n",ans1);
	else if(k==2)printf("%lld\n",ans2);
	else if(k==3)printf("%lld\n",ans3);
	else{
		ll ans=0;
		if(ans3-ans2==ans1){
			ans+=1ll*k/2*ans2;
			if(k&1)ans+=ans1;
		}
		else if(ans3-ans2==ans2-ans1){
			ans=ans1+1ll*(k-1)*(ans2-ans1);
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int b[n];
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)//动态规划 
	{
		b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d",b[n-1]);
	return 0;
}

Measured memory_bytes: 4592
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush


# T = int(stdin.readline())
# for i in range(T):
    #N=int(stdin.readline())
N,K=list(map(int,stdin.readline().split()))
vis=set()
for k in range(K):
    dk=int(stdin.readline())
    ar=list(map(int,stdin.readline().split()))    
    for sn in ar:
        vis.add(sn)

print(N-len(vis))        

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int cnt=0;
  while(a>=b){
    cnt++;
    b*=2;
  }
  while(b>=c){
    cnt++;
    c*=2;
  }
  if(cnt<=k)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c=mii()

chk=False

for i in range(1,b+1):
    if a*i %b==c:
        chk=True
if chk==True:
    print("YES")
else:
    print("NO")








Measured memory_bytes: 63340
#include <stdio.h>
#include <string.h>

#define MAX 500000
#define MAAAAX 2000000000

int L[(MAX/2)+2];
int R[(MAX/2)+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;

  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=R[n2]=MAAAAX;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void Sort(int A[],int n,int left,int right){
  int mid;
  
  if(left+1<right){
    mid=(left+right)/2;
    Sort(A,n,left,mid);
    Sort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  Sort(A,n,0,n);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}
  
  
  



Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
const int mod=2019;
char s[maxm];
int a[maxm];
int n;
signed main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        a[i]=s[i]-'0';
    }
    map<int,int>mark;
    mark[0]=1;
    int sum=0;
    int base=1;
    int ans=0;
    for(int i=n;i>=1;i--){
        sum=(sum+a[i]*base%mod)%mod;
        ans+=mark[sum];
        mark[sum]++;
        base=base*10%mod;
    }
    cout<<ans<<endl;
    return 0;
}
/*
对于s[l,r],如果是2019的倍数,那么满足:
s[l]*10^(n-l)%2019+
*/


Measured memory_bytes: 5556
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

const long long MOD = 1000000007;

using namespace std;



int main(void) {

    long long i, j;
    long long n, k;
    long long sum = 0;
    long long temp;
    long long min, max;
    vector<long long> a;
    vector<long long> ans;

    cin >> n;
    cin >> k;

    if (n <= k) {
        cout << "unsafe" <<endl;
    }else {
        cout << "safe" << endl;
    }


    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	double n;
	cin >> n;
	cout << setprecision(20) << n * n*pi << " " << 2 * n*pi << endl;
}


Measured memory_bytes: 3288