akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector <int> dx = {1, -1, 0, 0};
vector <int> dy = {0, 0, 1, -1};

typedef pair <int, int> P;

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

    int h, w;
    cin >> h >> w;

    char s[h][w];
    for (int i = 0; i < h; i++) cin >> s[i];

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            // start = (i, j)
            if (s[i][j] == '#') continue;

            vector < vector <int> > d(h, vector<int>(w, 100005));
            int start = i * w + j;
            priority_queue <P, vector<P>, greater<P>> q;
            q.push(P(0, start));

            while (q.size()) {
                P p = q.top();
                q.pop();

                if (d[p.second / w][p.second % w] <= p.first) continue;
                d[p.second / w][p.second % w] = p.first;

                for (int l = 0; l < 4; l++) {
                    int x = p.second / w + dx[l];
                    int y = p.second % w + dy[l];

                    if (x < 0 || x >= h) continue;
                    if (y < 0 || y >= w) continue;
                    if (s[x][y] == '#') continue;
                    if (d[x][y] <= p.first) continue;

                    q.push(P(p.first + 1, x * w + y));
                }
            }

            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    if (d[k][l] < 100005) {
                        ans = max(ans, d[k][l]);
                    }
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=X[:]
Y=X[:]
YY=X[:]
P=[]
SC=0
N,M,L,O=0,0,0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  N,M=-1,-10**20
  L,O=N,M
  for j in range(26):
    if Y==-1:
      N,M=0,X[0]+S[i][0]
    if M<X[j]+S[i][j]:
      L,O=N,M
      N,M=j,X[j]+S[i][j]
    elif O<X[j]+S[i][j]:
      L,O=j,X[j]+S[i][j]
  XX[N]-=X[N]
  X[N]=0
  P.append([N,L])
  SC+=X[N]
SC2=0
for i in range(10**5*3):
  d,q=randrange(0,D),randrange(0,26)
  SC2=SC
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d][0]=q
    XX=YY[:]
    SC=SC2
for i in range(D):
  SC2=SC
  d,q=i,P[i][1]
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d]=P[d][::-1]
    XX=YY[:]
    SC=SC2
T=0
X=[0]*26
SC=0
for i in range(D):
  print(P[i][0]+1)

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

const int maxn = 200010;
int n, a[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    auto chk = [&](int x) {
        map<long long, long long> mp;
        for (int i = 2; i <= n; i++) if (a[i - 1] >= a[i]) {
            if (x == 1) return 0;
            while (!mp.empty()) {
                int mx = mp.rbegin()->first;
                if (mx > a[i]) mp.erase(mx);
                else break;
            }
            int j = a[i];
            while (j && mp[j] + 1 == x) mp.erase(j), j--;
            if (!j) return 0; mp[j]++;
        }
        return 1;
    };
    int l = 1, r = n, ans;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (chk(mid)) r = (ans = mid) - 1;
        else l = mid + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     sd                  " "
#define     nl                  "\n"
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IOS()               ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     siz(a)              sizeof(a)/sizeof(a[0])
#define     out(a)              for (auto i: a) cout<<i<<" "; cout<<"\n"
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed;cout<<setprecision(n)<<val<<"\n"

ll mod(ll a){return ((a%MOD)+MOD)%MOD;}

ll fpow(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%MOD;
        base=(base*base)%MOD;
        expo>>=1;}
    return res;}

ll modinv(ll a){return mod(fpow(mod(a), MOD-2));}

void solve(){
    int n;cin>>n;
    int a[n],b[n],c[n];
    for(int i = 0 ;i < n; ++i) cin >> a[i];
    for(int i = 0 ;i < n; ++i) cin >> b[i];
    for(int i = 0 ;i < n-1; ++i) cin >> c[i];
    c[n-1]=0;
    int sum = 0;
    for(int i = 0; i < n ; ++i){
        sum+=b[a[i]-1]+(i>0 && a[i]==a[i-1]+1?c[a[i-1]-1]:0);
    }
    cout<< sum<<nl;
}

signed main() { 
    IOS();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
vector<string> SS;

int main()
{
	string S;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> S;
		//cout << S << endl;
		sort(S.begin(),S.end());
		//cout << S << endl;
		SS.push_back(S);
	}
	
	sort(SS.begin(),SS.end());

	/*
	for (int i = 0; i < N; ++i)
	{
		cout << SS[i] << endl;
	}
	*/

	long long ans = 0;
	long long cnt = 1;
	long long temp = 1;

	for (int i = 0; i < N-1; ++i)
	{
		if (SS[i] == SS[i+1])
		{
			cnt++;
		}
		else if(cnt > 1)
		{
			ans += (cnt * (cnt - 1)) / 2;
			cnt = 1;
		}
	}

	if(cnt > 1)
	{
		ans += (cnt * (cnt - 1)) / 2;
		cnt = 1;
	}

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

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007


ll dp[3001][3001];
ll maxValue(vector<int>&arr, int n, int i, int j, int turn){
	ll a,b;
	if(i==j){
		return arr[i];
	}
	if(dp[i][j]>-1) return dp[i][j];
	if(turn){
		a = max(arr[i] - maxValue(arr,n,i+1,j,abs(turn-1)),
			arr[j]-maxValue(arr,n,i,j-1,abs(turn-1)));
		return dp[i][j] = a;
	}
	else{
		b = max(arr[i] - maxValue(arr,n,i+1,j,abs(turn-1)),
		 arr[j] - maxValue(arr,n,i,j-1,abs(turn-1)));
		return dp[i][j] = b;
	} 
}
void solve(){
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    ll ans = maxValue(arr,n,0,n-1,1);
    t1(ans)
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 74224
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	auto n = readln.chomp;
	writefln("%s%s%s", n[0], n.length-2, n.back);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
string s;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int n = 0;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.rbegin(), b.rend());
	for(int i = 0; i < n; ++i){
		if(a[i] == b[0]){
			cout << b[1] << endl;
		}
		else{
			cout << b[0] << endl;
		}
	}





    return 0;
}

Measured memory_bytes: 3200
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long H, long W, long[][] A, long[][] B) {
    const L = (H + W) * 80;
    auto dp = new long[][][](H + 1, W + 1, L);
    auto diff0 = abs(A[0][0] - B[0][0]);
    dp[1][1][diff0 + (L / 2)] = true;
    dp[1][1][-diff0 + (L / 2)] = true;

    foreach (h; 1 .. H + 1) {
        foreach (w; 1 .. W + 1) {
            if (h == 1 && w == 1)
                continue;

            auto diff = abs(A[h - 1][w - 1] - B[h - 1][w - 1]);
            foreach (i; 0 .. L) {
                dp[h][w][i] =
                    (0 <= i - diff && dp[h - 1][w][i - diff])
                    || (i + diff < L && dp[h - 1][w][i + diff])
                    || (0 <= i - diff && dp[h][w - 1][i - diff])
                    || (i + diff < L && dp[h][w - 1][i + diff]);
            }
        }
    }

    return iota(L).filter!(i => dp[H][W][i])
        .map!(i => abs(i - (L / 2)))
        .reduce!min;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long H;
    H = input.front.to!long;
    input.popFront;

    long W;
    W = input.front.to!long;
    input.popFront;

    long[][] A = new long[][](cast(size_t) (H), cast(size_t) (W));
    foreach (i; 0 .. cast(size_t) (H)) {
        foreach (j; 0 .. cast(size_t) (W)) {
            A[i][j] = input.front.to!long;
            input.popFront;
        }
    }

    long[][] B = new long[][](cast(size_t) (H), cast(size_t) (W));
    foreach (i; 0 .. cast(size_t) (H)) {
        foreach (j; 0 .. cast(size_t) (W)) {
            B[i][j] = input.front.to!long;
            input.popFront;
        }
    }

    static if (is(ReturnType!solve == void))
        solve(H, W, A, B);
    else {
        auto ans = solve(H, W, A, B);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 686716
#include <bits/stdc++.h>
const int maxn = 3;
using namespace std;
char s[maxn];
int main()
{
    int t;
    cin >> t;
    int sum = 0;
    while (t--) {
        int a, b;
        cin >> a >> b;
        sum += (b - a + 1);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
bool check(int n,int d[10]){
    while(1){
        if(n<=0)break;
        if(d[n%10]==1)return false;
        n/=10;
    }
    return true;
}
 
int main(){
    
    int n,k,in,d[10]={};
    
    cin>>n>>k;
    rep(i,0,k){
        cin>>in;
        d[in]=1;
    }
    while(1){
        if(check(n,d))break;
        n++;
    }
    cout<<n<<endl;
    
    return 0;
}

Measured memory_bytes: 256
while n = gets.to_i
  break if n.zero?
  output = Array.new(7,0)
  n.times do
    age = gets.to_i
    temp = (age - (age%10))/10
    index = (6 < temp ? 6 : temp)
    output[index] += 1
  end
  puts output
end

Measured memory_bytes: 6100
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main(){
    init();
	string s;cin>>s;
	if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3])cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
}

Measured memory_bytes: 256
L, R = map(int,input().split())

MOD = 2019

l = L%MOD

if R-L+1 >= 2019:
    print(0)
else:
    ans = 10**10
    for i in range(R-L+1):
        for j in range(i+1,R-L+1):
            s1 = l + i
            s2 = l + j
            ans = min(ans, s1*s2%MOD)
            #print(s1,s2,ans)
    print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	
	public void buildMaxHeap(int[] nums) {
		int[] heap = new int[nums.length + 1];
		heap[0] = -1;
		for(int i = 0; i < nums.length; i++)
			heap[i + 1] = nums[i];
		
		for(int i = nums.length/2; i > 0; i--)
			maxHeapify(heap, i);
		
		for(int i = 0; i < nums.length; i++)
			nums[i] = heap[i + 1];
	}
	
	public void maxHeapify(int[] nums, int index) {
		int left = getLeftIndex(index);
		int right = getRightIndex(index);
		
		int largest = index;
		if(left < nums.length && nums[left] > nums[largest])
			largest = left;
		
		if(right < nums.length && nums[right] > nums[largest])
			largest = right;
		
		if(largest != index) {
			swap(nums, index, largest);
			maxHeapify(nums, largest);
		}
	}
	
	public void swap(int[] nums, int first, int second) {
		int temp = nums[first];
		nums[first] = nums[second];
		nums[second] = temp;
	}
	
	public int getLeftIndex(int index) {
		return index * 2;
	}
	public int getRightIndex(int index) {
		return index * 2 + 1;
	}
	public int[] trim(int [] nums) {
		int[] arr = new int[nums.length - 1];
		for(int i = 0; i < arr.length; i++)
			arr[i] = nums[i + 1];
		
		return arr;
	}
	
	
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int length = scan.nextInt();
		int[] nums = new int[length];
		
		for(int i = 0; i < length; i++)
			nums[i] = scan.nextInt();
		
		Main heap = new Main();
		heap.buildMaxHeap(nums);
		for(int i = 0; i < length; i++)
			System.out.print(" " + nums[i]);
System.out.println();
	}
}



Measured memory_bytes: 167944
import java.io.IOException;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int MAX = 10000000;
		boolean[] prim = new boolean[MAX + 1];
		for (int i = 2; i <= Math.sqrt(MAX); i++) {
			if (!prim[i]) {
				for (int j = i * 2; j <= MAX; j += i) {
					prim[j] = true;
				}
			}
		}
		NavigableSet<Integer> set = new TreeSet<Integer>();
		for (int i = 13; i <= MAX; i += 2) {
			if (!prim[i] && !prim[i - 2] && !prim[i - 6] && !prim[i - 8])
				set.add(i);
		}
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int ans = set.floor(n);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 35028
import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int steps=sc.nextInt();
	    int price[]=new int[n];
	    int sum=0;
	    for(int i=0;i<n;i++){
	      price[i]=sc.nextInt();    
	    }
	    for (int i = 0; i < n-1; i++) 
            for (int j = 0; j < n-i-1; j++) 
                if (price[j] > price[j+1]) 
                { 
                    int temp = price[j]; 
                    price[j] = price[j+1]; 
                    price[j+1] = temp; 
                }
        for(int i = 0; i < steps; i++){
            sum=sum+price[i];
        }        
	    System.out.println(sum); 
    }
}

Measured memory_bytes: 38792
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m;
	double sum = 0;

	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		//cout << a[i] << endl;
	}
	if (a[m - 1] < sum / 4 / m) cout << "No" << endl;
	else cout << "Yes" << endl;

}

Measured memory_bytes: 888
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new ARC103_C().doIt();
	}
	class ARC103_C{
		void doIt() {
			int n = sc.nextInt();
			int va[] = new int[100001];
			int vb[] = new int[100001];
			for(int i = 0;i < n;i++) {
				int v = sc.nextInt();
				if(i % 2 == 0)va[v]++;
				else vb[v]++;
			}
			int maxa = 0;
			int numa = 0;
			int maxb = 0;
			int numb = 0;
			for(int i = 0;i < 100001;i++) {
				if(va[i] > maxa) {
					maxa = va[i];
					numa = i;
				}
				if(vb[i] > maxb) {
					maxb = vb[i];
					numb = i;
				}
			}
			int ans = n - maxa - maxb;
			if(numa == numb) {
				Arrays.sort(va);
				Arrays.sort(vb);
				ans = Math.min(n-maxa-vb[99999],n-maxb-va[99999]);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 60500
/*
[abc128] E - Roadwork
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;
const int MAX_Q = 2e5;

enum EV {
    EV_T = 0,
    EV_S = 1,
    EV_D = 2,
};

int N, Q;
int S[MAX_N], T[MAX_N], X[MAX_N];
int D[MAX_Q];

void solve() {
    vector<pair<int, pair<EV, int>>> es;
    for (int i = 0; i < N; i++) {
        es.push_back({S[i] - X[i], {EV_S, X[i]}});
        es.push_back({T[i] - X[i], {EV_T, X[i]}});
    }
    for (int i = 0; i < Q; i++) {
        es.push_back({D[i], {EV_D, i}});
    }
    sort(es.begin(), es.end());

    vector<int> ans(Q);
    set<int> cur;
    for (auto& e : es) {
        switch (e.second.first) {
            case EV_T:
                cur.erase(e.second.second);
                break;
            case EV_S:
                cur.insert(e.second.second);
                break;
            default:
                ans[e.second.second] = cur.empty() ? -1 : *cur.begin();
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        cin >> S[i] >> T[i] >> X[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    solve();

    return 0;
}


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

int main() {
  int A, B,C,K;
  cin >> A>>B>>C>>K;
  
  int ans=0;
  if(K<=A){
    ans=K;
  }else if(K>A && K<=(A+B)){
    ans=A;
  }else{
    ans=A-(K-A-B);
  }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std; 
void solve()
{
	string s,ss;cin>>s>>ss;
	ll c=0;
	for(ll i=0;i<ll(s.size());++i)
		if(s[i]!=ss[i])
			c++;
		cout<<c;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        solve();
    return 0;
}

Measured memory_bytes: 3864
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,S = map(int,input().split())
    a = list(map(int,input().split()))
    MOD = 998244353
    
    dp = np.zeros(3000+10,dtype=int)
    ans = 0
    
    for num in a:
        dp[0] += 1
        dp[num:] += dp[:-num].copy()
        dp %= MOD
        ans += dp[S]
        
    print(ans%MOD)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 15264
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), M = Reader.Int();
        var E = EdgeRead(N, M);
        var seen = new bool[N];

        Func<int, List<int>> Gen = (start) =>
        {
            var res = new List<int>();
            for (int a = start; a != -1 && !seen[a]; )
            {
                seen[a] = true;
                res.Add(a + 1);
                a = Array.Find(E[a], i => !seen[i]);
            }
            return res;
        };
        seen[0] = true;
        var R = Gen(E[0][0]);
        seen[0] = false;
        var L = Gen(0);
        var ans = L.Reverse<int>().Concat(R);

        Console.WriteLine(ans.Count() + "\n" + string.Join(" ", ans));
    }


    int[][] EdgeRead(int V, int E = -1, int origin = 1)
    {
        if (E == -1) E = V - 1;
        var es = new List<int>[V];
        for (int i = 0; i < V; i++) es[i] = new List<int>();
        for (int i = 0; i < E; i++)
        {
            int a = Reader.Int() - origin, b = Reader.Int() - origin;
            es[a].Add(b);
            es[b].Add(a);
        }
        return es.Select(a => a.ToArray()).ToArray();
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 37600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;
int main(){
    int K; cin>>K;
    int A,B; cin>>A>>B;
    bool can=false;
    for(int i=A;i<=B;i++){
        if(i%K==0)can=true;
    }
    if(can){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    };
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

struct shop {
    ll a, b;
};

bool operator<(shop a, shop b) {
    if(a.a == 0 and b.a == 0) {
        return a.b < b.b;
    }
    return a.a * (b.b + 1) > b.a * (a.b + 1);
}

//const ll mod = 1000000007;
ll N, T;
ll dp[201000][50];
vector<shop> shops[2];
ll ans = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> T;
    for(int i = 0; i < N; i++) {
        shop now;
        cin >> now.a >> now.b;
        if(now.a == 0) {
            shops[1].push_back(now);
        } else {
            shops[0].push_back(now);
        }
    }
    for(int i = 0; i <= 1; i++) {
        sort(shops[i].begin(), shops[i].end());
    }
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j < 50; j++) {
            dp[i][j] = 2e9;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < shops[0].size(); i++) {
        for(int j = 0; j < 49; j++) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j+1], dp[i][j] + 1 + shops[0][i].a * (dp[i][j] + 1) + shops[0][i].b);
        }
    }
    vector<ll> Sum(shops[1].size() + 1);
    for(int i = 0; i < shops[1].size(); i++) {
        Sum[i+1] = Sum[i] + shops[1][i].b + 1;
    }
    for(ll i = 0; i < 50; i++) {
        for(ll j = 0; j < Sum.size(); j++) {
            if(T >= dp[shops[0].size()][i] + Sum[j]) {
                chmax(ans, i + j);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	long long h, w; cin >> h >> w;
	if (h == 1 || w == 1) cout << 1 << endl;
	else cout << (h * w) / 2 + (h * w) % 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int ab_count = 0;
		int head_b = 0;
		int tail_a = 0;
		int contain_ba = 0;
		// 整数の入力
		int n= sc.nextInt();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			boolean aflag = false;
			for(char c: s.toCharArray()) {
				if (aflag && c == 'B') {
					ab_count++;
				}
				
				if (c == 'A') {
					aflag = true;
				} else {
					aflag = false;
				}
			}
			if(s.toCharArray()[0] == 'B') {
				head_b++;
			}
			
			if(s.toCharArray()[s.length()-1] == 'A') {
				tail_a++;
				if(s.toCharArray()[0] == 'B') {
					
					contain_ba++;
				}
			}
			

		}
		
		int ab = Math.min(tail_a, head_b);
		if (tail_a == contain_ba && head_b == contain_ba) {
			ab--;
		}
		if (ab >= 0) {
		System.out.println(ab+ab_count);
		} else {
			System.out.println(ab_count);
		}
		
//		System.out.println(ab_count);
//		System.out.println(head_b);
//		System.out.println(tail_a);
//		System.out.println(contain_ba);


	}
}

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

int main() {
  vector<vector<int>> a(12,vector<int>(12));
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) ans = min(ans,cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

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

void trace(int A[], int N){
    int i;
    for(i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << "\n";
}

void insertionSort(int A[], int N){
    int i, j, v;
    for(i=1; i<N; i++){
        v = A[i];
        j = i - 1;
        while (j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(void){
    int N, i, j;
    int A[100];
    
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    
    trace(A, N);
    insertionSort(A,N);

    return 0;
}


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

# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
d = []
A = []
count = []

for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

for i in range(K):
    for j in range(d[i]):
        count.append(A[i][j])

answer = list(set(count))

print(N - len(answer))


Measured memory_bytes: 9132
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int ans = x + n;
        for (int i = 0; i < a.length; i++) {
            for (int j = 1; j <= d; j++) {
                int tmp = j * a[i] + 1;
                if(tmp <= d) {
                    ans++;
                } else {
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
	// your code goes here
	int n,H,W;
	
	
	while(1){
		cin>>H>>W;
		if(H==0 && W==0){break;}
		for( int i=1 ; i<=H ; i++){
			for( int j=1 ; j<=W ; j++){
				if( (i+j)%2 == 0){
					cout<<"#";
				}else{
					cout<<".";
				}
			}
				cout<<endl;
			
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char c = s[0];
    for (int i = 1; i < n; i++){
        if (s[i] != c){
            ans++;
            c = s[i];
        }
    }
    cout << ans+1 << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3780
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_098_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(3).
    01 S      PIC X(101).

    01 chr    PIC X(1)   VALUE SPACE.
    01 str    PIC X(101) VALUE SPACE.

    01 i      PIC 9(3).
    01 j      PIC 9(3).
    01 k      PIC 9(3).

    01 flg    PIC 9(1)   VALUE 0.
    01 cur    PIC 9(3).

    01 len    PIC 9(1)   VALUE 1.
    01 cnt    PIC 9(2)   VALUE 0.
    01 cntmax PIC 9(2)   VALUE 0.

    01 ans    PIC Z9.

    01 X1.
        03 XNUM PIC 9(2) VALUE 0.
        03 X11 OCCURS 26.
            05 X PIC X(1).

    01 Y1.
        03 YNUM PIC 9(2) VALUE 0.
        03 Y11 OCCURS 26.
            05 Y PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT S.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        MOVE S(i : len) TO chr;

        MOVE 0 TO flg;

        PERFORM VARYING j FROM 1 BY 1 UNTIL XNUM < j
            IF X(j) = chr THEN
                MOVE 1 TO flg
            END-IF;
        END-PERFORM;

        IF flg = 0 THEN
           ADD 1 TO XNUM;
           MOVE chr TO X(XNUM);
        END-IF;

        INITIALIZE Y1;

        COMPUTE cur = i + 1;

        MOVE S(cur : N - i) TO str;

        PERFORM VARYING j FROM 1 BY 1 UNTIL N - i < j
            MOVE str(j : len) TO chr;

            MOVE 0 TO flg;

            PERFORM VARYING k FROM 1 BY 1 UNTIL YNUM < k
                IF Y(k) = chr THEN
                    MOVE 1 TO flg
                END-IF;
            END-PERFORM;

            IF flg = 0 THEN
                ADD 1 TO YNUM;
                MOVE chr TO Y(YNUM);
            END-IF;
        END-PERFORM;

        MOVE 0 TO cnt;
        PERFORM VARYING j FROM 1 BY 1 UNTIL XNUM < j

            PERFORM VARYING k FROM 1 BY 1 UNTIL YNUM < k
                IF X(j) = Y(k) THEN
                    ADD 1 TO cnt;
                END-IF;
            END-PERFORM;

        END-PERFORM;

        COMPUTE cntmax = FUNCTION MAX(cntmax, cnt);

    END-PERFORM.

    MOVE cntmax TO ans.
    DISPLAY ans.

    STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n, m;
  cin >> n >> m;
  int v[n][n] = {};
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v[a - 1][b - 1]++;
    v[b - 1][a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      ans += v[i][j];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
function Main(input){
  input = input.trim().split('\n');
  var ans = '';
  if (input[0] === input[1].slice(0,-1)){
    ans = 'Yes'
  }else{
    ans = 'No';
  }
  console.log(ans);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29500
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N, K; cin >> N >> K; 
	pair<long long int, int> A[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i].second >> A[i].first; 
	}
	sort(A, A + N, greater<pair<long long int, int>>()); 
	long long int sum = 0; 
	int type = 0; 
	int kosuu[100010] = {};
	for(int i = 0; i < K; i++){
		if(!kosuu[A[i].second]) type ++; 
		kosuu[A[i].second] ++; 
		sum += A[i].first; 
	}
	long long int B[100010] = {}; 
	for(int i = 1; i <= N; i++){
		B[i] = -1e18; 
	}
	B[type] = sum; int index = K - 1; 
	for(int i = K; i < N; i++){
		if(kosuu[A[i].second]) continue; 
		while(kosuu[A[index].second] == 1 && index >= 0){
			index --; 
		}
		if(index == -1) break; 
		type ++; kosuu[A[index].second] --; kosuu[A[i].second] ++; 
		B[type] = B[type-1] - A[index].first + A[i].first; index --;
	}
	long long int ans = 0; 
	for(int i = 1; i <= N; i++){
		ans = max(ans, B[i] + (long long) i * i); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-


def main():
    from itertools import product
    import sys
    input = sys.stdin.readline

    n, m, x = map(int, input().split())
    c = list()
    a = list()

    for i in range(n):
        bi = list(map(int, input().split()))

        ci = bi[0]
        c.append(ci)

        ai = bi[1:]
        a.append(ai)

    ans = float('inf')

    for p in list(product(range(2), repeat=n)):
        tmp = [0 for _ in range(m)]
        cost = 0

        for index, pi in enumerate(p):
            if pi == 1:
                for idx, aii in enumerate(a[index]):
                    tmp[idx] += aii

                cost += c[index]

        is_ok = True

        for t in tmp:
            if t < x:
                is_ok = False
                break

        if is_ok:
            ans = min(ans, cost)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    } else {
    	return a.first < b.first;
    }
}

int main() {
	int		a,b,c,i,j,k,n,m,x,l,y,ans = 0;
	
	cin >> n;	
	
	vector<pair<int , int>> p(n);
	vector<int> q(n);

	for(i=0; i<n; i++) {
		cin >> x >> l;
		p[i] = make_pair(x-l, x+l);
		q[i] = 1;
	}
	
	sort(p.begin(), p.end(), compare_by_b);
	
	//for(i=0;i<n;i++) {
	//	printf("%d %d\n",p[i].first, p[i].second);
	//}
	j = p[0].second;
	for(i=1;i<n;i++) {
		//printf("%d\n",p[i].first);
		if (q[i]==1) {
			if (j > p[i].first) {
				q[i] = 0;
			} else {
				j = p[i].second;
			}
		}
	}
	
	
	ans = 0;
	for(i=0;i<n;i++) if (q[i] == 1) ans++;
	cout << ans << endl;


}


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

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int n = Integer.parseInt(br.readLine().trim());
        int [] intarray = inputval();
        int t = intarray[0];
        int a = intarray[1];
        int [] hArray = inputval();
        double min = Integer.MAX_VALUE;
        int index = 0;
        for (int i=0; i<hArray.length; i++){
            if (Math.abs(a-(t-hArray[i]*0.006)) < min){
                min = Math.abs(a-(t-hArray[i]*0.006));
                index = i;
            }
        }
        System.out.println(index+1);

    }

}



Measured memory_bytes: 32744
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	min := math.MaxInt64
	profit := math.MinInt64

	var val int
	fmt.Scan(&val)
	min = val

	scanner := bufio.NewScanner(os.Stdin)

	for i := 1; i < n; i++ {
		scanner.Scan()
		val, _ = strconv.Atoi(scanner.Text())

		if profit < val-min {
			profit = val - min
		}

		if val < min {
			min = val
		}
	}

	fmt.Println(profit)
}



Measured memory_bytes: 4172
#include <stdio.h>

int main(int argc, char** argv)
{
	char str[1200];
	int i, cnt[26];

	memset(cnt, 0, sizeof(cnt));
	while (scanf("%s", str) != EOF) {

		for (i = 0; str[i] != '\0'; i++) {
			if (str[i] >= 'A' && str[i] <= 'Z') {
				cnt[str[i] - 0x41]++;
			}

			if (str[i] >= 'a' && str[i] <= 'z') {
				cnt[str[i] - 0x61]++;
			}
		}
	}

	int max = sizeof(cnt) / sizeof(int);
	for (i = 0; i < max; i++) {
		printf("%c : %d\n", i + 0x61, cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 544
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

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

}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
private static Scanner s;
static int blen = 0;
static int[] b = new int[20];

public static void main(String[] args) {
	s = new Scanner(System.in);
	int a = s.nextInt(),c;

	for(int i = 0;i < a;i++) {
		b[i] = s.nextInt();
		blen++;
	}

	c = s.nextInt();
	int[] d = new int[200];
	for(int i = 0;i < c;i++) {
		d[i] = s.nextInt();
	}

	for(int i = 0;i < c;i++) {
		if(hantei(0,0,d[i])){
			System.out.println("yes");
		}else {
			System.out.println("no");
		}
	}
}

public static boolean hantei(int j,int t,int di) {
	if(t == di) {
		return true;
	}
	for(int i = j;i < blen; i++) {
		if(hantei(i + 1, t + b[i], di)){
			return true;
		}
	}
	return false;
	}
}


Measured memory_bytes: 26692
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
const int N = 200000;
int fac[N+1];
int inv[N+1];
ll COM(ll n,ll k){
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}

/*----------------------------------------------------------------*/
signed main(){

    int n,a,b;
    cin >> n >> a >> b;

    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }

    int ans;
    ans = (bitpow(2,n)-1+MOD)%MOD;

    debug(ans);

    ll inva = 1;
    ll invb = 1;
    for(ll x = n;x > n-a;x--)inva = (inva*x)%MOD;
    for(ll x = n;x > n-b;x--)invb = (invb*x)%MOD;

    ans = (ans+2*MOD-inva*inv[a]%MOD-invb*inv[b]%MOD)%MOD;

    cout << ans << endl;

    cerr << inva << endl;
    cerr << invb << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc156.contest.atcoder.jp/tasks/abc156_b

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin>>A>>B>>C;
    int a=0,b=0,c=0;
    char t='a';
    while(1){
        if(t=='a'){
            if(a==A.size()){
                cout<<'A';
                return 0;
            }
            t=A[a++];
        }
        else if(t=='b'){
            if(b==B.size()){
                cout<<'B';
                return 0;
            }
            t=B[b++];
        }
        else{
            if(c==C.size()){
                cout<<'C';
                return 0;
            }
            t=C[c++];
        }
    }
    return 0;
}


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

using namespace std;

bool month_checker(string str)
{
    if (str == "01" || str == "02" || str == "03" || str == "04" || str == "05" || str == "06" || str == "07" || str == "08" || str == "09" || str == "10" || str == "11" || str == "12")
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{

    string s;
    cin >> s;

    if(month_checker(s.substr(0, 2))){
        if(month_checker(s.substr(2, 2))){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(month_checker(s.substr(2, 2))){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
}

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

using namespace std;
int main() {
	int N,M;
	cin >> N>> M;
	vector<bool>B(N + 1); 
	vector<int>C(N + 1);
	int ans = 0;
	int pena = 0;

	for (int n = 0;n<M;++n) {
		int p;
		string s;
		cin >> p >> s;
		if ("AC" == s && false == B[p]) {
			ans++;
			pena+=C[p];
			B[p] = true;
		}
		else if ("WA" == s && false == B[p]) {
			C[p]++;
		}
		else if ("WA" == s && true == B[p]) {
			//
		}
		else {
		}
	}
	cout << ans  << " "<<pena<<  endl;
	return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
 
int main(void) {
  int i, j;
  for(i = 1; i < 10; ++i) {
    for(j = 1; j < 10; ++j) {
      printf("%dx%d=%d\n", i, j, i * j);
    }
  }
  return 0;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    if (s == "SSS") {
        cout << 0 << endl;
    } else if (s == "RRR") {
        cout << 3 << endl;
    } else if (s == "RRS" || s == "SRR") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3604
def main():
    S = list(input())
    for i, c in enumerate(S):
        if i % 2 == 0 and c == "L":
            print("No")
            return
        if i % 2 == 1 and c == "R":
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()
        
        



Measured memory_bytes: 2940