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

int main() {
	int N, ans = 0;
	cin >> N;
	for (int i = 1; i <= N; i += 2) {
		int a = 0, j;
		for (j = 1; j <= i; ++j) {
			if (0 == i % j) ++a;
		}
		if (8 == a) ++ans;
	}
	cout << ans;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  def scan(a:Array[Int],value:Int,l:Int,r:Int):Boolean = {
    val mid = (l+r)/2
    if(a(mid) == value) true
    else if(l>=r) false
    else {
      val (new_l,new_r) = if(a(mid)<value) (mid+1,r) else (l,mid-1)
      scan(a,value,new_l,new_r)
    }
  }

  def search(a:Array[Int],value:Int) = {
    scan(a,value,0,a.length-1)
  }

  def main(args:Array[String]) = {
    readInt
    val s = readLine.split(" ").map(_.toInt).toArray
    readInt
    val t = readLine.split(" ").map(_.toInt).toArray
    println(t.count(i=> search(s,i)))
  }
}

Measured memory_bytes: 95896
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> commonDivisor = new ArrayList<Integer>();
        for(int i = 1; i <= Math.min(A,B); i++){
            if(A % i == 0 && B % i == 0){
                commonDivisor.add(i);
            }
        }

        int index = commonDivisor.size() - K;
        out.println(commonDivisor.get(index));
    }
}



Measured memory_bytes: 22612
package main

import (
	"fmt"
)

// 以下の問題
// https://atcoder.jp/contests/abc148/tasks/abc148_b

func main() {
	var (
		N    int
		S, T string
	)
	fmt.Scan(&N, &S, &T)

	for i := 0; i < N; i++ {
		fmt.Print(string(S[i]) + string(T[i]))
	}
}


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

using namespace std;

#define ll long long
#define up(i,j,n)		for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)		a=max(a,b)
#define cmin(a,b)		a=min(a,b)
#define Auto(i,node)	for(int i=LINK[node];i;i=e[i].next)

const int MAXN=305;
const ll oo=1LL<<40;

int g[MAXN][MAXN],N,cnt=0;
bool vis[MAXN];
ll dis[MAXN],ans=0;
struct Edge{
	int x,y,v;
}eds[MAXN*MAXN];

bool cmp(Edge a,Edge b){return a.v<b.v;}

struct edge{
	int y,next,v;
}e[MAXN*MAXN<<1];

int LINK[MAXN],len=0;

inline void ins(int x,int y,int v){
	e[++len].next=LINK[x];LINK[x]=len;
	e[len].y=y;e[len].v=v;
}
inline void Ins(int x,int y,int v){
	ins(x,y,v);
	ins(y,x,v);
}

deque<int>q;

void SPFA(int S){
	fill(dis,dis+N+1,oo);
	fill(vis,vis+N+1,0);
	dis[S]=0;vis[S]=1;
	q.push_back(S);
	while(!q.empty()){
		int node=q.front();q.pop_front();
		Auto(i,node)if(dis[e[i].y]>dis[node]+e[i].v){
			dis[e[i].y]=dis[node]+e[i].v;
			if(!vis[e[i].y]){
				vis[e[i].y]=1;
				q.push_back(e[i].y);
			}
		}
		vis[node]=0;
	}
}

int main(){
//	freopen("input.in","r",stdin);
	scanf("%d",&N);
	up(i,1,N)up(j,1,N){
		scanf("%d",&g[i][j]);
		if(i<j)eds[++cnt]=(Edge){i,j,g[i][j]};
	}
	sort(eds+1,eds+cnt+1,cmp);
	up(i,1,cnt){
		SPFA(eds[i].x);
		if(dis[eds[i].y]<eds[i].v){
			puts("-1");
			return 0;
		}
		if(dis[eds[i].y]>eds[i].v){
			Ins(eds[i].x,eds[i].y,eds[i].v);
			ans+=eds[i].v;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1280
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int k = sc.nextInt();
		int digit = n.length();
		int[][][] dp = new int[digit+1][k+1][2];
		dp[0][0][0] = 1;
		for(int i = 1; i <= digit; i++) {
			int x = Character.getNumericValue(n.charAt(i-1));
				for(int j = 0; j <= k; j++) {
					dp[i][j][1] = dp[i-1][j][1];
					if(j > 0)
						dp[i][j][1] += dp[i-1][j-1][1] * 9;
					if(x == 0)
						dp[i][j][0] = dp[i-1][j][0];
					else {
						dp[i][j][1] += dp[i-1][j][0];
						if(j > 0) {
							dp[i][j][0] = dp[i-1][j-1][0];
							dp[i][j][1] += dp[i-1][j-1][0] * (x-1);
						}
					}
				}
		}
		System.out.println(dp[digit][k][0] + dp[digit][k][1]);
 
	}
 
}

Measured memory_bytes: 22612
n = int(input())
numbersA = input().split()
numbersB = input().split()
diff = []
plusTotal = 0
minousTotal = 0

for i in range(0,n):
	diff.append((int(numbersB[i]) - int(numbersA[i])))
	if diff[i] < 0:
		minousTotal += diff[i]
	else:
		plusTotal += diff[i] // 2



if plusTotal >= abs(minousTotal):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 4852
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int n;
    double sum;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        float money;
        string type;
        cin >> money >> type;
        if (type == "JPY") {
            sum += money;
        } else {
            sum += (money * 380000.0f);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	ll a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	ll g = b - a;

	bool ok = false;
	rep(i, n)if (c * i - d * (n - 1 - i) <= g && g <= d * i - c * (n - 1 - i))ok = true;
	
	cout << (ok ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

void printLine(int *A, int N)
{
    int i;

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

void swap(int *a, int *b)
{
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

void bubbleSort(int *A, int N)
{
    int i, j, v, flag, num = 0;
    
    flag = 1;
    while (flag) {
        flag = 0;
        for (i = N - 1; i > 0; i--) {
            if (A[i] < A[i - 1]) {
                swap(&A[i], &A[i - 1]);
                num++;
                flag = 1;
            }
        }
    }

    printLine(A, N);
    printf("%d\n", num);
}

int main()
{
    int N;
    int A[100] = {0};
    int i;

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

    bubbleSort(A, N);

    return 0;
}


Measured memory_bytes: 2036
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    ll dig = 0, Kt = K;
    while(Kt > 0){
        dig++; Kt/=2;
    }
    
    vl A(N); REP(i, N) cin >> A[i];
    vl c1(50, 0), c0(50, 0);
    REP(i, 50) REP(j, N){
        if(A[j] >> i & 1) c1[i]++;
        else c0[i]++;
    }
    vvl dp(50, vl(2, -LINF)); // N, 1=under
    dp[49][0] = 0;
    RFOR(i, 48, -1){
        ll kd = K >> i & 1;
        if(kd == 1){
            dp[i][0] = dp[i+1][0] + c0[i] * (1ll << i); // 1
            dp[i][1] = dp[i+1][0] + c1[i] * (1ll << i); // 0
            if(dp[i+1][1] != -LINF) dp[i][1] = max(dp[i][1], max(c0[i], c1[i]) * (1ll << i) + dp[i+1][1]); // 0, 1
        }
        else{
            dp[i][0] = dp[i+1][0] + c1[i] * (1ll << i); // 0
            if(dp[i+1][1] != -LINF) dp[i][1] = max(c0[i], c1[i]) * (1ll << i) + dp[i+1][1];
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endstr;
    return 0;
}


Measured memory_bytes: 1024
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score+[0])  
print(ans)  

Measured memory_bytes: 104240
n = int(input())
adat = []
bdat = []
for _ in range(n):
    a,b = map(int, input().split())
    adat.append(a)
    bdat.append(b)
adat.sort()
bdat.sort()

if n % 2 == 1:
    aa = adat[n//2]
    bb = bdat[n//2]
    print(bb-aa + 1)

else:
    aa1 = adat[n//2-1]
    aa2 = adat[n//2]
    bb1 = bdat[n//2-1]
    bb2 = bdat[n//2]
    #print(aa1,aa2,bb1,bb2)
    aaa = (aa1+aa2) / 2
    bbb = (bb1+bb2) / 2
    cnt = bbb - aaa
    cnt = cnt // 0.5
    print(int(cnt + 1))


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

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

  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }  
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n;
	cin >> n;
	
	Array b(9, 0);
	
	REP(i, n) {
		ll a;
		cin >> a;
		for (int i = 0; i < 8; i++) {
			if (a < 400*(i+1)) {
				b[i]++;
				break;
			}
		}
		if (a >= 3200)b[8]++;
	}

	ll count= 0;
	for (int i = 0; i < 8; i++) {
		if (b[i] > 0) count++;
	}

	ll con_max = count + b[8];

	cout << max(1LL, count) << " " << con_max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>
#include <algorithm>
#include <sstream>

using namespace std;
class Dll
{
    list<int> l;

public:
    void exec(string line)
    {
        if (line == "deleteFirst")
            return l.pop_front();
        if (line == "deleteLast")
            return l.pop_back();

        int key = stoi(line.substr(7));
        if (line[0] == 'i')
            return l.push_front(key);

        // もし対象のキーがあったら消す
        auto t = find(l.begin(), l.end(), key);
        if (t != l.end())
            l.erase(t);
    }
    list<int> ansewr() const
    {
        return l;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cin.ignore();
    Dll dll;
    for (int i = 0; i < n; i++)
    {
        string line;
        getline(cin, line);
        dll.exec(line);
    }
    auto l = dll.ansewr();
    auto i = l.begin();
    for (; i != --l.end(); i++)
    {
        cout << *i << " ";
    }
    if (l.size())
    {
        cout << *i << endl;
    }
    return 0;
}



Measured memory_bytes: 34444
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B; cin >> A >> B;
    if (A / 10 == 0 && B / 10 == 0) printf("%d\n", A*B);
    else printf("%d\n", -1);
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    k = I()
    r = 0
    for a,b,c in itertools.product(range(1,k+1), repeat=3):
        r += math.gcd(math.gcd(a,b), c)

    return r


print(main())





Measured memory_bytes: 10960
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2 == 1:
    print(B[N//2]-A[N//2]+1)
else:
    r = (B[N//2-1]+B[N//2])
    l = (A[N//2-1]+A[N//2])
    print(r-l+1)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, long long C, std::vector<std::string> s)
{
    long long a = A, b = B, c = C;
    for (int i = 0; i < N; i++)
    {
        if (s[i] == "AB")
        {
            if (A > B || A == B && s[i + 1] == "BC")
                A--, B++;
            else
                A++, B--;
            if (A < 0 || B < 0)
            {
                puts("No");
                return;
            }
        }
        if (s[i] == "AC")
        {
            if (A > C || A == C && s[i + 1] == "BC")
                A--, C++;
            else
                A++, C--;
            if (A < 0 || C < 0)
            {
                puts("No");
                return;
            }
        }
        if (s[i] == "BC")
        {
            if (C > B || C == B && s[i + 1] == "AB")
                C--, B++;
            else
                C++, B--;
            if (C < 0 || B < 0)
            {
                puts("No");
                return;
            }
        }
    }
    A = a, B = b, C = c;
    puts("Yes");
    for (int i = 0; i < N; i++)
    {
        if (s[i] == "AB")
        {
            if (A > B || A == B && s[i + 1] == "BC")
                A--, B++, puts("B");
            else
                A++, B--, puts("A");
            if (A < 0 || B < 0)
            {
                puts("NO");
                return;
            }
        }
        if (s[i] == "AC")
        {
            if (A > C || A == C && s[i + 1] == "BC")
                A--, C++, puts("C");
            else
                A++, C--, puts("A");
            if (A < 0 || C < 0)
            {
                puts("NO");
                return;
            }
        }
        if (s[i] == "BC")
        {
            if (C > B || C == B && s[i + 1] == "AB")
                C--, B++, puts("B");
            else
                C++, B--, puts("C");
            if (C < 0 || C < 0)
            {
                puts("NO");
                return;
            }
        }
    }
}

// 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);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    std::vector<std::string> s(N + 1);
    for (int i = 0; i < N; i++)
    {
        std::cin >> s[i];
    }
    s[N] = "111";
    solve(N, A, B, C, std::move(s));
    return 0;
}


Measured memory_bytes: 6456
use std::io::*;
use std::str::FromStr;

const MOD: usize = 1_000_000_007;

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut vec: Vec<bool> = vec![false; n];
    for _ in 0..m {
        let a: usize = read();
        vec[a-1] = true;
    }

    let mut dp: Vec<usize> = vec![0; n+1];
    dp[0] = 1;
    for i in 0..n {
        if !vec[i] {
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
            if i > 0 {
                dp[i+1] += dp[i-1];
                dp[i+1] %= MOD;
            }
        }
    }
    println!("{}", dp[n]);
}

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


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

main(){
  int n; cin >> n;
  string s; cin >> s;
  char pre = s[0];
  int cnt = 1;
  for ( int i = 1; i < n; i++ ){
    if ( pre == 'x' && s[i] == 'x' ) break;
    pre = s[i];
    cnt++;
  }
  cout << cnt << endl;
}

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

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

    //good luck kittu!
    string s; cin>>s;
    if(s[2]==s[3] && s[4]==s[5])  cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a == b) Console.WriteLine("a == b");
            else if (a > b) Console.WriteLine("a > b");
            else Console.WriteLine("a < b");
        }
    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 100000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll r,D,x;
  cin>>r>>D>>x;
  for(int i=0;i<10;i++){
    x=r*x-D;
    cout<<x<<endl;
  }
  return 0;
}


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

const int INF = 0x3f3f3f3f;

int cnt[7507] = {1};

void print(int n, char c) {
	rep(i, n) putchar(c);
}

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	c -= a; d -= b;
	print(c, 'R');
	print(d, 'U');
	print(c, 'L');
	print(d+1, 'D');
	print(c+1, 'R');
	print(d+1, 'U');
	print(1, 'L');
	print(1, 'U');
	print(c+1, 'L');
	print(d+1, 'D');
	print(1, 'R');
	return 0;
}

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

using ll = long long;
static const ll MOD = 998244353;

// 座標圧縮
map<int, int> compress(vector<int> &x, bool sorted = false) {
  map<int, int> comp;
  if (!sorted) sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  for (int i = 0; i < x.size(); i++) comp[x.at(i)] = i;
  return comp;
}

// Segment-Tree
struct SegmentTree {
  int n;
  vector<int> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.assign(2 * n - 1, 0);
  }
  
  // i番目の値にxを加算
  void add(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] += x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  
  // [a, b)の和
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  int query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    else {
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }
};

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<pair<int, int>> v(n);
  vector<int> keep(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    keep[i] = v[i].second;
  }
  
  sort(v.begin(), v.end());
  
  map<int, int> mp = compress(keep);
  
  vector<ll> lu(n), ld(n), ru(n), rd(n); // i番目の点より左上, 左下, 右上, 右下にある点の個数
  SegmentTree stl(n), str(n);
  for (int i = 0; i < n; i++) {
    lu[i] = stl.query(mp[v[i].second] + 1, n);
    ld[i] = stl.query(0, mp[v[i].second]);
    stl.add(mp[v[i].second], 1);
  }
  for (int i = n - 1; i >= 0; i--) {
    ru[i] = str.query(mp[v[i].second] + 1, n);
    rd[i] = str.query(0, mp[v[i].second]);
    str.add(mp[v[i].second], 1);
  }
  
  ll ans = ((power(2, n, MOD) - 1) * n) % MOD;
  for (int i = 0; i < n; i++) {
    ll keep = 0;
    keep += power(2, lu[i] + ld[i], MOD) - 1;
    keep += power(2, ld[i] + rd[i], MOD) - 1;
    keep += power(2, rd[i] + ru[i], MOD) - 1;
    keep += power(2, ru[i] + lu[i], MOD) - 1;
    keep -= power(2, lu[i], MOD) - 1;
    keep -= power(2, ld[i], MOD) - 1;
    keep -= power(2, rd[i], MOD) - 1;
    keep -= power(2, ru[i], MOD) - 1;
    keep %= MOD;
    ans -= keep;
  }
  
  ans = ((ans % MOD) + MOD) % MOD;
  
  cout << ans << '\n';
}

Measured memory_bytes: 25384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B; cin >> A >> B;
    cout << A*B << '\n';
}

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

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

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, C;
	vector<llong> p;

	cin >> N >> C;
	p.resize(C);
	llong sum = 0;
	for(int i = 0; i < C; i++){
		cin >> p[i];
		sum += p[i];
	}


	cout << sum/(N+1) + (sum%(N+1)?1:0) << endl;

	return 0;
}


Measured memory_bytes: 3088
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.28 21:36:12
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int d;
    cin >> d;
    vector< int > c(26);
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector< vector< int > > s(d, vector< int >(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    for (int i = 0; i < d; i++) {
        cin >> t[i];
        t[i]--;
    }
    vector< int > las(26,0);
    ll total = 0;
    for (int i = 0; i < d; i++) {
        total += s[i][t[i]];
        las[t[i]] = i + 1;
        
        for (int j = 0; j < 26; j++) {
            total -= c[j] * (i + 1 - las[j]);
        }
        cout << total << endl;
    }
    return 0;
}


Measured memory_bytes: 3576
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(n+1), b(n);
		REP(i, n + 1) cin >> a[i];
		REP(i, n) cin >> b[i];
		LL ans = 0;
		RREP(i, n) {
			LL t = min(a[i+1], b[i]);
			b[i] -= t;
			a[i+1] -= t;
			ans += t;
			t = min(a[i], b[i]);
			b[i] -= t;
			a[i] -= t;
			ans += t;
			
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
    cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
    cout << a << " " << c << " " << b << endl;
    else if (c <= b && b <= a)
    cout << c << " " << b <<" "<< a << endl;
    else if ( b <= c && c <= a)
    cout << b <<" "<< c <<" " << a << endl;
    else if (c <=a && a <= b)
    cout << c <<" "<< a <<" " << b << endl;
    else if (b <= a && a <= c)
    cout << b <<" "<< a <<" " << c << endl;
    
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	int m,n;
	double sum1,sum2,degree,rest1,rest2;

	while(true){
		scanf("%d",&m);
		if(m == 0)break;

		sum1 = sum2 = 0;
		rest1 = 0,rest2 = 0;

		for(int i = 0; i < m-1; i++){
			scanf("%lf",&degree);
			sum1 += sin((M_PI*degree)/180);
			rest1 += degree;
		}

		rest1 = 360 - rest1;
		sum1 += sin((M_PI*rest1)/180);

		scanf("%d",&n);

		for(int i = 0; i < n-1; i++){
			scanf("%lf",&degree);
			sum2 += sin((M_PI*degree)/180);
			rest2 += degree;
		}

		rest2 = 360 - rest2;
		sum2 += sin((M_PI*rest2)/180);

		if(fabs(sum1-sum2) < 0.00000001){
			printf("0\n");
		}else if(sum1 > sum2){
			printf("1\n");
		}else{
			printf("2\n");
		}
	}

    return 0;
}

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

int main(){

int n;
cin >> n;
int hako[n];

int i;

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

for(i=n-1;i>=0;--i){
cout << hako[i] ;

if(i!=0){
cout << " ";
}
else {
cout << endl;
}

}


return 0;
}



Measured memory_bytes: 3052
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cmp::{max, min};

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

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };
  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };
  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };
  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };
  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i32,
    a: i32,
    b: i32,
    s: String,
  }
  let mut x = 0;
  let mut y = 0;
  for c in s.chars() {
    match c {
      'a' => {
        if x < a + b {
          println!("Yes");
          x += 1;
        } else {
          println!("No");
        }
      },
      'b' => {
        if x < a + b && y < b {
          println!("Yes");
          x += 1;
          y += 1;
        } else {
          println!("No");
        }
      },
      _ => {
        println!("No");
      }
    }
  }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//数式系の問題を見たときにはまず、いろいろな検証を加える前に
//数式の変形や、問題の読み替えを試みるべきかもしれない
//今回の問題では、割り算の式N=km+k=k(m+1)と変形することで
//m+1はNの約数であるという部分条件を読み取ることができるため
//検証の対象を約数に絞ることができ高速化される

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n; cin>>n;
	vll div;

	for(int i=1; i<=sqrt(n); i++){
		if (n%i == 0){
			div.pb(i);
			if (n != i*i)
				div.pb(n/i);
		}
	}

	ll ans=0;
	for(auto cur:div){
		if (cur==1) continue;
		if (n/(cur-1) == n%(cur-1))
			ans += cur-1;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0;i < H;i++){
            for (int j = 0;j < W;j++){
                cout << "#";
            }
            cout << "\n";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
use proconio::input;
use rand::prelude::*;
use std::collections::BTreeSet;

fn eval_lasts(days: i64, cs: &Vec<i64>, schedule: &Vec<BTreeSet<i64>>) -> i64 {
    let mut score = 0;

    for i in 0..cs.len() {
        let mut last = -1;

        for d in schedule[i].iter() {
            let x = d - last;
            let n = (x * (x - 1)) / 2;
            score -= cs[i] * n;
            last = *d;
        }
        let x = days - last;
        let n = (x * (x - 1)) / 2;
        score -= cs[i] * n;
    }

    score
}

fn eval(
    days: u64,
    cs: &Vec<i64>,
    sats: &Vec<Vec<i64>>,
    ts: &Vec<u64>,
) -> (i64, Vec<BTreeSet<i64>>) {
    let mut score = 0;

    let mut schedule = vec![BTreeSet::<i64>::new(); 26];

    for day in 0usize..(days as usize) {
        let contest = ts[day as usize] as usize;
        score += sats[day][contest] as i64;
        schedule[contest].insert(day as i64);
    }

    (score, schedule)
}

fn main() {
    input! { days: u64 };
    let mut cs = vec![0; 26];

    for i in 0..26 {
        input! {
            x: i64
        };

        cs[i] = x;
    }

    let mut sats = vec![vec![0; 26]; days as usize];
    for d in 0..days {
        for i in 0..26 {
            input! {
                s: i64
            };

            sats[d as usize][i as usize] = s;
        }
    }

    let mut ts = vec![0u64; days as usize];
    for i in 0..ts.len() {
        ts[i] = (i as u64) % 26;
    }

    let (mut base_score, mut schedule) = eval(days, &cs, &sats, &ts);

    let mut cur_score = base_score + eval_lasts(days as i64, &cs, &schedule);

    for _ in 0..100000 {
        let d = rand::random::<usize>() % days as usize;
        let q = rand::random::<usize>() % 26;

        let prev = ts[d as usize] as usize;
        let mut next_score = base_score;
        next_score -= sats[d][prev];
        next_score += sats[d][q];

        schedule[prev].remove(&(d as i64));
        schedule[q].insert(d as i64);

        let s2 = eval_lasts(days as i64, &cs, &schedule);

        if next_score + s2 > cur_score {
            base_score = next_score;
            cur_score = next_score + s2;
            ts[d as usize] = q as u64;
        } else {
            schedule[q].remove(&(d as i64));
            schedule[prev].insert(d as i64);
        }
    }

    for t in ts {
        println!("{}", t + 1);
    }
}


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

int main(){
  ll N,W;
  cin >>N>>W;
  vector<ll> w(N);
  vector<ll> v(N);
  for(ll i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  
  ll dp[110][100100];
  
  for(ll i=0;i<=W;i++){
    dp[0][i]=0;
  }
  
  for(ll i=0;i<=N-1;i++){
    for(ll sumw=1;sumw<=W;sumw++){
      if(sumw>=w[i]){
        dp[i+1][sumw]=max(dp[i][sumw-w[i]]+v[i],dp[i][sumw]);
      }
      else{
        dp[i+1][sumw]=dp[i][sumw];
      }
    }
  }
  
  cout << dp[N][W] <<endl;
}

                         

Measured memory_bytes: 82528
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
  int options; cin >> options;
  
  int t; cin >> t;
  int a; cin >> a; a *= 1000;
  int h;
  int ave;
  
  vi H(0);
  REP(i, options){
    cin >> h;
    H.PB(h);
  }
  
  vi Ave(0);
  REP(i, options){
    ave = t*1000-H[i]*6;
    Ave.PB(ave);
  }
  
   REP(i, options)
    if(Ave[i] == a){
      cout << i+1;
       return 0;
    }
  
  REP(i, options){
     Ave[i] = a - Ave[i];
  }
  
  REP(i, options)
    if(Ave[i] < 0)
      Ave[i] *= -1;
  
  int min = *min_element(ALL(Ave));
  
  REP(i, options)
   if(min == Ave[i]){
    cout << i+1;
     return 0;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a=2LL,b=1LL,c;
  int n;
  cin >> n;
  for(int i=0;i<n-1;i++){
    c=b;
    b+=a;
    a=c;
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  string s;
  cin >> s;
  bool f = s.find("000") != string::npos;
  rep(i,1,10) {
    f |= s.find(to_string(111*i)) != string::npos;
  }
  cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  long long A, B, V, W, T;
  scanf("%lld", &A);
  scanf("%lld", &V);
  scanf("%lld", &B);
  scanf("%lld", &W);
  scanf("%lld", &T);
  if (abs(B-A)>T*(V-W)){
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long L,R;
    cin >> L >> R;

    long long ans = 0;
    long long L_by_2019 = L / 2019;
    long long R_by_2019 = R / 2019;
    if (L_by_2019 < R_by_2019) {
        ans = 0;
    }
    else{
        ans = 2019;
        for (long long i=L; i<=R; i++) {
            for (long long j=i+1; j<=R; j++) {
                if (ans>(i*j)%2019) {
                    ans = (i*j)%2019;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
V = list(map(int,input().split()))
import heapq 
m = min(N,K)
M = 0
for i in range(m+1):
    for j in range(m-i+1):
        v1 = V[:i]
        v3 = V[N-j:]
        # print(v1,v3)
        v = v1+v3
        heapq.heapify(v)
        h = K - len(v)
        while v and len(v) and h >0:
            q = heapq.heappop(v)
            h-=1
            if q > 0:
                heapq.heappush(v,q)
                break
        tmp = sum(v)
        # print(v,v3)
        M = max(M,tmp)
print(M)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll gcd(ll N, ll M){

if(N%M == 0)return M;

else return gcd(M, N%M);

}

ll F(ll N, ll M){
return N/gcd(N, M)*M;
}

int main() {
ll N, Ans = 1;cin >> N;
vector<ll> T(N);

rep(i, 0, N)cin >> T[i];

rep(i, 0, N){

Ans = F(T[i], Ans);

}

cout << Ans;

}

Measured memory_bytes: 3560
#include <iostream>

#include <map>
#include <string>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cinttypes>


using namespace std;

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

	typedef pair<int, int> answer;
	vector<answer> que;
	que.push_back(answer(0, 0));

	vector<answer> nextQue;

	for (int index = n.size() - 1; index >= 0; --index)
	{
		int d = n[index] - '0';

		while (!que.empty())
		{
			answer ans = que.back();
			que.pop_back();

			int c = d + ans.second;
			int nextCarry = 0;

			if (c >= 10)
			{
				c -= 10;
				++nextCarry;
			}

			if( c <= 5)
				nextQue.push_back(answer(ans.first + c, nextCarry));

			if( c >= 5)
				nextQue.push_back(answer(ans.first + 10 - c, nextCarry + 1));
		}

		que.swap(nextQue);
		nextQue.clear();

		sort(que.begin(), que.end());
		que.erase(unique(que.begin(), que.end()), que.end());

		int min = que[0].first + que[1].second;

		for (int i = 1; i < que.size(); ++i)
		{
			if (min + 2 <= que[i].first + que[i].second)
				que.erase(que.begin() + i);
		}
	}

	int ans = 1 << 30;
	
	for( auto a : que )
	{
		ans = min(a.first + a.second, ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1412
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global


int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n,k;
	cin >> n >> k;
	if(k == 1) cout << 0;
	else cout << n-k;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int i,d[6],t;
    char dir[101];
    for(i=0;i<6;i++)
    scanf("%d ",&d[i]);
    
    scanf("%s", dir);
    for(i=0;dir[i]!='\0';i++){
        switch(dir[i]){
            case 'E':
            t=d[0];
            d[0]=d[3];
            d[3]=d[5];
            d[5]=d[2];
            d[2]=t;
            break;
            case 'N':
            t=d[0];
            d[0]=d[1];
            d[1]=d[5];
            d[5]=d[4];
            d[4]=t;
            break;
            case 'S':
            t=d[0];
            d[0]=d[4];
            d[4]=d[5];
            d[5]=d[1];
            d[1]=t;
            break;
            case 'W':
            t=d[0];
            d[0]=d[2];
            d[2]=d[5];
            d[5]=d[3];
            d[3]=t;
            break;
        }
    }
   
   printf("%d\n",d[0]);
   
   return 0;
    
}



Measured memory_bytes: 2108
my $K = <STDIN>;
my $s = <STDIN>;
my @dat = split(/ /,$s);

$diff = $dat[1] -$dat[0];
$flag = 0;
for($i=0;$i<=$diff;$i++){
  if( (($dat[0]+$i)%$K)==0  ){
      $flag=1;
      last;
  }
}
if( $flag ){ 
  print "OK";
}else{
  print "NG";
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAX = 1e5;

int a[MAX + 1];
int dp[MAX + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main() {
	fast_io();
//	freopen("input/dp_b.txt", "r", stdin);
	
	int n, k;
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for(int i = 2; i <= n; i++) {
		dp[i] = INT_MAX;
	}
	
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i - j <= 0) break;
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n] << '\n';
	
	return 0;
}

Measured memory_bytes: 1024
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,k=rl()
p=rl()
p.sort()
ans=0
for i in range(k):
    ans+=p[i]
print(ans)

Measured memory_bytes: 62568