akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq
import numpy as np
input = sys.stdin.readline
N = int(input())
a = [int(x) for x in input().strip().split()]
a_a = a[:N]
sum_a_a = sum(a_a)
a_b = [-1 * i for i in a[-N:]]
sum_a_b = -sum(a_b)
l = [0] * (N + 1)
l[0] = sum_a_a
l[-1] = -sum_a_b
heapq.heapify(a_a)
heapq.heapify(a_b)
for i in range(N):
    t = heapq.heappop(a_a)
    sum_a_a = sum_a_a - t + max(t, a[N+i])
    heapq.heappush(a_a, max(t, a[N+i]))
    l[i+1] += sum_a_a
    t = -heapq.heappop(a_b)
    sum_a_b = sum_a_b - t + (min(t, a[-1-N-i]))
    heapq.heappush(a_b, max(-t, -1*a[-1-N-i]))
    l[-2-i] -= sum_a_b

print(max(l))

Measured memory_bytes: 47752
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
ll ans=0;
int digit(int x){
int ret=0;
while(x){
x/=10;
ret++;
}
return ret;
}
int main(){
    cin>>n;
    int count[10][10];
    ll ans=0;
    rep(i,10)rep(j,10)count[i][j]=0;
    for(int x=1;x<=n;x++){
        count[x/llpow(10,digit(x)-1)][x%10]++;
    }
    for(ll al=1;al<=9;al++){
        for(ll as=1;as<=9;as++){
           ans+=count[al][as]*count[as][al];
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);

    int N = scn.nextInt();
    int[] Nmonster = new int[N + 1];

    for (int i = 0; i < N + 1; i++) {
      Nmonster[i] = scn.nextInt();
    }
    long Nbeaten = 0;
    for (int i = 0; i < N; i++) {
      int Nbeatble = scn.nextInt();

      if (Nbeatble < Nmonster[i]) {
        Nbeaten += Nbeatble;

      } else {
        Nbeaten += Nmonster[i];
        Nbeatble -= Nmonster[i];
        int diff = Nbeatble - Nmonster[i + 1];
        if (diff >= 0) {
          Nbeaten += Nmonster[i + 1];
          Nmonster[i + 1] = 0;

        } else {
          Nbeaten += Nbeatble;
          Nmonster[i + 1] -= Nbeatble;
        }
      }


    }

    System.out.println(Nbeaten);

  }
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  vector <bool> counted(N, false);
  int nhas = 0;
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      cin >> a;
      a--;
      if (counted[a] == false) {
        nhas++;
        counted[a] = true;
      }
    }
  }
  cout << (N - nhas) << endl;
  return 0;
}

Measured memory_bytes: 3632
def main():
    import sys
    input=sys.stdin.buffer.readline
    n=int(input())+1
    dp=[0]*n*2
    for h,a in zip(map(int,input().split()),map(int,input().split())):
        l,r,s=n,h+n,0
        while l<r:
            if l&1:
                t=dp[l]
                if t>s:s=t
                l+=1
            if r&1:
                r-=1
                t=dp[r]
                if t>s:s=t
            l>>=1
            r>>=1
        s+=a
        i=h+n
        if s>dp[i]:
            dp[i]=s
            i>>=1
            while i:
                s,t=dp[i+i],dp[i-~i]
                if t>s:s=t
                if s>dp[i]:dp[i]=s
                else:break
                i>>=1
    print(dp[1])
main()

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

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

    int ans = 0;
    for(int i = 1; i <= k; i++)
        for(int j = 1; j < i; j++)
            if((i%2 == 0 && j%2 != 0)||( i%2 != 0 && j%2 == 0)) ans++;
            
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct node{
  int parent,left,right;
};
node type[25];

void preorder(int x){
  if(x!=-1){
    cout<<" "<<x;
    preorder(type[x].left);
    preorder(type[x].right);
  }
}

void inorder(int x){
  if(x!=-1){
    inorder(type[x].left);
    cout<<" "<<x;
    inorder(type[x].right);
  }
}

void postorder(int x){
  if(x!=-1){
    postorder(type[x].left);
    postorder(type[x].right);
    cout<<" "<<x;
  }
}

int main(){
  int n; cin>>n;
  for(int i=0;i<n;++i) type[i].parent=-1;
  for(int i=0;i<n;++i){
    int id,l,r; cin>>id>>l>>r;
    type[id].left=l;
    type[id].right=r;
    if(l!=-1) type[l].parent=id;
    if(r!=-1) type[r].parent=id;
  }
  int root;
  for(int i=0;i<n;++i)
    if(type[i].parent==-1) root=i;
  cout<<"Preorder"<<endl;
  preorder(root);
  cout<<endl<<"Inorder"<<endl;
  inorder(root);
  cout<<endl<<"Postorder"<<endl;
  postorder(root);
  cout<<endl;
  return 0;
}



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

int main(){
	int a[5],minv,sum=0,b[5];
  	for(int i=0;i<5;++i)cin>>a[i];
  	for(int i=0;i<5;++i){
      if(a[i]%10==0)b[i]=a[i]/10;
      else b[i]=a[i]/10+1;
      sum+=b[i];
    }sum*=10;
  	minv=a[0]%10;
  	for(int i=1;i<5;++i)if(a[i]%10!=0)minv=min(minv,a[i]%10);
    if(minv!=0)sum-=(10-minv);
  	cout<<sum<<endl;return 0;
  	
}

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

int main(){
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ){
    cout << "vowel"  << endl;
  } else {
   cout << "consonant" << endl;
  }
}


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

using namespace std;

int num[100005];

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int minx = 999999999;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        if(num[i]<minx)
        {
            minx = num[i];
        }
    }
    int cnt= 0;
    for(int i=0;i<n;i++)
    {
        if(minx == num[i])
            cnt++;
    }
    if((n-cnt) %(k-cnt)==0)
    {
        printf("%d",(n-cnt)/(k-cnt));
    }
    else
    {
        printf("%d",(n-cnt)/(k-cnt)+1);
    }
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

def in_sec(a, b, c):
    return min(a, b) <= c <= max(a, b)
def dist(xp, yp, xq, yq):
    return math.sqrt((xq - xp) ** 2 + (yp - yq) ** 2)
def min_d(x, y, xp, yp, xq, yq):
    vx, vy = [xp - xq, yp - yq]
    vx1, vy1 = [x - xp, y - yp]
    vx2, vy2 = [x - xq, y - yq]
    if (vx1 * vx + vy1 * vy) * (vx2 * vx + vy2 * vy) < 0:
        a, b, c = [yq - yp, xp - xq, xp * (yp - yq) + yp * (xq - xp)]
        return abs(a * x + b * y + c) / math.sqrt(a ** 2 + b ** 2)
    return min(dist(x, y, xp, yp), dist(x, y, xq, yq))

q = input()

for loop in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
    #(y1 - y0)(x - x0) = (x1 - x0)(y - y0)
    a1, b1, c1 = [y1 - y0, x0 - x1, x0 * (y1 - y0) - y0 * (x1 - x0)]
    a2, b2, c2 = [y3 - y2, x2 - x3, x2 * (y3 - y2) - y2 * (x3 - x2)]
    det = a1 * b2 - b1 * a2
    if det == 0:
        dx, dy = [x2 - x0, y2 - y0]
        if dx * a1 + dy * b1 == 0 and \
            not(max(x0, x1) < min(x2, x3) or max(x2, x3) < min(x0, x1) \
            or max(y0, y1) < min(y2, y3) or max(y2, y3) < min(y0, y1)):
            print 0
            continue
    else:
        xdet = c1 * b2 - c2 * b1
        ydet = c2 * a1 - c1 * a2
        if in_sec(det * x0, det * x1, xdet) and in_sec(det * y0, det * y1, ydet) \
            and in_sec(det * x2, det * x3, xdet) and in_sec(det * y2, det * y3, ydet):
            print 0
            continue

    ans = min(min_d(x0, y0, x2, y2, x3, y3), min_d(x1, y1, x2, y2, x3, y3), 
        min_d(x2, y2, x0, y0, x1, y1), min_d(x3, y3, x0, y0, x1, y1))
    print "%.10f" % ans


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

int main(void)
{
    int N;
    cin >> N;

    int x = 111;
    for (;;)
    {
        if (N <= x)
        {
            break;
        }
        x += 111;
    }
    cout << x << endl;
    return (0);
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n,m,c = map(int, input().split())
    b = list(map(int, input().split()))
    for _ in range(n):
        temp = c
        a = list(map(int, input().split()))
        for j in range(m):
            temp += a[j]*b[j]
        if temp > 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c=0,d,x,y,z;
  string s,t;
  //

  // ここから
  IN(n);
  Vi p(n);
  VIN(p)
  FOR(i,1,(n-1)){
    if(p[i-1] < p[i] && p[i] < p[i+1]) c++;
    else if(p[i+1] < p[i] && p[i] < p[i-1]) c++;
  }
  OUT(c);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int a[3005][3005];
ll dp[3005][3005][4];
int main()
{
int R,C;
int K;


cin>>R>>C;
cin>>K;
rep(i,K)
{
int r,c,v;
cin>>r>>c>>v;
a[r-1][c-1]=v;
}

for(int i=0;i<R;i++)
{
for(int j=0;j<C;j++)
{
for(int k=2;k>=0;k--)
dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+a[i][j]);

for(int k=3;k>=0;k--)
{
    dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
    dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);


}



}
}
ll ans=0;
for(int i=0;i<4;i++)
ans=max(ans,dp[R-1][C-1][i]);
cout <<ans;
return 0;
}

Measured memory_bytes: 320596
#include<stdio.h>
#include<string.h>

#define N   3
#define LIM 32
#define HN  362897

struct dep{
    int depth;
    int key;
};

int puz[N][N]={
    {1,2,3},
    {4,5,6},
    {7,8,0}};

int min = LIM;
struct dep h[HN];

int Hash1(int x){
    return x % HN;
}

int Hash2(int x){
    return 1 + x % (HN-1);
}

int Hash3(int x, int y){
    return (Hash1(x) + y * Hash2(x)) % HN;
}

void Dfs(int x[N][N], int n){
    int i,j,l,m,a=0,b=1;
    int f=0;
    int tmp[N][N];

    for(i = 0 ; i < N ; i++){
        for(j = 0 ; j < N ; j++){
            if(puz[i][j] != x[i][j]){
              f++;
            }
            if(x[i][j] == 0){
                l = i;
                m = j;
            }
            a += x[i][j] * b;
            b *= 10;
        }
    }

    if(f == 0){
        if(min >= n){
            min = n;
        }
        return;
    }
    if(n > min){
      return;
    }
    i = 0;
    while(1){
        b = Hash3(a, i);
        if(h[b].key == 0){
          h[b].key = a;
          h[b].depth = n;
          break;
        }
        else if(h[b].key == a){
            if(h[b].depth > n){
              h[b].depth = n;
              break;
            }
            else{
              return;
            }
        }
        i++;
    }

    if(l > 0 && l < N){
        memcpy(tmp, x, sizeof(int)*N*N);
        f = tmp[l][m];
        tmp[l][m] = tmp[l-1][m];
        tmp[l-1][m] = f;
        Dfs(tmp, n+1);
    }

    if(m > 0 && m < N){
        memcpy(tmp, x, sizeof(int)*N*N);
        f = tmp[l][m];
        tmp[l][m] = tmp[l][m-1];
        tmp[l][m-1] = f;
        Dfs(tmp, n+1);
    }

    if(l >= 0 && l < N-1){
        memcpy(tmp, x, sizeof(int)*N*N);
        f = tmp[l][m];
        tmp[l][m] = tmp[l+1][m];
        tmp[l+1][m] = f;
        Dfs(tmp, n+1);
    }

    if(m >= 0 && m < N-1){
        memcpy(tmp, x, sizeof(int)*N*N);
        f = tmp[l][m];
        tmp[l][m] = tmp[l][m+1];
        tmp[l][m+1] = f;
        Dfs(tmp, n+1);
    }
}

int main(){
    int i,j;
    int puz[N][N];

    for(i = 0 ; i < N ; i++){
        for(j = 0 ; j < N ; j++){
            scanf("%d",&puz[i][j]);
        }
    }
    Dfs(puz,0);

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

    return 0;
}



Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n,a[300000],ans=0;
  cin>>n;
  for(int i=0;i<3*n;i++)cin>>a[i];
  sort(a,a+n*3);
  for(int i=1;i<=n;i++){
    ans+=a[n*3-2*i];
  }
  cout<<ans<<endl;
}

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

void Value_Check(int *p,int key){
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == key){
                *(p + i * 3 + j) = 0;
                return;
            }
        }
    }
}

void Hit_Check(int *p,bool *flag){

    int sum;
    
    //横チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //縦チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + j * 3 + i) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //斜めチェック
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + i) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
    
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + (2-i)) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
}

int main(void){
    
    int data[3][3];
    int N;
    bool flag = false;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> data[i][j];
        }
    }
    
    cin >> N;
    
    for(int i=0;i<N;i++){
        int b_i;
        cin >> b_i;
        Value_Check(&data[0][0],b_i);
    }
    
    Hit_Check(&data[0][0],&flag);
    
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
  int N; cin >>N;
  vector<int> check(N);
  int sum=0;
  rep(i,0,N) {
    cin >>check[i];
    sum+=check[i];
  }
  if (sum%10) {
    cout <<sum <<endl;
    return 0;
  } else {
    sort(check.begin(),check.end());
    rep(i,0,N) {
      if (check[i]%10) {
        cout <<sum-check[i] <<endl;
        return 0;
      }
    }
  }
  cout <<0 <<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n, m = map(int, input().split())
l = []
a0 = 0
for i in range(m):
    a = int(input())
    if a - a0 == 0:
        print(0)
        exit()
    l.append(a - a0 - 1)
    a0 = a + 1
l.append(n - a0)
d = Counter(l)
key = list(d.keys())

ma = max(key)
fib = [1]*(ma + 1)
for i in range(2, ma + 1):
    fib[i] = fib[i - 2] + fib[i - 1]

ans = 1
for k in key:
    ans *= fib[k]**d[k]
    ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 502296
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Dice dice1 = new Dice(br.readLine());
		Dice dice2 = new Dice(br.readLine());
		int i = 0;
		while(true){
			if (dice1.getTop() == dice2.getTop()) {

			}else if (dice1.getTop() == dice2.getForth()){
				dice2.sim("N");
			}else if (dice1.getTop() == dice2.getRight()){
				dice2.sim("W");
			}else if (dice1.getTop() == dice2.getBack()){
				dice2.sim("S");
			}else if (dice1.getTop() == dice2.getLeft()){
				dice2.sim("E");
			}else if (dice1.getTop() == dice2.getBottom()){
				dice2.sim("NN");
			}else{
				System.out.println("No");
				break;
			}

			if (dice1.getForth() == dice2.getForth()) {
				
			}else if(dice1.getForth() == dice2.getRight()){
				dice2.sim("WSE");
			}else if(dice1.getForth() == dice2.getBack()){
				dice2.sim("WSSE");
			}else if(dice1.getForth() == dice2.getLeft()){
				dice2.sim("ESW");
			}else{
				System.out.println("No");
				break;
			}
			if (dice1.getRight() !=dice2.getRight() && dice1.getLeft() != dice2.getLeft()) {
				System.out.println("No");
				break;
			}

			if (dice1.getTop() == dice2.getTop() && dice1.getForth() == dice2.getForth() && dice1.getRight() == dice2.getRight() && dice1.getLeft() == dice2.getLeft() && dice1.getBack() == dice2.getBack() && dice1.getBottom() == dice2.getBottom()){
				System.out.println("Yes");
				break;
			}else{
				if (i%4 == 0) {
					dice2.sim("E");
				}else if(i%4 == 1){
					dice2.sim("N");
				}else if(i%4 == 2){
					dice2.sim("W");
				}else if(i%4 == 3){
					dice2.sim("S");
				}

			}
			i++;

		}
	}
}



class Dice{
	private int top;
	private int forth;
	private int right;
	private int left;
	private int back;
	private int bottom;
	Dice(String str){
		String[] s = str.split(" ");	
		top = Integer.parseInt(s[0]);
		forth = Integer.parseInt(s[1]);
		right = Integer.parseInt(s[2]);
		left = Integer.parseInt(s[3]);
		back = Integer.parseInt(s[4]);
		bottom = Integer.parseInt(s[5]);
	}

	public void sim(String st){
		int work;
		for (int i = 0; i<st.length() ; i++ ) {
			switch(st.charAt(i)){

				case 'N':
				work = top;
				top = forth;
				forth = bottom;
				bottom = back;
				back = work;
				break;

				case 'E':
				work = top;
				top = left;
				left = bottom;
				bottom = right;
				right = work;
				break;

				case 'S':
				work = top;
				top = back;
				back = bottom;
				bottom = forth;
				forth = work;
				break;

				case 'W':
				work = top;
				top = right;
				right = bottom;
				bottom = left;
				left = work;
				break;

			}
		}

	}
	public int getTop(){
		return top;
	}
	public int getForth(){
		return forth;
	}

	public int getRight(){
		return right;
	}
	public int getLeft(){
		return left;
	}
	public int getBack(){
		return back;
	}
	public int getBottom(){
		return bottom;
	}
}

Measured memory_bytes: 24564
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100100];
int b[100100];

int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	long long ans=0;
	for (int i=0;i<n;i++) {
		scanf("%d%d",&a[i],&b[i]);
		if ((a[i]|k)<=k) ans+=b[i];
	}
	for (int j=30;j>=0;j--) {
		long long now=0;
		if ((k&(1<<j))==0) continue;
		int w=k^(1<<j);
		w|=((1<<j)-1);
		for (int i=0;i<n;i++) {
			if ((a[i]|w)<=w) now+=b[i];
		}	
		ans=max(ans,now);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>  
#include <algorithm> 
#include <string> 
#include <cstdlib>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair< int,int>;
using node = tuple<string,int,int>;
const int MAX_N = (1 << 21) - 1;
const int inf = numeric_limits<int>::max();

int main(void){
  int n;
  cin >> n;
  vector<node> res;
  for(int i = 0;i < n;++i){
    string s;
    int p;
    cin >> s >> p;
    res.push_back(node{s,100-p,i+1});
  }
  sort(res.begin(),res.end());
  for(auto r : res){
    string s;
    int p,id;
    tie(s,p,id) = r;
    cout << id << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <sstream>
#include <iomanip>

using namespace std;

int main(){
	int L, H;
	cin >> L >> H;

	int tall = 0;
    for(int i = 1; i < 999; ++i){
		tall += i;
		if(L < tall){
			int tmp = tall - L;
			if(tall + (i+1) - tmp == H){
				cout << tall - L << endl;
				break;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 384
c[];main(n,m,i){for(;scanf("%d%d",&m,&n)*m;puts("")){int q[1001]={i=0},t=1,p=m;for(;n--;)for(*c=!scanf("%s",c+3),++i%3||strcat(c,"Fizz"),i%5||strcat(c,"Buzz"),*c||sprintf(c,"%d",i),strcmp(c+3,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);for(t=i=0;m--;q[++i]||(t=printf(" %d"+!t,i)));}}

Measured memory_bytes: 632
import java.util.*;

public class Main {
    int[] ans;
    int[] tree;

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

        int n = sc.nextInt();
        int q = sc.nextInt();

        ans = new int[n];
        tree = new int[n];

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            tree[b] = a;
        }

        for (int i = 0; i < q; i++) {
            int p = sc.nextInt() - 1;
            int x = sc.nextInt();
            ans[p] += x;
        }

        System.out.print(ans[0]);
        for (int i = 1; i < n; i++) {
            int parent = tree[i];
            ans[i] += ans[parent];
            System.out.print(" ");
            System.out.print(ans[i]);
        }
        System.out.println();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 155212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

template <typename T, typename U> T pow_fast(T x, U n) {
    T ret = (T)1;
    while(n) {
        if(n & (U)1) ret *= x;
        x *= x;
        n >>= 1;
    }
    return ret;
}

template <typename ModType, ModType MOD> struct ModInt {
    ModType val;
    ModInt() : val(0) {}
    ModInt(ModType x) : val(x % MOD) {
        if(val < 0) val += MOD;
    };
    operator ModType() const { return val; }
    ModInt &operator+=(const ModInt &m) {
        val += m.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    ModInt &operator-=(const ModInt &m) {
        val -= m.val;
        if(val < 0) val += MOD;
        return *this;
    }
    ModInt &operator*=(const ModInt &m) {
        (val *= m.val) %= MOD;
        return *this;
    }
    ModInt &operator/=(const ModInt &m) {
        *this *= m.inverse();
        return *this;
    }
    ModInt operator+(const ModInt &m) const { return ModInt(*this) += m; }
    ModInt operator-(const ModInt &m) const { return ModInt(*this) -= m; }
    ModInt operator*(const ModInt &m) const { return ModInt(*this) *= m; }
    ModInt operator/(const ModInt &m) const { return ModInt(*this) /= m; }
    ModInt inverse() const { return pow_fast(*this, MOD - 2); }
    ModInt pow(ModType n) const {return pow_fast(*this, n); }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &rhs) {
        os << rhs.val;
        return os;
    }
    friend std::istream &operator>>(std::istream &is, ModInt &rhs) {
        ModType value;
        is >> value;
        rhs = ModInt(value);
        return is;
    }
};
template <class mint> struct Comb {
    vector<mint> fact;
    vector<mint> ifact;
    const int N;
    Comb(int n) : N(n + 1), fact(n + 1), ifact(n + 1) { makeFact(); }
    void makeFact() {
        fact[0] = ifact[0] = 1LL;
        for(int i = 1; i < N; i++) {
            fact[i] = fact[i - 1] * (mint)i;
            ifact[i] = fact[i].inverse();
        }
    }
    mint operator()(int n, int r) {
        if(n < 0 || r < 0 || r > n) return 0;
        if(r > n / 2) r = n - r;
        return fact[n] * ifact[n - r] * ifact[r];
    }
};

int main(){
    using mint = ModInt<ll, MOD>;
    Comb<mint> comb(2e6+10);
    int x, y;
    cin >> x >> y;
    if((x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int k = (x+y)/3;
    x -= k;
    y -= k;
    if(x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << comb(x+y, x) << endl;

    return 0;
}

Measured memory_bytes: 31616
S = list(input())
count = 0

for i in range(1,len(S)):
    if S[i-1] == "0":
        if S[i] == "0":
            count += 1
            S[i] = "1"
    else:
        if S[i] == "1":
            count += 1
            S[i] = "0"
print(count)

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

int main()
{
	int A, B, K;
	scanf("%d%d%d", &A, &B, &K);

	int i, j, k;
	if (2 * K < B - A + 1) {
		for (i = A; i < A + K; i++)
			printf("%d\n", i);
		for (i = B - K + 1; i <= B; i++)
			printf("%d\n", i);
	} else {
		for (i = A; i <= B; i++)
			printf("%d\n", i);
	}

	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,a[15],ans; 
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	sort(a+1,a+n+1);
	cout<<ans-a[n]/2<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int32_t tmp = 0;
    for (int i = 0; i < k; ++i) {
        tmp += v[i];
    }
    int32_t res = tmp;
    for (int i = 0; i < n - k; ++i) {
        tmp = tmp - v[i] + v[i + k];
        res = max(res, tmp);
    }
    cout << setprecision(12) << double(res + k) / 2 << endl;
}



Measured memory_bytes: 1024
# coding=utf-8
from collections import deque

n, q = map(int, input().split())
queue = deque(maxlen = 100000)
total_time = 0

for i in range(n):
    name, time = input().split()
    queue.append([name, int(time)])

while queue:
    poped = queue.popleft()
    if poped[1] > q:
        queue.append([poped[0], poped[1] - q])
        total_time += q
    else:
        total_time += poped[1]
        print(poped[0], total_time)

Measured memory_bytes: 16076
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	const double PI=3.14159265358979323846;
	double R;
	cin>>R;
	printf("%.9lf\n",2*PI*R);
	return 0;
}



Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 9e18;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 200005;

int N, X;
int A[SIZE];

int main (){
	
	scanf("%d %d", &N, &X);
	int ans=0;
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
		ans=__gcd(ans,abs(A[i]-X));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int H, W;

	while (1) {

		cin >> H >> W;

		if (H == 0 && W == 0)break;
		else {

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {

					cout << "#";

				}
				cout << endl;
			}
			cout << endl;

		}

	}

	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k;cin >> n >> k;
    vector<ll> x(n);rep(i,n) cin >> x[i];
    ll ans = LINF;
    rep(i,n-k+1){
        ll t = llabs(x[i]-x[i+k-1]);
        ans = min(ans,min(llabs(x[i]),llabs(x[i+k-1])) + t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    vector<string> vs;
    int H, W;
    cin >> H >> W;
    
    vs.resize(H);
    for(int i = 0; i < H; i++)
    {
        cin >> vs[i];
        cout << vs[i] << endl << vs[i] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 504
#include <iostream>
using namespace std;
int main() {
    char c;
    cin >> c;
    if (c == 'a' || c=='i' || c=='u' || c== 'e' || c =='o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t,pro=0,m,sum=0;
	cin>>n>>t;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	m=a[0];
	for(int i=0;i<n;i++){
		pro=max(pro,a[i]-m);
		m=min(m,a[i]);
	}
	m=0;
	map<int,int> ma;
	for(int i=0;i<n;i++){
		//cout<<a[m]<<endl;
		if((a[i]-a[m])==pro){
			sum+=ma[a[m]];
			ma[a[m]+1]=ma[a[m]];
			ma[a[m]]=0;
			a[m]++;
		}
		if(a[i]<=a[m]){
			m=i;
		}
		ma[a[i]]++;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 10560
#include <iostream>
#include <algorithm>

int main()
{
	int N;
	
	int min = 10000000,max = -10000000;

	std::cin >> N;
	int input[N];
	for(int i=0;i<N;i++){
		std::cin>>input[i];
		min = std::min(input[i], min);
		max = std::max(input[i], max);
	}

	
	int ans = 1000000000;
	for(int i=min;i<=max;i++){
		int sum = 0;
		for(int j=0;j<N;j++){
			sum += (i-input[j])*(i-input[j]);
		}
		ans = std::min(ans,sum);
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def prime_len(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return len(a)


n = int(input())
c = 0
for z in make_divisors(n):
    if prime_len(z) == 1:
        tmp = n / z
        if tmp.is_integer():
            n = tmp
            c += 1
        else:
            continue

print(c)


Measured memory_bytes: 9216
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/**
 * B - Popular Vote
 * N 種類の商品に対して人気投票を行いました。
 * 商品 i は Ai 票を得ています。
 * この中から人気商品 M 個を選びます。
 * ただし、得票数が総投票数の 1/4M 未満であるような商品は選べません。
 * 人気商品 M 個を選べるなら Yes、選べないなら No を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 全商品数
        int n = sc.nextInt();
        // 人気商品の数
        double m = sc.nextDouble();

        // 総得票数（最大が1000）
        Integer[] a = new Integer[n];
        int votesAllNum = 0;
        for( int i = 0; i < n; i++ ) {
            a[i] = sc.nextInt();
            votesAllNum += a[i];
        }
        Arrays.sort( a, Collections.reverseOrder() );

//        System.out.println( Arrays.asList( a ) );

        // 総得票数の1/4M
        double votesNum = votesAllNum / ( 4 * m );
        int cnt = 0;
        String result = "No";
        // 各商品の得票数が指定数を上回っているか
        for( int i = 0; i < n; i++ ) {
            if( a[i] >= votesNum ) {
                cnt++;
                if( cnt >= m ) {
                    result = "Yes";
                    break;
                }
            }
        }

        System.out.println( result );

        sc.close();
    }
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
char s[N], t[N];
char ani[] = {'S', 'W'};

bool check(int u, int l, int r)
{
	t[0] = ani[l], t[1] = ani[u], t[2] = ani[r];
	if (t[1] == 'S' && s[1] == 'o' && t[0] != t[2]) return false;
	if (t[1] == 'S' && s[1] == 'x' && t[0] == t[2]) return false;
	if (t[1] == 'W' && s[1] == 'x' && t[0] != t[2]) return false;
	if (t[1] == 'W' && s[1] == 'o' && t[0] == t[2]) return false;
	
	for (int i = 2; i <= n; i ++ )
		if (t[i] == 'S')
		{
			if (s[i] == 'o') t[i + 1] = t[i - 1];
			else t[i + 1] = t[i - 1] == 'S' ? 'W' : 'S';
		}
		else
		{
			if (s[i] == 'x') t[i + 1] = t[i - 1];
			else t[i + 1] = t[i - 1] == 'S' ? 'W' : 'S';
		}
	
	return t[0] == t[n] && t[n + 1] == t[1];
}

int main()
{
	scanf("%d%s", &n, s + 1);
	
	for (int i = 0; i < 2; i ++ )
		for (int j = 0; j < 2; j ++ )
			for (int k = 0; k < 2; k ++ )
				if (check(i, j, k))
				{
					t[n + 1] = '\0';
					puts(t + 1);
					return 0;
				}
	
	puts("-1");
    return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>

int main() {
	int n, result = 0, memo = 0;
	char str[105];
	int num[200]={};
	scanf("%d", &n);
	scanf("%s", str);

	for (int i = 0; i < n-1 ; i++) {

		for (int j = 0; j <= i; j++)
		{
			num[str[j]] = 1;
		}

		for (int j = n - 1; j > i; j--)
		{
			if (num[str[j]] >= 1)
			{
				memo++;
				num[str[j]] = 0;
			}
		}

		for (int j = 'a'; j <= 'z'; j++)
		{

			num[j] = 0;
		}
		if (memo > result)
		{
			result = memo;
		}
		memo = 0;
	}
	printf("%d", result);
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b)
    {
        cout << 0 << '\n';
        return 0;
    }
    if (n == 1)
    {
        if (a != b)
        {
            cout << 0 << '\n';
        }
        else
        {
            cout << 1 << '\n';
        }
    }
    else
    {
        ll l_sums = (n - 1 - 1) * a;
        ll r_sums = (n - 1 - 1) * b;
        cout << r_sums - l_sums + 1 << '\n';
    }
}


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

using namespace std;

int main() {
	int n; cin >> n;
	string tmp;
	vector<string> deck, copy;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		deck.emplace_back(tmp);
	}copy = deck;
	for (int i = 0; i < deck.size(); i++) {
		for (int j = deck.size()-1; j > i; j--) {
			if (deck[j][1] < deck[j - 1][1])swap(deck[j], deck[j - 1]);
		}
	}
	for (int i = 0; i < copy.size(); i++) {
		int mini = i;
		for (int j = i; j < copy.size(); j++) {
			if (copy[j][1] < copy[mini][1])mini = j;
		}
		swap(copy[i], copy[mini]);
	}
	for (int i = 0; i < deck.size() - 1; i++) {
		cout << deck[i] << " ";
	}cout << deck[deck.size() - 1] << endl;
	cout << "Stable" << endl;
	for (int j = 0; j < copy.size() - 1; j++) {
		cout << copy[j] << " ";
	}cout << copy[copy.size() - 1] << endl;
	if (copy == deck)cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(10**6)

mod=10**9+7
def dfs(v):
  if checked[v]==1:
    return
  checked[v]=1
  dp[v][0]=1
  dp[v][1]=1
  for u in g[v]:
    if checked[u]==0:
      dfs(u)
      dp[v][0]=(dp[v][0]*(dp[u][0]+dp[u][1]))%mod
      dp[v][1]=(dp[v][1]*dp[u][0])%mod

n=int(input())
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
dp=[[0,0] for _ in range(n+1)]
checked=[0]*(n+1)
dfs(1)
print((dp[1][0]+dp[1][1])%mod)

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  double S, T;
  
  S = 0.0;
  for (int i = 0; i < N; i++) {
    S = S + 1.0/A.at(i);
  }
    
  T = 1.0/S;
    
  cout << fixed << setprecision(10);
  cout << T << endl;
 
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W>=x+r && 0<=x-r && H>=y+r && 0<=y-r){cout<<"Yes"<<endl;
	}
	else {cout<<"No"<<endl;
	}





	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;

int cha[maxn];

int mark[maxn];
int getroot(int x) {
	if (x == cha[x]) return x;
	return cha[x] = getroot(cha[x]);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	int m = 0;
	cin >> n >> m;
	for(int i=0;i<n;i++) cha[i] = i;
	for(int i=0;i<m;i++) {
		int u = 0;
		int v = 0;
		int z = 0;
		cin >> u >> v >> z;
		u--;
		v--;
		
		int x = getroot(u);
		int y = getroot(v);
		if (x != y) {
			cha[x] = y;
		}
	}

	for(int i=0;i<n;i++) {
		mark[getroot(i)]=1;
	}

	int res= 0;
	for(int i=0;i<n;i++) res += mark[i];
	cout << res;
	return 0;
}


Measured memory_bytes: 1152
#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;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1)
{
	cout << n << "\n";
	exit(0);
}
int n;
double long a[3009];
double long dp[3009][3009];

double long fun(int i, int h)
{

	if (i == n)
	{
		int t = n - h;
		if (2 * h > n)
			return 1.00;
		else
			return 0.00;
	}
	if (dp[i][h] != -1.0)
		return dp[i][h];
	return dp[i][h] = a[i] * fun(i + 1, h + 1) + (1.0 - a[i]) * fun(i + 1, h);
}

int32_t main()
{
	AB_BHI_NI_DEGI
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= n; j++)
			dp[i][j] = -1.0;
	}
	cout.precision(20);
	cout << fixed;
	cout << fun(0, 0) << "\n";

	return 0;
}

Measured memory_bytes: 141824
#include <stdio.h>
main(){

  int i,j;
  int a[100],n,mini,kaisu = 0,c;

  scanf("%d",&n);

  for(i = 0 ; i < n  ;i++){
    scanf("%d",&a[i]);
  }
  
  
  for(i = 0 ; i <= n - 1 ; i++){
    mini = i;
    for(j = i ; j <= n - 1 ; j++){

      if(a[j] < a[mini]){

	mini = j;
	
      }
    }
    if(mini != i) {
    c = a[i];
    a[i] = a[mini];
    a[mini] = c;
    kaisu++;
    }
  }
  
  for(i = 0 ; i < n ; i++){
    if(i) printf(" ");
    printf("%d",a[i]);
  }

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

}

Measured memory_bytes: 604
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

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

    if ( k<=(a+b) )
        cout<<min(a,k)<<endl;
    else
        cout<<a-(k-a-b)<<endl;   
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[][] f = new int[n][];
            int[][] p = new int[n][];
            int output = int.MinValue;
            for(int i = 0; i < n; i++)
            {
                f[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            }
            for(int i =0; i<n;i++)
            {
                p[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            }
            for(int i = 1; i <= 1023;i++)
            {
                int ans = 0;
                for(int j = 0; j < n; j++)
                {
                    int open = 0;
                    for(int k = 0; k < 10;k++)
                    {
                        if ((i >> k & f[j][k]) == 1) open++;
                    }
                    ans += p[j][open];
                }
                output = Math.Max(output, ans);
            }
            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vector<P> v(m);
    rep(i,m) cin >> v[i].first >> v[i].second;
    auto cnt = [](int n) {
        if(n == 0) return 1;
        int ret = 0;
        while(n > 0) {
            ret++;
            n /= 10;
        }
        return ret;
    };
    rep(i,1000) {
        if(cnt(i) != n) continue;
        string s = to_string(i);
        bool ok = true;
        for(auto p : v) {
            if(s[p.first-1]-'0' != p.second) {
                ok = false;
            }
        }
        if(ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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


using namespace std;

int main()
{
    int N,D;
    int ans;
    cin >> N >> D;

    ans = N/(2*D+1);

    if(N%(2*D+1) == 0)
    {
        ans+=0;
    }
    else
    {
        ans+=1;
    }

    cout << ans << endl;
    


}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long X, long long Y, long long Z){
  cout << Z << " " << X << " " << Y << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  long long Z;
  scanf("%lld",&Z);
  solve(X, Y, Z);
  return 0;
}


Measured memory_bytes: 256