akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
xの約数の個数：
xを素因数分解し、xの素因数のべきそれぞれに1を足したものの積

n/2以下の素数のリストを作り、各i(i>=2)について
・iの素因数の数だけリストの値を更新
素因数分解は、小さい方の素数から割っていき、1になったら終了
*/

bool is_prime[1010];
vector<int> p;
void era( const int N ){
    for( int i = 0; i <= N; i++ ) is_prime[ i ] = true;//初期化  
    for( int i = 2; i <= N; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= N; j += i ){
                is_prime[ j ] = false;
            }
            p.emplace_back( i );
        }
    }
}

void solve(){
    int n;
    cin >> n;
    era(n);
    //cout << p[0] << p[1] << endl;
    int siz = p.size();
    //cout << p.size() << endl;
    int a[siz];//n!の素因数になりうる素数の数を表現するリスト
    rep(i,siz){
        a[i]=0;
    }
    for(int i=2; i<=n; i++){
        int x=i;
        int j=0;
        while(x!=1){
            if(x%p[j]==0){
                x = x/p[j];
                a[j]++;
            }
            else{
                j++;
            }
        }
    }
    ll count = 1;
    rep(i,siz){
        count = count*(1+a[i]);
        count = count % MOD;
    }
    cout << count << endl;

}

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


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int r,g,b,n; cin >> r >> g >> b >> n;
    int ans = 0;

    for(int i = 0;i <= n/r;i ++){
        for(int j = 0;j <= n/g;j ++){
            if(0 <= n-i*r-j*g && (n-i*r-j*g)%b == 0) ans ++;
        }
    }

    cout << ans << endl;
}



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

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int get_num(string inp)
{
	int ret = 0;
	
	for (int i=0; i<inp.length(); i++)
	{
		if (inp[i] == ' ')
		{
			return ret;
		} else {
			ret++;
		}
	}
}


int main()
{
	string inp;
	int num;
	
	while (getline(cin, inp))
	{
		if (inp == "END OF INPUT") break;
		
		inp += " ";
		
		while (inp != "")
		{
			num = get_num(inp);
			cout << num;
			inp = inp.substr(num+1);
		}
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,amari;
  cin >> n >> a;
  amari = n%500;
  //cout << amari << endl;
  if (a >= amari){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#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 <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > digit;
  int sign = 1;
  if (N==0){
    printf("0\n");
    return 0;
  }
  while(N!=0){
    if (abs(N)%2==1){
      digit.push_back(1);
      N -= sign;
    } else {
      digit.push_back(0);
    }
    sign *= -1;
    N = N/2;
  }
  for (int i=digit.size()-1; i>=0; i--){
    printf("%d",digit[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int H = GetInt();
		int W = GetInt();
		int A = GetInt();
		int B = GetInt();

		int[,] s = new int[H, W];
		for(int i = 0; i < B; i++)
			for(int j = 0; j < A; j++)
				s[i, j] = 1;

		for(int i = B; i < H; i++)
			for(int j = A; j < W; j++)
				s[i, j] = 1;

		var sb = new StringBuilder();
		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
				sb.Append(s[i, j].ToString());
			sb.Append("\n");
		}

		Console.Write(sb);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const long INF = 1000000007;
    public static void Main()
    {
        int N = IntRead();
        int[] p = IntLine();
        int index = N - 1;
        bool f = false;
        for (int i = 0; i < N; i++)
        {
            Console.Write(p[index] + " ");
            index += (f ? +2 : -2);
            if (index == -2) { f = true; index = 1; }
            else if (index == -1) { f = true; index = 0; }
        }
        Console.WriteLine();
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static long GCD(long a, long b)
    {
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 37420
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
#define R(i)((m[way[i][0]] + m[way[i][1]] + m[way[i][2]]) % m[9]) 

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

const int way[8][3] = { {0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6} };

int res;
int m[10];

void dfs(int);

int main(void){
    for(;cin >> m[0], ~m[0]; cout << res << endl){
        COUNT(i, 9) cin >> m[i];

        res = 0;
        dfs(0);
    }

    return 0;
}

void dfs(int num){
    if(num == 10){
        int r = R(0), inc = 1;
        COUNT(i, 7) inc &= R(i) == r;
        res += inc;
        return;
    }

    if(!m[num]){
        COUNT(i, 10) if(find(m, m + 10, i) == m + 10) m[num] = i, dfs(num + 1);
        m[num] = 0;
    }
    else dfs(num + 1);
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
using namespace std;


int main(){
   int a,b,d,r;
   double f;
   cin >> a >> b;
   d = a / b;
   r = a % b;
   f = (double)a / (double)b;
   printf("%d %d %.8lf\n",d,r,f);  
   return 0;

}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)


main(){
  int n,k;
  while(cin>>n>>k && n){
    int turi=k-n;
    int a=0,b=0,c=0;
    a=turi/1000;
    turi%=1000;
    b=turi/500;
    turi%=500;
    c=turi/100;
    cout << c <<" " << b <<" " << a << endl;

  }
}

Measured memory_bytes: 0
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
while len(a)>1:
    for i in range(len(a)):
        if not i==0:
            a[i] %= a[0]
    a = sorted(list(set(a)))
    if a[0]==0:
        a.pop(0)
print(a[0])

Measured memory_bytes: 14252
# import itertools
# import math

import sys
input = sys.stdin.readline


def solve(N, A, B):
    return min(N * A, B)


# N = int(input())
# S = input()
N, A, B = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, A, B))


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[210];
    rep(i, n) cin >> a[i];
    int ans = 0;
    while(true){
        bool ok = true;
        rep(i, n) {
            if(a[i] % 2 == 0) a[i] /= 2;
            else ok = false;
        }
        if(ok) ans++;
        else break;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<long long int>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vb vector<bool>
#define vvl vector<vector<ll> >
#define vvi vector<vector<int> >
#define pl pair<ll,ll>
#define pb push_back
#define PI 3.14159265
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fri(s,n) for(int i=s;i<n;i++)
#define frj(s,n) for(int j=s;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define vsi vector<set<int> >
#define pii pair<int,int>
#define inf 1e9
#define vpii vector<pair<int,int> >


ll power(ll a,ll b){
    if(b==0)
        return 1;
    if(b&1)
        return a*power(a,b-1);
    ll temp=power(a,b/2);
    return temp*temp;
    }
ll mycompare(ll a,ll b){
    return a>b;
    }
vector<string> matrix;
int totalpath(int i,int j,vvi &dp){
    if(matrix[i][j]=='#')
        return 0;
    if(i==0 && j==0)
        return 1;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(i==0)
        return dp[i][j]=totalpath(i,j-1,dp)%mod;
    if(j==0)
        return dp[i][j]=totalpath(i-1,j,dp)%mod;
    return dp[i][j]=(totalpath(i-1,j,dp)%mod+totalpath(i,j-1,dp)%mod)%mod;
    }
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast;
    int n,m;
    cin>>n>>m;
    matrix.resize(n);
    fri(0,n)
        cin>>matrix[i];
    vvi dp(n,vi(m,-1));
    cout<<totalpath(n-1,m-1,dp);
    }


Measured memory_bytes: 8416
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, D;
  cin >> N >> D;
  int ans = 0;
  if(N % (D * 2 + 1) == 0) {
    ans = N / (D * 2 + 1);
  } else {
    ans = N / (D * 2 + 1) + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if (A + B - 1 <= N and N <= A * B and A <= N and B <= N) {
        vector<int> a(N);
        for (int i = 0; i < N; i++) a[i] = N - i;
        reverse(a.begin(), a.begin() + A);
        if (B > 1) {
            const int rest = N - A;
            const int num = rest / (B - 1);
            int pos = A;
            for (int i = 0; i < rest % (B - 1); i++) {
                reverse(a.begin() + pos, a.begin() + pos + num + 1);
                pos += num + 1;
            }
            for (int i = rest % (B - 1); i < B - 1; i++) {
                reverse(a.begin() + pos, a.begin() + pos + num);
                pos += num;
            }
        }
        for (int i = 0; i < N; i++) {
            cout << a[i] << " ";
        }
        cout << endl;
    } else {
        cout << "-1\n";
    }
    return 0;
}


Measured memory_bytes: 3328
//2018.12.27
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

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

    int mn = 1000;
    for (int i = 0; i < s.size() - 2; i++) {
        t = s.substr(i, 3);
        mn = min(mn, abs(753 - stoi(t)));
    }
    
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
while line = gets do
    break if line == nil
    x1, y1, x2, y2, x3, y3, xp, yp = line.split(" ").map{|item| item.to_f}
    
#または 
#readlines.each do |i|
#    x1, y1, x2, y2, x3, y3, xp, yp = i.split(" ").map{|item| item.to_f}

    def c(x1, y1, x2, y2, x, y)
        (y2 - y1)*(x - x1) - (x2 - x1)*(y - y1)
    end

    gx, gy = (x1 + x2 + x3) / 3, (y1 + y2 + y3) / 3
    
    r1 = c(x1, y1, x2, y2, gx, gy)*c(x1, y1, x2, y2, xp, yp) > 0
    r2 = c(x2, y2, x3, y3, gx, gy)*c(x2, y2, x3, y3, xp, yp) > 0
    r3 = c(x3, y3, x1, y1, gx, gy)*c(x3, y3, x1, y1, xp, yp) > 0
    puts (r1 && r2 && r3) ? "YES" : "NO"
end

#または
#if (r1 && r2 && r3) then puts "YES"
#else puts "NO"




#条件演算子の && ||
#「かつ」を表す条件演算子 &&
#「または」を表す条件演算子 ||
#(例)true && false = false　false && false = false　true && true = false
#(例)true || false = true  true || true = true



Measured memory_bytes: 6876
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    ll N,K;
    cin >> N >> K;
    vec<ll> A(N);
    map<ll,vec<ll>> m;
    ll s = 0;
    m[0].push_back(0);
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        a--;
        if(a<0) a = K-1;
        (s += a)%=K;
        m[s].push_back(i+1);
    }
    ll ans = 0;
    for(auto& x:m){
        int n = x.second.size();
        vec<ll> v = x.second;
        for(ll i=0;i<n;i++){
            ll id = upper_bound(v.begin(),v.end(),v[i]+K-1)-v.begin();
//            cerr << i << " " << id << endl;
            ans += id-i-1;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int w, h;
    cin >> w >> h;
    vector<pair<ll, bool>> pqs;
    rep(i, w + h) {
        ll p;
        cin >> p;
        pqs.emplace_back(p, i < w);
    }
    int a = w + 1, b = h + 1;
    ll ans = 0;
    sort(pqs.begin(), pqs.end());
    rep(i,w+h){
        if(pqs[i].second){
            ans += b * pqs[i].first;
            a--;
        } else {
            ans += a * pqs[i].first;
            b--;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, k, minc=0, act=0, l;
  cin >> n >> k;
  bool b=false;
  vecll a(n);
  vecll p(n, -1);
  forll(i, 0, n){
	cin >> a[i];
  }
  p[0] = minc;
  
  forll(i, 0, k){
	minc++;
	act = a[act] - 1;
	if(i == k-1)
	  break;
	if (p[act] != -1){
	  b = true;
	  l = minc - p[act];
	  break;
	}
	p[act] = minc;
  }
  
  if(b == false){
	cout << act + 1 << endl;
	return 0;
  }
  k = (k - p[act] + 1) % l - 1;
  if (k < 0)
	k = l-1;
  forll(i, 0, k){
	act = a[act] - 1;
  }
  cout << act + 1 << endl;
}


Measured memory_bytes: 6420
import bisect

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

YZ = Y*Z
BC = []
for b in B:
  for c in C:
    BC.append(b+c)

BC.sort()
# 2つのリストから1つずつ要素を取り出したときに和がx以上となる組合せ
def count_large_2(L1, L2, x):
  L1.sort()
  L2.sort(reverse=True)
  N1, N2 = len(L1), len(L2)
  i = j = 0
  c = 0
  while i<N1 and j<N2:
    if L1[i]+L2[j] >= x:
      c += 1
      j += 1
      if j >= N2:
        c += (N1-i-1) * N2
    else:
      i += 1
      if i>=N1:
        continue
      c += j
  return c


def check(S):
  c = count_large_2(BC, A, S)  
  return c >= K



Sl = 0
Sr = A[0]+B[0]+C[0]+1

while Sr - Sl > 1:
  mid = (Sl + Sr) // 2
  if check(mid):
    Sl = mid
  else:
    Sr = mid


Ans = []
for a in A:
  for b in B:
    if a + b + C[0] < Sr:
      break
    for c in C:
      if a + b + c >= Sr:
        Ans.append(a+b+c)
      else:
        break

Ans.sort(reverse=True)
Ans = Ans + [Sl]*(K-len(Ans))
for ans in Ans:
  print(ans)

Measured memory_bytes: 110424
#include <stdio.h>

int main(){
  int n,i,j;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(j=1;j<n;j++){
    printf("%d ",a[(n-j)]);
  }
  printf("%d\n",a[0]);
  return 0;
}

Measured memory_bytes: 2664
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#include<sstream>
#include<time.h>

#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define MEM(a) memset(a, 0, sizeof(a))
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
#define endl "\n"
#define eps 1e-8
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  998244353;

int n, m, k;
ll a[N];

void solve()
{
    scanf("%d", &n);
    ll ans = 1, tmp = 1e18;
    for(int i = 0; i < n; ++i) scanf("%lld", &a[i]);
    for(int i = 0; i < n; ++i) {
        if(a[i] == 0) {
            ans = 0;
            break;
        }
        if(ans == -1) continue;
        if(ans > tmp/a[i])
            ans = -1;
        else ans *= a[i];
    }
    if(ans > tmp) ans = -1;
    printf("%lld\n", ans);
}

int main()
{
//    FAST();
//    init();
//    int _;scanf("%d", &_); while(_--)
//    while(scanf("%d", &n)&&n)
//    while(scanf("%d%d%d", &n, &m, &k)&&(n+m+k))
    solve();
    return 0;
}


Measured memory_bytes: 4544
//Author - Soumik Roy
//Date & Time - August 24, 2020 9:59 PM
//Problem name - D - Wizard in Maze
//Problem url - https://atcoder.jp/contests/abc176/tasks/abc176_d
//Time limit - 2000 ms
//Memory Limit - 1024 MB    

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int INF=1e9;
int h,w,ch,cw,dh,dw;
int dir[]={0,1,0,-1,1,0,-1,0};
vector<string> grid;
int bfs()
{
	int magic[h+1][w+1];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			magic[i][j]=INF;
	}
	priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > q;
	q.push(mp(0,mp(ch,cw)));
	magic[ch][cw]=0;
	while(!q.empty())
	{
		pii node=q.top().S;
		int m=magic[node.F][node.S];
		q.pop();
		for(int i=0;i<8;i+=2)
		{
			pii next=mp(node.F+dir[i],node.S+dir[i+1]);
			if(next.F<0 || next.S<0 || next.F>=h || next.S>=w)
				continue;
			if(grid[next.F][next.S]=='#')
				continue;
			if(magic[next.F][next.S]>m)
			{
				magic[next.F][next.S]=m;
				q.push(mp(m,next));
			}
		}
		for(int nx=node.F-2;nx<=node.F+2;nx++)
		{
			for(int ny=node.S-2;ny<=node.S+2;ny++)
			{
				if(nx<0 || ny<0 || nx>=h || ny>=w)
					continue;
				if(grid[nx][ny]=='#') continue;

				if(magic[nx][ny]>m+1)
				{
					magic[nx][ny]=m+1;
					q.push(mp(m+1,mp(nx,ny)));
				}
			}
		}
	}
	return magic[dh][dw];
}
void solve()
{
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--,cw--,dh--,dw--;
	grid.clear();
	for(int i=0;i<h;i++)
	{
		string s;
		cin>>s;
		grid.eb(s);
	}
	
	int ans=bfs();
	if(ans==INF)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 8620
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	max := -10000000
	if a+b > max {
		max = a + b
	}
	if a-b > max {
		max = a - b
	}
	if a*b > max {
		max = a * b
	}

	fmt.Println(max)
}


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

using namespace std;

int count(int x, int k){
    int res = 0;
    while(x < k){
        x *= 2;
        res++;
    }
    return res;
}
double pow(int x){
    double res = 1.0;
    for(int i = 0; i < x; i++){
        res *= 0.5;
    }
    return res;
}
int main(){
    int n, k;
    cin >> n >> k;
    double pro = 0;
    if(k <= n){
        for(int i = 1; i < k; i++){
            pro += 1 / static_cast<double>(n) * pow(count(i, k));
        }
        pro += (n - k + 1) / static_cast<double>(n);
    }else{
        for(int i = 1; i <= n; i++){
            pro += 1 / static_cast<double>(n)* pow(count(i, k));
        }
    }
    printf("%.12lf\n", pro);
}


Measured memory_bytes: 3676
import sys

N = int(input())
a = list(map(int, sys.stdin.readline().split()))
box = [0] * N
if N % 2 == 0:
    half = N // 2 - 1
else:
    half = N // 2
    
ball_count = 0
ball_box = []

for i in range(N - 1, -1, -1):
    m = N // (i + 1)
    count = 0
    for j in range(1, m + 1):
        count += box[(i + 1) * j - 1]
        count %= 2
    if a[i] != count:
        box[i] = 1
        ball_count += 1
        ball_box.append(i + 1)
            
print(ball_count)
if ball_box != 0:
    ball_box = [str(ball_box[i]) for i in range(ball_count - 1, -1, -1)]
    box_ans = " ".join(ball_box)
    print(box_ans)

Measured memory_bytes: 19044
#include<bits/stdc++.h>
#define N 200005
using namespace std;
vector<int> G[N];
int n,m,a[N],b[N],c[N],d[N],w[N],lw,f[N],ans;
int find(int x){ return f[x] ? f[x]=find(f[x]) : x;}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]),a[n+1]^=a[i];
	for(i=1;i<=n;i++) scanf("%d",&b[i]),b[n+1]^=b[i];
	n++;
	for(i=1;i<=n;i++) if(a[i]!=b[i]) ++m,c[m]=a[i],d[m]=b[i];
	ans=m;
	if(a[n]!=b[n]) ans-=2;
	else{
		for(i=1;i<=m;i++)
			if(c[i]==a[n]) break;
		if(i<=m) ans--;
	  }
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++) if(a[i]!=b[i]){ printf("-1"); return 0;}
	for(i=1;i<=m;i++) w[++lw]=c[i],w[++lw]=d[i];
	sort(w+1,w+lw+1);
	lw=unique(w+1,w+lw+1)-w-1;
	for(i=1;i<=m;i++){
		c[i]=lower_bound(w+1,w+lw+1,c[i])-w;
		d[i]=lower_bound(w+1,w+lw+1,d[i])-w;
		if(find(c[i])!=find(d[i])) f[find(c[i])]=find(d[i]);
	  }
	for(i=1;i<=lw;i++)
		if(find(i)==i) ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
using namespace std;
int main(){
    string a,b;
    cin >> a >> b;
    string ans;
    if(a.length()>b.length()){
        ans ="GREATER";
    }else if(a.length()<b.length()){
        ans = "LESS";
    }else{
        if(a==b){
        ans ="EQUAL";
        }else{
            for(int i=0;i<1000;i++){
                if(a.substr(i,1)!=b.substr(i,1)){
                    if(stoi(a.substr(i,1))>stoi(b.substr(i,1))){
                        ans ="GREATER";
                    }else{
                        ans ="LESS";
                    }
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

class Pair {
	int a, b;

	Pair(int a, int b) {
		this.a = a;
		this.b = b;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		int[] A = new int[M];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
		int[] num = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		Pair[] usable = new Pair[M];
		for (int i = 0; i < M; i++) {
			usable[i] = new Pair(A[i], num[A[i]]);
		}
		Arrays.sort(usable, Comparator.comparingInt((Pair p) -> p.b).thenComparingInt(p -> p.a));
		TreeMap<Integer, Integer> higher = new TreeMap<>();
		for (Pair pair : usable) {
			higher.put(pair.b, pair.a);
		}

		final String INF = String.valueOf((char) 0);
		String[] maxNum = new String[N + 1];
		Arrays.fill(maxNum, INF);
		maxNum[0] = "";
		for (int i = 2; i <= N; i++) {

			for (Map.Entry<Integer, Integer> entry = higher.floorEntry(i);
				 entry != null;
				 entry = higher.lowerEntry(entry.getKey())) {
				String base = maxNum[i - entry.getKey()];
				if (base == INF) continue;
				String candidate = base + entry.getValue();
				if (numeroComp.compare(maxNum[i], candidate) > 0) maxNum[i] = candidate;
			}
		}
		System.out.println(maxNum[N]);
	}

	Comparator<String> numeroComp = Comparator.comparingInt(String::length).thenComparing(s -> s).reversed();
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 338000
#include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;


int main() {
	int N,M;
	vector<int>a;
	vector<int>b;
	int g;
	map<int, int>A ;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {

		cin >> g;
		a.push_back(g);
		cin >> g;
		b.push_back(g);
	}
	for (int i = 0; i < M; i++) {
		A[a[i]]++;
		A[b[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << A[i]<<endl;

	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,K,Q;
  cin>>N>>K>>Q;
  
  vector<ll>A(Q);
  vector<ll>safe(N);
  vector<ll>sum(N);
  
  rep(i,Q){
    cin>>A[i];
  }
  
  rep(i,Q){
    safe[A[i]-1]++;
  }
  rep(i,N){
    sum[i]=K-(Q-safe[i]);
  }
  
  rep(i,N){
    if(sum[i]>0){
      cout<<"Yes"<<endl;
    }
else{
  cout<<"No"<<endl;
}
  }
}
  

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	if(s == "A") s = "T";
	else if(s == "T") s = "A";
	else if(s == "C") s = "G";
	else if(s == "G") s = "C";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

#define cmax(_a, _b) (_a < (_b) ? _a = (_b), 1 : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b), 1 : 0)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))

#define maxn 100010
typedef long long ll;
typedef double db;

int a[maxn];
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int ans = 1;
	for (int i = 2; i <= n; ++i)
		if (s[i] != s[i - 1]) ++ans;
	printf("%d\n", ans - 1);
	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 int long long  
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s.erase( 0, 8 );
    reverse(s.begin(), s.end());
    cout << s  << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=100100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,c,k,a[N],ans;
	int i,j;
int main(){
	//freopen("1.out","w",stdout);
	n=read();c=read();k=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	for(i=1;i<=n;i=j){
		for(j=i;j<=n&&j-i+1<=c&&a[j]<=a[i]+k;j++);
		ans++;
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
use std::io;


/// https://beta.atcoder.jp/contests/arc063/tasks/arc063_a
fn main() {
    let s = read_one::<String>()
        .chars().collect::<Vec<char>>();
    let mut cnt = 0;
    let mut c = s[0];
    for i in 1..s.len() {
        if c != s[i] { cnt += 1; c = s[i]; }
    }

    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
int n, m, i, j, k, c[9];
char s[9][9] = {"", "AC", "WA", "TLE", "RE"};
int main(){
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%s", s[0]);
		for(j=1; j<=4; j++){
			if(strcmp(s[j], s[0]) == 0){
				c[j]++;
			}
		}
	}
	for(i=1; i<=4; i++){
		printf("%s x %d\n", s[i], c[i]);
	}
	return 0;
}

Measured memory_bytes: 1732
use std::cmp;
use std::collections::*;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let a: u32 = sc.read().unwrap();
    let b: u32 = sc.read().unwrap();

    if a & b & 1 == 1 {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

ll gain[42][2];
ll dp[42][2];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; ll k;
	read(n, k);

	rep(i, 0, n) {
		ll t; read(t);
		rep(j, 0, 42) {
			if (t & (1ll << j)) gain[j][0] += 1ll << j;
			else gain[j][1] += 1ll << j;
		}
	}

	rep(i, 0, 42)
		dp[i][0] = dp[i][1] = -0x3f3f3f3f3f3f3f3fll;
	dp[41][1] = 0;
	for (int i = 40; i >= 0; i--) {
		// tight -> tight
		chmax(dp[i][1], dp[i + 1][1] + gain[i][(k >> i) & 1]);
		// tight -> non-tight
		if (k & (1ll << i))
			chmax(dp[i][0], dp[i + 1][1] + gain[i][0]);
		// non-tight -> any
		chmax(dp[i][0], dp[i + 1][0] + max(gain[i][0], gain[i][1]));
		//printf("%2d NT: %20lld T: %20lld G0: %20lld G1: %02lld\n", i, dp[i][0], dp[i][1], gain[i][0], gain[i][1]);
	}

	die(max(dp[0][0], dp[0][1]));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[3*N];
    ll ans = 0;
    rep(i, 3*N) cin >> A[i];
    sort(A, A+3*N);
    rep(i, N) ans += A[N + i*2];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fo(i, k, n) for (int i = k; i <= n; ++ i)
#define fod(i, k, n) for (int i = k; i >= n; -- i)
template <typename T, typename U>
static inline void maxx (T &x, U y) {
  if (x < y) {
    x = y;
  }
}
template <typename T, typename U>
static inline void minn (T &x, U y) {
  if (x > y) {
    x = y;
  }
}
template<typename T>
void read (T &x) {
  x = 0;
  T neg = 1;
  register T c = getchar ();
  if (c == '-') {
    neg = -1;
  }
  while (c < 48 || c > 57) {
    c = getchar ();
  }
  for (; c < 48 || c > 57; c = getchar ());
  for (; c <= 57 && c >= 48; c = getchar ()) {
    x = (x << 3) + (x << 1) + (c & 15);
  }
  x *= neg;
}
template<typename T>
void write (T x) {
  bool neg = 0;
  if (x < 0) {
    x *= -1;
    neg = 1;
  }
  char snum[65];
  int i = 0;
  do {
    snum[++ i] = x % 10 + '0';
    x /= 10;
  }
  while (x);
  //-- i;
  if (neg) {
    putchar ('-');
  }
  while (i > 0) {
    putchar (snum[i --]);
  }
}
///declare
string s;
int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
//  else {
//    freopen(".inp", "r", stdin);
//    freopen(".out", "w", stdout);
//  }
//  ios_base :: sync_with_stdio (0);
//  cin.tie (nullptr);
//  cout.tie (nullptr);
  cin >> s;
  fo (i, 0, s.size () - 1) {
    if (i % 2 == 0 && ! (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) return cout << "No", 0;
    if (i % 2 == 1 && ! (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) return cout << "No", 0;
  }
  cout << "Yes";
  return 0;
}


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

#define ll long long
int main()
{
	
	int n; cin>>n;
	ll dp[n+1] = {};
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 2; i<=n; i++)
	{
		dp[i] = dp[i-1] + dp[i-2];
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>
 
using namespace std;
 
typedef long long int lld;
 
const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;
 
lld gcd(lld a,lld b)
{
	if (b == 0)
	{
		return a;
	}
	return gcd(b,a%b);
}
 
int main()
{
	lld n,a[MAXN] = {0},k;
 
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

 
	lld min = INF+1;
	lld max = 0;
 
	for(int i = 0; i < n; i++)
	{
		if (min >= a[i])
		{
			min = a[i];
		}
		if (max <= a[i])
		{
			max = a[i];
		}
	}
 
	if (k > max)
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
 
 
	lld sol = a[0];
 
	for(int i = 1; i < n; i++)
	{
		sol = gcd(sol,a[i]);
	}
 
	if (k % sol == 0)
	{
		cout << "POSSIBLE" << endl;
	}else
	{
		cout << "IMPOSSIBLE" << endl;
	}
 
	return 0;
}

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

using namespace std;

int n,l,dp[100005],a[100005];

int calc(int i){
  return l-a[i];
}

int func(int i){

  if(i>n)return 0;
  if(dp[i]>0)return dp[i];
  if(a[i]>a[i-1] && a[i]>a[i+1])return calc(i);

  int res=0;
  if(a[i]<a[i-1])res=max(res,func(i-1));
  if(a[i]<a[i+1])res=max(res,func(i+1));

  return dp[i]=calc(i)+res;
}

int main(void){
  int in;
  
  while(cin >> n >> l){
    
    for(int i=0;i<n+2;i++)dp[i]=0;

    for(int i=1;i<n+1;i++)
      cin >> a[i];

    a[0]=a[n+1]=0;

    int res=0;
    for(int i=1;i<n+1;i++)
      res=max(res,func(i));

    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, a, b;
    cin >> n >> a >> b;
    long sum = n/(a+b)*a + min(n%(a+b), a);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var x = long.Parse(Console.ReadLine());
            var year = 0;
            var money = 100L;
            while (money < x)
            {
                year++;
                money = (long)(money * 1.01);
            }
            Console.WriteLine(year);
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> T(N, 0);
  for(int i=0; i<N; i++){
    cin >> T.at(i);
  }
  int M;
  cin >> M;
  vector<int> P(M, 0);
  vector<int> X(M, 0);
  for(int i=0; i<M; i++){
    cin >> P.at(i);
    cin >> X.at(i);
  }
  int Sum=0;
  for(int i=0; i<N; i++){
    Sum += T.at(i);
  }
  for(int i=0; i<M; i++){
    cout << Sum + X.at(i) - T.at(P.at(i)-1) << endl; 
  }
}
    

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

typedef long long ll;
ll k;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> k;
	Graph g(k);
	for(int i=1; i<k; ++i){
		if(i % 10 != 9) g[i].push_back(Edge(1, i, (i+1)%k));
		g[i].push_back(Edge(0, i, 10*i%k));
	}
	vector<int> dist(k, 1e9);
	dist[1] = 0;
	deque<int> dq;
	dq.push_back(1);
	while(!dq.empty()){
		int p = dq.front();
		dq.pop_front();
		for(int i=0; i<g[p].size(); ++i){
			int j = g[p][i].to;
			if(g[p][i].cost == 0){
				if(dist[p] < dist[j]){
					dist[j] = dist[p];
					dq.push_front(j);
				}
			}else{
				if(dist[p] + 1 < dist[j]){
					dist[j] = dist[p] + 1;
					dq.push_back(j);
				}
			}
		}
	}
	cout << dist[0] + 1 << "\n";
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll H,W;
vector <string> S;
vv_ll P;
int main(){
  //TEST=true;
  MOD = 1000000007;
  cin >> H >> W;
  S.assign(H+10,"");
  P.assign(H+10,v_ll(W+10,0));
  for (ll i=0;i<H;i++){
    cin >> S[i];
  }
  for (ll i=0;i<H;i++){
    ll p=1;
    for (ll j=0;j<W;j++){
      if (S[i][j]=='#'){
        p=1;P[i][j]+=0;
      }
      if (S[i][j]=='.'){
        P[i][j]+=p;p++;
      }
    }
  }
  for (ll i=0;i<H;i++){
    ll p=1;
    for (ll j=W-1;j>=0;j--){
      if (S[i][j]=='#'){
        p=1;P[i][j]+=0;
      }
      if (S[i][j]=='.'){
        P[i][j]+=p;p++;
      }
    }
  }
  for (ll j=0;j<W;j++){
    ll p=1;
    for (ll i=0;i<H;i++){
      if (S[i][j]=='#'){
        p=1;P[i][j]+=0;
      }
      if (S[i][j]=='.'){
        P[i][j]+=p;p++;
      }
    }
  }
  for (ll j=0;j<W;j++){
    ll p=1;
    for (ll i=H-1;i>=0;i--){
      if (S[i][j]=='#'){
        p=1;P[i][j]+=0;
      }
      if (S[i][j]=='.'){
        P[i][j]+=p;p++;
      }
    }
  }
  ll ans = 0;
  for (ll j=0;j<W;j++){
    for (ll i=0;i<H;i++){
      if (P[i][j]>ans){ans=P[i][j];}
    }
  }
  cout << ans-3 << endl;
}


Measured memory_bytes: 38016
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val s = scala.io.StdIn.readLine
  var cnt = 0
  (0 to s.length - 3).foreach { i =>
    if (s(i) == 'A' && s(i + 1) == 'B' && s(i + 2) == 'C')
      cnt += 1
  }
  println(cnt)
}


Measured memory_bytes: 25544
import math
n=int(input())
ceil=math.ceil(math.sqrt(n))
def f(a,b):
  return max(len(str(a)),len(str(b)))
tmp=10**9
for a in range(1,ceil+1):
  if n%a==0:
    b=n//a
    tmp=min(tmp,f(a,b))
print(tmp)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func trace(A []int, n int) {
	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", A[i])
	}
	fmt.Printf("\n")
}

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

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	count := 0
	for i := 0; i <= N-1; i++ {
		for j := N - 1; j >= i+1; j-- {
			if A[j] < A[j-1] {
				A[j], A[j-1] = A[j-1], A[j]
				count++
			}
		}
	}
	trace(A, N)
	fmt.Println(count)
}



Measured memory_bytes: 1120