akhauriyash/Code-Regression huggingface dataset:
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0]*2 for _ in range(n)]

for i in range(n-1, -1, -1):
    dp[i][0] = abs((a[i-1] if i > 0 else w) - a[n-1])
    dp[i][1] = abs((a[i-1] if i > 0 else z) - a[n-1])

    for j in range(i+1, n):
        dp[i][0] = max(dp[i][0], dp[j][1])
        dp[i][1] = min(dp[i][1], dp[j][0])

print(dp[0][0])


Measured memory_bytes: 43372
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>


#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
 
using namespace std;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 2e9+7, mod=1e9+7;
const int N = 3e5+134, N1=1e7+134;

ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	cout << n/500*1000+(n%500)/5*5;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		for(int i = 10; i < 1010; i++) {
			if((int)(i * 0.08) == a && (int)(i*0.1) == b) {
				System.out.println(i);
				return;
			}
		}
		System.out.println("-1");
		
	}

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  int ans =0;
  for(int i=0;i<=n-2;i++) {
    ans += (a[i+1]-a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		
		// 計算
		long result = Long.MAX_VALUE;
		for(long i = 1; i <= sqrt(n); i++){
		    if(n%i == 0){
		        long a = n/i;
		        long b = i;
		        result = min(result, a + b - 2);
		    }
		    
		}
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 23764
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc178/tasks/abc178_d

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,szeof(a))
#define pp pair<ll,ll>
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
#define el cout<<'\n';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll dp[2001];

ll find(ll n){

    if(n==0)
    return 1;

    if(n<0)
    return 0;

    if(dp[n]!=-1)
        return dp[n];
    ll ans=0;
    for(int i=3;i<=n;i++){
        ans+=find(n-i);
        ans=ans%mod;
    }
    dp[n]=ans;
    return ans;
}
void solve(){
 ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    
    cout<<find(n);
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {
     solve();
     cout<<endl;
    }
	return 0;
}

Measured memory_bytes: 3576
// ABC152_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    if (N == M)
    {
        cout << "Yes" << "\n";
    } else {
        /* code */
        cout << "No" << "\n";
    }
    
    
    return 0;
}

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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll z = max({a*c,a*d,b*c,b*d});
    cout<<z;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
    int ara[12],i,j,t,n=10;
    for(i=0;i<n;i++)
    {
        scanf("%d", &ara[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(ara[j]>ara[j+1])
            {
                t=ara[j];
                ara[j]=ara[j+1];
                ara[j+1]=t;
            }
        }
    }
    for(i=9;i>6;i--)
        printf("%d\n", ara[i]);
    return 0;
}

Measured memory_bytes: 0
n = int(input())
m = int(input())
S = m
S_max = S
for _ in range(n):
    i, o = map(int, input().split())
    S += i - o
    if S < 0:
        print(0)
        exit(0)
    elif S_max < S:
        S_max = S
print(S_max)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=3010 ;

int main(){
	int r ,g ,b ,n;scanf("%d%d%d%d", &r, &g,&b, &n);
	int ans=0;
	for (int x=0; x<=n; ++x)
		for (int y=0; y<=n; ++y){
			int zz= n-x*r-g*y;
			if ( zz>=0 && zz%b==0) ++ans;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,y,z;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(b%d==0){
		x=b/d;
	
	}
	else{
		x=b/d;
		x=x+1;
	}
	if(c%e==0){
		y=c/e;
	}
	else{
		y=c/e;
		y=y+1;
	}
	if(x<y){
		z=a-y;
		printf("%d\n",z);
	}
	else{
		z=a-x;
		printf("%d\n",z);
	}
	return 0;
}

Measured memory_bytes: 1808
#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, m;
    cin >> n >> m;
    priority_queue<int> a;
    rep (i, n)
    {
        int temp;
        cin >> temp;
        a.push(temp);
    }

    rep (i, m)
    {
        int dc = a.top();
        a.pop();
        a.push(dc /= 2);
    }

    ll ans = 0;
    while (!a.empty())
    {
        int temp = a.top();
        a.pop();
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
def resolve():
    '''
    code here
    '''
    S = input()
    
    is_1st = False
    if S[2] == S[3]:
        is_1st = True

    is_2nd = False
    if S[4] == S[5]:
        is_2nd = True

    is_ans = False
    if is_1st and is_2nd:
        is_ans = True
    
    print('Yes') if is_ans else print('No')
    
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
N = gets.to_i


def n(digits)
  return 1 if digits < 0
  ans = 0
  while digits >= 0
    ans += (10 ** digits)
    digits -= 1
  end
  ans
end

ns = N.to_s.chars
n_head = ns[0].to_i
n_tail = ns[-1].to_i
n_middle = (ns[1..-2] || ['0']).join('').to_i
digits = N.to_s.size
ans = 0
(1..N).each do |n|
  if digits == 1
    ans += 1
    next
  end
  next if n % 10 == 0
  ns = n.to_s.chars
  tail = ns[0].to_i
  head = ns[-1].to_i
  is_same = head == tail
  ans += 1 if is_same
  next if head * 10 + tail > N
  if head > n_head
    ans += n(digits - 3)
  elsif head == n_head
    if tail > n_tail
      ans += n(digits - 3)
      ans += n_middle
    else
      ans += n(digits - 3)
      ans += n_middle + 1 if digits - 2 > 0
    end
  else # head < n_tail
    ans += n(digits - 2)
  end
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, cur;
    bool operator == (const point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (const point b) {return !(*this == b);}
    friend bool operator < (const point a, const point b)
    {
        if(a.x != b.x)
            return a.x < b.x;
        return a.y < b.y;
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}
bool overflow;
ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         if(ans > ans * ans % mod)
                overflow = 1;
         ans = ans * ans % mod;
    }
    else
    {
        ans = fast_exp(x, n - 1);
        if(ans > ans * x % mod)
            overflow = 1;
        ans = ans * x % mod;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 1, ans = 0, p;
        cin >> n;
        ans = (n * 360 / __gcd(n, 360ll)) / n;
        cout << ans << "\n";
     }
     return 0;
}


Measured memory_bytes: 3636
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();
      	String sa = "";
      	String sb = "";
      	for(int i = 0; i < b; i++) sa += String.valueOf(a); 
      	for(int i = 0; i < a; i++) sb += String.valueOf(b); 
      	if(Integer.parseInt(sa) > Integer.parseInt(sb)){
          System.out.print(sa);
        }else{
          System.out.print(sb);
        }
    }
}

Measured memory_bytes: 21716
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int n =N/1000;
    if(N%1000==0){System.out.println(0);}
    else{System.out.println((n+1)*1000-N);}
  }
}

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

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	std::string s;
	std::cin >> s;
	std::cin.ignore();

	if (s == "A") {
		std::cout << "T" << '\n'; 
	}
	else if (s == "C") {
		std::cout << "G" << '\n'; 
	}
	else if (s == "T") {
		std::cout << "A" << '\n'; 
	}
	else if (s == "G") {
		std::cout << "C" << '\n'; 
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int MAX = 110;
const int INF = 1e7;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int dist[MAX][MAX];
bool used[MAX][MAX];

int main() {
  // 入力
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = (i == j ? 0 : INF);
    }
  }
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }

  // ワーシャルフロイド法
  for (int k = 0; k < N; k++) { // 経由頂点
    for (int i = 0; i < N; i++) { // 始点
      for (int j = 0; j < N; j++) { // 終点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  // 始点s、終点tとした時に、点aと点bを結ぶ辺が最短経路に含まれればdist[s][a] + cost[a][b] + dist[b][t] = dist[s][t]が成り立つ
  // さらに、全頂点間の最短距離が求まっているので、始点をsとして、dist[s][a] + cost[a][b] = dist[s][b]も成り立つ
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < M; k++) {
      if (dist[i][a[k]] + c[k] == dist[i][b[k]]) {
        used[a[k]][b[k]] = true;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) if (!used[a[i]][b[i]]) {
    ans++;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def f(N):
    if N == 1: return 0
    fact = factorization(N)
    ans = 0
    count_list = [0]
    for i in range(100):
        for j in range(i+2):
            count_list.append(i+1)
    for k, count in fact:
        ans += count_list[count]
    return ans

def main():
    N = int(input())
    print(f(N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9520
def main():
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]

    DP = [[0, 0, 0] for _ in range(N)]
    DP[0] = abc[0]

    for i in range(1, N):
        for j in range(3):
            tmp = [abc[i][j] + DP[i-1][k] for k in range(3) if k != j]
            DP[i][j] = max(tmp)

    print(max(DP[-1]))

if __name__ == '__main__':
    main()

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


int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  p.at(0) = -1;
  for (int i = 1; i < n; i++) {
    cin >> p.at(i);
  }
  vector<vector<int>> children(n);  // ある組織の子組織の番号一覧
 for (int i = 1; i < n; i++) {
   int parent = p.at(i);  // i番の親組織の番号
   children.at(parent).push_back(i);  // parentの子組織一覧にi番を追加
 }
 int ans;
 for (int i = 1; i < n; i++) {
   cout << children.at(i).size() << endl;
 }
 cout << 0 << endl;
return 0;
}


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

class Program
{
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int A = a[0];
        int B = a[1];
        int C = a[2];
        if (A <= C && C <= B)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13268
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int x,y; cin >> x >> y;
	vector<int> arr = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	cout << (arr[x] == arr[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from bisect import bisect_right

def main():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    # print(s,t)
    s = [-10**12] + s + [10**12]
    t = [-10**12] + t + [10**12]

    for _ in range(Q):
        x = int(input())
        i = bisect_right(s,x)
        j = bisect_right(t,x)
        # print(i,j,x)
        ans = []

        ans.append(max(abs(s[i-1] - x), abs(t[j-1] - x)))
        ans.append(max(abs(s[i] - x), abs(t[j] - x)))
        ans.append(abs(s[i-1] - x) + abs(t[j] - x) + min(abs(s[i-1]-x), abs(t[j]-x)))
        ans.append(abs(s[i] - x) + abs(t[j-1] - x) + min(abs(s[i]-x), abs(t[j-1]-x)))

        print(min(ans))

if __name__ == "__main__":
    main()


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

int main()
{
 int a, b;
 cin >> a >> b;
 if(((a+b)%2)==1)	cout << "IMPOSSIBLE";
 else cout << (a+b)/2;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = abs(a[0] - 0);
  for(int i = 1; i < n; i++) {
    sum += abs(a[i] - a[i-1]);
  }
  sum += abs(a[n-1]);
  //cout << sum << endl;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(i == 0) {
      ans = sum + abs(a[1]) - abs(a[0]) - abs(a[1] - a[0]);
    }else if(i == n-1) {
      ans = sum + abs(a[n-2]) - abs(a[n-2] - a[n-1]) - abs(a[n-1]);
    }else {
      ans = sum + abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <cstdio>

using namespace std;

int n;
int q;

int seg[100000*4];

int query(int k, int l, int r, int a, int b) {
  if (r <= a || b <= l) {
    return 0;
  }
  if (a <= l && r <= b) {
    return seg[k];
  }
  int m = (l + r) / 2;
  return query(2*k+1, l, m, a, b) + query(2*k+2, m, r, a, b);
}

void add(int k, int l, int r, int x, int y) {
  if (!(l <= x && x < r))
    return;
  if (r - l == 1) {
    seg[k] += y;
  }
  else {
    int m = (l + r) / 2;
    add(2*k+1, l, m, x, y);
    add(2*k+2, m, r, x, y);
    seg[k] = seg[2*k+1] + seg[2*k+2];
  }
}

int main(int argc, char *argv[])
{
  scanf(" %d %d", &n, &q);

  int c, x, y;
  for (int i = 0; i < q; i++) {
    scanf(" %d %d %d", &c, &x, &y);
    --x;
    if (c) { // get
      int ret = query(0, 0, n, x, y);
      printf("%d\n", ret);
    } else { // add
      add(0, 0, n, x, y);
    }
  }
  
  return 0;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;


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

	FOR(i,1,50000)
		if (i*(i + 1) / 2 >= X)
		{
			printf("%d\n", i);
			break;
		}

	return 0;
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto a = RDA;

	bool[long] set;
	set[0] = true;
	foreach (i; 0..N)
	{
		bool[long] nSet;
		foreach (key; set.keys)
		{
			if (a[i] == key+1)
				nSet[key+1] = true;
			else
				nSet[key] = true;
		}
		set = nSet;
	}
	long ans;
	foreach (key; set.keys)
		ans.chmax(key);
	if (ans == 0)
		writeln(-1);
	else
		writeln(N-ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 12560
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(int i=0; i<H; i++){
        cin >> S[i];
    }
    bool fst = false;
    vector<vector<int>> G(H,vector<int> (W,-1));
    int now = 1;
    for(int i=0; i<H; i++){
        bool pre = false;
        vector<int> temp(W);
        for(int j=0; j<W; j++){
            if(S[i][j] == '#'){
                if(pre){
                    now++;
                }else{
                    pre = true;
                }
            }
            temp[j] = now;
        }
        if(pre){
            G[i] = temp;
            now++;
        }
        if(!fst and pre){
            for(int k=0; k<i; k++){
                G[k] = G[i];
            }
            fst = true;
        }else if(fst and !pre){
            G[i] = G[i-1];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << G[i][j] << (j!=W-1 ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1280
n = input()
R = range(n)
P = [map(int,raw_input().split())+[i]for i in R]

a = range(n)
def root(x):
    if x != a[x]:a[x]=x=root(a[x])
    return x
def unite(x, y):
    x=root(x);y=root(y)
    a[max(x,y)]=min(x,y)
Q=[]
def s(i):
    P.sort(key=lambda x:x[i])
    for j in R[:-1]:
        Q.append((P[j+1][i] - P[j][i], P[j][2], P[j+1][2]))
s(0);s(1);Q.sort()
ans = 0
for w,x,y in Q:
    if root(x)!=root(y):
        ans += w
        unite(x, y)
print ans


Measured memory_bytes: 47896
import math
n,d=map(int,input().split())
X=[]
for i in range(n):
    x=list(map(int,input().split()))
    X.append(x)
cnt=0
for i in range(n):
    for j in range(i+1,n):
        s=0
        for a,b in zip(X[i],X[j]):
            s+=(a-b)**2
        s=math.sqrt(s)
        if s.is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
def hoge():
  dp = [0] * (n + 5)
  dp[1] = abs(h_list[1] - h_list[0])
  for i in range(2, n):
    dp[i] = min(
      dp[i - 2] + abs(h_list[i] - h_list[i - 2]),
      dp[i - 1] + abs(h_list[i] - h_list[i - 1])
      )
  return dp[n - 1]

def solve():
  global n, h_list
  n = int(input())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

Measured memory_bytes: 13980
n = input()
k = int(input())

n_list = []
for a in n:
    n_list.append(int(a))
n_num = len(n_list)

if n_num < k:
    print('0')
else:

    dp = [[[0] * (n_num + 1) for _ in range(2)]for _ in range(n_num + 1)]

    dp[0][0][0] = 1
    for i in range(n_num):
        for smaller in range(2):
            for j in range(n_num):
                lim = 9 if smaller else n_list[i]
                for x in range(lim + 1):
                    if x != 0:
                        ns = j + 1
                    else:
                        ns = j
                    nlt = smaller | (x < n_list[i])
                    dp[i + 1][nlt][ns] += dp[i][smaller][j]
    ans = dp[n_num][0][k] + dp[n_num][1][k]
    print(ans)

Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;
  char ch = s[k-1];
  string ans="";
  for(int i=0;i<n;i++){
      if(s[i]!=ch){
          s[i]='*';
      }
  }
  cout<<s<<"\n";


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int M = 998244353;

class ModComb {
    long long *fact, *facti;
    int mod;

    int modinv(int a) {
        int x = mod, y = a, p = 1, q = 0, r = 0, s = 1;
        while (y != 0) {
            int u = x / y;
            int x0 = y; y = x - y * u; x = x0;
            int r0 = p - r * u, s0 = q - s * u;
            p = r; r = r0; q = s; s = s0;
        }
        return q < 0 ? q + mod : q;
    }
public:
    explicit ModComb(int n, int m) : mod(m) {
        fact = new long long[n+1];
        facti = new long long[n+1];
        fact[0] = 1; facti[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i-1] * i) % m;
            facti[i] = modinv(fact[i]);
        }
    }

    long long get(int n, int k) {
        if (n < 0 || k < 0 || k > n) return 0;
        return fact[n] * facti[k] % M * facti[n-k] % M;
    }
};

int main() {
    long long n, a, b, k; cin >> n >> a >> b >> k;
    ModComb mc(n, M);
    long long ans = 0;
    for (int p = 0; p <= n; p++) {
        // a*p + b*q = k
        if ((k - a*p) % b) continue;
        long long q = (k - a*p) / b;
        ans += mc.get(n, p) * mc.get(n, q) % M;
        if (ans >= M) ans -= M;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <cstdio>

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

  int res=1;
  int prev;
  scanf("%d", &prev);

  int state=0;
  for (int i=1; i<N; ++i) {
    int A;
    scanf("%d", &A);

    if (state == 1) {
      if (prev > A) {
        ++res;
        state = 0;
      }
    } else if (state == -1) {
      if (prev < A) {
        ++res;
        state = 0;
      }
    } else if (state == 0) {
      if (prev < A) {
        state = 1;
      } else if (prev > A) {
        state = -1;
      }
    }

    prev = A;
  }

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


Measured memory_bytes: 128
a,b = map(int,input().split())
import fractions
import collections
import copy
def prime_factorization(n):
    a = [1]
    n1 = copy.deepcopy(n)
    while n % 2 == 0:
        n //= 2
    if n1 != n:
        a.append(2)
    f = 3
    while f * f <= n:
        if n % f == 0:
            n //= f
            if a[-1] != f:
                a.append(f)
        else:
            f += 2
    if a[-1] != n and n != 1:
        a.append(n)
    return a
print(len(prime_factorization(fractions.gcd(a,b))))


Measured memory_bytes: 5176
import heapq

# s:始点, path[from]:[[cost,to]...] 隣接リスト
def dijkstra(s,path):
    inf = float('inf')
    n = len(path)

    # 距離をinfで初期化
    d = [inf for i in range(n)]
    d[s] = 0

    # sへの距離は0
    q = [(0,s)]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば良い
    while q:
        c,p = heapq.heappop(q)

        # 頂点pまでの距離がheap内のpまでの距離より小さい場合、continue
        if d[p]<c:
            continue

        # 頂点pから伸びる、全ての辺の距離を確認
        for cost,to in path[p]:
            # 頂点pから行ける頂点の距離がpまでの距離とpからの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[to] > d[p] + cost:
                d[to] = d[p]+cost
                heapq.heappush(q,(d[to], to))
    return d


n,m,s,t = map(int, input().split())
s-=1
t-=1
train = [list(map(int, input().split())) for i in range(m)]

yen = [[] for i in range(n)]
snuke = [[] for i in range(n)]

for i in range(m):
    u,v,a,b = train[i]
    u-=1
    v-=1
    yen[u].append([a,v])
    yen[v].append([a,u])
    snuke[u].append([b,v])
    snuke[v].append([b,u])

from_s = dijkstra(s,yen)
to_t = dijkstra(t,snuke)

left = [0 for i in range(n)]
left[-1]=from_s[n-1]+to_t[n-1]


for i in range(1,n):
    left[-i-1]=min(left[-i],from_s[-i-1]+to_t[-i-1])

for i in range(n):
    print(10**15-left[i])



Measured memory_bytes: 129752
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

map <string,bool> m;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int n=read<int>();
	int ans=0;

	while(n--)
	{
		string s;
		cin>>s;
		if(!m[s])
		{
			++ans;
			m[s]=true;
		}
	}

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

	return 0;

}

Measured memory_bytes: 19256
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    [a] <- getIntegerList
    print $ a * a
    return ()
    
 


  -- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-
main = do
    [a,b] <- getIntegerList
    case a+b of
        3 -> putStrLn "3"
        4 -> putStrLn "2"
        5 -> putStrLn "1"
    return ()


    a <- getChar
    putStrLn [chr$(ord a)+1]

ord 'a' --> 97
chr 97 --> 'a'

main = do 
    [a,b] <- getDoubleList
    print $ ceiling $  a / b
  


 「/」はdouble同士でしか使えない

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine

getStringList    = words <$> getLine
getDoubleList    = map (read :: String -> Double) . words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















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

#define pb push_back
#define ff first
#define ss second
#define N 1503
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef pair<int,int> pii;
typedef long long int ll;
typedef long int li;
int mod1 = 998244353;

int m[2003],n,x,y,d;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++) {
        for(int j = i+1;j<=n;j++) {
            d = min(j-i,abs(x-i) + 1 + abs(y - j));
            m[d]++;
        }
    }
    for(int k =1;k<n;k++) cout<<m[k]<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(a,min(b,c))*(a+b+c-max(a,max(b,c))- min(a,min(b,c)))/2 << endl;    
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int K;
    cin >> K;
    string ans = "";
    REP(i, K) {
        ans += "ACL";
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 3688
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# dp[i]: 残りがi個の状態で先手が勝つかどうか
dp = [0 for _ in range(K+1)]

# dp[i] = 0: 残りi個で先手が負ける
# dp[i] = 1: 残りi個で先手が勝つ
# dp[i] = -1: 残りi個でも不明
  
for i in range(K + 1):
    # 遷移先: i-aで、そのとき手番は後手
    # どのi-aも1 = 後手がかならず勝つ = 負け
    # 1つでも0がある = 1つでも勝ち筋がある = (その手を打てば)勝ち
    # どのi-aにも遷移できない = 打てない = 負け
    for a in A:
        # 遷移先が存在し、かつそれが勝ち筋
        if i - a >= 0 and not dp[i - a]:
            dp[i] = 1
            break

if dp[K]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 44784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a < b && b < c) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(void)
{
  int k, a, b;
  cin >> k >> a >> b;
  int i;
  bool ok = false;
  for (i = a; i <= b; i++) {
    if (i % k == 0) {
      ok = true;
      break;
    }
  }
  if (ok) cout << "OK";
  else cout << "NG";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
H,W = list(map(int,input().split()))
if H%3 == 0 or W%3 == 0:
    print(0)
else:
    ans = float('inf')
    a,b,c = H//3*W,(H-H//3)*(W//2),(H-H//3)*(W-W//2)
    ans = min(ans,max(a,b,c)-min(a,b,c))
    a,b,c = (H+2)//3*W,(H-(H+2)//3)*(W//2),(H-(H+2)//3)*(W-W//2)
    ans = min(ans,max(a,b,c)-min(a,b,c))
    a,b,c = W//3*H,(W-W//3)*(H//2),(W-W//3)*(H-H//2)
    ans = min(ans,max(a,b,c)-min(a,b,c))
    a,b,c = (W+2)//3*H,(W-(W+2)//3)*(H//2),(W-(W+2)//3)*(H-H//2)
    ans = min(ans,max(a,b,c)-min(a,b,c))
    a,b,c = H//3*W,H//3*W,(H//3+1)*W
    ans = min(ans,max(a,b,c)-min(a,b,c))
    a,b,c = W//3*H,W//3*H,(W//3+1)*H
    ans = min(ans,max(a,b,c)-min(a,b,c))

    print(ans)

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

using namespace std;

int main() {
    int n, x;
    while (cin >> n) {
        map<int, int> xianren;
        for (int i = 0; i < n; i++) {
            cin >> x;
            auto it = xianren.find(x);
            if (it == xianren.end()) {
                xianren.insert(pair<int, int>(x, 1));
            } else {
                xianren.erase(it);
            }
        }
        cout << xianren.size() << endl;
    }
}

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

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

  int cnt=0;
  int T=0,S=0;    
  stack <char> st;
  for(int i=str.size()-1;i>=0;i--){
    if(str[i]=='T')st.push(1);
    if(str[i]=='S'&&!st.empty()&&st.top()==1)st.pop();
    else if(str[i]=='S') st.push(0);
  }
  cout <<st.size()<<endl;

  return 0;
}


Measured memory_bytes: 772
import java.lang.Math.*
import kotlin.comparisons.compareByDescending

const val MOD = 1000000007L
const val INF = 1000000007L

fun main(args: Array<String>) {
    val (w, h, x, y) = readLongList()

    print(w.toDouble() * h.toDouble() / 2.toDouble())
    print(" ")
    print(if (x + x == w && y + y == h) 1 else 0)

}

fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

inline fun <reified T> dualArray(h: Int, w: Int, init: (Int, Int) -> T) {
    Array(h) { i ->
        return@Array Array(w) { j ->
            return@Array init(i, j)
        }
    }
}

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    val former = mutableListOf<Long>()
    val latter = mutableListOf<Long>()
    (1..max).filter { value % it == 0L }
        .forEach {
            former.add(it)
            latter.add(value / it)
        }
    former.addAll(latter.reversed())
    return former
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

// 二分探索
fun List<Long>.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {
    var start = (_start - 1).toLong()
    var end = _end.toLong()
    while (end - start > 1) {
        val mid = (start + end) / 2
        if (this[mid.toInt()] < target) {
            start = mid
        } else {
            end = mid
        }
    }
    return end.toInt()
}

// bit全探索
inline fun Int.bitAllSearch(body: (Array<Int>) -> Unit) {
    for (bit in 0 until (1 shl this)) {
        val s = mutableListOf<Int>()
        for (i in 0 until this) {
            if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか
                s.add(i)
            }
        }
        body(s.toTypedArray())
    }
}

Measured memory_bytes: 38232
#include<bits/stdc++.h>
#define endl '\n'
#define PI 3.14159265358979323844
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define mp make_pair
#define pb push_back
#define int long long int 
#define forr(i,a,b) for (int i= a; i <b; ++i)
    using namespace std; 
 int n; int a[25][25];
 int dp[22][(1<<22)];
  int matching(int male , int e,int count){
      if(male==(e+1)){
           if(count==0)return 1;
           else return 0;}
    if(dp[male][count]!=-1)return dp[male][count]%1000000007;
    int ans=0;
    forr(j,0,e){
        if( count&(1<<j)){
        if(a[male][j+1]){
            ans+=matching(male+1,e,(count^(1<<j)))%1000000007;
            ans=ans%1000000007;
    }}}
   return dp[male][count]=ans;
      
  }
 
 
 
 signed main(){
     cin>>n;
     forr(i,1,n+1)forr(j,1,n+1)cin>>a[i][j];
     memset(dp, -1 , sizeof dp);
     cout<<matching(1,n,((1<<n)-1));
 }
 

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s; int k;
	cin >>s >>k;

	vector<VL> dp(5, VL(2));
	dp[0][0] = 1;
	rep(i, sz(s)){
		vector<VL> np(5, VL(2));
		rep(j, k+1) rep(d, 10){
			int nj = j + (d>0);
			if(d < s[i]-'0') np[nj][1] += dp[j][0];
			else if(d==s[i]-'0') np[nj][0] += dp[j][0];
			np[nj][1] += dp[j][1];
		}
		swap(dp, np);
	}
	cout << dp[k][0] + dp[k][1] <<"\n";
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])

	var keta = Math.floor(Math.log10(N))
	var count = 0

	if(keta % 2 == 0){
		count = N - Math.pow(10, keta) + 1
	}

	for(i=0; i < keta; i++){
		if(i % 2 == 0){
          count += Math.pow(10, i+1) - Math.pow(10, i)
		}
	}

	console.log(count)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,o=0;
	cin>>n;
	while(n--)
	{
		cin>>a;
		o^=a;
	}
	if(o==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}	
	return 0;
}

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

long long N, A[1 << 18];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	long long ret = 0;
	for (int i = 0; i < N; i++) {
		ret = (2LL * A[i] - ret);
	}

	long long ret2 = ret / 2;
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << ret2;
		ret2 = (2LL * A[i] - ret2);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2048
import copy

n,m = map(int,input().split())

cnt = [0]*(10**5+4)

yy = []
yp = []
for _ in range(m):
    a,b = map(int,input().split())
    a,b = b,a
    yy.append([a,0])
    yp.append([a,b])

inlist = copy.deepcopy(yp)
yp.sort()
yy = dict(yy)

for i in range(m):
    cnt[yp[i][1]]+=1
    yy[yp[i][0]] = cnt[yp[i][1]]

for key,value in inlist:
    print("{:06}{:06}".format(value,yy[key]))

Measured memory_bytes: 60700
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ds = Array(1000000) { 0 }
    val dTmp = readIntegers()
    for (i in 1..n) {
        val d = dTmp[i - 1]
        ds[d]++

        if (i == 1 && d != 0) {
            println(0)
            return
        }

        if (i != 1 && d == 0) {
            println(0)
            return
        }
    }

    var ans = 1L
    val mod = 998244353L
    for (i in 1 until (1000000 - 1)) {
        var pow = 1L
        for (j in 1..ds[i + 1]) {
            pow = (pow * ds[i]) % mod
        }
        ans = (ans * pow) % mod
    }
    println(ans)
}

fun readStrings() = readLine()!!.split(" ")
fun readIntegers() = readStrings().map(String::toInt)


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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  sort(a.begin(),a.end(),greater<int>());
  ll c=a[0];
  int b=1;
  for(int i=0;i<n-2;++i){
    c += a[b];
    //cout<<c<<endl;
    if(i%2==1) b++;
  }
  cout<<c<<endl;


}

Measured memory_bytes: 4844
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = false
    var cnt = 0
    repeat(n) {
        val (d1, d2) = readLine()!!.split(' ').map { it.toInt() }
        if (d1 == d2) cnt++
        else cnt = 0
        ans = ans || cnt == 3
    }
    if (ans) println("Yes")
    else println("No")
}


Measured memory_bytes: 37860