akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        s: chars
    }

    let mut dp = vec_md![0u64;s.len()+1;4];
    dp[0][0] = 1;
    for i in 0..s.len() {
        let k = if s[i] == '?' {3} else {1};
        for j in 0..4 {
            dp[i+1][j] += k * dp[i][j];
            dp[i+1][j] %= M;
        }
        match s[i] {
            '?' => {
                for j in 0..3 {
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= M;
                }
            },
            _ => {
                let d = (s[i] as u8 - b'A') as usize;
                dp[i+1][d+1] += dp[i][d];
                dp[i+1][d+1] %= M;
            }
        }
    }
    println!("{}", dp[s.len()][3]);
}

Measured memory_bytes: 10492
N = int(input())
*A, = map(int, input().split())
x2 = 0
for i in range(N):
    if i % 2 == 0:
        x2 += A[i]
    else:
        x2 -= A[i]
ans = [0] * N
ans[0] = x2 // 2
for i in range(N-1):
    ans[i+1] = A[i] - ans[i]
res = map(lambda x: x*2, ans)
print(*res)


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

int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll tak=(a+d-1)/d,aok=(b+c-1)/b;
	cout<<(tak>=aok?"Yes":"No");
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
// 型エイリアス
using pii = pair<int, int>;
using tisb = tuple<int, string, bool>;
using vi = vector<int>;
using vii = vector<vi>;

bool isPrime(int x){
  if(x==2) return true;

  if(x<2 || x%2==0) return false;

  int i = 3;
  while(i <= sqrt(x)){
    if(x%i==0) return false;
    i+=2;
  }

  return true;
}

int main(){
  int N; cin >> N;
  vi numbers(N);
  for(int i=0; i<N; ++i) cin >> numbers[i];
  int count = 0;

  for(int i=0; i<N; ++i){
    if(isPrime(numbers[i])) ++count;
  }

  cout << count << endl;
}


Measured memory_bytes: 3100
def main():
    n = int(input())
    p = list(map(int, input().split()))
    a = [0]*n
    b = [0]*n
    for i, v in enumerate(p):
        x, y = i+1, v-1
        a[y] += x
        b[y] += x
    for i in range(n-1):
        a[i+1] += a[i]
    for i in reversed(range(1, n)):
        b[i-1] += b[i]
    for v in a:
        print(v, end=" ")
    print()
    for v in b:
        print(v, end=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 11492
#include <iostream>

using namespace std;

int main(void)
{
    long long a, b, x, i, ans=0;

    cin >> a >> b >> x;

    if(a%x==0){
        cout << b/x - a/x + 1 << endl;
    }

    else{
        cout << b/x - a/x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = list(map(int , input().split()))
ps = set(p)
o = []
for i in range(110):
    if i in ps:
        continue
    o.append(i)

m = 1000
ans = -1
for oi in reversed(o):
    if abs(x - oi) <= m:
        ans = oi
        m = abs(x - oi)

print(ans)

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

int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		string s1,s2;
		cin>>s1>>s2;
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		int r = 0;
		string res = "";
		for(int c=0;c<max(s1.size(),s2.size());c++)
		{
			int s = r;
			r = 0;
			if(c < s1.size()) s += s1[c] -'0';
			if(c < s2.size()) s+= s2[c] - '0';

			r = s/10;
			s%=10;
			res = string(1,s+'0')+res;

		}
		if(r)
		{
			res = string(1,r+'0')+res;
		}
		cout<<(res.size() <= 80?res:"overflow")<<endl;
	}
}

Measured memory_bytes: 1216
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int x_1,x_2,y_1,y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    int dx = x_2-x_1;
    int dy = y_2-y_1;
    cout << x_2-dy << " " <<  y_2+dx << " " << x_1-dy << " " << y_1+dx << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif


int main(void) {
  int N;
  cin >> N;
  LONG t = 0, a = 0;
  REP(i, N) {
    LONG T, A;
    cin >> T >> A;
    if (T >= t || A >= a) {
      if(T >= t && A >= a) {
        t = T; a = A;
      } else if (T >= t) {
        auto mul = (LONG)((a + A - 1) / A);
        t = T * mul; a = A * mul;
      } else {
        auto mul = (LONG)((t + T - 1) / T);
        t = T * mul; a = A * mul;
      }
    } else if (t / T > a / A) {
      auto mul = (LONG)((t + T - 1) / T);
      t = T * mul; a = A * mul;
    } else {
      auto mul = (LONG)((a + A - 1) / A);
      t = T * mul; a = A * mul;
    }
    //cout << t << " " << a << endl;
  }
  cout << (t + a) << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back

signed main()
{
  int l;
  cin>>l;
  printf("%.12f",(l/3+(l%3)/3.0)*(l/3+(l%3)/3.0)*(l/3+(l%3)/3.0));
   
}

Measured memory_bytes: 256
N = int(input().strip())
S = input().strip()

Ss = list(S)
new_S = ""

for i, s in enumerate(Ss):
    if i == 0:
        new_S += s
        mae_S = s
        continue

    if mae_S == s:
        mae_S = s
        continue

    new_S += s
    mae_S = s

print(len(new_S))


Measured memory_bytes: 4084
import sys

N = 50001
lst = [True] * N
lst[0] = False
lst[1] = False
for i in range(2, int(N ** 0.5) + 1):
    if lst[i]:
        for j in range(i * i, N, i):
            lst[j] = False

primes = [i for i in range(1, N) if lst[i]]

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break
    elif n % 2 == 1:
        if lst[n - 2]:
            print(1)
        else:
            print(0)
    elif n == 4:
        print(1)
    else:
        counter = 0
        for prime0 in primes:
            prime1 = n - prime0
            if prime0 <= prime1 and lst[prime1]:
                #print(prime0, prime1)
                counter += 1
        print(counter)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m,d;
  cin >> m >> d;
  ll ans = 0;
  FOR(i,1,m+1){
    FOR(j,1,d+1){
      if((j%10) >= 2 && (j/10) >= 2 && i == (j/10) * (j%10)) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	if N == 0 {
		out(1)
		return
	}
	out(0)
}


Measured memory_bytes: 1772
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

#初期化
D, G = getlist()
G = G // 100
bit = []
for i in range(D):
	p, c = getlist()
	bit.append([i + 1, p, c // 100])

#bit全探索
ans = float("inf")

for i in range(1 << D):
    score = 0
    lest = []
    val = 0
    for j in range(D):
        if ((i >> j) & 1) == 1:
            lest.extend([bit[j][0]] * bit[j][1])
        else:
        	score += bit[j][0] * bit[j][1] + bit[j][2]
        	val += bit[j][1]
    lest = sorted(lest)
    lest = lest[::-1]
    for j in lest:
    	if score >= G:
    		break
    	else:
    		val += 1
    		score += j
    ans = min(ans, val)

print(ans)

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


int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x3, y3, x4, y4;
  
  x3 = -(y2-y1) +x2;
  y3 = x2-x1 +y2;
  x4 = -(y3-y2) +x3;
  y4 = x3-x2 +y3;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [ list(map(int, input().split())) for _ in range(m) ]
import numpy as np
ans = np.array([ [0] * n ] * n)

for i in ab:
    ans[i[0]-1][i[1]-1] += 1
    ans[i[1]-1][i[0]-1] += 1
for  i in ans:
    print(sum(i))  

Measured memory_bytes: 12420
#include <cstdio>
#include <iostream>
#define MAX_INDEX 100
using namespace std;
int H,W;
char field[MAX_INDEX + 1][MAX_INDEX + 1];
int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};
bool check(int nx,int ny,char now){
    return nx >= 0 && nx < H && ny >= 0 && ny < W && field[nx][ny] == now;
}
void dfs(int x,int y){
    char now = field[x][y];
    field[x][y] = '.';
    for(int i = 0 ; i < 4 ; i++){
        int nx = x + dx[i],ny = y + dy[i];
        if(check(nx,ny,now)) dfs(nx,ny);
    }
}
int main(){
    while(cin >> H >> W){
        if(!(H || W)) break;
        for(int i = 0 ; i < H ; i++)
        for(int j = 0 ; j < W ; j++)
            cin >> field[i][j];
        int ans = 0;
        for(int i = 0 ; i < H ; i++)
        for(int j = 0 ; j < W ; j++){
            if(field[i][j] != '.'){
                ans++;
                dfs(i,j);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include <string.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    string x;
    cin >> x;
    int ans = 0, sum = 0;
    for (int i = 0; i < x.size(); i++)
    {
        if (x[i] == 'R')
            sum++;
        else
            sum = 0;
        ans = max(sum, ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
    // template start ---8<-----------8<---
	FastScanner sc = new FastScanner(System.in);
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	// template end ---8<-----------8<---

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a-b)<=d && Math.abs(c-b)<=d || Math.abs(a-c)<=d) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

    // template start ---8<-----------8<---
	class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		FastScanner(InputStream in) {
			this.in = in;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	class Random {
		private long seed;
		private final long multiplier = 0x5DEECE66DL, addend = 0xBL, mask = (1L << 48) - 1;
		int bits, val;

		Random(long seed) {
			this.seed = seed;
		}

		int nextInt(int n) {
			do {
				bits = (int) ((seed = (seed * multiplier + addend) & mask) >>> 17);
				val = bits % n;
			} while (bits - val + (n - 1) < 0);
			return val;
		}

		double nextDouble() {
			return nextInt(10000000) / 10000000.0;
		}
	}

	final double TEMP = 10;
	static final long TL = 5850;
	static boolean submit = true;
    // template end ---8<-----------8<---

}



Measured memory_bytes: 21076
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_INT = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  vi v;
  int tmp;
  rep (i, 10) {
    cin >> tmp;
    v.pb(tmp);
  }
  sort(rall(v));
  rep (i, 3) {
    cout << v[i] << endl;
  }

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];

    bool flag = true;
    REP(i, n-1){
        if (v[i] != v[i+1]){
            flag = false;
        }
    }
    if (flag){
        cout << n/2 << endl;
        return 0;
    }

    vector<int> count_odd(100005, 0);
    vector<int> count_even(100005, 0);
    REP(i, n/2){
        count_even[v[2*i]]++;
        count_odd[v[2*i+1]]++;
    }

    vector<pii> odd_pair, even_pair;
    REP(i, 100005){
        odd_pair.push_back(make_pair(count_odd[i], i));
        even_pair.push_back(make_pair(count_even[i], i));
    }

    sort(odd_pair.begin(), odd_pair.end());
    sort(even_pair.begin(), even_pair.end());

    if(odd_pair[100004].second != even_pair[100004].second){
        cout << (n/2 - odd_pair[100004].first) + (n/2 - even_pair[100004].first) << endl;
    }else{
        int cand1 = (n/2 - odd_pair[100004].first) + (n/2 - even_pair[100003].first);
        int cand2 = (n/2 - odd_pair[100003].first) + (n/2 - even_pair[100004].first);
        cout << min(cand1, cand2) << endl;
    }
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main() {
    long long n,T;
    cin >> n >> T;
    long long t[n];
    for (int i = 0; i < n; ++i)
        cin >> t[i];
    long long sum = 0, start = 0, time = T;
    for (int i = 0; i < n; ++i){
        if (t[i] > time){
            sum += time - start;
            start = t[i];
            time = start + T;
        }
        else {
            time = t[i] + T;
        }
    }
    sum += time -start;
    cout << sum << endl;
}

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

using namespace std;
const int Nmax = 1e5 + 100;

int n, m, hist[Nmax];
bool res = true;

int main() {
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; ++i) {
        int u, v; scanf("%d %d", &u, &v);
        ++hist[u]; ++hist[v];
    }
    for(int i = 1; i <= n; ++i)
        if (hist[i]%2 == 1) res = false;
    cout << (res ? "YES" : "NO");
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        string s; cin>>s;
        bool f=true;
        rep(i,s.size())
        {
                if(i%2==0)
                {
                        if(s[i]=='L')f=false;
                }else
                {
                        if(s[i]=='R')f=false;
                }
        }
        if(f)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}

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

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  string ans = s+t;
  for(int i=n-1;i>=0;i--){
    string ps = s.substr(n-1-i);
    string pt = t.substr(0,i+1);
    
    if( ps == pt ){
      ans = s.substr(0,n-1-i) + t;
      break;
    }
  }
  cout << ans.size() << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {

            double d,e,r;


            string[] s = Console.ReadLine().Split(' ');
            r = double.Parse(s[0]);
            d = r*r*Math.PI;
            e = 2 * r * Math.PI;

            Console.WriteLine(d.ToString("F6")+" "+e.ToString("F6"));


        }
    }
}

Measured memory_bytes: 9292
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(c-a-b<0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	if(4*a*b>=(c-a-b)*(c-a-b))
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int i = 0;
 
		String s = "ACL";
      if(a == 1){
       System.out.println(s);
      } else {
       String cats_tochu = "";
       String cats = "";
        for(i=1; i<a; i++){
           cats_tochu = cats_tochu + s;
	       cats = cats_tochu + s;
        }
	   System.out.println(cats);
      }
	}
}

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

int main(void){

        char s[10],t[11];
        scanf("%s%s",s,t);
        int len1,len2;

        len1 = strlen(s) - 1;
        len2 = strlen(t) - 1;

        int judge = 0;

        for(int i=0;i<=len2-1;i++){
                if(s[i]!=t[i]){
                        break;
                }   
                if(i==len2-1){
                        judge = 1;
                }   
        }   

        if(judge==1){
                printf("Yes\n");
        }else{
                printf("No\n");
        }   
return 0;
} 

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

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  vector<int> A(N), B(N), C(N-1);
  rep(i, 0, N){
    cin >> A[i];
    A[i]--;
  }
  rep(i, 0, N) cin >> B[i];
  rep(i, 0, N-1) cin >> C[i];
  int res = 0;
  rep(i, 0, N){
    res += B[A[i]];
    if(i > 0){
      if(A[i] == A[i-1] + 1) res += C[A[i-1]];
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N), t(N);
  for(int i=0; i<N; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  int now_x = 0, now_y = 0, cur_t = 0;
  int i;
  for(i=0; i<N; i++){
    int move_num = x[i]+y[i]-now_x-now_y;
    int t_diff = t[i] - cur_t;
    if(t_diff < move_num || t_diff%2 != move_num%2){
      cout << "No";
      break;
    }
  }
  if(i==N){cout << "Yes";}
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll r,d,x;

int main(){
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        cout << r*x-d << endl;
        x = r*x-d;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    if (s == "AKIHABARA" || s == "AKIHABAR" || s == "AKIHABRA" || s == "AKIHBARA" || s == "KIHABARA" || s == "AKIHABR" || s == "AKIHBAR" || s == "AKIHBRA" || s == "KIHABRA" || s == "KIHABAR" || s == "KIHBARA" || s == "AKIHBR" || s == "KIHABR" || s == "KIHBAR" || s == "KIHBRA" || s == "KIHBR") {
        cout << "YES" << std::endl;
    } 
    else cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);

	int sumT = 1;
	int count = 0;
	while (sumT < B)
	{
		sumT = sumT - 1 + A;
		count++;
	}
	
	// 出力
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100005
ll ar[mx+10];
ll memo[mx+10];
ll n,k;

ll dp(ll ind){
    if(memo[ind]!=-1) return memo[ind];
    if(ind==n) return 0;
    ll cnt=100000000000000;
    for(ll i=1;i<=k;i++){
        if(ind+i<=n){
            ll x=abs(ar[ind]-ar[ind+i])+dp(ind+i);
            cnt=min(cnt,x);
        }
    }
    return memo[ind]=cnt;
}

int main()
{
    memset(memo,-1,sizeof(memo));
    cin>>n>>k;
    for(ll i=1;i<=n;i++) cin>>ar[i];
    cout<<dp(1)<<endl;
    return 0;
}


Measured memory_bytes: 11392
n,k = map(int, input().split())
a = k
l =[]
ans_temp = 0

while True:
  a /= 2
  l.append(a)
  if a <= 1:
    break

def sum_num(x):
  sum_temp = 0
  for i in range(1, x):
    for j in range(len(l)):
      if l[j] <= i:
        sum_temp += 0.5**(j+1)
        break
  return sum_temp

if n < k:
  ans_temp += sum_num(n+1)
else:
  ans_temp += sum_num(k) + (n - k + 1)

print(ans_temp / n)

Measured memory_bytes: 3064
<?php
  fscanf(STDIN, "%d%d%d%d", $a, $b, $c, $d);

  if(abs($a - $c) <= $d) {
    echo "Yes";
  } 
  elseif(abs($a - $b) <= $d && abs($b - $c) <= $d) {
    echo "Yes";
  }
  else {
    echo "No";
  }
?>


Measured memory_bytes: 3828
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[101010]={},mx=0,mn=mod;
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
		mx=max(mx,a[i]);
		mn=min(mn,a[i]);
	}
	if(mx-mn>1){
		cout<<"No"<<endl;
	}else if(mx-mn==1){
		int cn=0,cx=0;
		FOR(i,0,n){
			if(a[i]==mn)cn++;
			if(a[i]==mx)cx++;

		}
		if(cn<mx&&2*(mx-cn)<=cx){
			cout<<"Yes"<<endl;

		}else{
			cout<<"No"<<endl;

		}
	}else{
		if(mx==n-1||mx*2<=n){
			cout<<"Yes"<<endl;

		}else{
			cout<<"No"<<endl;

		}
	}

    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
    int n,l;
    string x;
    cin>>n>>l;
    vector<string> A;
    for(int i=0;i<n;i++){
        cin >> x;
        A.push_back(x);
    }
    sort(A.begin(),A.end());
    for(int i=0;i<A.size();i++) cout<<A[i];
    
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
using namespace std;



int main() {
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(i * 4 + j * 7 == n){
                cout << "Yes" << endl;
                return 0;
            }
            else{
                continue;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(void) {
  int h, w;
  cin >> h >> w;

  string board[h];
  for (int i = 0; i < h; ++i) cin >> board[i];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] =='#') continue;
      int num = 0;
      for (int d = 0; d < 8; ++ d) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        if(ni<0 or h<=ni)continue;
        if(nj<0 or w<=nj)continue;
        if(board[ni][nj] == '#') num++;
      }

      board[i][j] = char(num + '0');
    }
  }

  for (int i = 0; i < h; ++i) cout << board[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static int sum(int x) {
        int ans = 0;
        for (; x > 0; x /= 10) {
            ans += (x % 10);
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = Integer.MAX_VALUE;

        for (int i=1; i<N; i++) {
            int A = i;
            int B = N - A;

            int sumOfAB = sum(A) + sum(B);
            if (sumOfAB < ans) {
                ans = sumOfAB;
            }
        }

        System.out.println("" + ans);
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int a,b,ans=2147483647;
int main(){
	int n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(b<=t)ans=min(ans,a);
	}
	if(ans<2147483647)
		cout<<ans;
	else
		cout<<"TLE";
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    ll rcnt = 0;
    ll gcnt = 0;
    ll bcnt = 0;
    rep(i,n){
        if(s.at(i) == 'R') rcnt++;
        else if(s.at(i) == 'G') gcnt++;
        else if(s.at(i) == 'B') bcnt++;
    }

    ll subcnt = 0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int k = j+j-i;
            if(k>=n) continue;
            if( (s.at(i) != s.at(j)) && (s.at(k) != s.at(j)) && (s.at(i) != s.at(k))) subcnt++;
        }
    }
    ll total = rcnt * gcnt * bcnt - subcnt;
    cout << total << endl;
} 

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

int main() {
  int A,B,a=0;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10){
      if((i/10)%10==(i%10000)/1000)
      a++;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

pll binsearch(ll x,vll &v, ll n=20) {
    ll lb = 0, ub = v.size() - 1;
    REP(i, n){
        ll md = (lb + ub) / 2;
        if(x < v[md]) {
            ub = md;
        }else {
            lb = md;
        }
    }
    return {lb, ub};
}

void solve() {
    ll A, B, Q;
    cin >> A >> B >> Q;
    vll S(A), T(B);
    for(auto &a:S) cin >> a;
    for(auto &a:T) cin >> a;
    S.insert(S.begin()+0, -1e17);
    S.push_back(1e17);
    T.insert(T.begin()+0, -1e17);
    T.push_back(1e17);
    vll ans(Q);
    REP(i, Q) {
        ll x, s1, s2, t1, t2;
        cin >> x;
        pll ps = binsearch(x, S);
        pll pt = binsearch(x, T);
        s1 = S[ps.first]; s2 = S[ps.first +1];
        t1 = T[pt.first]; t2 = T[pt.first +1];
        vll a = {
            abs(x - s1)+abs(s1 - t1),
            abs(x - s1)+abs(s1 - t2),
            abs(x - t1)+abs(t1 - s1),
            abs(x - t1)+abs(t1 - s2),
            abs(x - s2)+abs(s2 - t1),
            abs(x - s2)+abs(s2 - t2),
            abs(x - t2)+abs(t2 - s1),
            abs(x - t2)+abs(t2 - s2)
        };
        ASC(a);
        ans[i] = a[0];
    }
    REP(i, Q) out(ans[i]);
}

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


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

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

    vector<ll>::iterator low = lower_bound(div.begin(), div.end(), sqrt(N));
    vector<ll>::iterator up = upper_bound(div.begin(), div.end(), sqrt(N));
    cout << min(N / *low + *low - 2, N / *up + *up - 2) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 384
while True:
	n,m = map(int, input().split(" "))
	if n+m == 0:
		break
	dp = []
	for i in range(n):
		d,p = map(int, input().split(" "))
		dp.append((d,p))
	ans = 0
	for d,p in sorted(dp, key=lambda x: x[1], reverse=True):
		if m == 0:
			ans += p * d
		elif m < d:
			ans += p * (d - m)
			m = 0
		else:
			m -= d
	print(ans)



Measured memory_bytes: 6812
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split())))for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:])if tuple(sorted(edge))in edges)==N-1
print(ans)

Measured memory_bytes: 52316
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  vector<int> D(M-1);
  for(int i=0; i<M; i++)
    cin >> X[i];
  sort(X.begin(), X.end());
  for(int i=1; i<M; i++)
    D[i-1] = X[i] - X[i-1];
  sort(D.begin(), D.end());
  if(N >= M)
    cout << 0 << endl;
  else
    cout << accumulate(D.begin(), D.begin() + M - N, 0) << endl;
  return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int num[10] = { 0 };
	num[a]++;
	num[b]++;
	num[c]++;
	if (num[5] == 2 && num[7] == 1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#define ll long long
using namespace std;

int main() 
{
    ll n, m;
    cin >> n >> m;
    vector<ll> pattern(n + 1, 0), judge(n + 1, 1);
    for(ll i = 0; i < m; i++) {
        ll c;   cin >> c;
        judge.at(c) = 0;
    }

    pattern.at(0) = 1;
    if(judge.at(1))
        pattern.at(1) = 1;
    for(ll i = 2; i <= n; i++) {
        if(judge.at(i))
            pattern.at(i) = (pattern.at(i - 1) + pattern.at(i - 2)) % 1000000007;
    }

    cout << pattern.at(n) << endl;
}

Measured memory_bytes: 1792
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

left = 1
right = W
up = 1
down = H

for i in reversed(range(N)):
    if T[i] == "U":
        down = min(H, down+1)
    elif T[i] == "D":
        up = max(1, up-1)
    elif T[i] == "L":
        right = min(W, right+1)
    else:
        left = max(1, left-1)

    if S[i] == "U":
        up += 1
    elif S[i] == "D":
        down -= 1
    elif S[i] == "L":
        left += 1
    else:
        right -= 1

    #print(left, right, " ", up, down)

    if left > right or up > down:
        print("NO")
        exit()

#print(left, right)
#print(up, down)
if left <= sc <= right and up <= sr <= down:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3784
#include"bits/stdc++.h"
using namespace std;
namespace whatever{
	int reads(){
		char ch=getchar();
		while(!isdigit(ch)&&ch!='-')
			ch=getchar();
		int sign=1;
		if(ch=='-'){
			sign=-1;
			ch=getchar();
		}
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value*sign;
	}

	void run(){
	//	freopen(".in","r",stdin);
	//	freopen(".out","w",stdout);
        long long n=reads();
        if(n==0){
            puts("0");
            return;
        }
		static char result[1000];
		int last=-1;
		for(int i=0; i<40; ++i){
			long long a=llabs(n);
			if(a&(1ll<<i)){
				if(i%2==0)
					n-=(1ll<<i);
				else
					n+=(1ll<<i);
				result[i]='1';
			}
			else
				result[i]='0';
			if(result[i]=='1')
				last=i;
		}
		for(int i=last; i!=-1; --i)
			putchar(result[i]);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=3e5+5,mo=998244353;
int vf[N],fac[N],inv[N];
inline int C(int n,int m){return 1ll*vf[m]*vf[n-m]%mo*fac[n]%mo;}
int n,a,b,i,ans;
long long k,x;
int main(){
	for(int i=*vf=*fac=1;i<N;++i)
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo,
		fac[i]=1ll*fac[i-1]*i%mo;
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	for(i=0;i<=n && 1ll*i*a<=k;++i)if((k-1ll*i*a)%b==0){
		x=(k-1ll*i*a)/b;
		if(x<=n)ans=(ans+1ll*C(n,i)*C(n,x))%mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int e[501][501] = {};
int main() {
    int n;cin >>n;
    rep(i,10){
        vector<int> u,v;
        rep(j,n){
            if((j>>i)&1){
                u.push_back(j);
            }else{
                v.push_back(j);
            }
        }
        if(u.size() && v.size())
        for(auto s:u)for(auto k:v) e[s][k] = e[k][s] = i+1;
    }
    rep(i,n-1){
        for(int j=i+1;j<n;j++)
        cout << e[i][j] << " ";
        cout << endl;
    }


    
}


Measured memory_bytes: 1408
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int s[1000],p[1000],q[1000],r[1000],c;
   int w,x,y,z;
   int n;
   while(cin>>n,n){
       int count=0;
       for(int i=0;i<n;i++){
           cin>>s[i]>>p[i]>>q[i]>>r[i];
       }
       cin>>w>>x>>y>>z;
       for(int i=0;i<n;i++){
           c=4*p[i]+4*r[i]+9*q[i];
           if(p[i]<=w&&q[i]<=x&&r[i]<=y&&c<=z){
               cout<<s[i]<<endl;
               count++;
           }     
       }
       if(count==0){
           cout<<"NA"<<endl;
       }
   }
    return 0;
}


Measured memory_bytes: 5416
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

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

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, k;
signed main() {
	cin >> n >> k;
	if (n >= 10)cout << k << endl;
	else cout << k + 100 * (10 - n) << endl;
	ggr
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
        string A, B, C;
        cin >> A >> B >> C ;
        cout << A[0] << B[0] << C[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll   int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 1000000000000000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define range 500005
#define lg 22
using namespace std;
int main()
{
	ll x;
	cin>>x;
	
	cout<<(!x)<<endl;
}

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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 3e5 + 77;
int A[N] , dp[N];

int32_t main()
{
    fast;  
    int n , k ; cin >> n >> k ;
    for(int i = 1; i <= n ; ++i){
        cin >> A[i];
    }
    for(int i = 1 ; i <= n ; ++i){
        dp[i] = 1;
        for(int j = i-1 ; i-j <= 100 && j >= 1 ; --j)
            if(abs(A[i]-A[j]) <= k) dp[i] = max(dp[i],dp[j]+1);
    }
    int ans = 0 ;
    // for(int i = 1 ; i <= n ; ++i) cout << dp[i] << ' ' ; cout << endl;
    for(int i = 1 ; i <= n ; ++i) ans = max(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

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

const int N = 4e5 + 10, mod = 1e9 + 7;
typedef long long ll;
ll n, K, fac[N], inv[N];

ll quick_pow(ll a, ll b) {
    ll ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
    } return ret;
}

ll C(ll n, ll m) {
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

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

    fac[0] = inv[0] = 1;
    rep(i, 1, 2 * n) fac[i] = fac[i - 1] * i % mod;
    inv[2 * n] = quick_pow(fac[2 * n], mod - 2);
    for (int i = 2 * n; i >= 1; i--) inv[i - 1] = inv[i] * i % mod;

    if (K >= n) {
        printf("%lld\n", C(2 * n - 1, n - 1));
    } else {
        ll tot = 0;
        rep(k, 0, K)
            tot = (tot + C(n, k) * C(n - (n - k) + (n - k - 1), n - k - 1) % mod) % mod;
        printf("%lld\n", tot);
    }
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,ans=0,a,b;
  cin>>n>>a>>b;
  repi(i,1,n+1){
    int c;
    c=(i-9*((i/10)+(i/100)+(i/1000)+(i/10000)));
    
    if(a<=c && c<=b){ans+=i;}
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 256