akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*
// 残り１この皿がi枚、残り２この皿がj枚、残り３この皿がk枚
// のときの期待値をexp[i][j][k]とする。
// 操作が１回進むと、、、
// 次に遷移するのは
// exp[i-1][j][k] ... i/Nの確率
// exp[i+1][j-1][k] ... j/Nの確率
// exp[i][j+1][k-1] ... k/Nの確率
// exp[i][j][k] ... (N-i-j-k)/Nの確率
// 遷移すると残り操作回数の期待値が１回分減ってくれるはず
//
//exp[i][j][k] = exp[i-1][j][k] x i/N
//             + exp[i+1][j-1][k] x j/N
//             + exp[i][j+1][k-1] x k/N
//             + exp[i][j][k] x (N-i-j-k)/N
//             + 1
//(i+j+k)x exp[i][j][k] = i x exp[i-1][j][k]
//                      + j x exp[i+1][j-1][k]
//                      + k x exp[i][j+1][k-1]
//                      + N
//exp[i][j][k] = (i x exp[i-1][j][k]
//             + j x exp[i+1][j-1][k]
//             + k x exp[i][j+1][k-1]
//             + N)/(i+j+k)
*/
int N;
vector<int> ai;
vector<vector<vector<double>>> ex;

double rec(int i1, int i2, int i3);

int main() {
  cin >> N;
  ai = vector<int>(N);
  ex = vector<vector<vector<double>>>(N+1,vector<vector<double>>(N+1,vector<double>(N+1, -0.1)));
  int i1=0,i2=0,i3=0;
  for (int i=0;i<N;i++){
    cin >> ai.at(i);
    if (ai.at(i)==1){
      i1++;
    } else if (ai.at(i)==2){
      i2++;
    } else {
      i3++;
    }
  }

  // rec(i1,i2,i3)を求めたい
  // 漸化式はプログラム前のコメント欄より
  cout << fixed << setprecision(10) << rec(i1,i2,i3) << endl;
}

double rec(int i1, int i2, int i3){
  if (ex.at(i1).at(i2).at(i3) >= 0) return ex.at(i1).at(i2).at(i3);
  if (i1 == 0 && i2 == 0 && i3 == 0) {
    return 0.0;
  }

  double ret = 0.0;
  if (i1 > 0) ret += rec(i1-1, i2, i3)*(double)i1;
  if (i2 > 0) ret += rec(i1+1, i2-1, i3)*(double)i2;
  if (i3 > 0) ret += rec(i1, i2+1, i3-1)*(double)i3;
  ret += (double)N;
  ret /= (double)(i1+i2+i3);

  ex.at(i1).at(i2).at(i3) = ret;
  return ret;
}

Measured memory_bytes: 217088
import sys
from io import StringIO
import unittest
import numpy as np

def resolve():
    li = sys.stdin.readlines()
    N = int(li[0].strip())
    a = list(map(int, li[1].strip().split(' ')))
    A = np.array(a[0::2])
    A = (A % 2 == 1)
    print(A.sum())
resolve()

Measured memory_bytes: 32092
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
foreach($a as $i => $b){
  $map[$i+1] = $b;
}
$sum = 0;
foreach($a as $i => $b){
  $sum += $map[$map[$i+1]] == $i+1;
}
echo $sum/2;

Measured memory_bytes: 18932
#include <iostream>

int main() {
    char b;
    std::cin >> b;

    switch (b) {
        case 'A':
            std::cout << 'T' << std::endl;
            break;
        case 'T':
            std::cout << 'A' << std::endl;
            break;
        case 'G':
            std::cout << 'C' << std::endl;
            break;
        case 'C':
            std::cout << 'G' << std::endl;
            break;
    }
}

Measured memory_bytes: 256
f=lambda s,h,w,a,q:s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]*q;g=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1];H,W,N=map(int,raw_input().split());a=[map(int,raw_input())for _ in[0]*H];s,s1,s2=[[[0]*(W+1)for _ in[0]*-~H]for _ in[0]*3]
for h in range(H):
	for w in range(W):s[h+1][w+1]=f(s,h,w,a,1);s1[h+1][w+1]=f(s1,h,w,a,w+1<W and a[h][w+1]);s2[h+1][w+1]=f(s2,h,w,a,h+1<H and a[h+1][w])
for _ in[0]*N:y1,x1,y2,x2=map(int,raw_input().split());print g(s,y1,x1,y2,x2)-g(s1,y1,x1,y2,x2-1)-g(s2,y1,x1,y2-1,x2)

Measured memory_bytes: 165276
def cin; gets.split.map(&:to_i) end

# exit if $0 != __FILE__

# n, *x = cin
# s = gets.chomp

# puts n

n,m = cin
ls = []
m.times do
  a = cin
  a.shift
  ls << a
end
ps = cin

c = 0

(2**n).times do |x|
  # p "x=#{x}"
  all = true
  m.times do |y|
    ons = ls[y].inject(0) {|memo, item| memo + x[item-1]}
    # p "ons=#{ons}"
    all = false if ons % 2 != ps[y]
  end
  c += 1 if all
end

puts c


Measured memory_bytes: 1788
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int C=1000000000;
	int S;
	cin>>S;
	int x1 = (S % C);
	if (x1 != 0) x1 = C - x1;
	int y2 = 1;
	int y1 = C;
	int x2 = (S + x1) / C;
	cout<<0<<" "<<0<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" ";
 
}


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

struct Node{
	int key;
	Node *parent, *left, *right;
};
Node *root, *NIL;
void insert(int x);
void Inorder(Node *u);
void Preorder(Node *u);
int main()
{
	int n, t;
	string s;
	cin >> n;
	while(n--){
		cin >> s;
		if(s == "insert"){
			cin >> t;
			insert(t);
		}
		else if(s == "print"){
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
	}
	return 0;
}
void insert(int t){
	Node *z, *y = NIL, *x = root;
	z = (Node *)malloc(sizeof(Node));//神奇了 
	z -> key = t;
	z -> left = NIL;
	z -> right = NIL;
	while(x != NIL){
		y = x;
		if(t < x -> key){
			x = x -> left;
		}
		else x = x -> right;
	}
	z -> parent = y;
	if(y == NIL) root = z;
	else{
		if(t < y -> key) y -> left = z;
		else y -> right = z;
	}
}

void Inorder(Node *u){
	if(u == NIL) return;
	Inorder(u -> left);
	printf(" %d", u -> key);
	Inorder(u -> right);
}

void Preorder(Node *u){
	if(u == NIL) return;
	printf(" %d", u -> key);
	Preorder(u -> left);
	Preorder(u -> right);
}















Measured memory_bytes: 26584
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


a, b = intsput()

if a in range(1, 10) and b in range(1, 10):
    print(a * b)
else:
    print(-1)


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

int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin>>a[i];
  
  int ans = 0;
  for(int i=0;i<n;++i){
    int mn=1e9+1, last=0;
    for(int j=0;j<n;++j){
      if (a[j]<=0) {
        for(int k=last;k<j;++k){
          a[k] -= mn;
        }
        last = j+1;
        if (mn!=1e9+1) ans += mn;
        mn = 1e9+1;
      } else mn = min(mn,a[j]);
    }
    for(int j=last;j<n;++j){
      if (mn!=1e9+1) a[j] -= mn;
    }
    if(mn!=1e9+1) ans += mn;
  }
  cout<<ans<<endl;
}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int menseki = a * b;
		int syu = 2 * (a + b);
		
		System.out.println(menseki + " " + syu);
		
	}
}

Measured memory_bytes: 26224
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
    while (true)
    {
        C=C-B;
        if(C<=0){
            cout<<"Yes"<<endl;
            return;
        }
        A=A-D;
        if(A<=0){
            cout<<"No"<<endl;
            return;
        }
    }
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,res="";
    cin>>s>>t;
    int n=s.size(),m=t.size(),i,j;
    int b[n+2][m+2];
    for(i=0;i<=n;i++)
    {
        b[i][0]=0;
    }
    for(i=0;i<=m;i++)
    {
        b[0][i]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                b[i][j]=b[i-1][j-1]+1;
            else
                b[i][j]=max(b[i-1][j],b[i][j-1]);
           // cout<<b[i][j]<<" ";
        } 
        //cout<<"\n";
    }
    //cout<<b[n][m];
    i=n;
    j=m;
    while(i>=0 && j>=0){
        if(b[i][j]>max(b[i-1][j],b[i][j-1]))
        {
            res+=t[j-1];
            i=i-1;
            j=j-1;
        }
        else{
            if(b[i-1][j]>b[i][j-1])
            {
                i=i-1;
                j=j;
            }
            else
            {
                i=i;
                j=j-1;
            }
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 35456
#include <stdio.h>

int main()
 {
 long long int X,h;
 int c1=0,c2=0;
 scanf("%lld",&X);
 while(X>=500)
 {
   X=X-500;
   c1++;
 }
 while(X>=5)
 {
   X=X-5;
   c2++;
 }
h=(1000*c1)+(5*c2);
printf("%lld",h);
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++){
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int num = 1;
    for (int i = 1; i < N; i++){
        if(d.at(i) == d.at(i - 1)){
            continue;
        }
        num++;
    }
    cout << num << endl;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> C(N), S(N), F(N);
  REP(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];

  REP(i, 0, N) {
    ll ans = 0;
    REP(j, i, N - 1) {
      ll t = max(S[j], ans);
      ans = (t + F[j] - 1) / F[j] * F[j] + C[j];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
	v.resize(n);
	for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int memo[200010][30];
int memo2[200010];

signed main() {
	string S;
	cin >> S;

	rep(i, 200010) rep(j, 30) memo[i][j] = S.size() + 1;

	int nt[30];
	rep(i, 30) nt[i] = S.size() + 1;

	for (int i = S.size(); i > 0; i--) {
		rep(j, 26) {
			memo[i][j] = nt[j];
		}
		nt[S[i - 1] - 'a'] = i;
	}
	rep(j, 26) {
		memo[0][j] = nt[j];
	}

	for (int i = S.size(); i >= 0; i--) {
		int npt = 0;
		rep(j, 26) {
			npt = max(npt, memo[i][j]);
		}
		memo2[i] = memo2[npt] + 1;
	}

	//rep(i, S.size() + 1) {
	//	int len = 0;
	//	int pt = i;
	//	while (pt <= S.size()) {
	//		len++;
	//		int npt = 0;
	//		rep(j, 26) {
	//			npt = max(npt, memo[pt][j]);
	//		}
	//		pt = npt;
	//	}
	//	memo2[i] = pt;
	//}

	string ret = "";
	int fpt = 0;
	while (fpt < S.size()) {
		int minChar = -1;
		int minLen = INT_MAX;
		rep(i, 26) {
			int pt = memo[fpt][i];
			int len = memo2[pt];
			//while (pt <= S.size()) {
			//	len++;
			//	int npt = 0;
			//	rep(j, 26) {
			//		npt = max(npt, memo[pt][j]);
			//	}
			//	pt = npt;
			//}
			if (len < minLen) {
				minLen = len;
				minChar = i;
			}
		}
		if (minLen > 0) {
			ret += (char)(minChar + 'a');
			fpt = memo[fpt][minChar];
		} else {
			ret += (char)(minChar + 'a');
			break;
		}
	}

	cout << ret << endl;

    return 0;
}


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

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


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Strings of Impurity
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4], t[MAX_N + 4];
int css[26][MAX_N], cns[26];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);
  int n = strlen(s);

  for (int i = 0; i < n; i++) {
    int c = s[i] - 'a';
    css[c][cns[c]++] = i;
  }

  int k = 0, p = 0;
  for (int i = 0; t[i]; i++) {
    int c = t[i] - 'a';
    int *cs = css[c], &cn = cns[c];

    if (cn == 0) {
      puts("-1");
      return 0;
    }

    int j = lower_bound(cs, cs + cn, p) - cs;
    if (j >= cn) {
      k++;
      p = 0;
      j = lower_bound(cs, cs + cn, p) - cs;
    }

    p = cs[j] + 1;
  }
  //printf("k=%d, p=%d\n", k, p);

  printf("%lld\n", (ll)k * n + p);
  return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int C[5];
int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    C[a]++; C[b]++; C[c]++; C[d]++; C[e]++; C[f]++;
    for(int i=1;i<=4;i++){
        if(C[i]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
constexpr ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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


	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			sum += D[i] * D[j];
		}

	}
	cout << sum << endl;
	
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] primeList = new int[10001];
        int limit = 104743;
        primeList[0] = 2;
        primeList[1] = 3;
        int count = 2;
        for (int i = 5; i <= limit; i += 2) {
            boolean wflag = true;
            for (int j = 1; primeList[j] * primeList[j] <= i; j++) {
                if (i % primeList[j] == 0) {
                    wflag = false;
                    break;
                }
            }
            if (wflag) {
                primeList[count++] = i;
            }
        }
        int[] sum=new int[10001];
        sum[0]=0;
        for(int i=1;i<10001;i++) {
            sum[i]=sum[i-1]+primeList[i-1];
        }
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n=sc.nextInt();
            if(n==0) {
                break;
            }
            System.out.println(sum[n]);
        }
    }
}


Measured memory_bytes: 26792
n,m=map(int,input().split())

X=[]

for i in range(n):
    X.append(list(map(int,input().split())))

Y=sorted(X,key=lambda x:x[0])

cnt=0
ans=0
for i in range(n):
    cnt+=Y[i][1]
    if cnt>m:
        ad=m-(cnt-Y[i][1])
        ans+=Y[i][0]*ad
        break
    ans+=Y[i][0]*Y[i][1]

print(ans)

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

int main()
{
    int a, b, c, d;

    while( cin >> a >> b >> c >> d )
    {
        if( a + b + c + d == 0 )
            break;

        if( b * c <= a )
        {
            cout << 0 << endl;
            continue;
        }

        int res = ( c * b - a ) / d;
        if( ( c * b - a ) % d == 0 )
            cout << res << endl;
        else
            cout << res + 1 << endl;
    }

    return 0;
}


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

using namespace std;

#define ll long long

const int mxN = 1e5;
int dp[mxN+1], h[mxN];

int main()
{
	int n, k; 
	cin >> n >> k; 
	for(int i = 1; i <= n; ++i)
		cin >> h[i];
	dp[1] = 0;
	for(int i = 2; i <= n; ++i){
		dp[i] = 1e9;
		for(int j = 1; j <= k; ++j){
			if(j<i)
				dp[i] = min(dp[i], dp[i-j] +abs(h[i-j]-h[i]));
		}
	}
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 4372
#include<stdio.h>
int main(void)
{
	int w[10],k[10],l,maxw=0,maxk=0,q,m,p,i;
	for(l=0;l<10;l++){
		scanf("%d",&w[l]);
}
for(l=0;l<10;l++){
		for(p=l+1;p<10;p++){
			if(w[l]<w[p]){
				q=w[p];
				w[p]=w[l];
				w[l]=q;
			}
		}
	}
	for (l=0;l<10;l++){
		scanf("%d",&k[l]);
}
for (l=0;l<10;l++){
		for(p=l+1;p<10;p++){
		if(k[l]<k[p]){
			m=k[p];
			k[p]=k[l];
			k[l]=m;
			}			
		}
	}
	for(i=0;i<3;i++){
		maxw=maxw+w[i];
		maxk=maxk+k[i];
	}
	printf("%d %d\n",maxw,maxk);
	return 0;
}


Measured memory_bytes: 2060
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    double w = Integer.parseInt(data[0]);
    double h = Integer.parseInt(data[1]);
    double x = Integer.parseInt(data[2]);
    double y = Integer.parseInt(data[3]);
    int multipleAns = (x==w/2.0 && y==h/2.0 ? 1 : 0);
    
    System.out.println(w*h/2.0 + " " + multipleAns);
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll inf = 1e18;
ll n, w;
vector<vector<ll>> g;
#define br cout<<endl;
ll dp[105][100005];
ll arr[105][2];
ll dfs(ll index ,ll wt,ll val)
{
if(index>=n)
return 0;
//cout<<wt<<endl;
if(dp[index][wt]!=-1)
return dp[index][wt];
    if(wt-arr[index][1]<0)
    {
        return dfs(index+1,wt,val);
    }
//cout<<"im here"<<endl;
    return dp[index][wt]=max(dfs(index+1,wt,val),arr[index][0]+dfs(index+1,wt-arr[index][1],arr[index][0]));






}


int main()
{

cin>>n>>w;
 memset(dp,-1,sizeof dp);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i][1]>>arr[i][0];
    }
   cout<<dfs(0,w,0);

}


Measured memory_bytes: 82304
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll D = 365;
vec c(26);
mat s(D, vec(26));
vec last(26, 0);


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    clock_t start = clock();

    cin >> D;
    Rep (i, 26) {
        cin >> c[i];
    }
    Rep (i, D) {
        Rep (j, 26) {
            cin >> s[i][j];
        }
    }

    vec t(D);
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> randd(0, 364), randq(0, 25);

    ll tmp = 0;
    Rep (i, D) {
        ll ans = 0;
        ll best = -inf;
        Rep (j, 26) {
            ll score = 0;
            score += s[i][j];
            Rep (k, 26) {
                if (k != j) score -= c[k] * (i+1-last[k]);   
            }
            if (score > best) {
                ans = j;
                best = score;
            }
        }

        last[ans] = i+1;
        tmp += s[i][ans];
        Rep (j, 26) {
            tmp -= c[j] * (i+1-last[j]);
        }

        t[i] = ans;
    }

    vector<set<ll>> days(26);
    Rep (i, 26) {
        days[i].insert(-1);
        days[i].insert(D);
    }
    Rep (i, D) {
        days[t[i]].insert(i);
    }


    ll cnt = 0;
    ll effective = 0;

    while (1.0 * (clock() - start) / CLOCKS_PER_SEC < 1.8) {
        cnt++;
        ll q = randq(mt);
        Rep (d, 365) {
            if (t[d] == q) continue;

            ll oldscore = tmp;

            tmp -= s[d][t[d]];
            tmp += s[d][q];
            auto old2 = days[t[d]].upper_bound(d);
            old2--;
            old2--;
            auto old1 = old2;
            old2++;
            old2++;
            auto new2 = days[q].lower_bound(d);
            auto new1 = --new2;
            new2++;
            // cout << *old1 << " " << *old2 << " " << *new1 << " " << *new2 << "\n";
            tmp += c[q] * (d-*new1) * (*new2 - d);
            tmp -= c[t[d]] * (d-*old1) * (*old2 - d);

            if (tmp > oldscore) {
                days[t[d]].erase(d);
                days[q].insert(d);
                t[d] = q;
                effective++;
            }

        }
        

    }

    Rep (i, D) {
        cout << t[i] + 1 << "\n";
    }

    // cout << (double)(clock() - start) / CLOCKS_PER_SEC << "\n";
    // cout << cnt << " " << effective << "\n";
}

Measured memory_bytes: 3768
def warshall_floyd(d, next_node):
    # d: nxn adjacent matrix
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
                    next_node[i][j] = next_node[i][k]


INF = float("inf")

n, m = map(int, input().split())
d = [[INF] * n for _ in range(n)]
next_node = [list(range(n)) for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for j in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    d[a][b] = d[b][a] = c

warshall_floyd(d, next_node)

used_path = set()
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        used_path.add((i, next_node[i][j]))
        used_path.add((next_node[i][j], i))

ans = m - len(used_path) // 2

print(ans)


Measured memory_bytes: 42608
import java.util.*;

public class Main{
	public static void main(String args[]){
        Scanner sc1 = new Scanner(System.in);
        int a = sc1.nextInt();
        int b = sc1.nextInt();
        int max = a+b;
        if(max < a-b){
            max = a-b;
        }
        if(max < a*b){
            max = a*b;
        }
        System.out.print(max);
    }
}

Measured memory_bytes: 21844
import java.util.*;

class Main{

    int n, k;
    int[] c, r;
    boolean[][] road;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        k = sc.nextInt();
        c = new int[n];
        r = new int[n];
        for(int i=0; i<n; i++){
            c[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        road = new boolean[n][n];
        for(int i=0; i<k; i++){
            int a = sc.nextInt()-1, b = sc.nextInt()-1;
            road[a][b] = true;
            road[b][a] = true;
        }

        System.out.println(dijkstra());
    }

    int dijkstra(){
        //pos, left, sum
        PriorityQueue<int[]> q = new PriorityQueue<int[]>(10, new Comparator<int[]>(){
                public int compare(int[] a, int[] b){
                    return a[2] - b[2];
                }
            });
        //q.add(new int[]{0, r[0], c[0]});
        q.add(new int[]{0, 0, 0});
        boolean[][] v = new boolean[n][n];

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], left = qq[1], sum = qq[2];

            //System.out.println(pos+" "+left+" "+sum);

            if(pos==n-1) return sum;
            if(v[pos][left]) continue;
            v[pos][left] = true;

            for(int i=0; i<n; i++){
                if(!road[pos][i]) continue;
                if(left-1>=0) q.add(new int[]{i, left-1, sum});
            }
            q.add(new int[]{pos, r[pos], sum + c[pos]});

        }
        return -1;
    }

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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, M; cin >> N >> M;
  int s[M], c[M]; rep(i,M) { cin >> s[i] >> c[i]; s[i]--; }
  int result = -1;
  int b[3] = {0,10,100}, e[3] = {10,100,1000};
  repr(i,b[N-1],e[N-1]) {
    int tmp = i, n[N] = {};
    rep(j,N) { n[j] = tmp%10; tmp /= 10; }
    reverse(n,n+N);
    bool ok = true;
    rep(i,M) if (n[s[i]]!=c[i]) ok = false;
    if (ok) { result = i; break; }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int vi[20],ci[20],n,i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> vi[i];
	}
	for(i=0;i<n;i++){
		cin >> ci[i];
	}
	i=0;
	int sum = 0;
	while(i<n){
		if(vi[i]-ci[i]>0) sum=sum+(vi[i]-ci[i]);
		i++;
	}		
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
d = dict()
m = 0
for _ in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] > m:
        m = d[s]

sd = sorted(d.items(), reverse=True, key=lambda x:x[1])
ans = []
for k, v in sd:
    if v == m:
        ans.append(k)
    else:
        break

for a in sorted(ans):
    print(a)

Measured memory_bytes: 114520
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	ll a,b;
	cin >> a >> b;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll ans = 0;
	rep(i,n-1){
		if((v[i+1]-v[i])*a<b){
			ans += (v[i+1]-v[i])*a;
		}else{
			ans += b;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
    int N, K;

    cin >> N >> K;

    if(N<1 || N>100){
        return 0;
    }
    if(K<1 || K>100){
        return 0;
    }

    int d[K], a[K][N], num[K], tmp=1;
    
    REP(i, K){
        cin >> d[i];
        if(d[i]<1 || d[i]>N){
            return 0;
        }

        tmp = 1;
        REP(j, d[i]){
            cin >> a[i][j];
            if(tmp>a[i][j] || a[i][j]>N){
                return 0;
            }
            tmp = a[i][j];
        }
    }

    int ans[N];

    REP(i, N){
        ans[i] = 0;
    }

    REP(i, K){
        REP(j ,d[i]){
            ans[a[i][j]-1] = 1;
        }
    }

    int sum = 0;
    REP(i, N){
        sum += ans[i];
    }

    //cout << "sum" << sum << "\n";

    cout << N-sum;
    
    return 0;

}

Measured memory_bytes: 3652
//ABC115 D
#include<iostream>
#include<math.h>
using namespace std;
int n;
long long x, ans;
long long p[51];
long long all[51];
void saiki(int l);
int main() {
	cin >> n >> x;
	p[0] = 1;
	all[0] = 1;
	for (int i = 1; i <= n; i++) {
		p[i] = p[i - 1] * 2 + 1;
		all[i] = all[i - 1] * 2 + 3;
	}
	ans = 0;
	saiki(n);
	cout << ans << endl;
	return(0);
}
void saiki(int l) {
	if (x <= l) {
		ans += 0;
	}
	else if (x <= all[l - 1] + 1) {
		x -= 1;
		saiki(l-1);
	}
	else if (x <= all[l-1]*2 +2) {
		ans += p[l - 1] + 1;
		x -= all[l - 1] + 2;
		saiki(l - 1);
	}
	else{
		ans += p[l];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define max3(a,b,c) max(a,max(b,c))
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mo 998244353
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define ms 16
#define endl '\n'

 
using namespace std ;
 
#define N 100005

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{  
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////

    lli p,q,r;
    cin>>p>>q>>r;

    cout<<min(p+q,min(p+r,q+r));

}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        //N円の商品を1000円札のみで買い、お釣りを表示
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int money = 1000;
 
 
 
        if (N % money == 0) {//お釣りなし
            System.out.println(0);
        }else {//お釣りあり
            money = (N/money +1)*1000;
            System.out.println(money-N);
        }
    }
 
 
 
}

Measured memory_bytes: 35680
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
  std::vector<int> v;
  string xyz ="";
int x=0,y=0,z=0,w=0,i=0,j=0,n=0;
  vector<pair<int, int> > pairs(n);
  std::cin >> x>>y;
  z=(x+y);
  w=(x-y);
  i=(x*y);
  if(z>=i&&z>=w)std::cout <<z  << '\n';
  else if(w>=i&&w>=z)std::cout <<w  << '\n';
  else std::cout <<i << '\n';

}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b;
    char op;
    while (scanf("%d %c %d", &a, &op, &b) == 3) {
        if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else if (op == '/') {
            printf("%d\n", a / b);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=2e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,bit[200010];

void add(int i,int x){
	while(i <= n + 1){
		bit[i] += x;
		i += i & -i;
	}
}

int sum(int i){
	int s = 0;
	while(i){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

signed main(){
	int k,a[200001] = {},ans = 0;
	vector<int> vec;
	cin >> n >> k;
	for(int i = 0;i < n;i++) {
		cin >> a[i + 1];
		a[i + 1] -= k;
		a[i + 1] += a[i];
		vec.push_back(a[i + 1]);
	}
	vec.push_back(0);
	sort(all(vec));
	vec.erase(unique(all(vec)),vec.end());
	for(int i = 0;i <= n;i++){
		int pos = lower_bound(all(vec),a[i]) - vec.begin();
		ans += sum(pos + 1);
		add(pos + 1,1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
ll ans=99999999999999;
ll temp;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0,j=n-k+1;i<j;i++){
		if(a[i]<0&&a[i+k-1]>0){
			temp=min(abs(a[i])*2+abs(a[i+k-1]),abs(a[i])+abs(a[i+k-1]*2));
			ans=min(ans,temp);	
		}else if(a[i]>=0){
			temp=a[i+k-1];
			ans=min(ans,temp);
		}else if(a[i+k-1]<=0){
			temp=abs(a[i]);
			ans=min(ans,temp);
		}
		
		
	}
	cout<<ans;
	return 0;
}


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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderSet =
//tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1e9
#define mod 132021913
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
ll power(ll b,ll p) {ll res=1,x=b; while(p > 0){if(p&1ll)res=res*x;x=x*x;p >>= 1;} return res;}

#define MX 200005
ll arr[MX], w[MX], ans[MX], n, k, sm;

int main()
{
	string str, comp;

	cin>>str>>comp;

	int cnt = 0;
	for(int i = 0; i< str.size(); i++) {
		if(str[i] != comp[i]) cnt++;
	}

	cout<<cnt<<endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    using triple = tuple<ll, ll, ll>;
    int n, q; cin >> n >> q;
    vector<triple> xlr(n);
    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        s -= x; t -= x;
        xlr[i] = make_tuple(x, s, t);
    }
    sort(xlr.begin(), xlr.end());

    vector<ll> ans(q, -1);
    set<pair<ll, ll>> did;
    rep(i, q) {
        ll d; cin >> d;
        did.insert(make_pair(d, i));
    }

    rep(i, n) {
        ll x, l, r; tie(x, l, r) = xlr[i];
        auto itr = did.lower_bound(make_pair(l, -1));
        while(itr!=did.end() && itr->first<r) { ans[itr->second] = x; did.erase(itr++); }
    }
    rep(i, q) cout << ans[i] << endl;

    return 0;
}




Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main(){
  ll n,k;
  cin >>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++) {
    cin >>a[i];
    if(a[i]==k) {
      cout << "POSSIBLE"<<endl;
      return 0;
    }
  }
  sort(a,a+n);
  if(a[n-1]<k){
    cout <<"IMPOSSIBLE"<<endl;
    return 0;
  }
  ll gc=a[0];
  for(ll i=1;i<n;i++) gc=gcd(a[i],gc);
    if(k%gc==0){
        cout << "POSSIBLE"<<endl;
        return 0;
      }
      else{
        cout <<"IMPOSSIBLE"<<endl;
        return 0;
      }
  cout <<"POSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace Parallelism
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> ans = new List<string>();

            for (int i = 0; i < n; ++i)
            {
                string[] input = Console.ReadLine().Split(' ');
                var x1 = decimal.Parse(input[0]);
                var y1 = decimal.Parse(input[1]);
                var x2 = decimal.Parse(input[2]);
                var y2 = decimal.Parse(input[3]);
                var x3 = decimal.Parse(input[4]);
                var y3 = decimal.Parse(input[5]);
                var x4 = decimal.Parse(input[6]);
                var y4 = decimal.Parse(input[7]);
                
                
                if ((y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1))
                {
                    ans.Add("YES");
                }
                else
                {
                    ans.Add("NO");
                }
            }
            foreach (string item in ans)
            {
                Console.WriteLine(item);
            }
        }
    }
}



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

int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    REP(i, 3) cout << s[i][i];

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<int> V[1000];
	int k = 2, m = 1;
	V[0].push_back(1);
	V[1].push_back(1);
	while(m < N){
		repp(i,0,k){
			V[i].push_back(m+i+1);
			V[k].push_back(m+i+1);
		}
		m += k;
		++k;
	}
	if(m == N){
		cout << "Yes" << endl;
		cout << k << endl;
		repp(i,0,k){
			cout << k-1;
			for(auto u : V[i]) cout << ' ' << u;
			cout << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

int main() {
  fast_io
  ll t=1; 
  while(t--) {
    string s,t; cin >> s >> t;
    ll ans = 0;
    loop(i,s.length()) {
      if(s[i]!=t[i]) ans++;
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 3868
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<bitset>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define ui unsigned int
//ios::sync_with_stdio(false);
#define ull unsigned long long
#define endl "\n"
#define int long long
#define double long double
#define jn jnn
using namespace std;
#define PI  3.1415926535898
const double eqs = 1e-6;
const long long max_ = 2000 + 7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const long long INF = 1e18;
inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
string node;
map<string, int>mp;
signed main() {
	int n;
	cin >> n;
	int ans = 0;
	while (n--){
		cin >> node;
		if (!mp.count(node)) {
			mp[node] = 1;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 19176
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    N = int(input())
    *A, = map(int, input().split())

    compress_dict = {x: i for i, x in enumerate(sorted(set(A)), start=1)}
    M = len(compress_dict)

    bit = Bit(M)
    ans = 0
    for cnt, x in enumerate(A, start=1):
        x = compress_dict[x]
        bit.add(x, 1)
        ans += cnt - bit.sum(x)

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 42168
sumup _ [] = []
sumup s (x:xs) =
  let s' = (s+x)
  in
    s':(sumup s' xs)

scan :: (Int,Int) -> [Int] -> (Int,Int)
scan (m,a) [] = (m,a)
scan (m,a) (x:xs) =
  let m' = min m x
      a' = max a (x-m)
  in
    scan (m',a') xs

ans (0:_) = []
ans (n:x) =
  let a = take n x
      s = (sumup 0 a)
      (_,d) = scan (0,-100000) s
      r = drop n x
  in
    d:(ans r)

main = do
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = ans i
  mapM_ print o

Measured memory_bytes: 5920
n=int(input())
a=list(map(int,input().split()))
ans=0
j=0
b=0
for  i in range(n):
    while j<n and b^a[j]==b+a[j]:
        b^=a[j]
        j+=1
    ans+=j-i    
    b^=a[i]
print(ans)

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

int main(){
	int n;
	cin>>n;
	int p[n],q[n],s[n],t[n];
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	rep(i,n)s[i]=i+1;
	rep(i,n)t[i]=i+1;
	int i=0;
	do{
		bool a=true;
		rep(i,n)a=a&&s[i]==p[i];
		if(a)break;
		i++;
	}while(next_permutation(s,s+n));
	int ac=i;
	i=0;
	do{
		bool a=true;
		rep(i,n)a=a&&t[i]==q[i];
		if(a)break;
		i++;
	}while(next_permutation(t,t+n));
	int bc=i;
	cout << abs(ac-bc) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long w = sc.nextLong();
			long h = sc.nextLong();
			long x = sc.nextLong();
			long y = sc.nextLong();

			double result1 = (double)(w * h) / 2;
			int result2 = 0;
			if (w % 2 == 0 && w / 2 == x && h % 2 == 0 && h / 2 == y) {
				result2 = 1;
			}
			System.out.println(result1 + " " + result2);
		}
	}

}


Measured memory_bytes: 21844