akhauriyash/Code-Regression huggingface dataset:
void E(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = temp;
}
void S(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = temp;
}
void N(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = temp;
}
void W(int d[6]){
    int temp;
    temp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = temp;
}

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i, n, t, f, l, r, b, c, count=0;
    int t2, f2, l2, r2, b2, c2;
    int d[6], d2[6];
    
    for(i=0; i<6; i++) {
        scanf("%d",&d[i]);
    }
    b = d[4];
    t = d[0];
    r = d[2];
    l = d[3];
    c = d[5];
    f = d[1];
    
    for(i=0; i<6; i++) {
        scanf("%d", &d2[i]);
    }
    b2 = d2[4];
    t2 = d2[0];
    r2 = d2[2];
    l2 = d2[3];
    c2 = d2[5];
    f2 = d2[1];
    
    while (d2[1] != f) {
        
        if((d2[1] != b) &&
           (d2[1] != t) &&
           (d2[1] != r) &&
           (d2[1] != l) &&
           (d2[1] != c) &&
           (d2[1] != f) ){
            count++;
            break;
        }
        
        if (d2[2] == f || d2[3] == f) {
            E(d2);
        }
        N(d2);
    }
    while(d2[5] != c){
        if(0 < count) break;
        E(d2);
    }
    while (d2[0] != t) {
        if(0 < count) break;
        E(d2);
    }
    
    b2 = d2[4];
    t2 = d2[0];
    r2 = d2[2];
    l2 = d2[3];
    c2 = d2[5];
    f2 = d2[1];
    
    if(b == b2 &&
       t == t2 &&
       r == r2 &&
       l == l2 &&
       c == c2 &&
       f == f2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;
const double PI=3.14159265358979323846;


int main(){
  ll N,K,H,mx=0;
  cin>>N>>K;
  H=K;
  vector<ll> A;
  vector<ll> F;
  REP(i,N){
    ll a;
    cin>>a;
    A.push_back(a);
  }
  REP(i,N){
    ll a;
    cin>>a;
    F.push_back(a);
  }

  SORT(A);
  SORT(F);
  REVERSE(F);
  
  REP(i,N) mx=max(mx,A.at(i)*F.at(i));
  
  ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = 1000000000001; // 「index = N-1」が条件を満たさないこともあるので、初期値は N
  
  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      
      K=H;
      ll s=0;
    
      for(ll i=0; i<N; ++i){
         s+=max(0ll,A.at(i)-mid/F.at(i));
      }
    
      if (K>=s){
        ok = mid;
      }
    
      else ng = mid;
  }
  
  cout<<ok<<endl;
}

Measured memory_bytes: 4848
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = { 
        digit(readLine().split(" ").map(_.toDouble))
    }   

    @tailrec
    def digit(n: Seq[Double]): Unit = {
       val d: Double = n(1) * n(3) - n(0) * n(4)
       val x: Double = zero((n(1) * n(5) - n(4) * n(2)) / d)
       val y: Double = zero((n(2) * n(3) - n(0) * n(5)) / d)
       println(f"$x%.3f $y%.3f")
       val next: String = readLine()
       if(next == null) Unit else digit(next.split(" ").map(_.toDouble))
    }

    def zero(n: Double): Double = if(Math.abs(n) == 0) 0 else n
}

Measured memory_bytes: 43904
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
typedef long long ll;
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll cum[n];
    ll sum=0;
    ll mod=1000000007;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        cum[i]=sum;
    }

    ll temp=cum[n-1];
    ll ans=0;
    ll x;
    for(int i=0;i<n;i++)
    {

        x=(a[i]*((temp-cum[i])%mod))%mod;
       
      ans=(ans+x)%mod;
    }

    cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    cin >> t;
    auto dp = vector<vector<int> >(s.size() + 1, vector<int>(t.size() + 1, 0));
    for (int i = 0; i < (int)s.size(); ++i) {
        for (int j = 0; j < (int)t.size(); ++j) {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
        }
    }
#ifdef DEBUG
    for (int i = 0; i < (int)s.size()+1; ++i) {
        for (int j = 0; j < (int)t.size()+1; ++j) {
            printf("%d%c", dp[i][j], j == (int)t.size() ? '\n' : ' ');
        }
    }
#endif
    string ans;
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j-1]) {
            --j;
        } else if (dp[i][j] == dp[i-1][j-1]+1) {
            --i; --j;
            ans += s[i];
        }
    }
    reverse(ans.begin(), ans.end());
    puts(ans.c_str());
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int count = 0, answer = 0;
	rep(i, s.size()) {
		if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
			count++;
			if (count > answer) answer = count;
			continue;
		}
		count = 0;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int n[3];

void swap(int i, int j){

    int temp;

    temp = n[i];
    n[i] = n[j];
    n[j] =temp;

//    printf("%p\n", &a);

    return;

}



int main(void){

    int i;

    //input
    for(i=0; i<3; i++){
        scanf("%d", &n[i]);
    }

    //babble sort
    if(n[2] < n[1]){
        swap(2,1);
    }
    if(n[1] < n[0]){
        swap(1,0);
    }
    if(n[2] < n[1]){
        swap(2,1);
    }


    printf("%d %d %d\n", n[0],n[1],n[2]);

    return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;

int dig(int X) {
  int res = 0;
  while (X > 0) {
    res += X % 10;
    X /= 10;
  }
  return res;
}

int main() {
  int N, ans = INF; cin >> N;
  for (int A = 1; A < N; A++) {
    int B = N - A;
    ans = min(ans, dig(A)+dig(B));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut stdin = io::stdin();
    let mut lines = String::new();
    let _ = stdin.read_to_string(&mut lines);
    let vec = lines.lines().collect::<Vec<&str>>();
    let vec2 = vec[0].split_whitespace().collect::<Vec<&str>>();
    let n :usize = vec2[0].parse().unwrap();
    let l :usize = vec2[1].parse().unwrap();
    let a :Vec<usize> = vec[1].split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut q :VecDeque<usize> = VecDeque::new();
    let mut b :Vec<(bool,usize,usize)> = Vec::new();
    let mut junjo :Vec<usize> = Vec::new();
    for i in 0..n {
        b.push((true,1,a[i]));
    }
    for i in 0..(n-1) {
        q.push_back(i);
    }
    while let Some(i) = q.pop_front() {
        let (flag, honsuu, nagasa) = b[i];
        if !flag { continue; }
        if i+honsuu >= n { continue; }
        let (_, honsuu2, nagasa2) = b[i+honsuu];
        let nagasa3 = nagasa + nagasa2;
        if nagasa3 < l {
            continue;
        } else {
            junjo.push(i+honsuu);
            b[i] = (true, honsuu+honsuu2, nagasa3);
            b[i+honsuu] = (false, honsuu2, nagasa2);
            q.push_back(i);
            for k in 0..i {
                if b[i-k-1].0 {
                    q.push_back(i-k-1);
                    break;
                }
            }
        }
    }

    if b[0].1 != n {
        println!("Impossible");
    } else {
        println!("Possible");
        while let Some(j) = junjo.pop() {
            println!("{}", j);
        }
    }
}


Measured memory_bytes: 8676
s = input()

a = [0]* (len(s)+1)

for i in range(len(s)):
    if s[i] == '<':
        a[i+1] = a[i]+1

s = s[::-1]

for i in range(len(s)):
    if s[i] == '>':
        a[len(s)-i-1] = max(a[len(s)-i-1], a[len(s)-i]+1)


print(sum(a))


Measured memory_bytes: 23716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    ll a, b, k;
    cin >> a >> b >> k;

    for (ll i=a; i<=min(b, a+k-1); i++){
        out(i);
    }
    for (ll i=max(b-k+1, a+k); i<=b; i++){
        out(i);
    }
    return 0;

}

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

using namespace std;

using ll = long long;

vector<bool> sieve(int n) {
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.emplace_back(i);
        for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return is_prime;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<bool> hoge(sieve(100000));
    vector<int> foo(100005, 0);
    for (int i = 1; i <= 100000; i++) {
        if (hoge[i] && hoge[(i + 1) / 2]) foo[i] = 1;
    }

    for (int i = 1; i <= 100000; i++) foo[i] += foo[i - 1];
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << foo[r] - foo[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
N,K,Q=map(int,input().split())
answer_count={}
for i in range(1,N+1):
    answer_count[i]=0

for _ in range(Q):
    a=int(input())
    answer_count[a]+=1

for id in range(1,N+1):
    if K-(Q-answer_count[id])>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 56932
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;



ll X[1001], Y[1001];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    vector<ll> U(N), V(N);
    for (int i = 0; i < N; i++) {
        U[i] = X[i] + Y[i];
        V[i] = X[i] - Y[i];
    }
    
    for (int i = 0; i < N; i++) {    
        for (int j = i+1; j < N; j++)
        if ((abs(X[i]-X[j]) + abs(Y[i]-Y[j])) % 2 != 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<ll> d(31, 1);
    ll inf = 2;
    for (int i = 1; i < 31; i++) {
        d[i] = d[i-1] * 2; inf *= 2;
    }
    vector<string> res(N);

    if ((X[0]+Y[0]) % 2 == 0) {
        d.insert(d.begin(),1);
        for (int i = 0; i < N; i++) {
            res[i].push_back('U');
            U[i] -= 1;
            V[i] += 1;
        }        
    }

    for (int i = 0; i < N; i++) {
        vector<ll> S1(31,0);
        vector<ll> S2(31,0);
        ll tmp = (U[i] + inf - 1)/2;
        ll j = 0;
        while (tmp > 0) {
            S1[j] = tmp % 2;
            tmp /= 2;
            j++;
        }
        tmp = (V[i] + inf - 1)/2; j = 0;
        while (tmp > 0) {
            S2[j] = tmp % 2;
            tmp /= 2;
            j++;
        }
        for (int j = 0; j < 31; j++) {
            if (S1[j] & S2[j]) res[i].push_back('R');
            else if (S1[j]) res[i].push_back('U');
            else if (S2[j]) res[i].push_back('D');
            else res[i].push_back('L');
        }
    }

    cout << d.size() << endl;
    for (int i = 0; i < d.size(); i++) {
        cout << d[i] << " ";
    } cout << endl;
    for (int i = 0; i < N; i++) {
        cout << res[i] << endl;
    }

    
    





}

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

using namespace std;
 
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

#ifdef LOCAL_DEFINE
	freopen("input.txt", "r", stdin);
#endif

	int a, b;
        cin >> a >> b;
        cout << a + (b / 2) << '\n';

#ifdef LOCAL_DEFINE
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

  return 0;
}

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

char c[7][7];

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	rep(i,h)rep(j,w) cin >> c[i][j];
	int ans = 0;
	rep(bith, 1 << h){
		rep(bitw,  1 << w){
			int count = 0;
			rep(i,h){
				rep(j,w){
					if(bith & 1 << i || bitw & 1 << j) continue;
					if(c[i][j] == '#') count++;
				}
			}
			if(count == k) ans++;
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define F first
#define re return
#define S second
#define ll long long
#define f(i) return cout<<i<<"\n",0;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define lp(i,a,b) for (int i=(a);i<=(int)(b);++i)
#define lp2(i,a,b) for (int i=(a);i>=(b);--i)
#define clr(c,x) memset(c,x,sizeof(c))
#define allr(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
const int N=2e5+5,mod=(int)1e9+7;
int cnt[N];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n,k,ans=0;
    cin>>n>>k;
    lp(i,1,n)
    cnt[i%k]++;
    lp(i,1,n)
    {
        int y=(k-(i%k))%k;
        if ((y+y)%k!=0) continue;
        ll z=cnt[y];
        z*=z;
        ans+=z;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int K;
    cin >> K;
    REP(i, K) { cout << "ACL"; }
    cout << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a, b, c := readI(), readI(), readI()
	if (a == b && b == c) || (a != b && b != c && c != a) {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1780
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();

        if(a*b%2 == 0){
            System.out.println("Even");
            System.exit(0);
        }
        else if(a*b%2 == 1){
            System.out.println("Odd");
        }
        
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 111;

int n,d,x,a[maxn];

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

  cin>>n>>d>>x;
  int tot = x;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  for (int day=0; day<d; day++) {
    for (int i=0; i<n; i++) {
      tot += (day%a[i] == 0);
    }
  }

  out(tot);
  

  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$m = $s = 0;
$min = 10 ** 9;
for ($i = 0; $i < $n; $i++) {
	if ($a[$i] < 0) $m++;
	$x = abs($a[$i]);
	if ($x < $min) $min = $x;
	$s += $x;
}
echo $m % 2 ? $s - $min * 2 : $s;

Measured memory_bytes: 14840
answer = [[[0]*10 for i in range(3)] for k in range(4)]
N = int(input())
for i in range(N):
    b, f, r, v = map(int, input().split())
    answer[b-1][f-1][r-1] += v
    
for i in range(3):
    for k in range(3):
        for l in range(10):
            print(" " + str(answer[i][k][l]),end="")
        print()
    print("#"*20)
for k in range(3):
    for l in range(10):
        print(" " + str(answer[3][k][l]),end="")
    print()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  string a;
  cin >> a;
  string ans = "AC";
  if (a.at(0) != 'A') ans = "WA";
  int cnt = 0;
  rep(i, a.size() - 1){
    if (isupper(a.at(i + 1))){
      cnt++;
      if (i == 0 || i == a.size() - 2 || a.at(i + 1) != 'C') ans = "WA";
    }
  }
  if (cnt != 1) ans = "WA";
  cout << ans << endl;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
mod = 2019
frem = []
srem = []
if r - l + 1 >= 2019:
    ans = 0
else:
    for i in range(l, r+1):
        frem.append(i % mod)
    for i in range(len(frem)):
        for j in range(i+1, len(frem)):
            # print(frem[i], frem[j])
            srem.append(frem[i]*frem[j] % mod)
    # srem.sort()
    ans = min(srem)

print(ans)

Measured memory_bytes: 75436
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int P = 924844033 , N = 2020;
int n,K,f[N]={1},g[N];
vi all;
void pp(int &x,int d){
    x += d;if(x >= P) x -= P;
}
vi merge(vi&a,vi&b){
    vi c(sz(a)+sz(b)-1,0);
    rep(i,0,sz(a)) rep(j,0,sz(b)) pp(c[i+j],1ll*a[i]*b[j]%P);
    return c;
}
int dp[N][N][2] , dp2[N][N][2];
vi gt(int sz,bool has1,bool has2){
    //cout << sz << " " << has1 << " " << has2 << endl;
    vi r(sz+1,0);
    if(has1){
        for(int i=0;i<=sz;++i) pp(r[i],dp2[sz][i][0]);
        if(has2) for(int i=0;i<=sz;++i) pp(r[i],dp2[sz][i][1]);
    }
    else{
        for(int i=0;i<=sz;++i) pp(r[i],dp[sz][i][0]);
        if(has2) for(int i=0;i<=sz;++i) pp(r[i],dp[sz][i][1]);
    }
    return r;
}

int main(){
    scanf("%d%d",&n,&K);
    dp[0][0][1] = 1;
    rep(i,1,n+1) rep(j,0,i+1){
        dp[i][j][0] = dp[i-1][j][0];
        pp(dp[i][j][0] , dp[i-1][j][1]);
        if(j) pp(dp[i][j][0] , dp[i-1][j-1][0]);
        if(j) pp(dp[i][j][1] , dp[i-1][j-1][0]) , pp(dp[i][j][1] , dp[i-1][j-1][1]);
    }
    dp2[0][0][0] = 1;
    rep(i,1,n+1) rep(j,0,i+1){
        dp2[i][j][0] = dp2[i-1][j][0];
        pp(dp2[i][j][0] , dp2[i-1][j][1]);
        if(j) pp(dp2[i][j][0] , dp2[i-1][j-1][0]);
        if(j) pp(dp2[i][j][1] , dp2[i-1][j-1][0]) , pp(dp2[i][j][1] , dp2[i-1][j-1][1]);
    }
    rep(i,1,N) f[i] = 1ll * f[i-1] * i % P;
    int ans = f[n];
    all.pb(1);
    for(int i=1;i<=min(K+K,n);++i){
        int j = 0;
        int cc = 0;for(j=i;j<=n;j+=K+K) ++cc;
        j -= K + K;
        vi v = gt(cc , i > K , j + K <= n);
        //rep(i,0,sz(v)) printf("%d%c",v[i]," \n"[i+1==sz(v)]);
        if(cc) all = merge(all , v);
    }
    rep(i,0,sz(all)) g[i] = all[i];
    rep(i,1,n+1){
        if(i&1) pp(ans , P - 1ll * f[n-i] * g[i] % P);
        else pp(ans , 1ll * f[n-i] * g[i] % P);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 45568
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  vector<bool> dp(k+1, false);

  REP(i, k+1){
    REP(j, n){
      if(i-a[j] < 0) break;
      dp[i] = dp[i] | !dp[i-a[j]];
    }
  }

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
#define ll long long
using namespace std;

const ll INF = (1LL<<32);
const int MAX = 100;
long long A[MAX + 1][MAX + 1];

void warshallFloyd(int V) {
  rep(k, V) rep(i, V) {
    if (A[i][k] == INF) continue;
    rep(j, V) {
      if (A[k][j] == INF) continue;
      A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
    }
  }
}

int main() {
  int V, E;
  cin >> V >> E;

  rep(i, V) rep(j, V) {
    A[i][j] = (i == j)? 0 : INF;
  }

  rep(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    A[s][t] = d;
  }

  warshallFloyd(V);

  rep(i, V) {
    if (A[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  rep(i, V) {
    rep(j, V) {
      if (A[i][j] != INF) cout << A[i][j];
      else cout << "INF";
      cout << ((j != V - 1)? " " : "\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int main(){
char c11,c12,c13;
cin>>c11>>c12>>c13;
char c21,c22,c23;
cin>>c21>>c22>>c23;
char c31,c32,c33;
cin>>c31>>c32>>c33;
cout<<c11<<c22<<c33;
return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
//#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define int long long
#define  mk(a, b) make_pair(a, b)
//#define x first;
//#define y second;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e12;
const int MOD = 1000000007;
const int MAXN = 3e5;
const ld eps = 1e-6;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    //        freopen("a.in", "r", stdin);
#else
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
#endif
}


void solve(){
    string s;
    cin >> s;
    if(s.size()&1){
        cout << "No";
        return;
    }
    for(int i=1; i<s.size(); i+=2){
        if(s[i-1]!='h' || s[i]!='i'){
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

signed main() {
    fast_io();
    int q = 1;
//    cin >> q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
long long sigma, ans, N;
long long a[200000];
multiset<long long> s;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    sigma += a[i];
    if (sigma == 0) {
      ans++;
    }
    s.insert(sigma);
  }
  while (!s.empty()) {
    set<long long>::iterator i = s.begin();
    size_t n = s.count(*i);
    if (n >= 2) {
      ans += n * (n - 1) / 2;
    }
    s.erase(*i);
  }

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



Measured memory_bytes: 11136
#include <stdio.h>
#include <limits.h>
#include <cmath>

using namespace std;

#define ul unsigned long int 

ul gcd(ul a, ul b) { 
   if (b == 0) return a; 
    return gcd(b, a % b);  
} 

ul lcm(ul a, ul b){
    return a * b / gcd(a, b);
}

// X以下のうちCでもDでも割り切れる数
ul f(ul X, ul C, ul D) {
    return X - X / C - X / D + X / lcm(C, D);
}

int main() {
    ul A, B;
    ul C, D;
    scanf("%ld", &A);
    scanf("%ld", &B);
    scanf("%ld", &C);
    scanf("%ld", &D);

    ul ans = f(B, C, D) - f(A-1, C, D); 
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	cin>>N;
	ll h,n;
	for(h = 1; h<=3500; ++h){
		for(n = h; n<=3500; ++n){
			ll div = (4*h*n-N*n-N*h); 
			if(div == 0)continue;
			ll w = (N*h*n) / div;
			// printf("[%lld, %lld] -> %lld, %lld\n", h,n,div, w);
			if((N*h*n) % div == 0 && w > 0){
				printf("%lld %lld %lld\n", h, n, w);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	rep(i, a) cin >> p[i];
	rep(i, b) cin >> q[i];
	rep(i, c) cin >> r[i];
	sort(rall(p));
	sort(rall(q));
	sort(rall(r));
	vector<int> res;
	rep(i, x) res.emplace_back(p[i]);
	rep(i, y) res.emplace_back(q[i]);
	rep(i, c) res.emplace_back(r[i]);
	sort(rall(res));
	ll ans = 0;
	rep(i, x + y) ans += res[i];
	dunk(ans);
	return 0;
}


Measured memory_bytes: 3572
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))



(defparameter modn (+ (expt 10 9) 7))

(defun func(x)
  (if (<= x 1)
	1
	(mod (* x (func (1- x))) modn)))

(princ (func (read)))


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x)  (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    int a;
    bool f = true;
    rep(i, n) {
        cin >> a;
        if(a % 2 == 0) {
            if(a % 3 != 0 && a % 5 != 0){
                f = false;
            }
        }
    }

    cout << (f ? "APPROVED" : "DENIED") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
int main(){
cin >> N;
ll mini;
cin >> mini;
ll res = -1000000000000LL;
for(int i=1;i<N;i++){
int a; cin >> a; 
res = max( res, a-mini );
mini = min( mini, (ll)a );
}
cout << res << endl;
}

Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    vector<vector<int> > a(3,vector<int>(3));
    vector<vector<int> > d(3,vector<int>(3));
    rep(i, 3){
        rep(j,3) cin>>a.at(i).at(j);
    }
    
    int n;
    cin>>n;
    int b;
    rep(i,n){
        cin>>b;
        rep(j,3)rep(k,3) if(b==a.at(j).at(k)) d.at(j).at(k)=1;
    }
    
    bool judge=false;
    rep(i,3){
        int cnt=0;
        rep(j, 3) cnt+=d.at(i).at(j);
        if(cnt==3) judge=true;
    }
    
    rep(i,3){
        int cnt=0;
        rep(j, 3) cnt+=d.at(j).at(i);
        if(cnt==3) judge=true;
    }
    
    int cnt=0;
    rep(i,3) cnt+=d.at(i).at(i);
    if(cnt ==3) judge=true;
    
    cnt=0;
    rep(i,3) cnt+=d.at(i).at(2-i);
    if(cnt==3) judge=true;
    
    if(judge) dunk("Yes");
    else dunk("No");
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n,m,c;
  cin>>n>>m>>c;
  vint b(m);
  repi(m)cin>>b[i];
  int a[n][m];
  rep(i,n)rep(j,m)cin>>a[i][j];
  int ans=0;
  rep(i,n){
      int res=0;
      rep(j,m)res+=a[i][j]*b[j];
      res+=c;
      if(res>0)ans++;
  }
  out(ans);

  return 0;
}


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

using namespace std;

int main(){
  int N,M,A;
  int temp,cunt=0;

  cin>>N>>M;
  for(int i=1;i<=M;i++){
    cin>>A;
    if(M<A)
      cunt++;
  }

  cout<<cunt<<endl;

  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int a,b,c;
    cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

int main (){
  int n, a, b;
  cin >> n >> a >> b;
  a = a * n;

  if (a == b) {
    cout << b << endl;
  }else if (a > b){
    cout << b << endl;
  }else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int N,A[1001],LCM;
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
void MRoy(){
    scanf("%d",&N);
    for(int i = 0;i<N;i++) {
        scanf("%d",A+i);
        if(i == 0) LCM = A[i];
        LCM = lcm(LCM, A[i]);
    }
    double SUM = 0;
    for(int i = 0;i<N;i++){
        SUM += (LCM/A[i]);
    }
    printf("%.10lf\n",(1.0*LCM/SUM));
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 26 18:51:52 2020

@author: 藤原聖士
"""

N = int(input())
a = list(map(int,input().split()))

list.sort(a,reverse=True)

fugou=1
count=0

for i in range(N):
    count+=a[i]*fugou
    fugou*=-1

print (count)

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

int main() {
	string name;
	int am, pm;
	
	while(cin >> name){
		cin >> am >> pm;
		cout << name << " " << am + pm << " " << am * 200 + pm * 300 << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long ans = 0;
    if (a[0] > 0) { cout << -1 << endl; return 0; }
    for (int i = 1; i < n; i++) if (a[i-1] + 1 < a[i]) { cout << -1 << endl; return 0; }
    for (int i = n-1; i > 0; i--) {
        ans += a[i];
        while (i > 0 && a[i] == a[i-1] + 1) i--;
    }
    cout << ans << endl;
}


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

int main(){
    string S;
    cin >> S;
    bool No=false, So=false, We=false, Ea=false;
    for(int i=0; i<S.size(); i++){
      if(S[i]=='N') No=true;
      if(S[i]=='S') So=true;
      if(S[i]=='W') We=true;
      if(S[i]=='E') Ea=true;
    }
    if(No!=So || We!=Ea){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
    double a, b, C;
    cin >> a >> b >> C;
    
    double cr = M_PI * C / 180;
    double h = b * sin(cr);

    printf("%.5f\n", 0.5 * a * h); // S
    printf("%.5f\n", a + b + sqrt(a * a + b * b - 2 * a * b * cos(cr))); // L
    printf("%.5f\n", h); // h

    return 0;
}


Measured memory_bytes: 3444
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int N = sc.nextInt();
        Integer a[] = new Integer[N];
        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int Alice = 0;
        int Bob   = 0;
        for (int i=0; i<N; i+=2) {
            Alice += a[i];
        }
        for (int i=1; i<N; i+=2) {
            Bob += a[i];
        }
        System.out.println(Alice - Bob);
        
    }
    
}

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: 21204
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a,b,c;
      cin>>a>>b>>c;
      int Train =a*b;
      int Taxi = c;
      if(Train>Taxi){
        cout<<Taxi<<endl;
      }
      else{
          cout<<Train<<endl;
      }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rank tipa_rank
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 1000000000
#define EPS 1e-6
#define EPS2 1e-8
using namespace std;
const ll MOD = INF + 7;
using namespace std;
int ans;
int n;
int a[100000];
bool good(int x)
{
	ll sz = 0;
	for(int i = 0; i <= x; i++)
	{
		sz += a[i];
	}
	bool good = true;
	for(int i = x + 1; i < n; i++)
	{
		if(a[i] <= 2 * sz)
		{
			sz += a[i];
		}
		else
		{
			good = false;
			break;
		}
	}
	return good;
}
int main()
{
	scanf("%d" , &n);
	for(int i = 0; i < n; i++)
		scanf("%d" , &a[i]);
	sort(a , a + n);
	int l = 0 , r = n - 1;
	while(abs(r - l) > 1)
	{
		int m = (l + r) / 2;
		if(good(m))
		{
			r = m;
		}
		else
		{
			l = m + 1;
		}
	}
	if(l > r)
	{
		swap(l , r);
	}
	if(good(l))
	{
		cout << n - l;
	}
	else
		cout << n - r;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
typedef long long ll;

using namespace std;

ll a, b, c, d;
ll a1[4];

int main() {
	cin >> a >> b >> c >> d;
	a1[0] = a * c; a1[1] = a * d; a1[2] = b * c; a1[3] = b * d;
	sort(a1, a1 + 4);
	cout << a1[3] << '\n';
}

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

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


int main(){
  int r, c;
  cin >> r >> c;
  int v[105][105];
  rep(i,r)rep(j, c){
    cin >> v[i][j];
  }
  int sum = 0;
  rep(i,c){
    rep(j,r){
      sum += v[j][i];
    }
    v[r][i] = sum;
    sum = 0;
  }

  rep(i, r+1){
    rep(j, c){
      sum += v[i][j];
      cout << v[i][j] << " ";
    }
    cout << sum << endl;
    sum = 0;
  }
}






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

int main(){
    long double PI = acos(-1);

    long double a,b,x; cin >> a >> b >> x;
    long double ans;

    if(a*a*b <= 2*x ) {
        ans = atan(2*(a*a*b-x) / (a*a*a));
    }else{
        ans = PI/2 - atan(2*x/(a*b*b));
    }

    long double d_ans = (ans * 180)/PI;
    printf("%Lf\n",d_ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> an(n + 1);
  std::vector<int> bn(n);
  for (auto &a : an) {
    std::cin >> a;
  }
  for (auto &b : bn) {
    std::cin >> b;
  }

  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    if (an[i] > bn[i]) {
      an[i] -= bn[i];
      sum += bn[i];
    } else {
      bn[i] -= an[i];
      sum += an[i];
      an[i] = 0;
      int before = an[i + 1];
      an[i + 1] = std::max(an[i + 1] - bn[i], 0);
      sum += before - an[i + 1];
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int s,w; cin >> s >> w;

    if(s<=w) cout << "unsafe" << endl;
    else cout <<"safe" << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{

	/* 自然数 */
	int num;

	/* 各桁の数字 */
	int dig;

	/* 和 */
	int sum = 0;

	scanf("%d", &num);

	int a = num;

	/* 自然数の各桁の数字の和を計算 */
	while(num){
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}

	/* 各桁の数字の和を出力 */
	printf("%s", a % sum == 0 ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll modpow(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=modpow(a,b/2,p);
		return t*t%p;
	}
	return a*(modpow(a,b-1,p))%p;
} 
//cout << fixed << setprecision(桁数);
//__builtin_popcount()
signed main(){
	ll k,n; cin>>k>>n;
	vl vec(n);
	rep(i,0,n) cin>>vec[i];
	ll ans=0;
	rep(i,1,n)chmax(ans,vec[i]-vec[i-1]);
	chmax(ans,vec[0]+(k-vec[n-1]));
	cout<<k-ans<<endl;
		
	return 0;
}


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

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

llint x,y;

int main()
{
	cin>>x>>y;
	if(y==1 || x%y==0)
	cout<<-1;
	else
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
cnt = 0
n = int(raw_input())
A = [int(raw_input()) for _ in range(n)]
G = [1] if n < 5 else [1, 4]
while G[-1]*3+1 <= n/3: G.append(G[-1]*3+1)
G.reverse()

def insersionSort(g):
	global cnt
	for i in range(g, n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v

def shellSort():
	for g in G:
		insersionSort(g)

shellSort()
print len(G)
print " ".join(map(str, G))
print cnt
print "\n".join(map(str, A))

Measured memory_bytes: 126968
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		String s = nextToken();
		int balance = 0;
		int ans = s.length();
		for (char c : s.toCharArray()) {
			if (c == 'S') {
				balance++;
			} else {
				if (balance > 0) {
					ans -= 2;
					balance--;
				}
			}
		}
		
		out.println(ans);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 13344
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();vector<ll>a(n,-1),b(n-1);
    for(ll i=0;i<n-1;++i)b[i]=in();
    for(ll i=0;i<n;++i){
        a[i]=i==0?b[0]:i==n-1?b[n-2]:min(b[i-1],b[i]);
    }
    cout<<accumulate(a.begin(),a.end(),0LL)<<endl;
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    int sum = 0;
    for (char c : s) sum += int(c - '0');
    cout << (sum % 9 == 0 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        int d1 = x2 - x1;
        int d2 = y2 - y1;

        System.out.println((x2 - d2) + " " + (y2 + d1) + " " + (x1 - d2) + " " + (y1 + d1));

	}

}


Measured memory_bytes: 23764