akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char S[12];
void solve(int dep, int use = 0){
  int i;
  if(dep==N){
    wt_L(S);
    wt_L('\n');
    return;
  }
  for(i=(0);i<(use+1);i++){
    S[dep] = 'a' + i;
    solve(dep+1,max_L(use, i+1));
  }
}
int main(){
  rd(N);
  solve(0);
  return 0;
}
// cLay varsion 20200314-1

// --- original code ---
// int N;
// char S[12];
// 
// void solve(int dep, int use = 0){
//   if(dep==N){
//     wt(S);
//     return;
//   }
//   rep(i,use+1){
//     S[dep] = 'a' + i;
//     solve(dep+1, max(use, i+1));
//   }
// }
// 
// {
//   rd(N);
//   solve(0);
// }


Measured memory_bytes: 2560
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        Arrays.sort(l, Collections.reverseOrder());
        int result = 0;
        for (int i = 0; i < k; i++) {
            result += l[i];
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21972
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine

getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

getStrArray :: Integer -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

ans :: [Integer] -> Integer
ans [x, y]
    | mod x y == 0 = -1
    | otherwise = x + lcm x y

main = do
    inp <- getIntArray
    print $ ans inp


Measured memory_bytes: 508
#include "bits/stdc++.h"

typedef long long ll;

typedef long double ld;

void ActivateFastIO()
{
	std::ios::sync_with_stdio(false);
	std::cout.tie(nullptr);
	std::cin.tie(nullptr);
}

template <typename type1, typename type2>
std::istream& operator>>(std::istream& in, std::pair<type1, type2>& p)
{
	in >> p.first >> p.second;
	return in;
}

template <typename type1, typename type2>
std::ostream& operator<<(std::ostream& o, const std::pair<type1, type2>& p)
{
	o << p.first << ' ' << p.second;
	return o;
}

template <typename type>
std::istream& operator>>(std::istream& in, std::vector<type>& v)
{
	for (int i = 0; i < v.size(); ++i)
	{
		in >> v[i];
	}
	return in;
}

template <typename type>
std::ostream& operator<<(std::ostream& o, const std::vector<type>& v)
{
	if (!v.empty())
	{
		o << v.front();
	}
	for (int i = 1; i < v.size(); ++i)
	{
		o << ' ' << v[i];
	}
	return o;
}

constexpr int MOD = 998244353;

ll power(ll b, int p)
{
	ll ans = 1;
	while (p)
	{
		if (p & 1)
		{
			ans = (ans * b) % MOD;
		}
		p /= 2;
		b = (b * b) % MOD;
	}
	return ans;
}

int GCD(int a, int b)
{
	while (b)
	{
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

template <typename type>
void Fill(void* arr, int size, type val)
{
	type* ptr = static_cast<type*>(arr);
	for (int i = 0; i < size; ++i, ++ptr)
	{
		*ptr = val;
	}
}

int main()
{
	ActivateFastIO();
	char grid[2][4];
	std::cin >> grid[0];
	std::cin >> grid[1];
	bool flag = true;
	for (int i = 0; i < 3; ++i)
	{
		if (grid[0][i] != grid[1][2 - i])
		{
			flag = false;
		}
	}
	std::cout << (flag ? "YES" : "NO") << '\n';
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> a(N);
  for (auto &ai : a)
    cin >> ai;
  vector<vector<int>> grid(H, vector<int>(W));

  int now = 0;
  int rem = a[now];

  for (int i = 0; i < H; i++)
  {
    if (i % 2 == 0)
    {
      for (int j = 0; j < W; j++)
      {
        grid[i][j] = now + 1;
        rem--;
        if (rem == 0)
        {
          now++;
          rem = a[now];
        }
      }
    }
    else
    {
      for (int j = W - 1; j >= 0; j--)
      {
        grid[i][j] = now + 1;
        rem--;
        if (rem == 0)
        {
          now++;
          rem = a[now];
        }
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cout << grid[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
cnt_d = [0] * (max_a + 1)

for ai in a:
    for multi in range(ai, max_a + 1, ai):
        cnt_d[multi] += 1

print(sum(cnt_d[ai] == 1 for ai in a))

Measured memory_bytes: 31992
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	int a, b, c;
	cin >> a >> b >> c;
	
	int count = 0;
	for (int i = a; i <= b; i++) {
		if (c % i == 0) count++;
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 3128
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif
 
#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

string s;

bool check(int a, int b) {
    --a;
    --b;
    for (int i = a; i < b; ++i) {
        if (s[i] == '#' && s[i + 1] == '#')
            return false;
    }
    return true;
}

void solve(bool __attribute__((unused)) read) {
    int n;  
    int a, b, c, d;
    cin >> n;
    cin >> a >> b >> c >> d;
    cin >> s;
    bool fl0 = check(a, c);
    bool fl1 = check(b, d);
    if (a < b && b < d && d < c) {
        bool fl2 = 0;
        for (int i = b - 1; i < d; ++i) {
            if (i > 0 && i < (int)s.size() - 1 && s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') {
                fl2 = 1;
            }
        }
        if (fl0 && fl1 && fl2)
            cout << "Yes\n";
        else
            cout << "No\n";
    } else {
        if (fl0 && fl1)
            cout << "Yes\n";
        else
            cout << "No\n";
    }

}

Measured memory_bytes: 592
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int x[100005];
int y[100005];
int n,w,h;

int main() {
    cin>>n>>w>>h;
    rep(i,n) {
        int a,b,c;
        cin>>a>>b>>c;
        x[max(0,a-c)]++;
        x[min(100004,a+c)]--;
        y[max(0,b-c)]++;
        y[min(100004,b+c)]--;
    }
    rep(i,100005) if(i) x[i]+=x[i-1];
    rep(i,100005) if(i) y[i]+=y[i-1];
    bool ok1=true;
    bool ok2=true;
    rep(i,w) ok1&=x[i]!=0;
    rep(i,h) ok2&=y[i]!=0;
    if(ok1||ok2) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 1940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, h[100], ta = 0;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	ta += h[0];
	for (int i = 1; i < n; i++) {
		if (h[i - 1] < h[i]) {
			ta += h[i] - h[i - 1];
		}
	}
	cout << ta << endl;
	getchar(); getchar();
	return 0;
}

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

int main(void){
    int N,L;
    cin>>N>>L;
    vector<string> S(N);
    for (int i=0;i<N;i++) cin>>S[i];
    sort(S.begin(),S.end());
    for (int i=0;i<N;i++) cout<<S[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

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>>;

auto R(int s, int n) {
    return boost::irange(s, n);
}
auto R(int n) {
    return boost::irange(0, n);
}
void show(const auto& v){
    for(auto i:v) cout << i << " ";
    cout << endl;
}

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

    VI p(n,0);
    VVI q(n,VI{});
    for(ll i:R(n)){
        int j;
        cin >> j;
        p.at(i)=j-1;
        q.at(p.at(i)).push_back(i);
    }
    queue<int> que;
    VI a(n,-1);
    for(ll i:R(n)){
        if(q.at(i).size()==0){
            a.at(i)=0;
            que.push(p.at(i));
        }
    }

    while(que.size()){
        int i = que.front();
        que.pop();
        if(a.at(i)>=0) continue;
        set<int> s;
        bool ng=false;
        for(int j:q.at(i)){
            if(a.at(j)<0) ng=true;
            s.insert(a.at(j));
        }
        if(ng) continue;
        int g=0;
        while(s.count(g)) g++;
        a.at(i)=g;
        que.push(p.at(i));
    }

    int loop_start;
    for(ll i:R(n)){
        if(a.at(i)==-1) {
            loop_start=i;
            break;
        }
    }
    int a_loop_start_1,a_loop_start_2;
    {
        set<int> s;
        for(ll i:q.at(loop_start)){
            s.insert(a.at(i));
        }
        a_loop_start_1=0;
        while(s.count(a_loop_start_1)) a_loop_start_1++;
        a_loop_start_2 = a_loop_start_1+1;
        while(s.count(a_loop_start_2)) a_loop_start_2++;
    }


    auto func = [&](int a_loop_start){
        a.at(loop_start)=a_loop_start;
        int next=p.at(loop_start);
        while(next!=loop_start){
            set<int> s;
            for(ll i:q.at(next)){
                s.insert(a.at(i));
            }
            int g=0;
            while(s.count(g)) g++;
            a.at(next)=g;
            next=p.at(next);
        }
        set<int> s;
        for(ll i:q.at(loop_start)){
            s.insert(a.at(i));
        }
        int g=0;
        while(s.count(g)) g++;
        return g==a.at(loop_start);
    };


    if(func(a_loop_start_1)) cout<<"POSSIBLE"<<endl;
    else if(func(a_loop_start_2)) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  map<int,int>M;
  for(int i=0;i<N;i++){
  int a;
    cin>>a;
    if(M.count(a))
      M.at(a)++;
    else
      M[a]=1;
  
  }vector<int>A={0};
  for(auto p:M){
  auto k=p.first;
    auto v=p.second;
    A.push_back(v);
  
  }sort(A.begin(),A.end());
  int m=A.size();
  if(m-1<=K)
    cout<<0<<endl;
  else{
   int ans=0;
    for(int i=1;i<=m-K-1;i++)
      ans+=A.at(i);
    cout<<ans<<endl;
  }
  
   return 0;
}

Measured memory_bytes: 10748
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int arr[5];
    for(int i=0;i<5;i++){
        cin>>arr[i];
    }
    for(int i=0;i<5;i++){
        if(arr[i]!=i+1){
            cout<<i+1<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3620
import math

input()
vx = [int(i) for i in input().split()]
vy = [int(i) for i in input().split()]

Dxy = []
for p in range(1,4):
    Dxy.append(sum([abs(vx[i] - vy[i]) ** p for i in range(len(vx))]) ** (1/p))

Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))
for res in Dxy:
    print("{0:.5f}".format(res))

Measured memory_bytes: 6852
#include <stdio.h>
#include <stdlib.h>

void solve(long **G, int n, int u, long *d, int t) {
  int i;
  char *flag;
  flag = (char*)malloc(sizeof(char) * n);
  for (i = 0; i < n; i++) {
    if(G[u][i] != -1 && (d[i] == -1 || d[i] > t+G[u][i])) {
      flag[i] = 1;
      d[i] = t+G[u][i];
    }
    else flag[i] = 0;
  }
  for (i = 0; i < n; i++) {
    if(flag[i] == 1) {
      solve(G,n,i,d,t+G[u][i]);
    }
  }
  free(flag);
}

int main()
{
  int n;
  int i,j,u,k,v;
  long **G,c;
  long *d;
  scanf("%d",&n);
  G = (long**)malloc(sizeof(long*) * n);
  for (i = 0; i < n; i++) {
    G[i] = (long*)malloc(sizeof(long) * n);
    for(j = 0; j < n; j++) G[i][j] = -1;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d %ld", &v, &c);
      G[u][v] = c;
    }
  }
  d = (long*)malloc(sizeof(long) * n);
  d[0] = 0;
  for (i = 1; i < n; i++) {
    d[i] = -1;
  }
  solve(G,n,0,d,0);
  for (i = 0; i < n; i++) {
    printf("%d %ld\n", i, d[i]);
  }
  return 0;
}



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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const ll INF = LLONG_MAX / 2;
const int MOD = 1e9 + 7;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	string s; cin >> s;
	int N = s.length();
	s = "a" + s + "a";
	int M; cin >> M;
	union_find uf(N + 2);
	while (M--) {
		int l, r; scanf("%d%d", &l, &r), r++;
		uf.unite(l, r);
		// cout << l << ' ' << r << endl;
	}
	for (int i = 1; i <= N + 1; i++) {
		uf.unite(i, N + 2 - i);
		// cout << i << ' ' << N + 2 - i << endl;
	}
	vector<int> a(N + 2);
	for (int i = 1; i <= N + 1; i++) {
		char c = s[i - 1], d = s[i];
		int j = uf.find(i);
		a[j] += c - d;
		c = s[N + 2 - i - 1], d = s[N + 2 - i];
		a[j] += c - d;
	}
	rep(i, N + 2) if (a[i] % 26) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Text;
 
class TEST{
	static void Main(){
		String s;
		while((s=Console.ReadLine())!=null){
			var mySol = new Sol(s);
			mySol.dmy();
		}
	}
}
 
 
class Node{
	public Node parent;
	public Node left;
	public Node right;
	public Node(){
		parent=null;
		left=null;
		right=null;
	}
}
 
 
class Sol{
 
	 
	public Sol(string sin){
		var s=sin.Split(' ');
		if(s[0][0]=='i')drawIntersection(s[1],s[2]);
		if(s[0][0]=='u')drawUnion(s[1],s[2]);
	}
	
	public void dmy(){
		//dummy (コンストラクタだけでは warningがでたorz。
	}
	
	public Node parse(String tree){
		// 文字列から2分木を復元
		Node TOP=new Node();
		Node Q=TOP;
		
		for(int i=1;i<tree.Length;i++){
 
			if(tree[i]=='('){
				if(tree[i-1]==','){
					Q.right=new Node();
					Q.right.parent=Q;
					Q=Q.right;
				}
				if(tree[i-1]=='('){
					Q.left=new Node();
					Q.left.parent=Q;
					Q=Q.left;
				}
			}
			if(tree[i]==','){
				continue;
			}
			if(tree[i]==')'){
				if(Q.parent!=null)Q=Q.parent;
 
			}
		}
		return TOP;
	}
 
	public String parse(Node P){
		//2分木から文字列へ
		String s="";
		s=s+"(";
		if(P.left!=null){
			s+=parse(P.left);
		}
		s+=",";
		if(P.right!=null){
			s+=parse(P.right);
		}
		s+=")";
		return s;
	}

	public void drawUnion(String sA,String sB){
		//和集合の2分木を作る。先頭ノートは確保必要
		Node A=parse(sA);
		Node B=parse(sB);
		
		Node C=new Node();
		C=makeUnion(A,B,C);
		Console.WriteLine(parse(C));
	}
	public void drawIntersection(String sA,String sB){
	
		Node A=parse(sA);
		Node B=parse(sB);
		
		Node C=new Node();
		C=makeIntersection(A,B,C);
		Console.WriteLine(parse(C));
	}
	
	public Node makeIntersection(Node A,Node B,Node C){
		if(A.left!=null && B.left!=null){
			C.left=new Node();
			C.left.parent=C;
			makeIntersection(A.left,B.left,C.left);
		}
		if(A.right!=null && B.right!=null){
			C.right=new Node();
			C.right.parent=C;
			makeIntersection(A.right,B.right,C.right);
		}
		return C;
	}
	
	public Node makeUnion(Node A,Node B,Node C){
		//AとBの和集合の2分木を作る
		//無いノードを追加していくだけ
		C=NodeCopy(C,A);
		C=NodeCopy(C,B);
		return C;
	}
	
	public Node NodeCopy(Node X,Node Y){
		if(Y.left!=null){
			if(X.left==null){
				X.left=new Node();
				X.left.parent=X;
			}
			NodeCopy(X.left,Y.left);
		}
		if(Y.right!=null){
			if(X.right==null){
				X.right=new Node();
				X.right.parent=X;
			}
			NodeCopy(X.right,Y.right);
		}
		return X;
	}
}

Measured memory_bytes: 5280
#include <iostream>

int main()
{
    int m, f, b;
    std::cin >> m >> f >> b;
    if (m + f < b) {
        std::cout << "NA" << std::endl;
    } else {
        std::cout << std::max(0, b - m) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
BI=[(b,i) for i,b in enumerate(B)]

# Segment tree(1-indexed,再帰を使わないもの)

seg_el=1<<(N.bit_length())# Segment treeの台の要素数
SEG=[(0,0)]*(2*seg_el)# 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(N):
    SEG[i+seg_el]=BI[i]

for i in range(seg_el-1,0,-1):# 親の部分もupdate
    SEG[i]=max(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el):# A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1# 子ノードへ
    
    while i!=0:
        SEG[i]=max(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):# 区間[l,r)に関するmaxを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=(0,0)

    while L<R:
        if L & 1:
            ANS=max(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=max(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

ANS=0
while True:
    x,y=getvalues(0,N)
    if x==0:
        break
    if x<A[y]:
        print(-1)
        sys.exit()

    elif x==A[y]:
        update(y,(0,y),seg_el)

    else:
        t=B[(y+1)%N]+B[(y-1)%N]
        if B[y]<t+A[y]:
            print(-1)
            sys.exit()
            
        q=(B[y]-A[y])//t
        ANS+=q
        B[y]-=t*q
        update(y,(B[y],y),seg_el)

print(ANS)
        

            


Measured memory_bytes: 124756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;



int main()
{
    ll n; cin >> n;
    map<string, ll> kind;
    ll kind_size = 0;
    ll count = 0;
    REP(i, n) {
        string _s; cin >> _s;
        sort(ALL(_s));
        kind[_s]++;
    }

    for (auto elem : kind) {
        count += elem.second * (elem.second - 1) / 2;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 11136
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N, T, A;
    cin >> N >> T >> A;
    long double mn = 1000000000.0;
    int mn_i = 0;
    REP(i, N){
        int H;
        cin >> H;
        long double l = T-H*0.006;
        if(chmin(mn, abs(l-A))){
            mn_i = i;
        }
    }
    cout << ++mn_i << el;
}



Measured memory_bytes: 256
A, B = map(int, input().split())
if A == 1:
  if B == 1:
    print('Draw')
  else:
    print('Alice')
else:
  if B == 1:
    print('Bob')
  elif A>B:
    print('Alice')
  elif A<B:
    print('Bob')
  else:
    print('Draw')

Measured memory_bytes: 3060
N = gets.to_i

$counts = [0] * (N + 1)

def add(x, y, z)
  n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
  if n <= N
    # puts "n=#{n}, #{x}, #{y}, #{z}"
    $counts[n] += 1
    false
  else
    # puts "over, n=#{n}, #{x}, #{y}, #{z}"
    true
  end
end

max = 100
(1..max).each do |x|
  (1..max).each do |y|
    (1..max).each do |z|
      add(x, y, z)
    end
  end
end

puts $counts[1..-1]


Measured memory_bytes: 14320
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string s, t;
vector<int> vs[26];
vector<int> vt[26];

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

  cin >> s >> t;

  for (int i = 0; i < s.size(); ++i) vs[s[i]-'a'].push_back(i);
  for (int i = 0; i < t.size(); ++i) vt[t[i]-'a'].push_back(i);

  for (int i = 0; i < 26; ++i) {
    if (vs[i].size() == 0) continue;
    int ti = -1;
    for (int j = 0; j < 26; ++j) {
      if (vt[j].size() != 0 && vs[i][0] == vt[j][0]) {
        ti = j; break;
      }
    }
    if (ti < 0 || vs[i].size() != vt[ti].size()) {
      cout << "No" << endl;
      return 0;
    }

    for (int j = 0; j < vs[i].size(); ++j) {
      if (vs[i][j] != vt[ti][j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;

}


Measured memory_bytes: 2940
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1616&lang=jp
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    ll n, m;
    while (cin >> n >> m, n || m)
    {
        vector<ll> v(n);
        for (int i = 0; i < n; ++i)
            cin >> v[i];

        ll maxV = 0;
        for (int i = 0; i < n; ++i)
        {
            for (int j = i + 1; j < n; ++j)
            {
                if (v[i] + v[j] <= m)
                {
                    maxV = max(maxV, v[i] + v[j]);
                }
            }
        }
        if (maxV != 0)
            cout << maxV << endl;
        else
            cout << "NONE" << endl;
    }
    return 0;
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  ll n, x, m; cin >> n >> x >> m;
  vec c(m, -1);
  vector<ll> a(m+2);
  int s, e;
  a[0] = x;
  for (int i = 1; i < m+2; i++) {
    a[i] = a[i-1] * a[i-1] % m;
    if (c[a[i]] == -1) c[a[i]] = i;
    else {
      s = c[a[i]];
      e = i;
    }
  }

  int y = (n-s) / (e-s); //繰り返し回数
  int z = (n-s) % (e-s); //最後のあまり個数
  ll sa = 0, sb = 0, sc = 0;
  rep(i, s) {
    sa += a[i];
  }
  for (int i = s; i < e; i++) {
    sb += a[i];
  }
  for (int i = s; i < s+z; i++) {
    sc += a[i];
  }

  cout << sa + sb*y + sc << endl;
}


Measured memory_bytes: 4516
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()) mp[s[i]];
  mp.size() == s.size() ? cout << "yes" << endl : cout << "no" << endl;
  return 0;
}

Measured memory_bytes: 256
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 2e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

string s;
char t[maxn], d[maxn];

int N, Q;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> N >> Q >> s;
	for (int i = 0; i < Q; i++) 
		cin >> t[i] >> d[i];
	int pre, suf, l, r, mid, cnt = 0;
	l = -1;
	r = N;
	while (r - l > 1) {
		mid = (l + r) >> 1;
		int x = (l + r) >> 1;
		for (int i = 0; i < Q; i++)
			if (t[i] == s[x]) {
				x += ((d[i] == 'L') ? -1 : +1);
				if (x < 0 || x == N)
					break;
			}
		if (x < 0)
			l = mid;
		else
			r = mid;
	}
	pre = l + 1;	
	l = -1;
	r = N;
	while (r - l > 1) {
		mid = (l + r) >> 1;
		int x = (l + r) >> 1;
		for (int i = 0; i < Q; i++)
			if (t[i] == s[x]) {
				x += ((d[i] == 'L') ? -1 : +1);
				if (x < 0 || x == N)
					break;
			}
		if (x == N)
			r = mid;
		else
			l = mid;
	}
	suf = N - r;
	cout << max(0, N - pre - suf) << "\n";
}


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

int main(){
	// sengen
	long long n,k;
	// nyuryoku
	cin >> n >> k;
	// keisan
	int i=1;
	int keta;
	while(1){
		if(pow(k,i-1)<=n && pow(k,i) > n){
			keta = i;
			break;
		}
		i++;
	}
	// syutsuryoku
	cout << keta;
}

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


int main() {
  int N;
  string S, T;
  cin >> N;
  cin >> S;
  cin >> T;

  string ret = "";
  for(int i=0;i<N;i++){
    ret.append(1, S.at(i));
    ret.append(1, T.at(i));
  }

  cout << ret << endl;
}


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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    cout << max(10*a+b+c, max(10*b+c+a, 10*c+b+a)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


	    while (true) {
		    String[] line = br.readLine().split(" ");

		    int m = Integer.parseInt(line[0]);
		    int f = Integer.parseInt(line[1]);
		    int r = Integer.parseInt(line[2]);

		    if (m == -1 && f == -1 && r == -1) break;

		    if (m == -1 || f == -1) {
		    	System.out.println("F");
		    } else if (80 <= m + f) {
		    	System.out.println("A");
		    } else if (65 <= m + f && m + f < 80) {
		    	System.out.println("B");
		    } else if (50 <= m + f && m + f < 65) {
		    	System.out.println("C");
		    } else if (30 <= m + f && m + f < 50) {
		    	if (50 <= r) {
			    	System.out.println("C");
		    	} else {
			    	System.out.println("D");
		    	}
		    } else 	if (m + f < 30) {
		    	System.out.println("F");
		    }
	    }
	}
}

Measured memory_bytes: 24452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX = 2e5+6;
bool prime[10000009];
int main(){
   ll n,k=1;
   cin>>n;
   ll a[n];
   ll ans=0,l=0;
   rep(i,n) cin>>a[i];
   while(l<n){
       if(a[l]==k) {k++;ans++;}
       l++;
   }
  (ans>=1)? cout<<n-ans:cout<<-1;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    string S;
    cin >> S;
    bool a=true;
    int N=S.size();
    for(int i=0; i<=(N-3)/2; i++){
        if(S.at(i)!=S.at(N-i-1)) a=false;
    }
    for(int i=0; i<=(N-3)/2; i++){
        if(S.at(i)!=S.at((N-3)/2-i)) a=false;
    }
    for(int i=(N+1)/2; i<=N-1; i++){
        if(S.at(i)!=S.at((3*N-1)/2-i)) a=false;
    }
    if(a==true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0017
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	str	= Console.ReadLine();
				if( str == null ) {
					break;
				}

				while( true ) {
					string	tmp	= "";
					foreach( var c in str ) {
						if( (c >= 'a') && (c <= 'z') ) {
							int	cn	= c + 1;
							if( cn > 'z' ) {
								cn	= 'a';
							}
							tmp	+= (char)cn;
						} else {
							tmp	+= c;
						}
					}
					if( (tmp.IndexOf( "the" ) >= 0) || (tmp.IndexOf( "this" ) >= 0) || (tmp.IndexOf( "that" ) >= 0) ) {
						Console.WriteLine( tmp );
						break;
					} else {
						str	= tmp;
					}
				}
			}
		}
	}
}

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

int64_t mod=1000000007;

int64_t f(int n,vector<int64_t>&a){
  if(a.at(n)!=-1)return a.at(n);
  else{
    a.at(n)=(f(n-1,a)+f(n-3,a));
    a.at(n)%=mod;
    return a.at(n);
  }
}

int main(){
  int s;
  cin>>s;
  vector<int64_t>a(s+1,-1);
  if(s<3){cout<<0<<endl;return 0;}
  a.at(0)=0,a.at(1)=0,a.at(2)=0;
  a.at(3)=1;
  int64_t ans;
  ans=f(s,a);
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
def getDis(X,p):
    res = 0
    for x in X:
        res += (x-p)**2
    return res

n = int(input())
X = list(map(int,input().split()))

p = sum(X)//n

for i in range(n):
    d = getDis(X,p)
    if d>getDis(X,p+1):
        p+=1
    elif d>getDis(X,p-1):
        p-=1
    else:
        break

print(d)

Measured memory_bytes: 9012
while True:
    
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    
    for i in range(h):
        for j in range(w):
            if (i+j)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
/* main code starts from line 123. */

/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second
#define pb push_back


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define EACH(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)
#define REACH(i, v) for (auto itr = (v).rbegin(); itr != (v).rend(); itr++)

#define SORT(v) sort(ALL(v))
#define GSORT(v) sort(ALL(v), greater<decltype((v).front())>())


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n-1 to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}


/* ---------- Debug ---------- */

#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;
#define testP2(a, b) cout << "(" << a << ", " << b << ")" << endl;


/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

/* ---------- Global Variance ----------- */


/* ------------- Functions -------------- */


/* ----------- Main Function ------------ */

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

    VI A(3);
    cin >> A[0] >> A[1] >> A[2];
    int K;
    cin >> K;
    GSORT(A);

    REP(i, K) {
        A[0] *= 2;
    }
    int sum = 0;
    REP(i, 3) {
        sum += A[i];
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
	/*
	int a, b;
	std::cin >> a >> b;

	if (a - b * 2 > 0) {
		std::cout << a - b * 2;
	}
	else {
		std::cout << 0;
	}
	*/

	int N;
	std::cin >> N;
	std::vector<int> takoyaki;
	for (int i = 0; i < N; ++i) {
		int hoge;
		std::cin >> hoge;
		takoyaki.push_back(hoge);
	}

	int sum = 0;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			sum += takoyaki[i] * takoyaki[j];
		}
	}
	std::cout << sum;
	return 0;
}

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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE 
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    double n,x,t;
    cin>>n>>x>>t;
    cout<<int(ceil(n/x)*t);
    return 0;
 } 

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

using namespace std;

const long long int INF = 1LL<<60;
const long long int mod = 1e9 + 7;

using Graph = vector<vector<int>>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N+1);
  Graph G(N+1);
  for(int i=1; i<=N; i++) {
    cin >> H[i];
  }
  for(int i=1; i<=M; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  vector<bool> candidate(N+1, true);
  for(int i=1; i<=N; i++){
    if(G[i].size() == 0) ans++;
    else {
      if(candidate[i]) {
        bool good = true;
        for(auto nv: G[i]) {
          if(H[i] > H[nv]){
            candidate[nv] = false;
          } else {
            good = false;
            candidate[i] = false;
          }
        }
        if(good) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8692
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
    int K,N;

    cin >> N;
    cin >> K;

    string S;
    cin >> S;
    if(S[K-1] == 'A')S[K-1]='a';
    else if(S[K-1]=='B')S[K-1]='b';
    else S[K-1]='c';

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  string L;
  cin >> L;
  vector<ll> dp1(L.size()),dp2(L.size());
  dp1.at(0)=1;
  dp2.at(0)=2;
  rep(i,L.size()-1){
    if(L.at(i+1)=='1'){
      dp1.at(i+1)=3*dp1.at(i)+dp2.at(i);
      dp2.at(i+1)=2*dp2.at(i);
      dp1.at(i+1)%=MOD;
      dp2.at(i+1)%=MOD;
    }else{
      dp1.at(i+1)=3*dp1.at(i);
      dp2.at(i+1)=dp2.at(i);
      dp1.at(i+1)%=MOD;
      dp2.at(i+1)%=MOD;
    }
  }
    cout << (dp1.at(L.size()-1)+dp2.at(L.size()-1))%MOD << endl;
}

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


int main(){

	int n=0;
	cin>>n;
	int *S=new int[n];
	for(int i=0; i<n;i++)
		cin>>S[i];

	int q=0;
	cin>>q;
	int *T=new int[q];
	for(int i=0; i<q; i++)
		cin>>T[i];

	int match=0;
	for(int i=0; i<q; i++)
		for(int j=0; j<n; j++)
			if(T[i]==S[j]){
				match++;
				break;
			}

	cout<<match<<endl;
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main() {
	int a, b, c, x, y;
	long ans, sum1, sum2;
	cin >> a >> b >> c >> x >> y;
	ans = a * x + b * y;
	sum1 = 2 * c * max(x, y);
	if (x > y) sum2 = 2 * c * y + (x - y) * a;
	else sum2 = 2 * c * x + (y - x) * b;
	ans = min(min(ans, sum1), sum2);
	cout << ans;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

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

	double h, w, x, y;
	cin >> w >> h >> x >> y;
	cout << (w * h) / 2 << endl;
	if (2 * x == w && 2 * y == h) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll =  long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one

	void dfs(vector<string>& ans, string s, int n) {
		if (s.size() == n) {
			ans.push_back(s);
			return;
		}
		// もっとも高い数字をみる
		int top = 1;
		rep(i, s.size()) {
			chmax(top, (s[i] - 'a') + 1);
		}

		rep(i, top + 1) {
			string t;
			t = s + (char)('a' + i);
			dfs(ans, t, n);
		}
	}
}

int main() {

	int n = inp1;

	// 標準型をすべて出しなさい

	// n種類の文字が出てくる
	// よって，aから初めてn個目までの文字しか出てこない
	vector<string> ans;
	dfs(ans, "a", n);

	sort(allof(ans));

	rep(i, ans.size()) {
		Cout(ans[i]);
	}

	return 0;
}

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

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> c(n), t(n);
    REP(i, n) cin >> c[i] >> t[i];
    int ans = 10000;
    REP(i, n) {
        if(t[i] <= T) ans = min(ans, c[i]);
    }
    if(ans < 10000)
        cout << ans << endl;
    else
        cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 1e9+123;
void yes()
{cout << "Yes" << endl;}
void no()
{cout <<  "No" << endl;}
void q()
{cout << -1 << endl;}

void solve()
{	
	string s, t;
	cin >> s >> t;
	for(int i=0; i<s.size(); i++)
		if(s[i] != t[i])
			return no();
	return yes();
}
int main()
{	
//	int t;
//	cin >> t;
//	while(t--)
		solve();
}

Measured memory_bytes: 3632
N,M=map(int,input().split())
H=list(map(int,input().split()))
T=[[] for i in range(N+1)]
AB=[list(map(int,input().split())) for i in range(M)]
ans=0
for i in range(M):
    T[AB[i][0]].append(AB[i][1])
    T[AB[i][1]].append(AB[i][0])

for i in range(1,N+1):
    flag=True
    for j in range(len(T[i])):
        if H[T[i][j]-1]>=H[i-1]:
            flag=False
    if flag:
        ans+=1
        #print(i)

print(ans)

Measured memory_bytes: 41272
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define FP find_parent
#define MP make_pair

const int MAX_N = 200000;
const int MAX_K = 100000;
const int MAX_L = 100000;

int par[2][MAX_N];
int depth[2][MAX_N];

void init(int n, int type) {
  for (int i=0; i<n; i++) {
    par[type][i] = i;
    depth[type][i] = 0;
  }
}

int find_parent(int x, int type) {
  if (par[type][x] == x) {
    return x;
  } else {
    return par[type][x] = find_parent(par[type][x], type);
  }
}

void unite(int x, int y, int type) {
  x = find_parent(x, type);
  y = find_parent(y, type);
  if (x == y) return;

  if (depth[type][x] < depth[type][y]) {
    par[type][x] = y;
  } else {
    par[type][y] = x;
    if (depth[type][x] == depth[type][y]) depth[type][x]++;
  }
}

int main() {
  int N, K, L, p, q, r, s;
  int type;
  cin >> N >> K >> L;
  type = 0;
  init(N, type);
  for (int i=0; i<K; i++) {
    cin >> p >> q; p--; q--;
    unite(p, q, type);
  }
  type = 1;
  init(N, type);
  for (int i=0; i<L; i++) {
    cin >> r >> s; r--; s--;
    unite(r, s, type);
  }

  map<pair<int, int>, int> ans;
  for (int i=0; i<N; i++) {
    ans[MP(FP(i, 0), FP(i, 1))]++;
  }

  for (int i=0; i<N; i++) {
    cout << ans[MP(FP(i, 0), FP(i, 1))] << " ";
  } cout << endl;
  return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

template<class t>
class Vector2{
	public:
		t x;
		t y;
		Vector2():x(0), y(0){}
		Vector2(t a, t b):x(a), y(b){}
		Vector2(const Vector2 &o):x(o.x), y(o.y){}

		Vector2& operator+=(Vector2 o){x+=o.x;y+=o.y;return *this;}
		Vector2& operator-=(Vector2 o){x-=o.x;y-=o.y;return *this; }
		Vector2& operator*=(t o){x*=o;y*=o;return *this;}
		Vector2& operator/=(t o){x/=o;y/=o;return *this;}

		Vector2 operator+(Vector2 o){return Vector2(*this)+=o;}
		Vector2 operator-(Vector2 o){return Vector2(*this)-=o;}
		Vector2 operator*(t o){return Vector2(*this)*=o;}
		Vector2 operator/(t o){return Vector2(*this)/=o;}

		double abs(){
			return sqrt(x*x+y*y);
		}

		Vector2 normal(){
			return (*this) / abs();
		}
};

template<class t>
double abs(Vector2<t> x){
	return x.abs();
}

template<class t>
double dot(Vector2<t> x, Vector2<t> y){
	return x.x * y.x + x.y * y.y;
}

template<class t>
double cross(Vector2<t> x, Vector2<t> y){
	return x.x * y.y - x.y * y.x;
}

template<class t>
void output(Vector2<t> x){
	printf("%lf %lf\n", x.x, x.y);
}


template<class t>
class straight_line{
	public:
		Vector2<t> f;
		Vector2<t> s;
		straight_line(){
			f = Vector2<t>(0,0);
			s = Vector2<t>(1,0);
		}
		straight_line(Vector2<t> a,Vector2<t> b){
			f = a;
			s = b;
		}

		Vector2<t> projection(Vector2<t> pos){
			pos -= f;
			Vector2<t> n = (s-f).normal();
			Vector2<t> res;
			res = n * dot(pos,n) + f;
			return res;
		}
};

int main(){
	straight_line<double> line;
	{
		Vector2<double> first;
		Vector2<double> second;
		cin >> first.x >> first.y >> second.x >> second.y;
		line = straight_line<double>(first,second);
	}
	int q;
	cin >> q;
	rep(i,q){
		double x,y;
		cin >> x >> y;
		Vector2<double> ans = line.projection(Vector2<double>(x,y));
		printf("%.10lf %.10lf\n",ans.x,ans.y);
	}
	return 0;
}



Measured memory_bytes: 3292