akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long A = fs.nextLong();
        long B = fs.nextLong();

        long C = A * B;

        Set<Long> s = new HashSet<>();
        for (long i = A; i <= C; i+=A) {
            s.add(i);
        }

        for (long i = B; i <= C; i+=B) {
            if (s.contains(i)) {
                System.out.println(i);
                break;
            }
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

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

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

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

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




Measured memory_bytes: 43588
N = int(input())

a_N = []
a_N = [int(i) for i in input().split(" ")]
# 別の標準入力
# a = list(map(int, input().split()))

num = 0

while(1):
	for i in range(N):
		if(a_N[i] % 2 != 0):
			break
		a_N[i] /= 2
	else:
		num += 1
		continue
	break

print(num)

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

const ll INF = 1ll << 60;
ll MOD = 2019;

int main()
{

    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    REP(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    vector<int> x(n, 0);
    int dsum = 0;

    for (int i = 1; i < n; i += 2)
    {
        dsum += a[i];
    }
    x[0] = sum - 2 * dsum;

    for (int i = 0; i < n; ++i)
    {
        if (i != n - 1)
            x[i + 1] = 2 * a[i] - x[i];
    }

    REP(i, n)
    printf("%d%c", x[i], i != n - 1 ? ' ' : '\n');

    return 0;
}

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

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

using namespace std;

int main(){
	int x; scanf("%d",&x);
	rep(k,1001) if(x-100*k>=0 && (x-100*k+4)/5<=k) return puts("1"),0;
	puts("0");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

#define MOD 1000000007
#define M 13

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<vector<ll>> dp(N+1, (vector<ll>(M)));
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, M) {
            if (S[i] != '?') {
                int tmp = (j*10 + (int)(S[i]-'0')) % M;
                dp[i+1][tmp] += dp[i][j];
                dp[i+1][tmp] %= MOD;
                continue;
            }
            rep(k, 10) {
                int tmp = (j*10 + k) % M;
                dp[i+1][tmp] += dp[i][j];
                dp[i+1][tmp] %= MOD;
            }
        }
    }
    cout << dp[N][5] << endl;
}


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

#define ll long long
#define fore(i, n) for(i=0;i<n;i++)

template<typename T>
void output_vector(const vector<T>&v, int start=-1, int end=-1)
{
	if(start<0)start=0;
	if(end<0)end=v.size();
	
	for (int i = start; i < end; i++)
        cout << v[i]<<"\n";
}

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    ll sum=0;
    for(int i=0;i<s.length(); i++)
        sum+=s[i]-'0';
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ld ans = 0;

    rep(i, n) {
        ld x;
        cin >> x;
        string u;
        cin >> u;
        if (u == "BTC") x *= 380000.0;
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		String s,s1;
		s=sc.next();
		s1=sc.next();
		int t,f=0;
		if(((s1.length()-s.length()) ==1) && (Character.isLetter(s1.charAt(s1.length()-1))))
		{
		    for(t=0;t<s.length();t++)
		    {
		        if(s.charAt(t) != s1.charAt(t))
		        f=1;
		    }
		    if(f==0)
		    {
		        System.out.println("Yes");
		    }
		    else{
		        System.out.println("No");
		    }
		}
		else{
		    System.out.println("No");
		    
		}
		    
		    
		}
}


Measured memory_bytes: 35712
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n,k;
	cin >> n >> k;
	
	ll ans = 0;
	
	for(int b=k+1; b<=n; b++){
		ans += ((n+1)/b)*(b-k);
		if(k==0) ans--;
		if(n%b < b-1) ans += max(0, n%b + 1 - k);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
        public static void main(String[] args) {
            int i=1;
            Scanner sc = new Scanner(System.in);
        while(true){
                int x = sc.nextInt();
                  if(x==0){
                      break;
                   }
                   System.out.printf("Case %d: %d\n",i,x);
                  i++;
                  }
            }
}


Measured memory_bytes: 62724
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> v;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        v[x]++;
    }
    GPQ<int> v2;
    for (auto &&x : v) if(x.second) v2.emplace(x.second);
    int ans = 0;
    int p = (int)v2.size()-k;
    for (int i = 0; i < p; ++i) {
        ans += v2.top(); v2.pop();
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10748
a, b = gets.split.map(&:to_i)
grid = []
50.times { grid << ("." * 100).split("") }
50.times { grid << ("#" * 100).split("") }
0.step(48, 2) do |h|
  break if b <= 1
  0.step(99, 2) do |w|
    break if b <= 1
    grid[h][w] = "#"
    b -= 1
  end
end
51.step(99, 2) do |h|
  break if a <= 1
  0.step(99, 2) do |w|
    break if a <= 1
    grid[h][w] = "."
    a -= 1
  end
end
puts "100 100"
grid.each do |r|
  puts r.join
end


Measured memory_bytes: 2300
s = str(input())

DREAM   = "dream"
DREAMER = "dreamer"
ERASE   = "erase"
ERASER  = "eraser"

pre = ""
while len(s) > 0 and pre != s:
    pre = s[:]
    if s[0] == "d":
        if len(s) <= 5:
            s = s.replace(DREAM, "", 1)
        elif s[5] != "e":
            s = s.replace(DREAM, "", 1)
        else:
            if s.find(ERASE) == len(DREAM):
                s = s.replace(DREAM, "", 1)
            else:
                s = s.replace(DREAMER, "", 1)
    else:
        if s.find(ERASE) == s.find(ERASER):
            s = s.replace(ERASER, "", 1)
        else:
            s = s.replace(ERASE, "", 1)
#    print(s)
if len(s) == 0:
    print("YES")
else:
    print("NO")

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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define pw(x) (1LL<<x)
#define eprintf(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)

#define db(x) cerr << #x << ": " << x << '\n'
#define db2(x, y) cerr << "(" << #x << ", " << #y << "): (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << "): (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto xxxx: a) cerr << xxxx << " "; cerr << '\n'

typedef long long ll;
typedef double dbl;

int bpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {
            res = (ll)res * x % mod;
        }
        x = (ll)x * x % mod;
        n >>= 1;
    }

    return res;
}

int getNum(int n, char* s, int mod) {
    if (mod <= 0) {
        return 0;
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        res = (ll)res * 2 % mod;
        res += s[i] - '0';
        if (res >= mod) {
            res -= mod;
        }
    }

    return res;
}

int f(int n) {
    int res = 0;
    while (n > 0) {
        ++res;
        n %= __builtin_popcount(n);
    }
    return res;
}

vector<int> solve(int n, char* s) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') ++cnt;
    }

    int low = getNum(n, s, cnt - 1);
    int high = getNum(n, s, cnt + 1);
    vector<int> res(n);
    for (int i = 0; i < n; ++i) {
        if (s[i] == '0') {
            int cur = high;
            cur += bpow(2, n - i - 1, cnt + 1);
            if (cur >= cnt + 1) {
                cur -= cnt + 1;
            }
            res[i] = f(cur) + 1;
        } else {
            if (cnt == 1) {
                res[i] = 0;
            } else {
                int cur = low;
                cur -= bpow(2, n - i - 1, cnt - 1);
                if (cur < 0) {
                    cur += cnt - 1;
                }
                res[i] = f(cur) + 1;
            }
        }
    }

    return res;
}

int main() {
    const int N = 2e5 + 5;
    int n;
    scanf("%d", &n);
    static char s[N];
    scanf("%s", s);
    auto res = solve(n, s);
    for (int x: res) {
        printf("%d\n", x);
    }
    return 0;
}


Measured memory_bytes: 4320
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    char S;
    cin >> N;
    int cnt[4] = {};
    REP(i, N) {
        cin >> S;
        if (S == 'P') {
            cnt[0]++;
        } else if (S == 'W') {
            cnt[1]++;
        } else if (S == 'G') {
            cnt[2]++;
        } else {
            cnt[3]++;
        }
    }
    REP(i, 4) {
        if (cnt[i] == 0) {
            cout << "Three" << endl;
            return 0;
        }
    }
    cout << "Four" << endl;
    return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	ll ans = 0;
	for(ll i = 1; i <= N; ++i) {
		ans += i*(N-i+1);
	}
	for(int i = 0; i < N-1; ++i) {
		int u,v; cin >> u >> v;
		if(u>v) swap(u,v);
		ll l = u, r = (N+1)-v;
		ans -= l*r;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
//https://atcoder.jp/contests/abc141/tasks/abc141_b
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    bool hantei = true;
    for(int i=0; i<s.size(); i+=2){
        if(s.at(i) == 'L') hantei=false;
    }
    for(int i=1; i<s.size(); i+=2){
        if(s.at(i) == 'R') hantei = false;
    }
    if(hantei)cout << "Yes" << endl;
    else    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    double A;
    cin>>A;
    double res = A*2*3.1415926535;
    printf("%.10f\n",res);

}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for(int i = 0; i < n; i++)
    {
        if((i + 1) & 1 && s[i] == 'L')
        {
            cout << "No";
            return 0;
        }
        else if(!((i + 1) & 1) && s[i] == 'R')
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


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

using ll = long long;
using pint = pair<int, int>;

const ll INF = 1e12;
const ll MOD = 1e9 + 7;

ll N;
string S;

int main()
{
    cin >> S;
    string A = S;

    ll result1 = 0;
    for (int i = 0; i < A.size() - 1; ++i)
    {
        if (A[i + 1] == A[i])
        {
            if (A[i + 1] == '0')
                A[i + 1] = '1';
            else
                A[i + 1] = '0';

            result1++;
        }
    }

    A = S;
    ll result2 = 0;
    for (int i = A.size() - 1; i > 0; --i)
    {
        if (A[i - 1] == A[i])
        {
            if (A[i - 1] == '0')
            {
                A[i - 1] = '1';
            }
            else
            {
                A[i - 1] = '0';
            }
            result2++;
        }
    }

    cout << min(result1, result2) << endl;
}

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

void solve(){
	char c, b;
	cin >> c;
	b = toupper(c);
	if(c == b) cout << "A\n";
	else cout << "a\n";
}

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;

int main(){
	cin>>n>>k;
	ll t=2*k+2*n-1,S=0;
	for(int i=0;i<n;i++) S+=k+2*n+i;
	if(t*n>S){
		cout<<-1<<endl;
		return 0;
	}
	vl a,b;
	set<int> st;
	ll sa=t-k-2*n;
	for(ll i=0;i<sa;i++){
		a.push_back(k+sa+i);
		if(i<sa-1){
			a.push_back(k+i);
			st.insert(k+i);
		}
		st.insert(k+sa+i);
	}
	for(ll i=k;i<k+n;i++){
		if(st.find(i)==st.end()){
			a.push_back(i);
		}
	}
	for(ll i=n-1;i>=0;i--) b.push_back(k+n+i);
	vpll c(n);
	for(int i=0;i<n;i++){
		c[i]={a[i]+b[i],i};
	}
	sort(c.begin(),c.end());
	vl d(n);
	for(int i=0;i<n;i++){
		d[c[i].second]=k+2*n+i;
	}
	for(int i=0;i<n;i++) cout<<a[i]<<' '<<b[i]<<' '<<d[i]<<endl;
}

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

char s[11], z[5] = "YAKI";

int main(){
	scanf("%s", s);
	f(i, 0, 4)if (s[i] != z[i]) { printf("No\n"); return 0; }
	printf("Yes\n");
}

Measured memory_bytes: 256
S = input()
S2 = S[::-1]
if(S != S2):
  print('No')
else:
  N = len(S)
  sl = S[:(N-1)//2]
  sr = S[(N+1)//2:]
  sl2 = sl[::-1]
  sr2 = sr[::-1]
  if(sl == sl2 and sr == sr2):
    print('Yes')
  else:
    print('No')

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

int main() {
  ll h, w;
  cin >> h >> w;
  
  if (h==1 || w==1) cout << 1 << endl;
  else {
    if (h%2==1 && w%2==1) cout << h*w/2 + 1 << endl;
    else cout << h*w/2 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);
    int cnt=0;
    int a, b;
    for(int i=0; i<N; i++) {
        scanf("%d %d", &a, &b);
        if(a==b) {
            cnt++;
            if(cnt==3) {
                printf("Yes");
                return 0;
            }
        } else cnt=0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1724
import sys
import itertools
import fractions
stdin = sys.stdin

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

N=int(input())
C=nl()
mod=10**9+7
n=0
C.sort()
two=[0]*(N+1)
two[0]=1
for i in range(N):
    two[i+1]=(two[i]*2)%mod
ans=0
for i in range(N):
    l=i
    r=N-1-i
    now=two[r]
    if(r!=0):
        now+=two[r-1]*r
    now*=two[i]
    now*=C[i]
    ans+=now
    ans%=mod

ans*=two[N]
print(ans%mod)
    


Measured memory_bytes: 27504
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> a >> b >> x;   

    if (a > x) cout << "NO" << endl;
    else if( a+b >=x)
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
} 

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

ans = [0] * N

for i in range(N, 0, -1):
  t = 0
  for j in range(i + i, N + 1, i):
    t += ans[j - 1]
  k = t % 2
  if a[i - 1] != k:
    ans[i - 1] = 1

L = []
su = 0
for i in range(N):
  if ans[i] == 1:
    su += 1
    L.append(i + 1)

print(su)
if len(L) != 0:
  print(" ".join(map(str, L)))


Measured memory_bytes: 80488
import java.math.*;
import java.util.*;
import java.lang.Math;
public class Main {
    static int sol(int a, int b) {
        return (int) Math.pow(a - b, 2);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int li[][] = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                int tmp = sc.nextInt();
                li[i][j] = tmp;
            }
        }
        List<Integer> rtli= new ArrayList<>();
        for(int i=0;i<300;i++)
            rtli.add(i * i);
        int tmp = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                for (int k = 0; k < d; k++) {
                    tmp += sol(li[i][k], li[j][k]);
                }
                if (rtli.contains(tmp)){
                    cnt++;
                }
                tmp = 0;
            }
        }
        System.out.println(cnt);
        sc.close();
    }
}


Measured memory_bytes: 22612
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (S*T >= D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main(){
    int k,s,ans=0;
    cin >> k >> s;
    for(int x =0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z<=k && z>=0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	int data[265][2] = {0};  //data[i][0]...x data[i][1]...y
	int x_max, x_min, y_max, y_min;
	int ni, di;
	int i;

	do {
		data[0][0] = data[0][1] = 0;
		x_max = x_min = y_max = y_min = 0;

		scanf("%d", &n);
		if(!n)
			break;

		for(i = 1; i < n; i++) {
			scanf("%d %d", &ni, &di);

			switch(di) {
				case 0:
					data[i][0] = data[ni][0] - 1;
					data[i][1] = data[ni][1];
					break;
				case 1:
					data[i][1] = data[ni][1] - 1;
					data[i][0] = data[ni][0];
					break;
				case 2:
					data[i][0] = data[ni][0] + 1;
					data[i][1] = data[ni][1];
					break;
				case 3:
					data[i][1] = data[ni][1] + 1;
					data[i][0] = data[ni][0];
					break;
			}

			if(data[i][0] > x_max)
				x_max = data[i][0];
			if(data[i][0] < x_min)
				x_min = data[i][0];
			if(data[i][1] > y_max)
				y_max = data[i][1];
			if(data[i][1] < y_min)
				y_min = data[i][1];
		}

		printf("%d %d\n", x_max - x_min + 1, y_max - y_min + 1);
	} while(1);

	return 0;
}

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

// 二分木探索
bool BinarySearch(int num, int A[], int n) {
    int left = 0;
    int right = n;
    int mid;

    // 配列の真ん中より、探す値が
    // 大きいか小さいか等しいかで
    // 調べる範囲を狭めていく
    while(right > left){
        mid = (right + left) / 2;
        // 見つかったら終了
        if (A[mid] == num) {
            return true;
        // 前半を探索
        // A[mid]は等しくない事が保証されているので
        // mid - 1を終了位置とする
        } else if (A[mid] > num) {
            right = mid;
        // 後半を探索
        // A[mid]は等しくない事が保証されているので
        // mid + 1を開始位置とする
        } else if (A[mid] < num) {
            left = mid + 1;
        }
    }
    return false;
}

int main()
{
    static const int MAX = 200000;
    static const int MAX2 = 60000;
    int n, s, R[MAX], S[MAX2],tmp;
    int cnt = 0;

    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> R[i];
    }
    std::cin >> s;
    for (int i = 0; i < s; i++)
    {
        std::cin >> S[i];
    }

    // 各数値があるか線形探索
    for (int m=0; m<s; m++) {
        if (BinarySearch(S[m], R, n)) cnt++;
    }
    std::cout << cnt << "\n";
    return 0;
}


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

using namespace std;

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

  if (s.size() < 4 || s.substr(0, 4) != "YAKI") {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }

  return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A)
{
  if (A.size() == n + 1)
  {
    int now = 0;
    rep(i, q)
    {
      if (A[b[i]] - A[a[i]] == c[i])
        now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m)
  {
    dfs(A);
    A.back()++;
  }
}

int main(void)
{
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}

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

int main()
{
    long long int n,x,y,sum=0;
    string str;
    map<string,long long int>mp;
    cin>>n;
    while(n--)
    {
        cin>>str;sort(str.begin(),str.end());
        mp[str]++;
    }
    map<string,long long int>::iterator it;
    for(it=mp.begin(); it!=mp.end(); it++)
    {
       x=(it->second)-1;
       y=(x*(x+1))/2;
       sum+=y;
    }
    cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;
 
ll dp[100005][5];
 
ll solve(ll a[],ll b[],ll c[], ll idx,ll cc)
{
	if(idx < 0) return 0;
	if(dp[idx][cc] != -1)
		return dp[idx][cc];
	if(cc == 0)
	{
		ll a1 = a[idx] + solve(a,b,c,idx-1,2);
		ll a2 = b[idx] + solve(a,b,c,idx-1,3);
		ll a3 = c[idx] + solve(a,b,c,idx-1,1);
		ll ans = max(max(a1,a2),a3);
		dp[idx][cc] = ans;
		return ans;
	}	
	if(cc == 1)
	{
		ll a1 = a[idx] + solve(a,b,c,idx-1,2);
		ll a2 = b[idx] + solve(a,b,c,idx-1,3);
		ll ans = max(a1,a2);
		dp[idx][cc] = ans;
		return ans;
	}
	if(cc == 2)
	{
		ll a2 = b[idx] + solve(a,b,c,idx-1,3);
		ll a3 = c[idx] + solve(a,b,c,idx-1,1);
		ll ans = max(a2,a3);
		dp[idx][cc] = ans;
		return ans;
	}
	if(cc == 3)
	{
		ll a1 = a[idx] + solve(a,b,c,idx-1,2);
		ll a3 = c[idx] + solve(a,b,c,idx-1,1);
		ll ans = max(a1,a3);
		dp[idx][cc] = ans;
		return ans;
	}
	return 0;
}
int main()
{
	fast;
	ll n; cin>>n;
	ll a[n],b[n],c[n];
	for(ll i = 0; i < n; i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	memset(dp,-1,sizeof(dp));
	cout << solve(a,b,c,n-1,0) << endl;
	return 0;
}

Measured memory_bytes: 17712
N = int(input())

dists = []
while N:
    x, y = map(int, input().split())
    dists.append((x, y, x+y, y-x))
    N -= 1

dists1 = sorted(dists, key=lambda x: x[2])
dists2 = sorted(dists, key=lambda x: x[3])
# dists3 = sorted(dists, key=lambda x: x[4])
ans1 = abs(dists1[0][0] - dists1[-1][0]) + abs(dists1[0][1] - dists1[-1][1])
ans2 = abs(dists2[0][0] - dists2[-1][0]) + abs(dists2[0][1] - dists2[-1][1])

print(max(ans1, ans2))


Measured memory_bytes: 123380
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    inf=10**10
    n,k=map(int,readline().split())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)

    dp=np.full(n,inf,dtype=np.int64)
    dp[0]=0
    for i in range(n-1):
        end=min(n,i+k+1)
        sa=np.abs(h[i]-h[i+1:end])
        dp[i+1:end]=np.minimum(dp[i+1:end],dp[i]+sa)

    print(dp[n-1])

if __name__=="__main__":
    main()

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int n,k;
   cin>>n>>k;
   int ans=0;
   do{
      n/=k;
      ans++;
   }while(n>0);
   cout<<ans;
   


   return 0;
}

Measured memory_bytes: 256
N = int(input())
lst_a = [int(input()) for _ in range(N)]
lst_a.sort()
set_ans = set()


for a in lst_a:
    if a in set_ans:
        set_ans.remove(a)
    else:
        set_ans.add(a)
ans = len(set_ans)


print(ans)

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    dbg_out(T...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
    #define dbg(...) 42
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    set <int> s;
    fr(i, 0, n){
        int x;
        cin >> x;
        s.insert(x);
    }
    if(sz(s) == n) cout << "YES";
    else cout << "NO";
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> number(N);
    vector<int> count(N);

    for (int i = 0;i < N; i++)
        cin >> number.at(i);

    for (int i = 0; i < N; i++){
        while(number.at(i) % 2 == 0){
            count.at(i)++;
            number.at(i) /= 2;
        }
    }

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

    cout << count.at(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
//ll mod = 1000000007;
int x1[100000], x2[100000];
ll p2[100001];
int main()
{
	ll aaa, bbb;
	scanf("%lld%lld", &aaa, &bbb);
	for (int i = 0; i < 100000; i++)x1[i] = x2[i] = 0;
	for (int i = 0; i < 61; i++)x1[100000 - i - 1] = ((aaa&(1LL << i)) != 0);
	for (int i = 0; i < 61; i++)x2[100000 - i - 1] = ((bbb&(1LL << i)) != 0);
	p2[0] = 1;
	for (int i = 0; i < 62; i++)p2[i + 1] = p2[i] * 2;
	int rr = -1;
	for (int i = 0; i < 100000; i++)
	{
		if (x1[i] != x2[i])
		{
			rr = i;
			break;
		}
	}
	if (rr == -1)printf("1\n");
	else
	{
		ll ans = 1;
		vector<int>r1, r2;
		for (int i = rr + 1; i < 100000; i++)if (x1[i] == 0)ans = (ans + p2[100000 - i - 1]);
		for (int i = rr + 1; i < 100000; i++)r1.push_back(x1[i]);
		bool f = false;
		ll zc = 1;
		for (int i = rr + 1; i < 100000; i++)
		{
			if (x2[i])f = true;
			if (!f)r2.push_back(0);
			else r2.push_back(1), zc = (zc + p2[100000 - i - 1]);
		}
		if (r2 >= r1)ans = (ans + p2[100000 - rr - 1]);
		else ans = (ans + ans + zc);
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1024
import bisect
n = int(input())
*A, = map(int, input().split())
B = [A[i] + i for i in range(n)]
C = [i - A[i] for i in range(n)]
B.sort()
C.sort()
ans = 0
for b in B:
    ans += bisect.bisect_right(C, b) - bisect.bisect_left(C, b)
print(ans)


Measured memory_bytes: 33716
#include <iostream>
// #include <algorithm>
// #include <functional>
using namespace std;

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

    int sum_1 = 0;
    for (int i = 1; i < n; i++){
        if (s[i] == 'E') sum_1 ++;
    }

    int currentmin = sum_1;
    // int sum = sum_1;
    // cout << sum_1 << endl;

    for (int i = 1; i < n; i++){
        if(s[i - 1] == 'W') sum_1 ++;
        if(s[i] == 'E') sum_1 --;
        // cout << sum_1 << endl;
        if (sum_1 < currentmin) currentmin = sum_1;
    }
 
    cout << currentmin << endl;
    return 0;
}

// int main(){
//     int n;
//     string s;
//     cin >> n;
//     // for (int i = 0; i < n; i++) cin >> s[i];
//     cin >> s;

//     //累積和
//     int sum[n];
//     for (int i = 0; i < n; i++) sum[i] = 0;

//     for (int i = 0; i < n; i++){
//         for (int j = 0; j <= i; j++){
//             if(s[j] == 'W') sum[i] += 1;
//         }
//     }

//     int currentmin = 0;
//     int counter = 0;

//     for (int i = 0; i < n; i++){
//         if (i == 0) {
//             counter = n - sum[n-1];
//             currentmin = counter;
//         }else{
//             counter = sum[i - 1] + ( ( n - ( i + 1 )) - (sum[n-1] - sum[i]) );
//             if (counter < currentmin) currentmin = counter;
//         }
//         // cout << counter << currentmin << endl;
//     }
//     cout << currentmin << endl;
    
//     return 0;
// }

Measured memory_bytes: 900
#include <iostream>
#include <list>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string str;
    cin >> str;
    list<int> l(1), r(1);
    int cnt = 0;
    for(auto&& i : str){
        if(i == '<'){
            cnt++;
        }else{
            cnt = 0;
        }
        l.push_back(cnt);
    }
    reverse(begin(str), end(str));
    cnt = 0;
    for(auto&& i : str){
        if(i == '>'){
            cnt++;
        }else{
            cnt = 0;
        }
        r.push_front(cnt);
    }
    long long sum = 0;
    while(!l.empty()){
        sum += max(l.front(), r.front());
        l.pop_front();
        r.pop_front();
    }
    cout << sum << "\n";
}


Measured memory_bytes: 32004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
main(){
    int n;
    cin>>n;
    int a[n];
    ll b[n];
    for(int i=0;i<n;i++) cin>>a[i];
    b[0]=0;
    if(n>1) b[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        b[i]=min(b[i-1]+abs(a[i-1]-a[i]),b[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<b[n-1]<<endl;
}

Measured memory_bytes: 4792
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

inf = 10**9
lefts = [inf for _ in range(n+1)]
for a, b in ab:
    lefts[a] = min(lefts[a], b-1)

right = -1
ans = 0
for i in range(1, n+1):
    if lefts[i] == inf:
        continue
    if i > right:
        ans += 1
        right = lefts[i]
    else:
        right = min(lefts[i], right)
print(ans)

Measured memory_bytes: 31452
#include <stdio.h>
int main()
{
	int h, w, i, j, k;
	for (k = 0;; k++)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)
			break;
		else
		{
			for (i = 0; i<h; i++)
			{
				for (j = 0; j<w; j++)
					printf("#");
				printf("\n");

			}
			printf("\n");
		}
	}


	return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
//#include <tuple>
#include <map>
#include <cmath>
#include <numeric>
#include <complex>
#include <queue>

#include <iomanip>

#define LINE() cerr << "L:"<<__LINE __ <<endl;


using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
//typedef tuple<int, int, int> T;
typedef pair<ll, ll> Pl;
//typedef tuple<ll, ll, ll> Tl;


class Task{
	public:
	double pos;
	int isC;
	Task(double pos,int isC):pos(pos),isC(isC){

	}

	bool operator < (const Task& r) const{
		return pos < r.pos;
	}
	bool operator > (const Task& r) const{
		return pos > r.pos;
	}
};

int N,K,T,U,V,L;
int main() {
	cin >> N >> K >> T >> U >> V >> L ;

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

	priority_queue<Task,vector<Task>,greater<Task>> que;
	que.push(Task(0,0));
	que.push(Task(L,0));
	for(int i =0 ; i < N ; i++){
		que.push(Task(ds[i],1));
	}

	double res=0,pos=0,VT=0;int kc=0;
	while(!que.empty()){
		Task t=que.top();que.pop();
		// cout <<";" <<t.pos<<":"<< pos <<":"<<kc<<endl;
		double vt=min(VT,(t.pos-pos)/V);

		// cout <<VT<< "vt:"<<vt <<endl;
		res+=vt;
		VT-=vt;
		pos+=vt*V;
		
		double ut=(t.pos-pos)/U;
		res+=ut;
		pos=t.pos;

		//next
		if(t.isC)kc++;

		// cout <<"vt:"<<VT<<endl;
		if(kc>K || (VT<1e-9 && kc>0)){
			VT=T;
			kc--;
			if(pos+T*V<=L)que.push(Task(pos+T*V,0));

			// cout << pos<<"!"<<pos+T*V << ":"<<kc<<endl;
			
		}
	}
	cout<<fixed<<setprecision(15);
	cout <<res << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>

using namespace std;

int main(void)
{
    long n, k;
    cin >> n >> k;

    long mod = n % k;
    long a = labs(mod - k);
    long b = mod;
    long ans = std::min(a, b);

    cout << ans;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int[] a = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
		System.out.println((int)(0.5*(a[0]+a[1])*a[2]));
		sc.close();
	}

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

}


Measured memory_bytes: 35800
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 0; i < 5; i++) {
			if (a[i] == 0) {
				System.out.println(i + 1);
				return;
			}
		}
	}
}


Measured memory_bytes: 35684
// マトロイドに対する貪欲法とみて解く
// https://topcoder-g-hatena-ne-jp.jag-icpc.org/spaghetti_source/20121103/1351911603.html

#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);

	vector<pair<int,int>> p(n);
	rep(i,n) scanf("%d%d",&p[i].second,&p[i].first);
	sort(p.rbegin(),p.rend());

	set<int> S;
	rep(x,m) S.emplace(x);

	int ans=0;
	for(auto [b,a]:p){
		auto it=S.upper_bound(m-a);
		if(it!=S.begin()){
			S.erase(--it);
			ans+=b;
		}
	}
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

typedef long long ll;

string s;

int main(){
    cin >> s;
    int p = 0;
    for(int i=0;i<s.size();i++){
        if(i % 2 == 0){
            if(s[i] == 'p') p--;
        }else{
            if(s[i] == 'g') p++;
        }
    }
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h[n+1];
  h[0]=0;
  for(int i=1;i<=n;i++) cin>>h[i];
  int cost[n+1];
  cost[1]=0;
  cost[2]=abs(h[2]-h[1]);
  for(int i=3;i<=n;i++) cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
  cout<<cost[n];
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    static void solve(Scanner in) {
        int N = in.nextInt();
        int[] L = new int[2 * N];
        for (int i = 0; i < 2 * N; i++) {
            L[i] = in.nextInt();
        }

        Arrays.sort(L);
        int sum = 0;
        for (int i = 0; i < 2 * N - 1; i += 2) {
            sum += L[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 10068
import qualified Data.ByteString.Char8 as B
import Data.Maybe

main = do
  n <- fst . fromJust . B.readInteger <$> B.getLine
  if (solve n n 0) then (putStrLn "Yes") else (putStrLn "No")

solve :: Integer -> Integer -> Integer -> Bool
solve orig n sn
  | n == 0 = (orig `mod` sn) == 0
  | otherwise = solve orig (n `div` 10) (sn + (n `mod` 10))

Measured memory_bytes: 380
import math

def cmb(N,X,mod):
	P=1
	Q=1
	for i in range (X):
		P=P*(N-i)%mod
		Q=Q*(i+1)%mod
	return (P*pow(Q,mod-2,mod))%mod

N,A,B=map(int,input().split())
mod=pow(10,9)+7

ans=0
ans=(pow(2,N,mod)-1)

tmp_A=cmb(N,min(A,N-A),mod)
tmp_B=cmb(N,min(B,N-B),mod)
#print(ans,tmp_A,tmp_B)
ans=ans-tmp_A-tmp_B
print(ans%mod)

Measured memory_bytes: 3064
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
from collections import defaultdict as ddic, Counter, deque
import heapq, bisect, itertools
MOD = 10 ** 9 + 7

def solve(N, A):
    from fractions import gcd
    g  = A[0]
    for x in A:
        g=  gcd(g,x)
    if g > 1:
        return "not coprime"

    seen = set()
    for x in A:
        saw = set()
        while x % 2 == 0:
            x //= 2
            saw.add(2)
        d = 3
        while d*d <= x:
            while x%d == 0:
                saw.add(d)
                x //= d
            d += 2
        if x > 1:
            saw.add(x)

        for p in saw:
            if p in seen:
                return "setwise coprime"
        seen |= saw

    return "pairwise coprime"

N= rri()
A = rrm()

print solve(N, A)


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

int main() {
    int n;
    cin >> n;
    set<int> s[3];
    for(int i = 0; i < 3; ++i) {
        int m; cin >> m;
        for(int j = 0; j < m; ++j) {
            int a; cin >> a;
            s[i].insert(a);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if((s[0].count(i + 1) == 0 || s[1].count(i + 1)) && s[2].count(i + 1)) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3108