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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer day = sc.nextInt();
      	int minus = 25;
      	System.out.print("Christmas ");
      	for(int i = 0; i < (minus - day); i++){
          System.out.print("Eve ");
        }
      	System.out.println("");
	}
}

Measured memory_bytes: 21716
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
        int x, l;
        cin >> x >> l;
        A[i] = P(x+l, l);
    }
    sort(A.begin(), A.end());

    int right = -INF;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int x_l = A[i].first;
        int l = A[i].second;
        int x = x_l -l;
        if (x - l >= right) {
            cnt++;
            right = x + l;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
a, b, x = map(int, input().split())

def quotient(n, x):
  if n == -1:
    return 0
  elif n == 0:
    return 1
  else:
    return n // x + 1

a = quotient(a - 1, x)
b = quotient(b, x)

ans = b - a
print(ans)

Measured memory_bytes: 3060
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s
    };

    if n % 2 == 1 {
        println!("No");
        return
    }

    let a = n / 2;
    // debugln!("{}", &s[0..a]);
    // debugln!("{}", &s[a..n]);
    if &s[0..a] == &s[a..n] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import sys
from collections import deque
input = sys.stdin.readline

N,M = map(int,input().split())
H = list(map(int,input().split()))
D = [[] for i in range(N)]
Q = deque()
Q.append(0)
visited = [-1]*N
ans = 0

for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    D[A].append(B)
    D[B].append(A)


for i in range(N):
    if visited[i] == -1:
        cur = H[i]
        flag = 0
        for x in D[i]:
            if H[x] > cur:
                visited[i] = 0
                flag = 1
                break
            elif H[x] < cur:
                visited[x] = 0
            else:
                flag = 1
        if flag == 0:
            ans += 1

print(ans)

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t n;
    cin >> n;
    int64_t a[n];
    int64_t ans = 0;
    rep(i, n) {
        cin >> a[i];
        if ( i%2 == 0 && a[i]%2 == 1 ) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int maxn = 4010;
const int mod = 1e9+7;

int n, k;
int dp[maxn][maxn], fac[2000*2000+10], ifac[2000*2000+10], inv[2000*2000+10];

int binom(int x, int y) {
	if (y > x) return 0;
	return 1LL * fac[x] * ifac[y] % mod * ifac[x-y] % mod;
}

int main() {
	scanf("%d%d", &n, &k);
	if (k == 1){
		puts("1");
		return 0;
	}
	fac[0] = ifac[0] = 1; inv[1] = 1;
	for (int i = 2; i <= n*k; i++) inv[i] = mod - 1LL * (mod / i) * inv[mod % i] % mod;
	for (int i = 1; i <= n*k; i++) fac[i] = 1LL * fac[i-1] * i % mod, ifac[i] = 1LL * ifac[i-1] * inv[i] % mod;
	dp[0][0] = 1;
	for (int i = 1; i <= 2*n; i++) {
		for (int j = i&1; (i+j) <= 2*n; j+=2) {
			// j = ( - )
			// )
			if (j < n) {
				dp[i][j] = (dp[i][j] + dp[i-1][j+1]) % mod;
			}
			// (
			if (j > 0) {
				dp[i][j] = (dp[i][j] + 1LL * binom((k-2)*((j+i)/2)+i-1, k-2) * dp[i-1][j-1] % mod) % mod;
			}
		}
	}
	printf("%d\n", int (1LL * dp[2 * n][0] * fac[n] % mod));
	return 0;
}

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

using namespace std;
const int maxn = 1e5 + 30;typedef long long ll;
ll a[maxn];

typedef long long ll;
int n;
ll perform(bool pos){
  ll S = 0;
  ll ans = 0;
  for(int i=0;i<n;i++){
    pos = !pos;
    S += a[i];
    if(pos){
      if(S > 0) continue;
      ans += 1 - S;
      S = 1;
    }
    else{
      if(S < 0) continue;
      ans += S + 1;
      S = -1;
    }
  }
  return ans;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    int t; cin >> t; a[i] = t;
  }
  cout << min(perform(true), perform(false)) << "\n";
}


Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
h,w = map(int,input().split())
if w % 3 == 0 or h % 3 == 0:
    print(0)
else:
    arr = []
    smax = (h // 3 + 1) * w
    smin = (h - (h//3 + 1)) * (w//2)
    arr.append(smax - smin)
    smax = (w//3 + 1) * h
    smin = (w - (w//3 + 1)) * (h//2)
    arr.append(smax - smin)
    
    smin = (h//3) * w
    if smax != 0:
        if w % 2 == 1:
            smax = (h - (h//3)) * (w//2 + 1)
        else:
            smax = (h - (h//3)) * (w//2)
        arr.append(smax - smin)
    #print(smax,smin)
    
    smin = (w//3) * h
    if smax != 0:
        if h % 2 == 1:
            smax = (w - (w//3)) * (h//2 + 1)
        else:
            smax = (w - (w//3)) * (h//2)
        arr.append(smax - smin)
    #print(smax,smin)
        
    smax = (h//3 + 1) * w
    smin = (h//3) * w
    arr.append(smax - smin)
    smax = (w//3 + 1) * h
    smin = (w//3) * h
    arr.append(smax - smin)    
    print(min(arr))
    #print(arr)


Measured memory_bytes: 3064
import math
import sys

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()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

H,W = nm()
if H == 1: 
    print(1)
    exit(0)
if W == 1:
    print(1)
    exit(0)
    
print((H * W + 1)//2)


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

int N;
int S[100];

int main() {
  while (cin >> N) {
    if (N == 0) break;
    for (int i=0; i<N; i++) cin >> S[i];
    sort(S, S+N);
    int s = 0;
    for (int i=1; i<N-1; i++) s += S[i];
    cout << s / (N-2) << "\n";
  }
  return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int m=max({a,b,c});
  int mw=m;
  rep(i,k)mw*=2;
  
  cout <<a+b+c-m+mw<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)


int main() {


	
	string str;

	cin >> str;

	rep(i, 0, str.length()) {

		if (str[i] == 'A') {

			if (i < str.length() - 1) {
				if (str[i + 1] == 'C') {
					cout << "Yes" << endl;
					return 0;
				}
			}

		}

	}



	cout << "No" << endl;




			

	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char X[17];
    X[0] = 'C';
    X[1] = 'O';
    X[2] = 'D';
    X[3] = 'E';
    X[4] = 'F';
    X[5] = 'E';
    X[6] = 'S';
    X[7] = 'T';
    X[8] = 'I';
    X[9] = 'V';
    X[10] = 'A';
    X[11] = 'L';
    X[12] = '2';
    X[13] = '0';
    X[14] = '1';
    X[15] = '6';
    X[16] = '\0';

    char S[17];

    if (scanf("%s", S) < 1) return 0;

    int cnt = 0;
    for (int i = 0; i < strlen(S); i++) if (X[i] != S[i]) cnt++;

    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 1e5 + 10;
int N, A, B;
int X[MAXN];
ll ans;

int main() {
	register int i;
	scanf("%d%d%d", &N, &A, &B);
	for(i = 1; i <= N; ++i) {
		scanf("%d", X + i);
		if(i != 1) ans += min(1ll * (X[i] - X[i - 1]) * A, (ll) B);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
std::vector<std::vector<int> > hen;
std::pair<int, int> dfs(int i, int prev) {
	std::pair<int, int> res = {1, 1};
	for (auto j : hen[i]) if (j != prev) {
		auto tmp = dfs(j, i);
		res.first = (int64_t) res.first * (tmp.first + tmp.second) % MOD;
		res.second = (int64_t) res.second * tmp.first % MOD;
	}
	return res;
}
int main() {
	int n = ri();
	hen.resize(n);
	for (int i = 0; i + 1 < n; i++) {
		int a = ri() - 1, b = ri() - 1;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}
	auto res = dfs(0, -1);
	std::cout << (res.first + res.second) % MOD << std::endl;
	return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;


	if (k <= a) cout << k << endl;
	else if (k <= a + b) cout << a << endl;
	else cout << a - (k - a - b) << endl;

}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    while (cin >> n >> k, n) {
        int sum = 0, res = -INT_MAX;
        vector<int> v(n, 0);
        for (int i=0; i<n; ++i) {
            cin >> v[i];
            sum += v[i] - (k <= i ? v[i-k] : 0);
            res = max(res, (k-1 <= i ? sum : -INT_MAX));
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1532
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.bytes;2.upto(n+1){|i|a[i]=a[i-2]^((a[i-1]==87)^(s[~-i%n]==?o)?0:4)};a[0,2]==a[n,2]&&$><<a[0..-3].map(&:chr)*''}||(p -1)

Measured memory_bytes: 8032
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int main(){
    INT(n); vlint a(n); line(a);
    int ans = 0;
    rep(i, n){
        if (i%2 == 0 && a[i] % 2 == 1) ans ++;
    }
    print(ans);
}
    



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;

  int count = 0;
  while (A >= B)
  {
    B *= 2;
    count++;
  }
  while (B >= C)
  {
    C *= 2;
    count++;
  }

  if (count <= K)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3592
n = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(n)]
for i in range(1,n):
    B[i] = A[0]^A[i]
tmp = 0
for i in range(1,n):
    tmp = tmp^B[i]
ans = [0 for _ in range(n)]
ans[0] = A[0]^tmp
for i in range(1,n):
    ans[i] = ans[0]^B[i]

print(' '.join(map(str, ans)))

Measured memory_bytes: 117692
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  map<string,int> m;
  cin>>N;
  REP(i,N){
    string s;
    cin>>s;
    m[s]++;
  }
  cin>>M;
  REP(i,M){
    string t;
    cin>>t;
    m[t]--;
  }
  int ans=0;
  for(auto p:m){
    ans=max(ans,p.second);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

const int MOD = 1e9 + 7;

int main() {
  int i;
  int N, M;
  scanf("%d %d", &N, &M);
  long long ans;
  long long factorial[100010];
  factorial[0] = 1;
  for (i = 1; i <= 100010; ++i) {
    factorial[i] = (factorial[i - 1] * i) % MOD;
  }
  if (N - M > 1 || M - N > 1) {
    ans = 0;
  } else if (N == M) {
    ans = (((factorial[N]*factorial[N]) % MOD) * 2) % MOD;
  } else {
    ans = (factorial[N]*factorial[M]) % MOD;
  }
  printf("%lld", ans); 
  return 0;
}


Measured memory_bytes: 896
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    int n;
    cin >> n;
    vector<vector<int>> happiness (n + 1 , vector<int> (4 , 0)); 
    for (int i = 1; i <= n; i++){
        cin >> happiness[i][1] >> happiness[i][2] >> happiness[i][3];
    }
    vector<vector<int>> dp (n + 1, vector<int> (4 , 0));
    dp[1][1] = happiness[1][1];
    dp[1][2] = happiness[1][2];
    dp[1][3] = happiness[1][3];
    for (int i = 1; i < n; i++){
        for (int j = 1; j <= 3; j++){
            for (int jj = 1; jj <= 3; jj++){
                if (j == jj) continue;
                dp[i + 1][jj] = max (dp[i + 1][jj] , dp[i][j] + happiness[i + 1][jj]);
            }
        }
    }
    cout << max ({dp[n][1] , dp[n][2] , dp[n][3]}) << '\n';
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 14276
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val A = na(7)

    def calc(a0: Long, a1: Long, a3: Long, a4: Long) = {
      a0 / 2 * 2 + a1 + a3 / 2 * 2 + a4 / 2 * 2
    }

    val ans = if (A(0) > 0 && A(3) > 0 && A(4) > 0) {
      // 0, 3, 4の組みを一つ作るかどうか。2以上の場合は偶奇の差があるだけで実質0, 1と変わらない
      max(calc(A(0) - 1, A(1), A(3) - 1, A(4) - 1) + 3, calc(A(0), A(1), A(3), A(4)))
    } else {
      calc(A(0), A(1), A(3), A(4))
    }

    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 26952
# AGC 027: A – Candy Distribution Again
N, x = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

a.sort()
distributed = 0
beGlads = 0

for i in range(N):
    if distributed + a[i] > x:
        break
    else:
        distributed += a[i]
        beGlads += 1

print(beGlads if sum(a) >= x else beGlads - 1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
  int n;
  std::cin >> n;
  std::string str[n];
  for (int i = 0; i < n; i++) {
    std::cin >> str[i];
  }
  
  std::map<std::string, int> count;
  count["AC"] = 0;
  count["TLE"] = 0;
  count["RE"] = 0;
  count["WA"] = 0;
  
  for (int i = 0; i < n; i++) {
    count[str[i]]++;
  }
  
  std::cout << "AC x " << count["AC"] << std::endl;
  std::cout << "WA x " << count["WA"] << std::endl;
  std::cout << "TLE x " << count["TLE"] << std::endl;
  std::cout << "RE x " << count["RE"] << std::endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    unordered_set<char> us;
    cin >> S;
    for (auto c : S){
        us.insert(c);
    }
    if (us.size() == S.size()){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def gcd_core(a,b):
    if b == 0:
        return a
    else:
        return gcd_core(b,a%b)

def gcd(arr):
    g = gcd_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        g = gcd_core(g,arr[i])
    return g

n,k = map(int,input().split())
arr = []
for i in range(n):
    arr.append(int(input()))

arr.sort()
ans = 1000000000000000000
for i in range(n-k+1):
    if ans > arr[i+k-1]-arr[i]:
        ans = arr[i+k-1]-arr[i]

print(ans)

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
int x, y, a[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int main() {
	cin >> x >> y; x--, y--;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

bool dame(string s) {
    int n = s.size();
    rep(i, n) {
        if (s[i] != s[i % 2]) return false;
    }
    return true;
}

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

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

    if (dame(s)) {
        cout << "Second" << endl;
    } else {
        cout << ((s.size() % 2) ^ (s[0] == s.back()) ? "First" : "Second") << endl;
    }
}


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

 
int main() {
    int n;
    cin>>n;
    
    ll ans=0;
    rep(i,n){
        ll l,r;
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String [] args)
	{
		Scanner sc= new Scanner(System.in);
		int N= sc.nextInt();
		int K =sc.nextInt();
		
		int cost[] =new int[N];
		for(int i=0;i<N;i++)
		{
		
			cost[i]= sc.nextInt();
		}
		int dp[] =new int [N+1];
		Arrays.fill(dp,Integer.MAX_VALUE);
		dp[0]=0;
		dp[1]=Math.abs(cost[1]-cost[0]);
		//dp[1]=cost[1]-cost[0];
		
		for(int i=2;i<N;i++)
		{
			 for(int j=i-1,jump=0;j>=0 && jump<K;j--,jump++)
			 {
			 	dp[i]=Math.min(dp[i],Math.abs(cost[i]-cost[j]) +dp[j]);
			 }
		}
		
		System.out.println(dp[N-1]);
	}

}

Measured memory_bytes: 59332
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b;
	cin >> a >> b;
	if (a*b % 2 == 0)print("Even"); else print("Odd");





	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto n = lread();
    bool alleven = true;
    foreach(i;0..n)
    {
        auto a = lread();
        alleven = alleven && (a % 2 == 0);
    }

    auto ans = (!alleven)?"first":"second";
    ans.writeln;

}


Measured memory_bytes: 1276
n,m = map(int, input().split())
A = list(map(int, input().split()))

rem_cnts = {0:0}
curr_sum_rem = 0
for a in A:
    curr_sum_rem += a
    curr_sum_rem%=m
    rem_cnts.setdefault(curr_sum_rem,0)
    rem_cnts[curr_sum_rem] += 1

ans = 0
for cnt in rem_cnts.values():
    ans += cnt*(cnt-1)//2
ans += rem_cnts[0]

print(ans)

Measured memory_bytes: 62576
N = '0' + input()
L = len(N)

INF = float('inf')
dp = [[INF] * 2 for _ in range(L + 1)]
dp[0][0] = 0

for i in range(L):
    x = int(N[L - 1 - i])
    for j in range(2):
        for a in range(10):
            b = a - j - x
            temp1 = dp[i][j] + a + (b + 10 * (b < 0))
            temp2 = dp[i + 1][b < 0]
            dp[i + 1][b < 0] = min(temp1, temp2)

print(dp[L][0])


Measured memory_bytes: 202884
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int a, b;   cin >> a >> b;
    if (a >= 13)
    {
        cout << b;
    }
    else if (a <= 5)
    {
        cout << 0;
    }
    else
    {
        cout << b / 2;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int maxn = 1e3 + 7;

LL ans;

void dfs(LL rt) {
	
}

int main() {
	int x;
	cin >> x;
	if(x >= 30) puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  int c[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }
  int A[H][W];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
	c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int res = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(A[i][j] == -1){
	continue;
      }else{
	res += c[A[i][j]][1];
      }
    }
  }
  cout << res << endl;
}


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

using namespace std;

int main(){
    int N;
    vector<int> L;
    int ret = 0;

    cin >> N;
    int tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        L.push_back(tmp);
    }

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

    for(int i = 0; i < N - 2; i++){
        for(int j = i+1; j < N - 1; j++){
            
            auto itl = lower_bound(L.begin(), L.end(), L[i]+L[j]);
            size_t dist = distance(L.begin(), itl);
            ret += dist - j - 1;
        }
    }
    cout << ret;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char a = s[k-1];
    rep(i,n){
        if(s[i] != a){ 
            cout << '*';
        }
        else cout << s[i];
    }   
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] strs = sc.nextLine().split(" ");
        int w = Integer.parseInt(strs[0]);
        int h = Integer.parseInt(strs[1]);
        int x = Integer.parseInt(strs[2]);
        int y = Integer.parseInt(strs[3]);
        BigDecimal area = new BigDecimal(w).multiply(new BigDecimal(h)).divide(new BigDecimal(2)).setScale(10);
        int num = ((x*2==w)&&(y*2==h))?1:0;
        System.out.println(area+" "+num);
    }
}

Measured memory_bytes: 21844
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
n = int(input())
c = input()

wcount = c.count("W")
rcount = c.count("R")
check = 0

num = min(wcount, rcount)

if rcount < wcount:
    for i in range(rcount):
        if c[i] == "R":
            check += 1

else:
    for i in range(n - wcount, n):
        if c[i] == "W":
            check += 1

print(num - check)


Measured memory_bytes: 9384
Card = [[],[],[]]
for k in range(3):
    Card[k] = list(map(int,input().split()))
N = int(input())
Call = [int(input()) for k in range(N)]
Bin = [[0,0,0],[0,0,0],[0,0,0]]
for k in range(N):
    for l in range(3):
        for m in range(3):
            if Card[l][m] == Call[k]:
                Bin[l][m] =1
ans = 0
for k in range(3):
    if Bin[k][0] == Bin[k][1] and Bin[k][1] == Bin[k][2] and Bin[k][0] ==1:
        ans = 1
    if Bin[0][k] == Bin[1][k] and Bin[1][k] == Bin[2][k] and Bin[2][k] ==1:
        ans = 1
if Bin[0][0] == Bin[1][1] and Bin[1][1] == Bin[2][2] and Bin[2][2] ==1:
    ans = 1 
if Bin[0][2] == Bin[1][1] and Bin[1][1] == Bin[2][0] and Bin[2][0] == 1:
    ans = 1

if ans ==1:
    print('Yes')
else:
    print('No')


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

#define ll long long
#define ln "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define mod 1e9 + 7
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    fastio;

    ll a,b,c,d;
    cin >> a>> b>>c>>d;

    ll f=a*c;
    ll s = b*c;
    ll t = a*d;
    ll fo=b*d;
    cout << (ll)max(f, max(s, max(t, fo))) << ln; 

}


Measured memory_bytes: 3564
//2019/3/12
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();

		int B = sc.nextInt();

		int K = sc.nextInt();

		int ans = 0;

		int i = 0;

		if(A<B) {

			for(int j=A;i<K;j--) {

				if(A%j==0 && B%j==0) {

					i++;

					ans = j;
				}
			}
		}else {

			for(int j=B;i<K;j--) {

				if(A%j==0 && B%j==0) {

					i++;

					ans = j;
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin()
#define pb push_back
using namespace std;

signed main(){
    #define int long long
    int n ;
    cin >> n;
    vector < int > a(3) , b(3);
    for(auto &i : a) cin >> i;
    for(auto &i : b) cin >> i;
    vector < int > dp(n + 1 , 0);
    for(int j = 0; j <= n ; ++j){
        for(int z = 0 ; z < 3; ++z)
        if(j >= a[z]){
            dp[j] = max(dp[j], dp[j-a[z]] + b[z]);
        }
    }
    int x = n;
    for(int i = 0; i <= n; ++i){
        x = max(x , dp[i] + n - i);
    }
    vector < int > f(x+1 , 0);
    for(int j = 0; j <= x ; ++j){
        for(int z = 0 ; z < 3; ++z)
        if(j >= b[z]){
            f[j] = max(f[j], f[j-b[z]] + a[z]);
        }
    }
    int ans = 0;
    for(int z = 0 ; z <= x;++z){
        ans = max(ans , f[z] + x - z);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 200005; 
typedef long long ll;
int n,k;
ll h[N],cnt;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%lld",&h[i]);
	sort(h+1,h+n+1);
	if(k>=n){
		puts("0");
		return 0;
	}
	for(int i=1;i<=n-k;++i)
		cnt += h[i];
	printf("%lld\n",cnt);
} 

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var ans = nk[1]*Math.Pow(nk[1]-1,nk[0]-1);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
let s = read_line ()
let f s = String.(init (length s) @@ fun i -> s.[length s - i - 1])
let _ = print_endline @@ if s = String.map (function 'b' -> 'd' | 'd' -> 'b' | 'p' -> 'q' | 'q' -> 'p' | c -> c) @@ f s then "Yes" else "No"

Measured memory_bytes: 2816
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;
void faster()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
	

const ll M = 300 + 10;
const ll N = 3 * 100 + 10;

vector <int> adj[N];
int n;
string s[N];
bool is_val = true;
int color[N];
ll deleted, distances[N], dist[N];

void BFS(int n, int r) {

    for (int i=0; i<n; i++) distances[i] = inf;
    distances[r] = 0;
	queue<int> q;
    q.push(r);

    while(q.size()) {
        int v = q.front();
        q.pop();

        for (auto u : adj[v]) {
            if(v == r && u == deleted) continue;
            if(distances[u] > distances[v] + 1) {
                distances[u] = distances[v] + 1;
                q.push(u);
            }
        }

    }
}

void bfs(int src)
{
	for (int i = 0; i < n; i++)
		dist[i] = inf;
	queue <int> q;
	dist[src] = 0;
	q.push(src);
	while(!q.empty())
	{
		int v = q.front();
		q.pop();
		for (auto u : adj[v])
		{
			if(dist[u] > dist[v] + 1)
			{
				dist[u] = dist[v] + 1;
				q.push(u);
			}
		}
	}
}

void dfs(int v)
{
	if(!color[v])
		color[v] = 1;
	for (auto u : adj[v])
	{
		if(!color[u])
			color[u] = 3 - color[v], dfs(u);
		else if(color[v] == color[u])
		{
			is_val = false;
		}	
	}
}


int main()
{
	faster();
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		for (int j = 0; j < n; j++)
		{
			if(s[i][j] == '1')
				adj[i].push_back(j);
		}
	}
	dfs(0);
	if(!is_val)
	{
		cout << -1 << endl;
		return 0;
	}
	ll length = inf;
	    for (int i = 0; i < n; i++) {
	       for (auto u : adj[i]) {
	            deleted = u;
	            BFS(n, i);
	            length = min(length, distances[u] + 1 * 1LL);
	        }
	    }
	if(length == inf)
	{
		bfs(0);
		ll ind = 0, maxi = 0;
		for (int i = 0; i < n; i++)
		{
			if(dist[i] > maxi)
			{
				maxi = dist[i];
				ind = i;
			}
		}
		bfs(ind);
		for (int i = 0; i < n; i++)
			maxi = max(maxi, dist[i]);
		cout << maxi + 1 << endl;
	}
	else
	{
		ll ans = 0;
		for (int i = 0; i < n; i++)
		{
			bfs(i);
			for (int j = 0; j < n; j++)
				ans = max(ans, dist[j]);
		}
		cout << ans + 1 << endl;
	}
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int n;
ll a[100001];

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i];
  }

  ll ans=0;
  ll tmp=0;
  REP(i,n+1){
    if(a[i]==0){
      ans += tmp/2;
      tmp=0;
    } else {
      tmp += a[i];
    }
  }

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


Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 番号の取得
    int num = sc.nextInt();

    // 総和
    int sum = 0;

    for (int i=1; i <= num; i++) {
      for (int j=1; j <= num; j++) {
        // i,jの最大公約数を求める
        int temp1 = 0;
        int x = i;
        int y = j;
        if (x < y) {
          temp1 = x;
          x = y;
          y = temp1;
        }
        // ユークリッド
        while((temp1 = x % y) != 0) {
          x = y;
          y = temp1;
        }
        for (int k=1; k <= num; k++) {
          // y,kの最大公約数を求める
          int temp2 = 0;
          int w = y;
          int z = k;
          if (w < z) {
            temp2 = w;
            w = z;
            z = temp2;
          }
          // ユークリッド
          while((temp2 = w % z) != 0) {
            w = z;
            z = temp2;
          }
          sum += z;
        }
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35848
using System;
using System.Linq;
using System.Collections.Generic;

namespace s8pc_4_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ret = long.MaxValue;
            for (int i = 0; i < Math.Pow(2, x[0]); i++)
            {
                List<int> list = new List<int>();
                for (int j = 0; j < x[0]; j++) if ((i >> j) % 2 == 1) list.Add(j);
                if (list.Count >= x[1])
                {
                    long now = 0; long high = 0;
                    for (int j = 0; j < x[0]; j++)
                    {
                        if (list.Contains(j))
                        {
                            if (a[j] > high) { high = a[j]; }
                            else { high++; now += high - a[j]; }
                        }
                        else if (a[j] > high) { high = a[j]; }
                    }
                    ret = Math.Min(ret, now);
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 17360
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

r = I()
print(2*3.141592*r)

Measured memory_bytes: 65492
#include<string>
#include<vector>
#include<sstream>
#include<iostream>
#include<algorithm>

using namespace std;

void part(int n,int k,string s)
{
	if(n==0){
		cout<<s.substr(0,s.length()-1)<<endl;
		return;
	}
	for(int i=min(n,k);i>=1;i--){
		stringstream ss;
		ss<<s<<i<<' ';
		part(n-i,i,ss.str());
	}
}

int main()
{
	for(int n;cin>>n,n;)	part(n,n,"");
	return 0;
}

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

int main() {
  int a, b, c, x, output;

  cin >> a >> b >> c >> x;
  output = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if ((500 * i) + (100 * j) + (50 * k) == x) output++;
      }
    }
  }
  cout << output << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£?????????????????????
		Scanner sc =new Scanner(System.in);

		//?§???????S?????????
		int S =sc.nextInt();
		//h??????????¨????
		//int h = S % 60;
		//??????????¨????
		//int m = S / 60;
		//s?§?????¨????
		//int s = S / 60 * 60;

		int h = (int)Math.floor(S / 3600);
        int m = (int)Math.floor((S % 3600) / 60);
        int s = (int)Math.floor((S % 3600) % 60);
		//??¨???
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26228
#include <stdio.h>
int main(void)
{
    int i = 0;
    int j = 0;
    int m[3000];
    int n[3000];
    
    while (1)
    {
        i++;
        scanf("%d %d", &m[i], &n[i]);
        if (m[i] == 0 && n[i] == 0)
            break;
    }
    do
    {
        j++;
        if (m[j] < n[j])
        {
            printf("%d %d\n", m[j], n[j]);
        }
        else
        {
            printf("%d %d\n", n[j], m[j]);
        }
    } while (j < i - 1);

    return 0;
}


Measured memory_bytes: 2628
import scala.io.StdIn._

object Main extends App {

  
  val n = readInt()
  val abc = Array.fill(n)(readLine().split(" ").map(_.toInt))
  def solve() = {
    val dp = Array.fill(n+1)(Array.fill(3)(0))
    
    for {
      i <- 0 until n
      j <- 0 until 3
      k <- 0 until 3 if j != k
    } {
      dp(i+1)(k) = Math.max(dp(i)(j) + abc(i)(k), dp(i+1)(k))
    }
    
    (0 to 2).foldLeft(0) { (acc, i) => 
      Math.max(acc, dp(n)(i))
    }
  }

  println(solve())

}



Measured memory_bytes: 65096
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N;
string s;

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

    int left[300010] = {0}, right[300010] = {0};

    // 左側にあるWの数をメモ
    for (int i = 1; i < N; i++) {
        left[i] = left[i-1];
        if (s[i-1] == 'W') left[i] += 1;
    }

    // 右側にあるEの数をメモ
    for (int i = N - 2; i >= 0; i--) {
        right[i] = right[i+1];
        if (s[i+1] == 'E') right[i] += 1;
    }
    //rep(i, N) cout << left[i] << " ";
    //cout << endl;
    //rep(i, N) cout << right[i] << " ";
    //cout << endl;

    // 左のWと右のEの数の和が最小になるように選ぶ
    int ans = INT_INF;
    for (int i = 0; i < N; i++) {
        int sum = left[i] + right[i];
        if (sum < ans) ans = sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b;
  
  cin>>a>>b;
  
  if(a%2==0 || b%2==0){
    cout<<"Even"<<endl;
  }
  
  else{
    cout<<"Odd"<<endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String U = sc.next();
        if(S.equals(U)){
            System.out.printf("%d %d", a-1, b);
        }else{
            System.out.printf("%d %d", a, b-1);
        }
        return;
    }
}

Measured memory_bytes: 21716
//#include <bits/stdc++.h>
//#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstring>
#include<bitset>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define mset(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)

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

using namespace std;
typedef long long ll;

#ifdef local
#define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
void err() {
    cout << endl;
}
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) {
    for (auto x: a)
        cout << x << ' ';
    err(args...);
}
template<typename T, typename... Args>
void err(T a, Args... args) {
    cout << a << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const long double eps = 1e-6;
//const int mod = 998244353;
const int maxn = 3e6;
const int M = 3e6+10;
const int N = 3e4+10;

int T = 0;
void testcase() {
    cout << "Case #" << (++T) << ": ";
}

void work() {
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    for(ll temp = x; x<=y;x<<=1){
        ans++;
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // local
    IOS;
   // init();
//     int t;
//     cin >> t;
//     for(;t--;)
    work();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100500;
ll n;
pair <ll, ll> arr[MAXN];
ll res[MAXN];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].first;
		arr[i].second = i;
	}

	sort(arr, arr + n);
	reverse(arr, arr + n);

	ll ptr = 0;
	ll min_ind = arr[0].second;
	ll val;

	while (ptr < n)
	{		
		val = arr[ptr].first;
		while (ptr < n && arr[ptr].first == val)
		{
			min_ind = min(min_ind, arr[ptr].second);
			ptr++;
		}
		res[min_ind] += ptr * (val - arr[ptr].first);
	}

	for (int i = 0; i < n; i++)
		cout << res[i] << '\n';
		
	return 0;
}



Measured memory_bytes: 3456