akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, A):
    for i in range(H):
        for j in range(W):
            if A[i][j] == 'S':
                s = (i, j)
    from collections import deque
    q = deque([s])
    d = [[None] * W for _ in range(H)]
    d[s[0]][s[1]] = 0
    r = [s]
    while q:
        x, y = q.popleft()
        for vx, vy in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
            if not (0 <= vx < H and 0 <= vy < W):
                continue
            if A[vx][vy] == '#':
                continue
            if d[vx][vy] is not None:
                continue
            c = d[x][y]
            if c + 1 <= K:
                q.append((vx, vy))
                d[vx][vy] = c + 1
                r.append((vx, vy))


    ans = INF
    for x, y in r:
        t = min(abs(x), abs(x-H+1), abs(y), abs(y-W+1))
        ans = min(ans, t)

    return 1 + -(-ans // K)


def main():
    H, W, K = read_int_n()
    A = [read_str() for _ in range(H)]
    print(slv(H, W, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 147700
#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 pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>maze(h,vector<char>(w));
    vector<vector<int>>up(h,vector<int>(w));
    vector<vector<int>>down(h,vector<int>(w));
    vector<vector<int>>left(h,vector<int>(w));
    vector<vector<int>>right(h,vector<int>(w));
    rep(i,h) rep(j,w) cin >> maze[i][j];
    rep(i,h){
        rep(j,w){
            if(maze[i][j]=='#') left[i][j]=0;
            else{
                if(j==0) left[i][j]=1;
                else left[i][j]=left[i][j-1]+1;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(maze[i][j]=='#') up[i][j]=0;
            else{
                if(i==0) up[i][j]=1;
                else up[i][j]=up[i-1][j]+1;
            }
        }
    }
    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            if(maze[i][j]=='#') down[i][j]=0;
            else{
                if(i==h-1) down[i][j]=1;
                else down[i][j]=down[i+1][j]+1;
            }
        }
    }
    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            if(maze[i][j]=='#') right[i][j]=0;
            else{
                if(j==w-1) right[i][j]=1;
                else right[i][j]=right[i][j+1]+1;
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            int x=left[i][j]+down[i][j]+right[i][j]+up[i][j]-3;
            ans=max(ans,x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67072
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		for(int i=0; i<N; i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();

		}

		int[] w0 = new int[N];
		int[] v0 = new int[N];
		int w0_cnt = 0;
		int[] w1 = new int[N];
		int[] v1 = new int[N];
		int w1_cnt = 0;
		int[] w2 = new int[N];
		int[] v2 = new int[N];
		int w2_cnt = 0;
		int[] w3 = new int[N];
		int[] v3 = new int[N];
		int w3_cnt = 0;
		for(int i=0; i<N; i++){
			if(w[i]==w[0]){
				w0[w0_cnt] = w[i];
				v0[w0_cnt] = v[i];
				w0_cnt++;
			}else if(w[i]==w[0]+1){
				w1[w1_cnt] = w[i];
				v1[w1_cnt] = v[i];
				w1_cnt++;
			}else if(w[i]==w[0]+2){
				w2[w2_cnt] = w[i];
				v2[w2_cnt] = v[i];
				w2_cnt++;
			}else if(w[i]==w[0]+3){
				w3[w3_cnt] = w[i];
				v3[w3_cnt] = v[i];
				w3_cnt++;
			}
		}

		Arrays.sort(v0);
		long[] v0_sum = new long[w0_cnt+1];
		v0_sum[0] = 0;
		if(w0_cnt!=0){
			for(int i=1; i<=w0_cnt; i++){
				v0_sum[i] += v0_sum[i-1] + v0[N-i];
			}
		}
		Arrays.sort(v1);
		long[] v1_sum = new long[w1_cnt+1];
		v1_sum[0] = 0;
		if(w1_cnt!=0){
			for(int i=1; i<=w1_cnt; i++){
				v1_sum[i] += v1_sum[i-1] + v1[N-i];
			}
		}
		Arrays.sort(v2);
		long[] v2_sum = new long[w2_cnt+1];
		v2_sum[0] = 0;
		if(w2_cnt!=0){
			for(int i=1; i<=w2_cnt; i++){
				v2_sum[i] += v2_sum[i-1] + v2[N-i];
			}
		}
		Arrays.sort(v3);
		long[] v3_sum = new long[w3_cnt+1];
		v3_sum[0] = 0;
		if(w3_cnt!=0){
			for(int i=1; i<=w3_cnt; i++){
				v3_sum[i] += v3_sum[i-1] + v3[N-i];
			}
		}

		int l;
		long sum = 0;
		long max = 0;
		for(int i=0; i<=W/w[0] && i<= w0_cnt; i++){
			for(int j=0; j<=(W-w[0]*i)/(w[0]+1) && j<= w1_cnt; j++){
				for(int k=0; k<=(W-w[0]*i-(w[0]+1)*j)/(w[0]+2) && k<= w2_cnt; k++){
					l = (int)((W - w[0]*i - (w[0]+1)*j - (w[0]+2)*k ) / (w[0]+3));
					if(l>w3_cnt){
						l = w3_cnt;
					}
					sum = v0_sum[i] + v1_sum[j] + v2_sum[k]+ v3_sum[l]; 
					if(sum>max){
						max = sum;
					}
				}
			}
		}

		System.out.print(max);

	}

}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define int long long
#define endl "\n"
#define print_array(name,n) for(int o=0;o<n;o++) cout<<name[o]<<" "

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int h,n;
    cin>>h>>n;
    int a;
    for(int i=0;i<n;i++){
    	cin>>a;
    	h = h-a;
    }
    if(h>0){
    	cout<<"No"<<endl;
    }
    else{
    	cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <stack>
#include <iostream>
using namespace std;
int main() {
 string word;
 stack<int> S;
 while (cin >> word) {
  if (word == "+") {
   int a = S.top();
   S.pop();
   int b = S.top();
   S.pop();
   int c = a + b;
   S.push(c);
  }
  else if (word == "-") {
   int a = S.top();
   S.pop();
   int b = S.top();
   S.pop();
   int c = b - a;
   S.push(c);
  }
  else if (word == "*") {
   int a = S.top();
   S.pop();
   int b = S.top();
   S.pop();
   int c = a * b;
   S.push(c);
  }
  else {
   int c = stoi(word);
   S.push(c);
  }
 }
 cout << S.top() << endl;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<long> a(n);
  for (long &x : a) {
    cin >> x;
  }

  bool plus;
  long sum = 0;
  long count_plus = 0;

  plus = false;

  for (long i = 0; i < n; i++) {
    plus = !plus;
    sum += a.at(i);
    if (plus) {
      if (sum > 0) {
        continue;
      } else {
        count_plus += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum < 0) {
        continue;
      } else {
        count_plus += 1 + sum;
        sum = -1;
      }
    }
  }
  long count_minus = 0;
  plus = true;
  sum = 0;

  for (long i = 0; i < n; i++) {
    plus = !plus;
    sum += a.at(i);
    if (plus) {
      if (sum > 0) {
        continue;
      } else {
        count_minus += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum < 0) {
        continue;
      } else {
        count_minus += 1 + sum;
        sum = -1;
      }
    }
  }
  cout << min(count_plus, count_minus) << endl;
}


Measured memory_bytes: 1024
let () =
  let rec aux u =
    let i = read_line () in
    let a,b = Scanf.sscanf i "%d %d" (fun a b ->  a,b) in
    if (a,b) = (0,0) then ()
    else aux (print_endline
                (if a > b then (Printf.sprintf "%d %d" b a)
                 else (Printf.sprintf "%d %d" a b)))
  in aux ()

Measured memory_bytes: 4496
#include <sstream>
#include <fstream>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
#include <cassert>
#include <bitset>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define per(i,x,n) for(int i=n-1;i>=x;i--)
using namespace std;
#define ll long long
//head
int n, L;
int l, r, mid;
struct Bottle {
    int up, down, val;
    bool operator < (const Bottle a)const {
        return val > a.val;
    }
} a[100005];
ll b[100005], c[100005], sum[100005];
bool check(int x) {
    x--;
    rep(k, 1, n + 1) {
        if(c[k] <= x)
            continue;
        ll p = L - a[k].up, go = 0;
        if(k <= x && sum[x + 1] - a[k].val >= p)
            return 1;
        if(k > x && sum[x] >= p)
            return 1;
    }
    return 0;
}
inline char gc() {
    static char buf[1<<20], *head = buf, *tail = buf;
    return (head == tail && (tail = (head = buf) + fread(buf, 1, 1 << 20, stdin), head == tail)? -1: *head++);
}
template <typename T> inline bool read(T &x) {
    static bool f;
    static char c;
    for (c = gc(), f = false; !isdigit(c); c =gc()) {
        if (c == EOF)
            return false;
        else if (c == 45)
            f = true;
    }
    for (x = 0; isdigit(c); c = gc())
        x = x * 10 + c - 48;
    if (f)
        x = -x;
    return true;
}
int main() {
    read(n);read(L);
    rep(i, 1, n + 1)read(a[i].up),read(a[i].down),a[i].val = a[i].up - a[i].down;
    rep(i, 1, n + 1)read(b[i]);
    sort(a + 1, a + n + 1);
    rep(i, 1, n + 1)sum[i] = sum[i - 1] + a[i].val;
    ll cnt = 1, dis = 0;
    rep(i, 2, n + 1) {
        dis += (a[i].val - b[cnt]);
        if(dis <= 0)
            break;
        cnt++;
    }
    c[1] = cnt;
    int k = 2;
    for(; k <= n; k++) {
        if(cnt < k - 1 || cnt == n)
            break;
        dis += (a[k - 1].val - a[k].val);
        while(dis > 0 && cnt < n)
            cnt++, dis += (a[cnt + 1].val - b[cnt]);
        c[k] = cnt;
    }
    for(; k <= n; k++)
        c[k] = cnt;
    int day = 1;
    for(int i = 1; a[i].val > 0 && i <= n; i++, day++);
    l = 1, r = day;
    while(l < r) {
        mid = (l + r) / 2;
        if(check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    if(check(l))
        cout << l << endl;
    else
        cout << -1 << endl;
    return 0;
}



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

def main():
    x = int(input())

    ans = 0
    ans += (x//11) * 2
    tmp = x%11
    if tmp != 0:
        if tmp <= 6:
            ans += 1
        else:
            ans += 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  int c;
  
  cin >> a >> b >> c;
 if (b >= a) {
  if (b/a < c) {
int k;
int s;
k=b%a;
s=b/a;
cout << s << endl;
               }   
  if (c <= b/a) {
    cout << c << endl;
                }
            }
else{
  cout << 0 << endl;
    }
  }


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int infi = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n, q;
std::set<std::pair<ll, int>> ss;
std::tuple<ll, ll, ll> a[200005];
ll ans[200005];
int main() {
	std::cin >> n >> q;

	for (int i = 0; i < n; ++i) {
		ll s, t, x;
		std::cin >> s >> t >> x;
		a[i] = std::make_tuple(x, s, t);
	}
	for (int i = 0; i < q; ++i) {
		ll d;
		std::cin >> d;
		ss.emplace(d, i);
	}

	std::sort(a, a + n);
	std::fill(ans, ans + q, -1);
	for (int i = 0; i < n; ++i) {
		ll x, s, t;
		std::tie(x, s, t) = a[i];

		auto it = ss.lower_bound({ s - x,-1 });
		while (it != ss.end()) {
			if (it->first >= t - x)
				break;
			ans[it->second] = x;
			ss.erase(it++);
		}
	}

	for (int i = 0; i < q; ++i)
		std::cout << ans[i] << std::endl;

	return 0;
}


Measured memory_bytes: 20608
#include <cstdio>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

map<string, int> m;

void build(void) {
    m["01234567"] = 0;
    queue<string> q;
    q.push("01234567");
    while (!q.empty()) {
        string t = q.front();q.pop();
        int i;
        for (i = 0; i < 8; i++) {
            if (t[i] == '0') break;
        }
        if (i != 0 && i != 4) {
            string u = t;
            swap(u[i], u[i - 1]);
            if (m.count(u) == 0) {
                q.push(u);
                m[u] = m[t] + 1;
            }
        }
        if (i != 3 && i != 7) {
            string u = t;
            swap(u[i], u[i + 1]);
            if (m.count(u) == 0) {
                q.push(u);
                m[u] = m[t] + 1;
            }
        }
        if (i > 3) {
            string u = t;
            swap(u[i], u[i - 4]);
            if (m.count(u) == 0) {
                q.push(u);
                m[u] = m[t] + 1;
            }
        }
        if (i < 4) {
            string u = t;
            swap(u[i], u[i + 4]);
            if (m.count(u) == 0) {
                q.push(u);
                m[u] = m[t] + 1;
            }
        }
    }
}

int main(void) {
    build();
    while (1) {
        string s;
        char c;
        for (int i = 0; i < 8; i++) {
            if(scanf(" %c", &c) == EOF) return 0;
            s += c;
        }
        printf("%d\n", m[s]);
    }
    return 0;
}

Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  string s;
  cin>>n>>s;
  set<int> r,g,b;
  for(int i = 0; i<n; i++){
    if(s[i] == 'R')r.insert(i);
    if(s[i] == 'G')g.insert(i);
    if(s[i] == 'B')b.insert(i);
  }
  ll ans = (r.size()*g.size()*b.size());
  for(auto it:r){
    for(auto itr:g){
        int z = max(it,itr);
        //auto itrr = lower_bound(b.begin(),b.end(),z);
        auto itrr = b.find(2*z-min(it,itr));
        if(itrr == b.end())continue;
        else if(*itrr>z)ans-=1;
    }
  }
  for(auto it:r){
    for(auto itr:b){
        int z = max(it,itr);
        //auto itrr = lower_bound(b.begin(),b.end(),z);
        auto itrr = g.find(2*z-min(it,itr));
        if(itrr == g.end())continue;
        else if(*itrr>z)ans-=1;
    }
  }
  for(auto it:b){
    for(auto itr:g){
        int z = max(it,itr);
        //auto itrr = lower_bound(b.begin(),b.end(),z);
        auto itrr = r.find(2*z-min(it,itr));
        if(itrr == r.end())continue;
        else if(*itrr>z)ans-=1;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    string R;
    cin >> R;
    if(R.length()<=10 && R.length()>=4)
    {
        int lenR=R.length();
        if(R[0]!='A')
        {
            cout<< "WA";
            return 0;
        }
        if(!(R[1]>='a' && R[1]<='z'))
        {
            cout<< "WA";
            return 0;
        }
        if(!(R[lenR-1]>='a' && R[lenR-1]<='z'))
        {
            cout<< "WA";
            return 0;
        }
        else
        {
            int count=0;
            for(int i=2;i<lenR-1;i++)
            {
                if(R[i]=='C')
                {
                    count++;
                }
                else if(!(R[i]>='a' && R[i]<='z'))
                {
                    cout<< "WA";
                    return 0;
                }
            }
            if(count!=1)
            {
                cout<< "WA";
                return 0;
            }
            cout<< "AC";
            return 0;

        }
    
    }
    else
    {
        cout<< "WA";
        return 0;
    }

}


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

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

  string rev1 = s;
  reverse(rev1.begin(), rev1.end());

  string s2 = s.substr(0, (s.length() - 1) / 2);
  string rev2 = s2;
  reverse(rev2.begin(), rev2.end());

  string s3, rev3;
  s3 = rev3 = s.substr((s.length() + 3) / 2 - 1, s.length());
  reverse(rev3.begin(), rev3.end());

  if (rev1 == s && rev2 == s2 && rev3 == s3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3552
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll h, w;
	cin >> h >> w;
	if(h == 1 || w == 1){
		cout << 1 << endl;
		return 0;
	}
	cout << (h * w + ((h & 1) == 1 && (w & 1) == 1)) / 2 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b+c || b ==a+c || c == a+b){
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val c = readLine()!!.toCharArray()
    var ans = 0

    var lp = 0
    var rp = n-1
    while (lp < n) {
        if (lp > rp && c[lp] == 'R') {
            ans++
            c[lp] = '_'
            lp++
        }
        if (lp < rp && c[lp] == 'W') {
            while (c[rp] != 'R' && rp > 0) rp--
            if (lp < rp) {
                c[lp] = 'R'
                c[rp] = 'W'
                ans++
            }
        }
        lp++
    }

    println(ans)
}


Measured memory_bytes: 38752
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n==1)
  {
    cout<<"1.0000000000";
  }
  else if(n%2==0)
  {
    cout<<"0.5000000000";
  }
  else
  {
    cout<<fixed<<setprecision(10)<<((double)(n/2+1)/n);
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	string A, B;
	cin >> A >> B;
	int tmp = stoi(A + B);
	for (int i = 1; i <= 1000; i++) {
		if (i * i == tmp) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 1000000000 + 7;
                int arr[MAX];
            //Global Variables



                int main()
                {
                    int w,a,b;
                    scanf("%d%d%d",&w,&a,&b);
                    if(b >= a+w)printf("%d\n",b - (a + w));
                    else if(a >= b+w)printf("%d\n",a - (b + w));
                    else printf("0\n");
                }


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

void dis_man(int nx[],int ny[],int n){
    int i;
    double dis1=0,dis2=0,dis3=0;
    for(i=0;i<n;i++){
        dis1 += abs(nx[i] - ny[i]);
        dis2 += pow((nx[i]-ny[i]),2);
        dis3 += pow(abs((nx[i]-ny[i])),3);
    }
    dis2 = sqrt(dis2);
    dis3 = cbrt(dis3);
    printf("%lf\n%lf\n%lf\n", dis1,dis2,dis3);
}

void dis_che(int nx[],int ny[], int n){
    int i;
    double dis=0;
    for(i=0;i<n;i++){
        dis = (dis > abs(nx[i]-ny[i])) ? dis : abs(nx[i]-ny[i]);
    }
    printf("%lf\n",dis);
}

int main(void){
    int nx[101] = {},ny[101]={},n,i;
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&nx[i]);
    for(i=0;i<n;i++) scanf("%d",&ny[i]);
    dis_man(nx,ny,n);
    dis_che(nx,ny,n);
    return(0);
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, id;
  edge(){}
  edge(int to, int id):to(to), id(id){}
};

int N, M;
int S, T;
vector<edge> G[1001];
vector<edge> rG[1001];

void init() {
  rep(i, 1001) G[i].clear();
  rep(i, 1001) rG[i].clear();
}

bool input() {
  init();
  cin >> N;
  if(N == 0) return false;
  cin >> S >> T;
  --S, --T;
  cin >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].emplace_back(b, i);
    rG[b].emplace_back(a, i);
  }

  return true;
}

pint mincost[2][1001];

struct State {
  int now, cost, rflag, redge;
  State(){}
  State(int now, int cost, int rflag, int redge)
    :now(now), cost(cost), rflag(rflag), redge(redge){}
  bool operator < (const State &s) const {
    return cost != s.cost ? cost > s.cost : redge > s.redge;
  }
};

pint dijkstra() {
  priority_queue<State> que;
  fill(mincost[0], mincost[2], make_pair(inf, -1));
  mincost[0][S] = make_pair(0, -1);
  que.emplace(S, 0, 0, -1);
  while(!que.empty()) {
    State s = que.top(); que.pop();
    int now = s.now;
    int cost = s.cost;
    int rflag = s.rflag;
    int redge = s.redge;
    if(now == T) return make_pair(cost, redge);
    if(mincost[rflag][now] < make_pair(cost, redge)) continue;
    for(edge e : G[now]) {
      if(make_pair(cost + 1, redge) < mincost[rflag][e.to]) {
	mincost[rflag][e.to] = make_pair(cost + 1, redge);
	que.emplace(e.to, cost + 1, rflag, redge);
      }
    }
    if(rflag) continue;
    for(edge e : rG[now]) {
      if(make_pair(cost + 1, e.id) < mincost[1][e.to]) {
	mincost[1][e.to] = make_pair(cost + 1, e.id);
	que.emplace(e.to, cost + 1, 1, e.id);
      }
    }
  }
  return make_pair(inf, -1);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(input()) {
    pint ans = dijkstra();
    cout << ans.first << " " << ans.second+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 4364
def func():
    return

n = int(input())
# s = input()
# a, b = map(int, input().split())
p = list(map(int, input().split()))
# a = input().split()

cnt = 0
min_ = n
for i in range(n):
    min_ = min(min_, p[i])
    if min_ == p[i]:
        cnt += 1

print(cnt)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;

    cout << (b-a - 1) * (b-a) / 2 - a << endl;

    return 0;
}


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

int main(){
  string a,b,f,g;
  ll c,d,e,h,i;
  cin >> a >>i;
  e=0;
  b=a[0];
  d=1;
  for(c=1;c<(ll)a.size();c++){
    f=a[c];
    if(b==f){
      d+=1;
    }
    else if(e==0){
      g=b;
      b=f;
      e+=floor(d/2);
      h=d%2;
      d=1;
    }
    else{
      b=f;
      e+=floor(d/2);
      d=1;
    }
  }
  if(d==a.size()){
    e=floor(i*a.size()/2);
  }
  else if(f==g){
  	e+=floor(d/2);
    e=e*i+(h*d%2)*(i-1);
  }
  else{
  	e+=floor(d/2);
    e=e*i;
  }
  cout << e << endl;
}

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

int main(){
  int n;
  cin>>n;
  int a[200000];
  int ia[200000];
  for(int i=0;i<n;++i){
    cin>>a[i];
    a[i]--;
    ia[a[i]] = i;
  }

  set<int> s;
  s.insert(-1);
  s.insert(n);
  long long ans = 0;
  for(int v=0;v<n;++v){
    auto it = s.lower_bound(ia[v]);
    int r = (*it);
    it--;
    int l = (*it);
    ans += (long long)(r-ia[v])*(ia[v]-l)*(v+1);
    s.insert(ia[v]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define ll long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const LL MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n;
LL id1,id2;
LL a[100048];
int v[100048];
int cnt[100048];

LL fac[100048],finv[100048],inv[100048];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<100010;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]* i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int x,int y)
{
	if(x<y) return 0;
	return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}

int main ()
{
	LL i;
	cin>>n;
	memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(ll i = 1; i <= n + 1; ++i){
        cin >> a[i];
        v[a[i]]++;
    }
    for(ll i = 1; i <= n + 1; ++i){
        if(v[a[i]] == 2 && !id1){
            id1 = i;
        }
        else if(v[a[i]] == 2) {
            id2 = i;
        }
    }
	LL ans;
	make();
	for (i=0;i<=n;i++)
	{
		ans=C(n+1,i+1);
		ans-=C(n-id2+id1,i);
		if (ans<0) ans+=MOD;
		printf("%d\n",ans);	
	}
	return 0;
}

Measured memory_bytes: 4736
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
import math
def resolve():
    N=pin()
    X=[x//400 for x in tupin()]
    s=set()
    free=0
    for x in X:
        if x>=8:
            free+=1
        else: s.add(x)
    t=len(s) if len(s) else 1   
    print(t,len(s)+free)
        
    
        #print("".join(X).split("0"))
#%%submit!      
resolve()


Measured memory_bytes: 64748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  cin>>n;
  if(n%2==0)cout<<n<<endl;
  else cout<<n*2<<endl;
  return(0);
}


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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
}

Measured memory_bytes: 384
n,a,b = map(int, input().split())

#距離
d = b-a
c = 0
if d % 2 == 0:
    c = d // 2
else:
    # 端っこに近い方に行く
    c = min(n-b, a-1)
    # 一試合距離を縮める
    c += 1
    d -= 1
    # お互い近づく
    c += (d // 2)

print(c)

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

#define pb   push_back
#define endl "\n"
#define ll   long long

#define W(t)            while(t--)
#define clr(a)          memset(a,0,sizeof(a))
#define rep(i,a,b)      for(i = a; i < b; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
	IOS
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int i, len1, len2, j;
	string s, t;

	cin >> s >> t;
	len1 = s.size();
	len2 = t.size();

	int ans = len2;
	rep(i, 0, len1 - len2+1)
	{
		int dif = 0;
		rep(j, 0, len2)
		{
			if (s[i + j] != t[j])
				dif++;

		}
		ans = min(dif, ans);
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll k, x;
    cin >> k >> x;
    ll sum = k * 500;
    string ans;

    ans = x > sum ? "No" : "Yes";

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long p[] = new long[num];
		for(int i = 0; i < num; i ++) {
			p[i] = sc.nextLong();
		}
		int count = 0;
		for(int i = 1; i < num - 1; i ++) {
			if(p[i] > p[i - 1] && p[i] < p[i + 1]) { count ++; }
			if(p[i] < p[i - 1] && p[i] > p[i + 1]) { count ++; }
		}
		System.out.println(count);
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n+1);
    vector<int> B(n);
    rep(i,n+1) cin >> A[i];
    rep(i,n) cin >> B[i];
    ll ans = 0;
    rep(i,n) {
        if (A[i] > B[i]) {
            ans += B[i];
        }else{
            ans += A[i];
            ans += min(B[i] - A[i], A[i+1]);
            A[i+1] = max(A[i+1]-(B[i] - A[i]), 0);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std ;
const int N=1e6+5 ;
int n ,  x  , t[N],freq[26];


int main()
{

    int n ;
    cin>>n ;
    int s=0 ;
    for (int i=1;i<=n;i++){
        if (int(log10(i)+1)%2==1)
            s++ ;
    }
    cout<<s;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1e9;

main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  for(int ii=0;ii<N;ii++){
    cin >> h[ii];
  }
  sort(h,h+N);
  //  reverse(h.begin(),h.end());
  int ans=INF;
  /*  for(int ii=0;ii<N;ii++){
    cout << h[ii] << endl;
    }*/
  for(int ii=0;ii<N-K+1;ii++){
    ans=min(ans,h[ii+K-1]-h[ii]);
    //    cout << h[ii] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n, mn = 1e9;

int main(){
    scanf("%d", &n);
    int an = 0;
    for(int i = 0; i<n; ++i){
       int x; 
       scanf("%d", &x);
       if(mn >= x)++an;
       mn = min(mn, x);
    }
    printf("%d\n", an);
} 

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int h;
    scanf("%d",&h);
    int i,n,a,s=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a);
        s+=a;
    }
      if(s>=h){
        printf("Yes\n");
      }
      else{
        printf("No\n");
      }

    return 0;
}


Measured memory_bytes: 1628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] count = new int[m];
        int k;
        int A;
        for(int i=0;i<n;i++){
            k = Integer.parseInt(sc.next());
            for(int j=0;j<k;j++){
                A = Integer.parseInt(sc.next())-1;
                count[A]++;
            }
        }
        int res = 0;
        for(int i=0;i<m;i++){
            if(count[i]==n)res++;
        }
        System.out.println(res);
        sc.close();
    }
    
}

Measured memory_bytes: 21712
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=100+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,cnt;int a[N];
int main(){
	n=read();m=read();rep(i,1,m)a[i]=read(),cnt+=a[i]&1;
	if(cnt>2)return puts("Impossible"),0;
	rep(i,2,m-1){
		if(!(a[i]&1))continue;
		if(a[1]&1){swap(a[i],a[m]);break;}
		else swap(a[i],a[1]);
	}
	rep(i,1,m)printf("%d ",a[i]);puts("");
	a[1]+=1;a[m]-=1;if(m==1)a[1]=1,a[m=2]=n-1;if(!a[m])m-=1;
	printf("%d\n",m);rep(i,1,m)printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 256
def isPrime(n):
    if n < 2:
    # 2未満は素数でない
        return False
    if n == 2:
    # 2は素数
        return True
    for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
    # nまでの数で割り切れなかったら素数
    return True

if __name__ == "__main__":
    n = int(input())
    while True:
        if isPrime(n):
            print(n)
            break
        else:
            n += 1

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		ll d=in(),w=in(),h=in();
		if(!d && !w && !h) break;
		ll minA=min({d*d+w*w,w*w+h*h,h*h+d*d});
		int N=in();
		LOOP(N){
			int R=in();
			if(4*R*R>minA) out("OK");
			else out("NA");
		}
	}
	return 0;
}



Measured memory_bytes: 3024
#include <stdio.h>

int main(void){
  int list[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d", &k);
  printf("%d\n", list[k-1]);
  return 0;
}


Measured memory_bytes: 128
(defun knapsack-p-map-rec-f (things w func)
  (if things
      (let* ((thing (car things))
             (dp-arr (knapsack-p-map-rec-f (cdr things) w func)))
        (if (>= w (car thing))
            (concatenate 'vector (subseq dp-arr 0 (car thing))
                         (map 'vector (lambda (in not-in)
                                        (funcall func not-in (+ in (cdr thing))))
                              dp-arr (subseq dp-arr (car thing))))
            dp-arr))
      (make-array w :initial-element 0)))

(defun knapsack-problem (n w things)
  (let* ((arr (knapsack-p-map-rec-f things (1+ w) #'max)))
    (aref arr (1- (length arr)))))

(let* ((n (read))
       (w (read))
       (things (loop :repeat n :collect (cons (read) (read)))))
  (princ (knapsack-problem n w things)))


Measured memory_bytes: 100836
#include <iostream>
#include <set>

using namespace std;

int main(){
 	int n;
  	int tmp;
  	set<int> nums;
  
  	cin >> n;
  	for(int i=0; i<n; i++){
      	cin >> tmp;
      	nums.insert(tmp);
    }
  
  	cout << nums.size();
  	
  	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline


n = int(input())
a = [int(item) for item in input().split()]
prev = a[0]
a_uniq = [a[0]]
for item in a:
    if item == prev:
        continue
    a_uniq.append(item)
    prev = item

if len(a_uniq) == 1:
    print(1000)
    exit()

increasing = None
if a_uniq[0] < a_uniq[1]:
    increasing = True
else:
    increasing = False

money = 1000
kabu = 0
if increasing:
    p = money // a[0]
    money -= p * a[0]
    kabu = p

prev = a_uniq[0]
ans = 1000
for item in a_uniq[1:]:
    if item < prev and increasing:
        money += kabu * prev
        kabu = 0
        increasing = False
        ans = max(ans, money)
    if item > prev and not increasing:
        p = money // prev
        money -= p * prev
        kabu = p
        increasing = True
    prev = item
if kabu:
    money += a_uniq[-1] * kabu
    ans = max(ans, money)
print(ans)

Measured memory_bytes: 61944
#include <bitset>
#include <cmath>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
	int n, q;
	cin >> n;
	vector<int> A(n);
	for (int& i : A) cin >> i;
	cin >> q;
	vector<int> m(q);
	for (int& i : m) cin >> i;
	unordered_set<int> a;
	for (int i = 0; i < pow(2.0, n); ++i) {
		bitset<20> b = i;
		int c = 0;
		for (int j = 0; j < n; ++j) {
			if (b[j]) c += A[j];
		}
		a.insert(c);
	}
	for (int& i : m) {
		if (a.count(i)) cout << "yes";
		else cout << "no";
		cout << endl;
	}
}


Measured memory_bytes: 3304
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int a[3];
  for(int i = 0; i<3;i++) cin>>a[i];
  sort(a,a+3);
  cout<<a[2]*10+a[0]+a[1]<<endl;
  return 0;
}


Measured memory_bytes: 256
fn main(){
    let mut v: Vec<i32> = read_vec();
    println!("{} {}", v[0] * v[1], (v[0] + v[1]) * 2)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5032
#include <stdio.h>

int main() {
	int n1, n2;
	scanf("%d %d", &n1, &n2);
	
	if(n2 % n1 == 0) {
		printf("%d", n1 + n2);
	} else {
		printf("%d", n2 - n1);
	}
	
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main()
{
    int i,n;
    cin>>n;
    i=n%10;
    if(i==2 ||i==4||i==5||i==7||i==9)
    {
        cout<<"hon";
    }
    if(i==0 || i==1||i==6||i==8)
    {
        cout<<"pon";
    }
    if(i==3)
    {
        cout<<"bon";
    }
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
A_list = list(map(int, input().split()))
MOD = 10**9 + 7

zeros = [0] * 61
ones = [0] * 61

for a in A_list:
    for i, b in enumerate([1 if (a >> j & 1) else 0 for j in range(61)]):
        if b == 1:
            ones[i] += 1
        else:
            zeros[i] += 1

res = 0
for a in A_list:
    twice = 1
    for i, b in enumerate([1 if (a >> j & 1) else 0 for j in range(61)]):
        if b == 1:
            cnt = zeros[i]
            ones[i] -= 1
        else:
            cnt = ones[i]
            zeros[i] -= 1
        res += twice * cnt
        twice *= 2
    res %= MOD
print(res)

Measured memory_bytes: 124932
h,w,k = (int(i) for i in input().split())
mod = 10**9+7
if w==1: print(1)
elif w==2: print((2**(h-1))%mod)
else:
	dp = [[0]*w for i in range(h+1)]
	dp[0][0],z = 1,[1,2,3,5,8,13,21]
	def f(x,a):
		if a==0:
			if x==0 or x==w-1: return z[w-2]
			else: return z[x-1]*z[w-x-2]
		elif a==1:
			if x==0: return 0
			elif x==w-1 or x==1: return z[w-3]
			else: return z[x-2]*z[w-x-2]
		else:
			if x==w-1: return 0
			elif x==0 or x==w-2: return z[w-3]
			else: return z[x-1]*z[max(0,w-x-3)]
	for i in range(h):
		for j in range(w):
			if j!=0 and j!=w-1: dp[i+1][j] = (dp[i][j]*f(j,0)+dp[i][j-1]*f(j,1)+dp[i][j+1]*f(j,2))%mod
			elif j==0: dp[i+1][j] = (dp[i][j]*f(j,0)+dp[i][j+1]*f(j,2))%mod
			else: dp[i+1][j] = (dp[i][j]*f(j,0)+dp[i][j-1]*f(j,1))%mod
	print(dp[-1][k-1])

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

using namespace std;

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

    if(s=="Sunny") cout << "Cloudy" ;
    else if(s=="Cloudy") cout << "Rainy" ;
    else if(s=="Rainy") cout << "Sunny" ;
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	if (N == 3) {
		puts("2 5 63");
	} else if (N%3 != 0) {
		int cnt = 0, sum = 0;
		for (int i = 1; i <= N-2 && i <= 15000; i++) {
			cout << i*2 << " ";
			sum += i*2;
			cnt++;
			if (i == 14999 && (N-cnt)%2 == 0)
				break;
		}
		assert(sum%3 == 0);
		assert((N-cnt)%2 == 0);
		for (int i = 1; i <= N-cnt; i++)
			cout << 3*(2*i-1) << " ";
		cout << endl;
	} else {
		int cnt = 0, sum = 0;
		for (int i = 1; i <= N-4 && i <= 15000; i++) {
			cout << i*2 << " ";
			sum += i*2;
			cnt++;
			if (i == 14999 && (N-cnt)%2 == 0)
				break;
		}
		assert(sum%3 == 0);
		assert((N-cnt)%2 == 0);
		for (int i = 1; i <= N-cnt; i++)
			cout << 3*(2*i-1) << " ";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
def main():    
    n,k = map(int,input().split())
    s = input()
    x = []
    tmp = 0
    for i in range(n-1):
        if s[i] == s[i+1]:
            tmp+= 1
        else:
            x.append(tmp)
            tmp = 0
    x.append(tmp)
    t = len(x)-2
    ans = sum(x)
    if s[0] == s[-1]:
        t = (len(x)-1)//2
        ans += 2*min(t,k)
    else:
        t = len(x)//2-1
        ans += 2*min(t,k)
        if k-t > 0:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,k,A[200001];
    cin>>n>>k;
    rep(i,n) cin>>A[i];
    int B[60]={0},C[60]={0};
    int K;
    ll p=k;
    for(K=0;p>0;K++) C[K]=p%2,p=p/2;
    rep(i,n){
        ll p=A[i];
        rep(j,K) B[j]+=(p+1)%2,p=p/2;
    }
    rep(i,K){
        if(B[i]>n/2) B[i]=1;
        else B[i]=0;
    }
    int x=1;
    reverse(B,B+K);
    reverse(C,C+K);
    rep(i,K){
        if(x==1){
            if(C[i]==1&&B[i]==0) x=0;
            if(C[i]==0&&B[i]==1) B[i]=0;
        }
    }
    ll X=0,ans=0;
    reverse(B,B+K);
    rep(i,K) X+=ll(pow(2,i))*B[i];
    rep(i,n) ans+=X^A[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

	double ans = 0;
	for (int i = 0; i < N; i++){
		string x, u;
		cin >> x >> u;

		if (u == "JPY"){
			ans += atoi(x.c_str());
		} else {
			ans += atof(x.c_str()) * 380000.f;
		}
	}

	cout << fixed << setprecision(5) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;
int x[1001];
void primefactor(int n){

  bool flag=true;
  for( int i=2LL ;i*i<=n;i++){
    while(n%i==0){
      x[i]++;
      n/=i;
      flag=false;
    }
  }
  if(n!=1)x[n]++;
}


int main(){
  string s;
  cin>>s;
  int res=0;
  for(int i=0;i<s.size()-1;i++){
  if(s[i]!=s[i+1])res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm> 
using namespace std;
long long a[2010],n,ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-2;i++)
		for(int o=i+1;o<n-1;o++)
			for(int j=o+1;j<n;j++)
				if(a[i]+a[o]>a[j] && a[o]-a[i]<a[j])
					ans++;	
	cout<<ans<<endl;				
} 

Measured memory_bytes: 256