akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<998244353>;
struct Combination {
    int N;
    //using mint = ModInt<1000000007>;
    //using mint = ModInt<998244353>;
    vector<mint> fact,ifact,invs;
    Combination(int N): N(N) {
        fact.resize(N + 1); ifact.resize(N + 1);
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        for (int i = 2;i < N + 1;++i) {fact[i] = fact[i - 1] * i;}
        ifact[N] = fact[N].inverse();
        for (int i = N;i >= 1;--i) {ifact[i - 1] = ifact[i] * i;}
    }
    void invs_build() {
        invs.resize(N + 1);
        invs[1] = 1;
        for (int i = 2;i < N + 1;++i) invs[i] = fact[i] * ifact[i - 1];
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n - k];
    }
    mint npk(int n,int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n - k];
    }
};

int main() {
    ll N,A,B,K; cin >> N >> A >> B >> K;
    Combination comb(N);
    mint ans = 0;
    rep(i,2*N + 1) {
        if((K - A*i)%B == 0) {
            ll x = i,y = (K - A*i)/B;
            ans += comb(N,x) * comb(N,y);
        }
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    char b;
    cin >> b;

    char ans;
    if (b == 'A') ans = 'T';
    else if (b == 'T') ans = 'A';
    else if (b == 'G') ans = 'C';
    else if (b == 'C') ans = 'G';

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string s; cin >> s; int len = s.length();
	int start, end;
	Rep(i, len){
		if(s[i] == 'A'){
			start = i;
			break;
		}
	}
	Rrep(i, len){
		if(s[i] == 'Z'){
			end = i;
			break;
		}
	}
	cout << end - start + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import math

def isprime(n):
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
    
    return True

N = int(input())
lst = []
j = 0

for i in range(N):
  d = int(input())
  if isprime(d):
    j += 1

print(j)


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

int main() {
	int w, h;
	do {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(i == 0 || i == (h - 1)  || j == 0 || j == (w - 1))
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	} while (true);
	return 0;
}


Measured memory_bytes: 3104
#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(){
    int n, d, x;
    cin >> n >> d >> x;

    int l, cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> l;
        int day = 1, j = 1;
        while(day <= d){
            day = j*l + 1;
            cnt++;
            j++;
        }
    }
    cout << cnt+x << endl;
    return 0;
}

Measured memory_bytes: 256
n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
total = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        r = 0
        for k in range(0,d):
            r += (x[i][k] - x[j][k])**2
        if (r**0.5).is_integer():
            total += 1
print(total)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)  (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007

double tick() {
	static clock_t oldt; clock_t newt = clock(); double diff =

		1.0*(newt - oldt) / CLOCKS_PER_SEC; oldt = newt; return diff;
}
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) {
	return (x%mod * 1LL * y%mod) %

		mod;
}
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}


int main()
{
	int n;
	cin >> n;
	set<int>s;
	rep(i, n) {
		int a;
		cin >> a;
		s.insert(a);
	}
	if (s.size() == n) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};

ll N, K;
string S;
// first: 0 なら false second: 連続する数
vector< pair<bool, ll> > a_s;

signed main()
{
    cin >> N >> K >> S;
    bool isOne = true;
    if(S[0] == '0') { isOne = false; }

    // 0 と 1 を連続する数で座標圧縮
    ll cur = 0;
    char prev = S[0];
    REP(i, S.length()) {
        if(S[i] != prev) {
            a_s.push_back({isOne, cur});
            isOne = !isOne;
            cur = 1;
        }
        else {
            cur++;
        }
        prev = S[i];
    }
    a_s.push_back({isOne, cur});

    CumulativeSum<ll> cs(a_s.size());       // 0 のとき 1
    CumulativeSum<ll> cs_val(a_s.size());   // 座圧を累積和でもつ
    REP(i, a_s.size()) {
        if(!a_s[i].first) { cs.Add(i, 1); }
        cs_val.Add(i, a_s[i].second);
    }
    cs.Build();
    cs_val.Build();

    // しゃくとり法
    ll ans = 0;
    ll lb = 0, rb = 0;
    while( lb <= rb ) {
        ans = max(ans, cs_val.Query(lb, rb));
        // 0 の区間が K 個をこえないなら右側を、そうでないなら左側を増やす
        if(rb < a_s.size() && cs.Query(lb, rb+1) <= K) { rb++; }
        else { lb++; }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template <class T> void swap(T& a, T& b) { T t = std::move(a); a = std::move(b); b = std::move(t); }

int main(void)
{
    string S;
    int i;

    cin >> S;

    if(S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else if (n == 2){
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    

    return 0;
}

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

int main (){
    ll N, A, B;
    cin>>N>>A>>B;
    if((A-B)%2==0){
      	if(A>=B){
          cout<<(A-B)/2<<endl;
        }
      	else{
          cout<<(B-A)/2<<endl;
        }
      
    }
    else{
        ll J=(A+B-1)/2;
      	ll K=(2*N-A-B+1)/2;
      	cout<<min(J, K)<<endl;
    }
}

Measured memory_bytes: 256
//Bismillahir Rahman-ir Rahim
//codermehraj@gmail.com
#include <bits/stdc++.h>
using namespace std;

bool kmneki(int a,int b){
	return a>b;
}

int main()
{  
    int m,n,sum=0;
    cin>>n>>m;
    int ar[n+1];
    for(int i=0;i<n;i++){
    	cin>>ar[i];
    	sum+=ar[i];
    }
    sum=ceil((double)((double)sum/(double)(4*m)));
    sort(ar,ar+n,kmneki);
    for(int i=0;i<m;i++){
    	if(ar[i]<sum){
    		cout<<"No\n";
    		return 0;
    	}
    }
    cout<<"Yes\n";
    return 0;
}


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

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

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $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! {a: i64, b: i64, c: i64, k:i64}
    if a == k {
        println!("{}", a);
        return;
    } else if a > k {
        println!("{}", k);
        return;
    }
    let k = k - a;
    if b >= k {
        println!("{}", a);
        return;
    }
    let k = k - b;
    println!("{}", a - k);
}


Measured memory_bytes: 2136
from collections import Counter

N, *A = map(int, open(0).read().split())

s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = s[i] + A[i]
    
ctr = Counter(s[1:])
ans = ctr[0]
for v in ctr.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 103244
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, a[N];
long long ans;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	n *= 3;
	for(int i = 1; i <= n; i++)
		scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n/3; i++)
		ans += a[n - 2*i + 1];
	printf("%lld\n", ans);
	return 0;
}

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

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

  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }

  sort(a.begin(), a.end());

  for (int i = 0; i < n; i++) cout << a[i].second << " ";
  cout << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int k,num;
long long ans=1,p=1;
long long f(long long  x)
{
	if(x==0) 
		return 0;
	else 
		return x%10+f(x/10);
}
int main(){
    cin>>k;
    while(num<k){
        cout<<ans<<endl;
        long long ans1=ans+p;
        long long ans2=ans+p*10;
        if( ans1*f(ans2) <= ans2*f(ans1) )
			ans=ans1;
        else
		{
			ans=ans2;
			p*=10;
		}
        num++;
    }
    return 0;
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int H,W,N;
  cin >> H >> W >> N;
  
  VI a(N);
  REP(i,N){
    cin >> a.at(i);
  }
  
  VVI b(H,VI(W));
  
  int t=0;
  REP(i,H) {
    REP(j,W) {
      if(a.at(t) == 0)t++;
      b.at(i).at(j) += t+1;
      a.at(t)--;
      
    }
  }
  
  REP(i,H) {
    REP(j,W) {
      if (i%2) cout <<  b.at(i).at(j);
      else cout <<  b.at(i).at(W-1-j);
      
      if(j+1 != W) cout << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int q,x,ara[10][10],i,j;
    for(i=1; i<=3; i++)
    {
        for(j=1; j<=3; j++)
            cin>>ara[i][j];
    }
    cin>>q;
    for(int que=1; que<=q; que++)
    {
        cin>>x;
        int flag=0;
        for(i=1; i<=3; i++)
        {
            for(j=1; j<=3; j++)
            {
                if(ara[i][j]==x)
                {
                    ara[i][j]=-1;
                }
            }
        }
    }
    /*for(i=1; i<=3; i++)
    {
        for(j=1; j<=3; j++)
        {
            cout<<ara[i][j]<<' ';
        }
        puts("");
    }*/
    if(ara[1][1]==-1 && ara[1][2]==-1 && ara[1][3]==-1)
        cout<<"Yes"<<endl;
    else if(ara[2][1]==-1 && ara[2][2]==-1 && ara[2][3]==-1)
        cout<<"Yes"<<endl;
    else if(ara[3][1]==-1 && ara[3][2]==-1 && ara[3][3]==-1)
        cout<<"Yes"<<endl;
    else if(ara[1][1]==-1 && ara[2][2]==-1 && ara[3][3]==-1)
        cout<<"Yes"<<endl;
    else if(ara[1][3]==-1 && ara[2][2]==-1 && ara[3][1]==-1)
        cout<<"Yes"<<endl;
    else if(ara[1][1]==-1 && ara[2][1]==-1 && ara[3][1]==-1)
        cout<<"Yes"<<endl;
    else if(ara[1][2]==-1 && ara[2][2]==-1 && ara[3][2]==-1)
        cout<<"Yes"<<endl;
    else if(ara[1][3]==-1 && ara[2][3]==-1 && ara[3][3]==-1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);

long a=sc.nextLong();
long b=sc.nextLong();
long c=sc.nextLong();
long d=c-a-b;
if(d>0 && (d*d)>(4*a*b))
System.out.println("Yes");
else
System.out.println("No");



}
}

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

int main() {
  int A = 0, B = 0;
  
  cin >> A >> B;
  
  if ((A % 2 == 1)&&(B % 2 == 1)) { //どちらも奇数のときのみ積も奇数
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll) 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1000005;

int main() {
    FAST
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll mx=arr[0];
    ll ans=0;
    for(int i=1;i<n;i++){
        if(arr[i]<arr[i-1])
        {
            ans+=abs(arr[i]-mx);
            arr[i]=mx;
        }
        mx=max(mx,arr[i]);
    }
    cout<<ans<<endl;

    return 0;
}


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

using ld=double;
const ld INF=1e15;
ld solve(int n){
    vector<ld> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];

    set<pair<ld,ld>> ps;
    for(int i=0;i<n;i++){
        ps.insert({x[i],y[i]});
        for(int j=0;j+1<n;j++){
            if(y[j]==y[j+1]) continue;            
            if(min(y[j],y[j+1])<=y[i] && y[i]<=max(y[j],y[j+1])){
                ld px=(x[j+1]-x[j])*(y[i]-y[j])/(y[j+1]-y[j])+x[j];
                ps.insert({px,y[i]});
            }
        }
    }
    
    vector<ld> tx,ty;
    for(auto &e:ps) tx.push_back(e.first),ty.push_back(e.second);
    ps.clear(),x.clear(),y.clear();
    int tn=tx.size();
    vector<map<int,ld>> d(tn);
    d[0][tn-1]=0;
    using Item=pair<ld,pair<int,int>>;
    priority_queue<Item,vector<Item>,greater<>> que;
    auto push=[&](int i,int j,ld v){
        if(!d[i].count(j) || v<d[i][j]){
            d[i][j]=v;
            que.push({v,{i,j}});
        }
    };
    auto isRange=[&](int i){
        return 0<=i && i<tn;
    };
    auto dist=[&](int f,int t){
        return sqrt((tx[t]-tx[f])*(tx[t]-tx[f])+(ty[t]-ty[f])*(ty[t]-ty[f]));
    }; 
    auto trans=[&](int i,int j){
        for(int di=-1;di<=1;di++){
            for(int dj=-1;dj<=1;dj++){
                if(isRange(i+di) && isRange(j+dj)){
                    if(ty[i+di]==ty[j+dj]) push(i+di,j+dj,d[i][j]+dist(i,i+di)+dist(j,j+dj));
                }
            }
        }
    };

    que.push({ld(0),{0,tn-1}});
    while(!que.empty()){
        auto ret=que.top(); que.pop();
        int i=ret.second.first,j=ret.second.second;
        if(i==j) return ret.first;
        if(d[i][j]<ret.first) continue;
        trans(i,j);
    }
    
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<fixed<<setprecision(10);
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5248
'''
Created on 2020/08/17

@author: harurun
'''

def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  mod=1000000000000000000

  A,B,C,K=map(int,pin().split())
  if abs(A-B)>mod:
    print("Unfair")
  elif K%2==0:
    print(A-B)
  else:
    print(B-A)

main()

Measured memory_bytes: 9036
//C - Count Order

#include <iostream>
#include<algorithm>

using namespace std;

const string np = "12345678";

int main()
{
    int n;

    cin >> n;

    string p = "";
    string q = "";
    
    string per = np.substr(0, n);

    string t;
    for(int i=0; i<n; i++) {
        cin >> t;
        p = p + t;
    }

    for(int i=0; i<n; i++) {
        cin >> t;
        q = q + t;
    }
    
    int pPos = 0;
    int qPos = 0;
    int cnt = 0;

    do{
        cnt++;

        if (per == p) pPos = cnt;
        if (per == q) qPos = cnt;

        if ((pPos > 0) && (qPos > 0)) break;

    }while(next_permutation(per.begin(), per.end()));
    
    cout << abs(pPos - qPos) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){

  int sum;
  char m;

  while(1){
    sum = 0;
    scanf("%c", &m);
    if(m=='0') break;
    while(m != '\n'){
      sum += m-48;
      scanf("%c", &m);
    }
    printf("%d\n", sum);
  }

  return 0;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();

    int[][] points = new int[n][d];
    int count = 0;

    for (int i = 0; i < n; ++i) {

      for (int j = 0; j < d; ++j)
        points[i][j] = sc.nextInt();

      for (int j = 0; j < i; ++j) {
        double dist = 0;

        for (int k = 0; k < d; ++k)
          dist += Math.pow(points[i][k] - points[j][k], 2);

        dist = Math.sqrt(dist);
        if (Math.round(dist) == dist)
          ++count;
      }
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
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 D, N;
    cin >> D >> N;
    int cnt = 0;
    //int k = pow(100, D) + 0.5;
    //dump(k);
    REP(i, 1, 10000000) {
        int num = i;
        int cnt100 = 0;
        while(num % 100 == 0) {
            cnt100++;
            num /= 100;
        }
        if (cnt100 == D) cnt++;
        if (cnt == N) {
            cout << i << endl;
            return 0;
        } 
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ac = 0
bc = 0
for i in range(N):
    if a[i] < b[i]:
        ac += (b[i] - a[i]) // 2
    else:
        bc += a[i] - b[i]
if ac >= bc:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 73852
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	int r, D, x;
	int ans[20];
	cin >> r >> D >> x;
	ans[0] = x;

	for (int i = 1; i < 11; i++)
	{
		ans[i] = r * ans[i - 1] - D;
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

inputs = [ input().split() for _ in range(m) ]

collectNum = 0
penaltyNum = 0


# AC前にWAを出した回数をカウントする　ACで'-1'にしてそれ以上カウントしない
waCounts = [0] * (n+1)

for inp in inputs:
    questNum = int(inp[0])
    result = inp[1]

    if waCounts[questNum] != -1:
        if result == 'AC':
            collectNum += 1
            penaltyNum += waCounts[questNum]
            waCounts[questNum] = -1
        elif result == 'WA':
            waCounts[questNum] += 1

print("{} {}".format(collectNum, penaltyNum))



Measured memory_bytes: 32912
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys

N = int(input())
S = input()

ans = 0
for i in range(10):
    code1 = S.find(str(i))
    if code1 == -1:
        continue
    for j in range(10):
        code2 = S.find(str(j), code1 + 1)
        if code2 == -1:
            continue
        for k in range(10):
            if S.find(str(k), code2 + 1) != -1:
                ans += 1

print(ans)


Measured memory_bytes: 38440
import sys
sys.setrecursionlimit(100000000)
S = int(input())

mod = 10**9+7

def dfs_memo(n):
    memo = [0]*(n+1)
    memo[3] = 1

    def dfs(n):
        if n < 3:
            return 0
        if memo[n] != 0:
            return memo[n]
        memo[n] = dfs(n-1)+dfs(n-3)
        return memo[n]
    return dfs(n)

if S <3:
    print(0)
else:
    print(dfs_memo(S)%mod)

Measured memory_bytes: 10720
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int x,y, z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from collections import defaultdict

    n = int(readline())
    dp = [0] * (n + 1)
    dp[0] = 1
    memo = defaultdict(int)
    mod = 10 ** 9 + 7
    for i in range(1, n + 1):
        c = int(readline())
        dp[i] = dp[i - 1]
        if 0 < memo[c] < i - 1:
            dp[i] += dp[memo[c]]
        memo[c] = i
        dp[i] %= mod
    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 37148
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n, h;
    cin >> n;
    int ct[130];
    for (int i = 0; i < 130; ++i)
        ct[i] = i * 4 + 4;
    long long sm = 1;
    while (n--) {
        cin >> h;
        sm += h;
        for (int i = 0; i < min(130, h); ++i)
            ct[i] ? --ct[i] : --sm;
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main(void) {
	string s;
    cin >> s;
    int count = 0;
    char num;

	for(int i = 0; i < s.length(); i++) {
        num = (i % 2 == 0 ? '0' : '1');
		if ((char)s[i] == num) {
            count++;
        }
    }
    int result = min(count, (int)s.length()-count);
    cout << result << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int N,A[1000],a,b,c;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a>>b>>c;
		if (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b)
		{
			A[i] = 1;
		}
		else
		{
			A[i] = 0;
		}
	}
	for (int j = 0; j < N; j++)
	{
		if (A[j] == 1)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
const int M=100000+5;
int main(){
	int N,t;
	cin >> N;
	int a[M]={0};
	for(int i=0;i<N;i++){
		scanf("%d",&t);
		a[t]++;
	}
	int max=a[0]+a[1];
	for(int i=1;i<M-1;i++){
		if(max<(a[i-1]+a[i]+a[i+1])) max=a[i-1]+a[i]+a[i+1];
		if(i==M-1 && max<a[M-2]+a[M-1]) max=a[M-2]+a[M-1];
		
	}
	printf("%d",max);
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(auto& e : p) cin >> e;
    sort(begin(p), end(p));
    cout << accumulate(begin(p), begin(p) + k, 0) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
int inf = 6000000000000;
vel dijk(vvel &way, vel &cost, int s) {
	int n = way.size(); int m = 7 * n;
	vel ans(m, inf);
	priority_queue<pin, vector<pin>, greater<pin>> que;//cost,pla
	que.push(mkp(0,s));
	while (!que.empty()) {
		pin x = que.top(); que.pop();
		int pla = x.second;
		if (ans[pla] == inf) {
			int sum_cost = x.first;
			ans[pla] = sum_cost;
			int nex_cost = sum_cost + cost[pla];
			int mod = nex_cost % 7;
			for (auto x : way[pla/7]) {
				que.push(mkp(nex_cost, x * 7 + mod));
			}
		}
	}
	return ans;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int sol(int a, int b, int c, int d) {
	return abs(a*c - b * d);
}
signed main(){
	vel ans(101, 0);
	rep(i, 4) {
		int e; cin >> e;
		ans[e]++;
	}
	rep(i, 101) {
		if (ans[i] % 2 == 1) { cout << "no" << endl; return 0; }
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 3720
import math
n,k=map(int,input().split())
if n < k:
  ans = 0
  for i in range(1,n+1):
    j = math.ceil(math.log2(k)-math.log2(i))
    ans += (0.5)**j / n
else:
  ans = 1
  for i in range(1,k+1):
    j = math.ceil(math.log2(k)-math.log2(i))
    ans -= (1 - (0.5)**j) / n
print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;
    if(n%2==0)n--;
    ll d=(n-1)/2;
    cout << "1 " << 1+d << "\n";ll l=n;ll r=2;ll t=0;m--;
    if(!m)return 0;
    while(--d and m--)
    {
        if(t==0)
        {
            cout << l << " " << l-d << "\n";
            t=1;l--;
        }
        else
        {
            cout << r << " " << r+d << "\n";
            t=0;r++;
        }
    }
    }

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}
	vector<bool> good(n, true);
	for (int i = 0; i < m; i++) {
		int a_in, b_in;
		cin >> a_in >> b_in;
		if (h.at(a_in - 1) <= h.at(b_in - 1)) {
			good.at(a_in - 1) = false;
		}
		if (h.at(b_in - 1) <= h.at(a_in - 1)) {
			good.at(b_in - 1) = false;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (good.at(i) == true) {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3792
#include<stdio.h>
long long a,b,c,d,ans;
int main()
{
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    ans=a*c;
    if(ans<a*d)
    {
        ans=a*d;
    }
    if(ans<b*c)
    {
        ans=b*c;
    }
    if(ans<b*d)
    {
        ans=b*d;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1732
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;
    long cnt;

    private void solve() {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        cnt = 0;
        shellSort(A, N);

        System.out.println(cnt);

        for (int num : A) {
            System.out.println(num);
        }

    }

    void insertionSort(int[] A, int n, int g) {
        for (int i = g; i < n; i++) {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v) {
                A[j + g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j + g] = v;
        }
    }

    void shellSort(int[] A, int n) {
        int h = 1;
        List<Integer> G = new ArrayList<Integer>();
        while (true) {
            if (h > n) {
                break;
            }
            G.add(h);
            h = 3 * h + 1;
        }
        System.out.println(G.size());

        // String ans = "";
        // for (int i = G.size() - 1; i >= 0; i--) {
        // ans += G.get(i);
        // ans += " ";
        // }
        // System.out.println(ans.trim());

        StringBuilder sb = new StringBuilder();
        for (int i = G.size() - 1; i >= 0; i--) {
            sb.append(G.get(i));
            sb.append(" ");
        }
        System.out.println(sb.toString().trim());

        for (int i = G.size() - 1; i >= 0; i--) {
            insertionSort(A, n, G.get(i));
        }
    }
}

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


int main(){
   int a,b,c,x,y;
   long long sum = 0;
   cin >> a >> b >> c >> x >> y;
    
     if (c*2<a || c*2 <b){ 
         if (c*2>a && x>y){
             sum += (c*2*y)+(a*(x-y));
         }
        else if (c*2>b && y>x){
             sum += (c*2*x)+(a*(y-x));
         }
        else
        {
             sum += c*2*max(x,y);
        }
        
    }
    else if (a+b > c*2){
        if (x > y){
            sum += c * 2 * y;
            sum += a * (x - y);
        }
        else
        {
            sum += c * 2 * x;
            sum += b * (y - x);
        }
    }
    else{
        sum += (a * x) + (b * y);
    }    
    cout << sum << endl;
          
   
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 
  int N,x,i,j,B=0,C=1,flag=0;
 
  scanf("%d",&N);
 
  for(i=0;i<N;i++){
      flag=0;
      B=0;
      C=1;
      for(j=0;j<10;j++){
      scanf("%d",&x);
      if(B>C && x>B)B=x;
      else if(B>C && x<B && x>C)C=x;
      else if(B<C && x>C)C=x;
      else if(B<C && x<C && x>B)B=x;
      else {flag=1; break;}
    }
      if(flag)printf("NO\n");
      else printf("YES\n");
}
 
  return 0;
}

Measured memory_bytes: 580
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, long long M, std::vector<long long> A){
	LL s=0;
	for(auto a:A){
		s+=a;
	}
	cout << max(-1LL,N-s) << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3336
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt() - 1;
			int P = sc.nextInt();
			int all = 0;
			int win = 0;
			for (int i = 0; i < N; ++i) {
				int X = sc.nextInt();
				all += X;
				if (i == M) win = X;
			}
			System.out.println(win == 0 ? 0 : (all * 100 - all * P) / win);
		}
	}
}

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

using namespace std;

int N, A, B, C;
vector<int> L;

int brute(int i, int a, int b, int c) {
  int res = 0;
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) return 1e9;
    return abs(A-a) + abs(B-b) + abs(C-c);
  }
  res = min({brute(i+1, a+L[i], b, c)+(a==0?0:10), 
            brute(i+1, a, b+L[i], c)+(b==0?0:10), 
            brute(i+1, a, b, c+L[i])+(c==0?0:10), 
            brute(i+1, a, b, c)});
  return res;

}

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

  cin >> N >> A >> B >> C;
  L.resize(N);
  for (auto &l : L) cin >> l;

  cout << brute(0, 0, 0, 0) << endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  int n, k, ko, x;
 
  scanf("%d%d",&n,&k);
 
  for(x=1,ko=k;n>=k;x++){
    k=k*ko;
  }
     
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 128
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 4*1e5+5;
const int LG = 25;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------


int main(){
    fastio;
    string s;
    cin>>s;
    ll cont = 0;
    f(i,0,s.size()){
        if(i&1){
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') cont;
            else {cout<<"No"<<endl;return 0;}
        }
        else{
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') cont;
            else {cout<<"No"<<endl;return 0;}
        }
        
    }

	cout<<"Yes"<<endl;

}

Measured memory_bytes: 3652
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	s := 0
	for m := n; m > 0; m /= 10 {
		s += m % 10
	}

	if n % s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
N = int(input())
before = ''
words = []
ans = 'Yes'
for idx in range(N):
  word = input()
  if idx == 0:
    before = word[0]
  if word in words or word[0] != before[-1]:
    ans = 'No'
    break
  words.append(word)
  before = word
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

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

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=1,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
 cin >> a >> b;
 if(a+b >= 10) cout << "error";
 else cout << a+b;
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

int main() {

  while ( true ) {
	int n, r;
	cin >> n >> r;

	if ( cin.eof() ) break;

	deque<int> A, B, C;
	for ( int i = 0; i < n; i++ ) {
	  C.push_back( i );
	}

	const int size_b = n / 2;
	const int size_a = n - size_b;
  
	for ( int i = 0; i < r; i++ ) {
	  int c;
	  cin >> c;
	  for ( int j = 0; j < size_b; j++ ) {
		B.push_back( C.front() );
		C.pop_front();
	  }
	  for ( int j = 0; j < size_a; j++ ) {
		A.push_back( C.front() );
		C.pop_front();
	  }

	  bool fin_a = false, fin_b = false;
	  while ( not fin_a or not fin_b ) {
		if ( not fin_a ) {
		  const int size = A.size() < c ? A.size() : c;
		  for ( int j = 0; j < size; j++ ) {
			C.push_back( A.front() );
			A.pop_front();
		  }
		  if ( A.empty() ) {
			fin_a = true;
		  }
		}
		if ( not fin_b ) {
		  const int size = B.size() < c ? B.size() : c;
		  for ( int j = 0; j < size; j++ ) {
			C.push_back( B.front() );
			B.pop_front();
		  }
		  if ( B.empty() ) {
			fin_b = true;
		  }
		}
	  }	
	}
	cout << C.at( n - 1 ) << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<double> vec(n);
  for (int i = 0; i < n;i++){
  cin >> vec.at(i);
  }
  double l = 0;
 for (int i = 0; i < n; i++){
  l += (1 / vec.at(i)) ;
  }
  cout << 1 / l;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include "math.h"

int main(int argc, char const *argv[]){
	int fig_1,fig_2;
	std::vector<int> dig;

	while(std::cin >> fig_1 >> fig_2){
		dig.push_back(log10(fig_1+fig_2)+1);
	}

	for (int i = 0; i < dig.size(); ++i){
		std::cout << dig[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3336
#include<cstdio>
#include<algorithm>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
typedef long long LL;
const int maxn=100000;

int X,Y,Z,n;LL ans,now,C;
struct data {int a,b,c;bool operator < (const data &c) const {return b-a<c.b-c.a;}};
data a[maxn+5];bool vis[maxn+5];
int ss,sb,Hs[maxn+5];pair<int,int> Hb[maxn+5];

#define Eoln(x) ((x)==10||(x)==13||(x)==EOF)
inline char readc()
{
	static char buf[100000],*l=buf,*r=buf;
	if (l==r) r=(l=buf)+fread(buf,1,100000,stdin);
	if (l==r) return EOF;return *l++;
}
inline int readi(int &x)
{
	int tot=0,f=1;char ch=readc(),lst='+';
	while ('9'<ch||ch<'0') {if (ch==EOF) return EOF;lst=ch;ch=readc();}
	if (lst=='-') f=-f;
	while ('0'<=ch&&ch<='9') tot=(tot<<1)+(tot<<3)+ch-48,ch=readc();
	return x=tot*f,Eoln(ch);
}
#define Push_s(x) Hs[++ss]=(x),push_heap(Hs+1,Hs+1+ss)
#define Pop_s() pop_heap(Hs+1,Hs+1+ss--)
#define Push_b(x,ID) Hb[++sb]=mp((x),(ID)),push_heap(Hb+1,Hb+1+sb)
#define Pop_b() pop_heap(Hb+1,Hb+1+sb--)
int main()
{
	readi(X);readi(Y);readi(Z);n=X+Y+Z;
	for (int i=1;i<=n;i++) readi(a[i].a),readi(a[i].b),readi(a[i].c),C+=a[i].c;
	sort(a+1,a+1+n);for (int i=X+1;i<=n;i++) Push_b(a[i].b-a[i].c,i);
	for (int i=1;i<=Y;i++) now+=Hb[1].fr,vis[Hb[1].sc]=true,Pop_b();
	for (int i=1;i<=X;i++) now+=a[i].a-a[i].c,Push_s(a[i].c-a[i].a);ans=now;
	for (int i=X+1;i<=n-Y;i++)
	{
		if (a[i].c-a[i].a<Hs[1]) now+=(LL)Hs[1]+a[i].a-a[i].c,Pop_s(),Push_s(a[i].c-a[i].a);
		if (vis[i])
		{
			while (vis[Hb[1].sc]) Pop_b();vis[Hb[1].sc]=true;
			now+=(LL)Hb[1].fr-a[i].b+a[i].c;Pop_b();
		}
		vis[i]=true;ans=max(ans,now);
	}
	return printf("%lld\n",ans+C),0;
}

Measured memory_bytes: 2304
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
if n == 1:
    print(a[0] // 2)
else:
    for i in range(0, n):
        res += a[i] // 2
        if i != n - 1 and a[i] % 2 == 1 and a[i + 1] != 0:
            res += 1
            a[i + 1] -= 1
    print(res)


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(int i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p=100,t;
    cin>>n;
    for(int i=1;1;i++){
    	p=p+(p/100);
    	if(p>=n) {
    	   t=i;
    	   break;
    	}
    }
    cout<<t;
    return 0;
}


Measured memory_bytes: 3648