akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    ans = 10 ** 18
    for i in range(K-1, N):
        a = X[i-K+1]
        b = X[i]
        if a < 0 and b > 0:
            ans = min(ans, (-a)*2+b, (-a)+b*2)
        elif b <= 0:
            ans = min(ans, -a)
        elif a >= 0:
            ans = min(ans, b)
    print(ans)





if __name__ == '__main__':
    main()

Measured memory_bytes: 58736
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
static const int MAX = 10000;
static const bool NOTV = 0;
static const bool VISIT = 1;
int v;

vector<int> G[MAX];
bool visit[MAX];
list<int> out;
void dfs(int s) {
	visit[s] = VISIT;
	for (int i = 0; i < G[s].size(); i++) {
		if (not visit[G[s][i]]) dfs(G[s][i]);
	}
	out.push_front(s);
}

void topoSort() {
	fill(visit, visit + v, NOTV);
	for (int i = 0; i < v; i++) {
		if (not visit[i]) dfs(i);
	}
}


int main() {
	int e, s, t;
	cin >> v >> e;
	for (int i = 0; i < e; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}
	topoSort();
	while (not out.empty()) {
		cout << out.front() << endl;
		out.pop_front();
	}
}

Measured memory_bytes: 4072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int N, K, total = 0;
    int i;
    scanf("%d\n", &N);
    scanf("%d\n", &K);
    for ( i = 0; i < N; i++ ){
        int x;
        scanf("%d\n", &x);
        if ( x > K - x ){
            total += (K - x)*2;
        } else {
            total += (2 * x);
        }
    }
    printf("%d\n", total);
    return 0;
}


Measured memory_bytes: 128
from fractions import gcd
a,b,c,d=map(int,input().split())
count=b-a+1
temp1=b//c-(a-1)//c
temp2=b//d-(a-1)//d
temp3=b//int((c*d)/gcd(c,d))-(a-1)//int((c*d)/gcd(c,d))
print(int(count-temp1-temp2+temp3))

Measured memory_bytes: 5344
#include <bits/stdc++.h>
//#pragma GCC optimize ("02")
#define ll long long
#define oo 1000000007
using namespace std;

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

	int k, n, ans1 = 0, maks = 0;
	cin >> k >> n;
	int a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	for(int i=1; i<n; i++){
		ans1 += abs(a[i]-a[i-1]);
		maks = max(maks, abs(a[i]-a[i-1]));
	}

	cout << min((ans1-maks)+(a[0]+k-a[n-1]), ans1);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      100007

const int mod = 1e9 + 7;

vi graph[MAXN], dp(MAXN, -1);

void dfs(int s)
{
   dp[s] = 0;
   for (auto u : graph[s])
   {
      if (dp[u] != -1)
      {
         dp[s] = max(dp[s], 1 + dp[u]);
         continue;
      }
      dfs(u);
      dp[s] = max(dp[s], 1 + dp[u]);
   }
}

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

   int n, m;
   cin >> n >> m;
   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      graph[x].push_back(y);
   }

   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      if (dp[i] == -1)
         dfs(i);
      ans = max(ans, dp[i]);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
#include<string.h>
int main(){
    char s[1200];
    int l,i,c;
    scanf("%[^\n]",s);
    l=strlen(s);
    for(i=0;i<l;i++){
        c=s[i];
        if(c>=65&&c<=90){
            printf("%c",c+32);
        }
        else if(c>=97&&c<=122){
            printf("%c",c-32);
        }
        else{
            printf("%c",s[i]);
        }
    }
printf("\n");
    return 0;
}



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

int main() {
	string s;
	cin >> s;
	bool step = true;
	for(int i=0;s[i]!=0;i++){
		if((i%2==0)&&(s[i]!='R')&&(s[i]!='U')&&(s[i]!='D')){
			step = false;
			break;
		}
		if((i%2==1)&&(s[i]!='L')&&(s[i]!='U')&&(s[i]!='D')){
			step = false;
			break;
		}
	}
	
	if(step==false) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int n,i,m=0;
    map<string,int>mp;
    map<string,int>::iterator it;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
        m=max(m,mp[s]);
    }
    for(it=mp.begin();it!= mp.end();it++)
    {
        if(m==it->second)
        {
            cout<<it->first<<endl;
        }
    }
    return 0;

}


Measured memory_bytes: 19152
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC164B
int main(void) {
  int n, k, i, cou=0, tmp,a,b,c,d;
  scanf(" %d %d %d %d", &a,&b,&c,&d);
  for(i=0; i < 100; i++){
    c-=b;
    if(c<=0){
      printf("Yes");
      return 0;
    }
    a-=d;
    if(a<=0){
      printf("No");
      return 0;
    }


  }

}


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

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

    string ans;
    int max = (b / k) * k;

    if(a <= max) ans = "OK";
    else ans = "NG";

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

Measured memory_bytes: 3596
fn precalc_combination(combination: &mut Vec<Vec<usize>>, size: usize, mod_n: usize) {
    combination[0][0] = 1;

    for n in 1..size {
        for k in 0..(n+1) {
            combination[n][k] = if k == 0 || k == n {
                1
            }
            else {
                ((combination[n-1][k-1] % mod_n) + (combination[n-1][k] % mod_n)) % mod_n
            }
        }
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mod_n = 1000000007usize;
    let max_n = 2000usize;
    let mut combination = vec![vec![0; max_n]; max_n];

    precalc_combination(&mut combination, max_n, mod_n);

    for i in 1..(k+1) {
        if n-k >= i-1 {
            let ins_comb = combination[n-k+1][i];
            let blue_comb = combination[k-1][i-1];
            println!("{}", (ins_comb*blue_comb) % mod_n);
        }
        else {
            println!("0");
        }
    }
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 3636
a, b, c, d = map(int, input().split())

area = [0 for i in range(max([b,d])+1)]

for i in range(a,b):
  area[i] += 1;

for i in range(c,d):
  area[i] += 1;

answer = 0
for i in area:
  if i == 2:
    answer += 1

print(answer)

Measured memory_bytes: 9084
#include<stdio.h>
int main()
{
	int a, b, c;
	int temp;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) temp = a,a = b,b = temp;
	if (b > c) {
		temp = b,b = c,c = temp;
		if (a > b) temp = a,a = b,b = temp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;

}


Measured memory_bytes: 2108
n,k,q = map(int, input().split())

point_list = [0]*n

for i in range(q):
    a = int(input()) -1
    point_list[a] = point_list[a] +1

for p in point_list:
    if p > q-k:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4680
#include<stdio.h>
#include<cstdlib>

#define NOT_FOUND 0

int binarySearch(int, int *);

int n,q;

int main(){
  int i, count = 0;
  int *S,*T;
  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n + 1);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  T = (int *)malloc(sizeof(int) * n + 1);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }
  
#ifdef D
  printf("S : ");
  for(i = 0; i < n; i++){
    printf("%d ",S[i]);
  }
  printf("\n");
  printf("T : ");
  for(i = 0; i < q; i++){
    printf("%d ",T[i]);
  }
  printf("\n");
#endif

  for(i = 0; i < q; i++){
    if(binarySearch(T[i],S) == 1){
      count++;
    }
  }

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


int binarySearch(int key, int *A){
  int left, right, mid;
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right) / 2;
    if(A[mid] == key){
      return 1;
    }else if(A[mid] < key){
      left = mid + 1;
    }else{
      right = mid;
    }
  }
  return NOT_FOUND;
}



Measured memory_bytes: 3176
#include <iostream>


using namespace std;


int main(){
  int ans=0;
  string S0, S1;
  cin >> S0 >> S1;
  for (int i = 0; i < S0.length(); ++i){
    if (S0.at(i) != S1.at(i)) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

const int MAXN=110;

int main()
{
	int n,A[MAXN],cnt=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&A[i]); 
	for(int i=0;i<n;i++)
	{
		int mi=i;
		for(int j=i+1;j<n;j++)
			if(A[j]<A[mi]) mi=j;
		if(mi!=i)
		{
			std::swap(A[mi],A[i]);
			cnt++;
		}
	}
	for(int i=0;i<n;i++)
		printf("%d%c",A[i],i+1==n?'\n':' ');
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    string X,Y;
    cin >> X >> Y;
    
    if(X == Y){
        cout << "=" << endl;
    }else if(X > Y){
        cout << ">" << endl;
    }else{
        cout << "<" << endl;
    }
}




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

int watch(int S){

        int h,m,s;

        h = S / 3600;
        m = (S - (h * 3600)) / 60;
        s = (S - (h * 3600)) % 60;

        cout << h << ":" << m << ":" << s << endl;

        return 0;
}

int main(){

        int S;

        cin >> S;
        watch(S);

        return 0;
}



Measured memory_bytes: 3084
N, M = map(int, input().split(' '))
A = list(map(int, input().split(' ')))


def main(n, m, a):
    # print(n,m,a)
    x = [new_a for new_a in a if not new_a < sum(a) / (4 * m)]

    # print(x)

    if len(x) >= m:
        res = 'Yes'
    else:
        res = 'No'

    print(res)


main(N, M, A)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int 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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string o,e;
cin>>o>>e;
for(int i=0;i<e.size();i++){
    cout<<o[i];
    cout<<e[i];
}
if(o.size()>e.size()){
    cout<<o[o.size()-1];
}
}










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

using namespace std;

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

    long long res = 0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合
        if (d != -1 && !(K & (1LL<<d))) continue;

        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;

            if (e > d) {
                if (K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else {
        printf("a == b\n");
    }
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <set>
int main()
{
  int N;std::cin >> N;
  std::vector<std::string> s(N);
  std::set<std::string> st;
  for(auto& e:s){std::cin >> e;st.insert(e);}
  if(st.size()!=N){return std::cout << "No"<<std::endl,0;}
  for(int i = 1; i < N; i++){if(s[i-1].back()!=s[i].front()){return std::cout << "No"<<std::endl,0;}}
  std::cout << "Yes"<<std::endl;	
  return 0;
}


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

int main(){
    string o, e;
    cin >> o >> e;
    rep(i, e.size()) {
        cout << o[i] << e[i];
    }
    if (o.size() > e.size()) {
        cout << o[e.size()];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << "\n";
	}
	else {
		cout << min({a * b, b * c, a * c}) << "\n";
	}
	return 0;
}




Measured memory_bytes: 256
a, b, c = map(int, input().split())
a, b, c = sorted((a, b, c))
counter = 0
counter += (c - b) // 2
b += ((c - b) // 2) * 2
if c - b == 1:
  counter += 1
  a += 1
  b += 1
counter += (c - a) // 2
a += ((c- a) // 2) * 2
if c - a == 1:
  counter += 2
  a += 2
  b += 1
  c += 1

print(counter)

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
struct Node
{
	int key;
	Node *right,*left,*parent;
};
Node*root,*NIL;
Node  * treeMinmum(Node *x)
{
	while(x->left!=NIL)x=x->left;
	return x;
}
Node * find(Node *u,int k)

{
	while(u!=NIL&&k!=u->key)
	{
		if(k<u->key)u=u->left;
		else u=u->right;
	}
	return u;
}
Node * treeSuccessor(Node *x)
{
	if(x->right!=NIL)return treeMinmum(x->right);
	Node *y=x->parent;
	while(y!=NIL&&x==y->right)
	{
		x=y;
		y=y->parent;
	}
	return y;
}
void treeDelete(Node *z)
{
	Node *y;
	Node *x;
	if(z->left==NIL||z->right==NIL)y=z;
	else y=treeSuccessor(z);
	if(y->left!=NIL)
	{
		x=y->left;
	}
	else 
	{
		x=y->right;
	}
	if(x!=NIL)
	{
		x->parent=y->parent;
	}
	if(y->parent==NIL)
	{
		root=x;
	}
	else
	{
		if(y==y->parent->left)
		{
			y->parent->left=x;
		}
		else 
		{
			y->parent->right=x;
		}
	}
	if(y!=z)
	{
		z->key=y->key;
	}
	free(y);
}
void insert(int k)
{
	Node *y=NIL;
	Node *x=root;
	Node *z;
	z=(Node*)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;
	while(x!=NIL)
	{
		y=x;
		if(z->key<x->key)
		{
		x=x->left;	
		}
		else
		{
		x=x->right;
	    }
	}
	z->parent=y;
	if(y==NIL)
	{
		root=z;
	}
	else
	{
		if(z->key<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);
}
int main()
{
	int n,i,x;
	string com;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		cin>>com;
		if(com[0]=='f')
		{
			scanf("%d",&x);
			Node *t=find(root,x);
			if(t!=NIL)printf("yes\n");
			else printf("no\n");
		}
		else if(com=="insert")
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(com=="print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if(com=="delete")
		{
			scanf("%d",&x);
			treeDelete(find(root,x));
		}
	}
	return 0;
}

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

int main(){
    int x;
    cin>>x;
    int a=x%100;
    int five=a/5;
    a%=5;
    int four=a/4;
    a%=4;
    int three=a/3;
    a%=3;
    int two=a/2;
    a%=2;
    int one=a;
    a%=1;
    int n=x-105*five-104*four-103*three-102*two-101*one;
    if(n>=0)cout<<1;
    else cout<<0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int ar,a[1000],cek[1000],seli,cek2[1000],nol;
int main(){
	int m,n;
	cin>>m>>n;
	
	for(int i=0;i<n;i++){
		cin>>ar;
		seli=abs(m-ar);
		
		if(ar<m){
			cek[seli]=1;
		}
		else{
			cek2[seli]=1;
		}
		if(ar==m){
			nol=1;
		}
	}
	if(n==0){
		cout<<m<<endl;
	}
	else if(nol==0){
		cout<<m<<endl;
	}
	else{
		for(int j=1;j<100;j++){
			if(cek[j]==0 ){
				cout<<m-j;
				break;
			}
			else if(cek[j]==1 and cek2[j]==0  ){
				cout<<m+j;
				break;
			}
		}	
	}
	
	
}

Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

int main()
{
    string S;
    
    cin >> S;
    
    const char* p = S.c_str();
    
    while (*p != 'A')
    {
        p++;
    }
    
    const char* aPtr = p;
    p++;
    const char* zPtr = p;
    
    while (*p != '\0')
    {
        if (*p == 'Z')
        {
            zPtr = p;
        }
        p++;
    }
    
    printf("%ld\n", zPtr - aPtr + 1);
    
    return 0;
}


Measured memory_bytes: 644
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int64_t N, K, Q, A;
  cin >> N >> K >> Q;
  vector<int64_t> score(N, K - Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> A;
    score[A - 1] += 1;
  }
  for (auto s : score)
  {
    cout << (s > 0 ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll sum = a[0]^a[1];
    for(int i = 2; i < n; i++){
        sum = sum^a[i];
    }
    rep(i,n){
        cout << ll(sum^a[i]) << " ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (ll i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
ll n;
ll arr[305];
ll rest = 0, total = 0;
ll pp[45];
vi v;

ll power(ll a, ll b){
	if (b == 0) return 1;
	if (b == 1) return a;
	ll half = power(a, b/2);
	half *= half;
	if (b % 2 == 1){
		half *= a;
	}
	return half;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> arr[i];
	}
	total = arr[0] + arr[1];
	ll ans = 0;
	REP(i, 2, n){
		rest = rest^arr[i];
	}

	REP(i, 0, 45){
		pp[i] = rest%2;
		if (pp[i] == 1){
			total -= power(2, i);
		} else {
			v.PB(power(2, i + 1));
		}
		rest/=2;
	}
	if (total < 0){
		cout << -1 << endl;
		return 0;
	}
	reverse(v.begin(), v.end());
	REP(i, 0, v.size()){
		if (total >= v[i]){
			total -= v[i];
			ans += v[i]/2;
		}
	}
	if (total != 0){
		cout << -1 << endl;
		return 0;
	}
	if (ans > arr[0]){
		cout << -1 << endl;
		return 0;	
	}
	for (ll i = 44; i >= 0; i--){
		if (pp[i]){
			if (arr[0] - ans >= power(2, i)){
				ans += power(2, i);
			}
		}
	}
	if (ans <= 0){
		cout << -1 << endl;
		return 0;
	}
	
	cout << arr[0] - ans << endl;
	
}

Measured memory_bytes: 3584
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long k = n/(a+b);
		long ao = k*a;
		long r = n%(a+b);

		if ( r <= a ) {
			ao = ao + r;
		} else {
			ao = ao + a;
		}
		System.out.println(ao);
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
  int n;
  cin >> n;
  map<int, int> a;
  ll res=0;
  rep(i,n){
    int t;
    cin >> t;
    if(a[t]<t) a[t]++;
    else res++;
  }
  for(auto itr=a.begin(); itr!=a.end(); itr++){
  	if((itr->second < itr->first))
  		res += itr->second;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
		// TODO Auto-generated method stub
		Scanner reader=new Scanner(System.in);
		int x=reader.nextInt();
		int a=reader.nextInt();
		int b=reader.nextInt();
		if(Math.abs(x-a)>=Math.abs(x-b)) {
			System.out.print("B");
		}
		else {
			System.out.print("A");
		}
 	}

}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNextInt()) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                int x = sc.nextInt();
                System.out.println((a <= x && x <= (a + b)) ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 20948
import sys


def solv(nums):
    for i in range(9):
        nums = foo(nums)
    return nums[0]

def foo(nums):
    nums = map(lambda a: (a[0] + a[1]) % 10, zip(nums, nums[1:]))
    return nums


for line in sys.stdin:
    nums = map(int, list(line.rstrip()))
    print solv(nums)

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

#define M 100;

int main(){
  int n,c,t,v;

  cin >> n;
  int A[n + 1][n + 1];
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      A[i][j] = 0;
    }
  }
  
  for(int i = 1;i <= n;i++){
    cin >> c >> t;
    for(int j = 1;j <= t;j++){
      cin >> v;
      A[c][v] = 1;
    }
  }

  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      if(j > 1) cout << " ";
      cout << A[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3136
N,K = map(int,input().split())

pro = 0

for i in range(1,min(N+1,K)):
	count = 1
	for _ in range(int(K**0.5)+1):
		if i * 2 < K:
			count += 1
			i = i * 2
	pro += (1/N) * (1/2) ** count

if N >= K:
	pro += (N-K+1)/N

print(pro)

Measured memory_bytes: 3060
use std::io::{stdin, Read};

fn main() {
    let mut d = String::new();
    stdin().read_line(&mut d);

    let args: Vec<i32> = d.trim().split_whitespace().filter_map(|it|it.parse().ok()).collect();
//    println!("{}", args[2].min(args[0] * args[1]));
    let (a, b) = (args[2], args[0] * args[1]);
    println!("{}", if a < b {a} else {b});
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringTokenizer st= new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        bw.write((c/a)*b+"");
        bw.close();
    }

}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M, R;
  cin >> N >> M >> R;
  VI rs(R);
  REP(i,R){
	cin >> rs[i];
	--rs[i];
  }

  VVI dist(N, VI(N, 1e9));
  REP(i,N) dist[i][i] = 0;
  REP(i,M){
	int a, b, c;
	cin >> a >> b >> c;
	--a;
	--b;
	mini(dist[a][b], c);
	mini(dist[b][a], c);
  }
  REP(k,N) REP(i,N) REP(j,N)
	mini(dist[i][j], dist[i][k] + dist[k][j]);

  SORT(rs);
  LL ans = 1e15;
  do{
	LL sum = 0;
	REP(i,R-1)
	  sum += dist[rs[i]][rs[i+1]];
	mini(ans, sum);
  }while(next_permutation(ALL(rs)));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define MAX_CLASS 8

int check(double m, int type);

int main(){
    double m500, m1000;
    string cls[MAX_CLASS] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
    while(cin >>m500 >>m1000){
        cout <<cls[max(check(m500, 0), check(m1000, 1))] <<endl;
    }
    return 0;
}

int check(double m, int type){
    double dx[2][MAX_CLASS - 1] = {{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0}, {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0}};
    int ret = 7;
    for(int i = 0; i < MAX_CLASS - 1; i++){
        if(m < dx[type][i]){
            ret = i;
            break;
        }
    }
    return ret;
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))
x = [0] * N
x[0] = sum([a[i] for i in range(N) if i % 2 == 0]) - sum([a[i] for i in range(N) if i % 2 != 0])
for i in range(N - 1):
    x[i + 1] = 2 * a[i] - x[i]
print(*x)

Measured memory_bytes: 14092
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//My friends are small
public class Main{

	int n, W, MOD = 1000000007;
	int[] w;
//	int[][] dp;
	Map<Integer, Integer>[][] mem;
	
	int get(int k, int rest, int min){
		if(rest<0)return 0;
		if(k<0)return rest<min?1:0;
		if(mem[k][rest].containsKey(min))return mem[k][rest].get(min);
//		if(dp[k][rest]!=-1)return dp[k][rest];
		int res = (get(k-1, rest, w[k])+get(k-1, rest-w[k], min))%MOD;
		mem[k][rest].put(min, res);
		return res;
//		return dp[k][rest] = (get(k-1, rest, w[k])+get(k-1, rest-w[k], min))%MOD;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); W = sc.nextInt();
		w = new int[n];
		for(int i=0;i<n;i++)w[i]=sc.nextInt();
		Arrays.sort(w);
//		dp = new int[n][W+1];
//		for(int[]a:dp)Arrays.fill(a, -1);
		mem = new Map[n][W+1];
		for(int i=0;i<n;i++)for(int j=0;j<=W;j++)mem[i][j]=new HashMap<Integer, Integer>();
		System.out.println(get(n-1, W, 1<<29));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int ans = 1000;
    while (k != 0)
    {
        ans--;
        if (a % ans == 0 && b % ans == 0)
        {
            k--;
            //     cout << ans << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
  m = [dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)]
  dp[i] = min(m)
print(dp[n-1])

Measured memory_bytes: 20444
//~ while (clock()<=69*CLOCKS_PER_SEC)
    //~ #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("O3")
    //~ #pragma GCC optimize("Ofast")
    //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    //~ #pragma GCC optimize("unroll-loops")
    #include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>

    using namespace __gnu_pbds;
    using namespace std;

    template <typename T>
    using ordered_set =
        tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

    #define sim template < class c
    #define ris return * this
    #define dor > debug & operator <<
    #define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug {
    #ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
    #else
    sim dor(const c&) { ris; }
    #endif
    };
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

    #define shandom_ruffle random_shuffle

    using ll=long long;
    using pii=pair<int,int>;
    using pll=pair<ll,ll>;
    using vi=vector<int>;
    using vll=vector<ll>;
    const int nax=1000*1007;
    const ll mno=1007;
    const ll mod = 1e9 + 7;

    void addSelf(ll& a, ll b) {
        a += b;
        if(a > mod) {
            a -= mod;
        }
    }

    int main() {
        
        int n, m;
        cin >> n >> m;
        vi a(n);
        int sum = 0;
        for(int& x : a) {
            cin >> x;

            sum += x;
        }
        float x = (float) sum/ (float)(4*m);
		int c = 0;
        //sort(a.begin(), a.end());
        for(int p : a) {
            if((float)p >= x) {
                ++c;
            }
            //else ++c;
        }
        if(c >= m) puts("Yes");
        else puts("No");
        return 0;
    }


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second



using namespace std;


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

   int a, b; cin >> a >> b;
   if(a % 2 == 1 && b % 2 == 1) cout << "Yes";
   else cout << "No"; 
   return 0;
}


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

const int N = 2050;
vector<int> E[N];

int DFS(int x, int p, int d, int mx) {
    int ans = 1;
    if (d != mx) {
        for (int y : E[x]) {
            if (y == p)
                continue;
            ans += DFS(y, x, d + 1, mx);
        }
    }
    return ans;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        E[a].push_back(b);
        E[b].push_back(a);
    }

    int ans = 0;
    if (k % 2 == 0) {
        for (int v = 1; v <= n; v++) {
            ans = max(ans, DFS(v, -1, 0, k / 2));
        }
    } else {
        for (int v = 1; v <= n; v++) {
            for (int u : E[v]) {
                ans = max(ans, DFS(v, u, 0, k / 2) + DFS(u, v, 0, k / 2));
            }
        }
    }
    ans = n - ans;
    printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  set<int> st;
  rep(i,4){
    int x;cin >> x;
    st.insert(x);
  }
  YESNO(st.count(1) && st.count(9) && st.count(7) && st.count(4));
  return 0;
}


Measured memory_bytes: 256
#import <stdio.h>
double FLOOR(double x) {
    long n = (long)x;
    return n + (((x != n) && (x < 0)) ? -1 : 0);
}
double ROUND(double x) {
    double n = FLOOR(x);
    double d = x - n;
    return ((x>=0)&&(d<0.5))||((x<0)&&(d<=0.5)) ? n : n+1;
}
double SQRT(double x) {
    double xHalf = 0.5 * x;
    long tmp = 0x5FE6EB50C7B537AAl - ( *(long*)&x >> 1); //initial guess
    double xRes = * (double*)&tmp;
    
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    return xRes * x;
}
int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    int x[10][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            int y;
            scanf("%d",&y);
            x[i][j] = y;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int L = 0;
            for (int k=0;k<d;k++){
                L += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            int p = (int)(ROUND(SQRT((double)L)));
            if(p*p==L) ans++;
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 2164
import java.math.BigDecimal

fun main() {
    val n = nextInt()
    val limit = BigDecimal(1000000000000000000L)
    var res = BigDecimal(1)
    repeat(n) {
        res *= nextLong().toBigDecimal()
        if (res > limit) {
            repeat(n - it - 1) {
                if (nextLong() == 0L) {
                    return println(0)
                }
            }
            return println(-1)
        }
    }
    println(res.toPlainString())
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))

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

#define ll long long
#define llu unsigned long long
#define PB push_back
#define F first
#define S second
const ll MOD = 1000000007;
const ll INF = 1000000007;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ck(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define ck(x...)
#endif

string gh = "here";

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
			freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
			freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
			freopen("C:\\Users\\HP\\Desktop\\err.txt", "w", stderr);
	#endif

	int a, b;
	cin>>a>>b;
	cout<<a*b;		
	
	return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>

using namespace std;

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

    cin >> a >> b >> c >> d;
    int ans = 0;
    if (a <= c and b >= c){
        if (d <= b){
            ans = d - c;
        }
        else{
            ans = b - c;
        }
    }
    else if (c <= a and d >= a){
        if (b <= d){
            ans = b - a;
        }
        else{
            ans = d - a;
        }
    }

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


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, a, b, c, ans = 100000000 ; 
    cin >> n >> a >> b >> c ; 
    vi bamboo(n);
    for (int &i: bamboo) cin >> i ; 
    for (int i=1;i<(1<<n);i++) { // 1 st.......
        int  x = bitcount(i) , f = 0, h = 0 ; 
        for (int t=0;t<n;t++){
            if ((i>>t)&1) h += bamboo[t];
        }
        f += abs(a-h)+ (x-1)*10;
        for (int j=1;j<(1<<n);j++) { // 2 nd.......
            int x = bitcount(j),s=0,h=0;
            if (i&j) continue; 
            for (int t=0;t<n;t++)
                if ((j>>t)&1) h += bamboo[t];
            s += abs(b-h)+(x-1)*10;
            for (int k=1;k<(1<<n);k++) { // 3 rd.......
                int  x = bitcount(k),t = 0, h=0;
                if (k&j or i&k) continue ; 
                for (int t=0;t<n;t++)
                    if ((k>>t)&1) h += bamboo[t];
                t += abs(c-h)+(x-1)*10; 
                if (f + s + t < ans ) { 
                    ans = f + s + t ; 
                }
            } 
        } 
    } 
    co(ans) ; 
}

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
}

ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}
ll fact(ll n,ll p) {
    ll res = 1;
    while (n > 1) {
        res = (res * ((n/p) % 2 ?  p-1 : 1)) % p;
        for (int i = 2; i <= n%p; ++i)
            res = (res * i) % p;
        n /= p;
    }
    return res % p;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}


int main(){
   IOS;
ll t;t=1;//cin>>t;
while(t--){
   ll n;cin>>n;
   ll a[n];ll ans=0;
   for(ll i=0;i<n;i++) cin>>a[i];
  
   for(ll i=0;i<n;i++){
       for(ll j=i+1;j<n;j++){
           for(ll k=j+1;k<n;k++){
             if(((a[i]!=a[j])&&(a[j]!=a[k]))&&a[k]!=a[i]){
               if((((a[i]+a[j])>a[k])&&((a[i]+a[k])>a[j]))&&((a[j]+a[k])>a[i])) {ans++;}}
           }
       }
   }
    
    cout<<ans<<"\n"; 
 }
    
return 0;    
}

Measured memory_bytes: 3648
N = int(input())
H = list(map(int,input().split())) + [10**10]

count=0
max_count=-1
for i in range(0,N,1):
    if H[i]>=H[i+1]:
        count +=1
    else:
        max_count=max(max_count,count)
        count=0
print(max_count)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int H, W;
    cin >> H >> W;
    char s[W][H];
    REP(i, H)
    {
        REP(j, W)
        {
            cin >> s[j][i];
        }
    }

    bool isAble = true;
    REP(i, H)
    {
        REP(j, W)
        {
            if (isAble)
            {
                if (s[j][i] == '#')
                {
                    bool isAbleLocal = false;
                    for (int dx = -1; dx <= 1; dx += 2)
                    {
                        if (j + dx >= 0 && j + dx <= W - 1)
                        {
                            if (s[j + dx][i] == '#')
                            {
                                isAbleLocal = true;
                            }
                        }
                    }
                    for (int dy = -1; dy <= 1; dy += 2)
                    {
                        if (i + dy >= 0 && i + dy <= H - 1)
                        {
                            if (s[j][i + dy] == '#')
                            {
                                isAbleLocal = true;
                            }
                        }
                    }
                    isAble = isAbleLocal;
                }
            }
        }
    }
    string ans = isAble ? "Yes" : "No";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void){
    char line[1201];
    int i=0;
    fgets(line,1201,stdin);
    while(line[i] != 0){
        if(isalpha(line[i])){
                if(islower(line[i]))
                    line[i]=toupper(line[i]);
                else
                    line[i]=tolower(line[i]);
        }
        i++;
    }
    printf("%s",line);
    return 0;
}

Measured memory_bytes: 524
import java.util.*;
import java.io.*;
class Main{
  public static void main(String[] args){
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String s = br.readLine();
      String t = br.readLine();
      StringBuilder sb1 = new StringBuilder(t);
      //System.out.println(s);
      int ans = 0;
      for(int i=0;i<s.length();i++){
        if(s.equals(t)){
          break;
        }else{
          char s1 = s.charAt(i);
          char t1 = t.charAt(i);
          if(!(s1==t1)){
            ans++;
            sb1.setCharAt(i, s1);
         }
       }
      }
       System.out.println(ans);
    }catch(IOException e){
       System.out.println(e);
    }
  }
}

Measured memory_bytes: 37316
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
#define PI 3.14159265358979323846
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int n;
int a[100005];

int cal_1(){
    int sum=0;
    int ans=0;
    for(int i=0;i<n;++i){
        sum+=a[i];
        if(i%2==0&&sum<=0){
            ans+=abs(1-sum);
            sum=1;
        }
        else if(i%2!=0&&sum>=0){
            ans+=abs(-1-sum);
            sum=-1;
        }
    }
    return ans;
}

int cal_2(){
    int sum=0;
    int ans=0;
    for(int i=0;i<n;++i){
        sum+=a[i];
        if(i%2==1&&sum<=0){
            ans+=abs(1-sum);
            sum=1;
        }
        else if(i%2==0&&sum>=0){
            ans+=abs(-1-sum);
            sum=-1;
        }
    }
    return ans;
}



signed main(){
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    cout<<min(cal_1(),cal_2())<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(W<x+r || x-r<0 || H<y+r || y-r<0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
		
	return 0;
}

Measured memory_bytes: 584