akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long double ll;
//typedef __int128_t lll;
using namespace std;

vvv dp = vvvl(301, 301, 301, -2);
ll n;

ll f(int a, int b, int c){
  if(a<0||b<0||c<0) return 0;
  if(dp[a][b][c]>-1) return dp[a][b][c];
  ll non_zero = a + b + c;
  ll ret = (a*f(a-1, b, c) + b*f(a+1, b-1, c) + c*f(a, b+1, c-1))/non_zero + n/non_zero;
  return dp[a][b][c] = ret;
}
int main(int argc, char const *argv[]) {
  std::cin >> n;
  std::vector<int> num(4, 0);
  re(i, n) {
    int a;std::cin >> a;
    num[a]++;
  }
  dp[0][0][0] = 0;
  std::cout << fixed << setprecision(20) << f(num[1], num[2], num[3]) << '\n';
  return 0;
}


Measured memory_bytes: 433408
N , W = map(int , input().split())
lst = [list(map(int,input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W + 1):
        if lst[i][1] <= j :
            dp[i+1][j] = max(dp[i][j], dp[i][j-lst[i][1]]+lst[i][0])
        else:
            dp[i+1][j] = dp[i][j]
#print(dp)
print(dp[N][W])


Measured memory_bytes: 25948
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	int n, p[100002] = { 0 };
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", p + i);
		p[i] = p[i] == i;
	}


	int total = 0;
	for (int i = 1; i <= n; i++) {
		if (!p[i])
			continue;
		total++;
		if (p[i + 1])
			i++;
	}

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

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int chmax(int a,int b){
    int res=a;
    if(a<b)res=b;
    return res;
}
int solve(vector<int> const& x,vector<int> const& v,int n,int c){
    int res=0;
    vector<int> max(n,0);
    int sum=v[n-1]-c+x[n-1];
    max[n-1]=chmax(0,sum);
    for(int i=n-2;i>=0;i--){
        sum+=v[i];
        sum+=c-x[i+1];
        sum-=c-x[i];
        max[i]=chmax(max[i+1],sum);
    }
    int buf=v[0]-x[0]*2+max[1];
    res=chmax(res,buf);
    rep1(i,n-2){
        buf+=v[i];
        buf+=x[i-1]*2;
        buf-=x[i]*2;
        buf+=max[i+1];
        buf-=max[i];
        res=chmax(res,buf);
    }
    res=chmax(res,max[0]);
    return res;
}
signed main(){
    int n,c;cin>>n>>c;
    vector<int> x(n);
    vector<int> v(n);
    int res=0;
    rep(i,n)cin>>x[i]>>v[i];
    if(n==1){
        res=chmax(res,v[0]-x[0]);
        res=chmax(res,v[0]+x[0]-c);
        goto FINE;
    }
    res=solve(x,v,n,c);
    reverse(x.begin(),x.end());
    rep(i,n){
        x[i]=c-x[i];
    }
    reverse(v.begin(),v.end());
    res=chmax(res,solve(x,v,n,c));
    FINE:
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int h = in.nextInt();
            int w = in.nextInt();
            out.println(H * W - (h * W + w * H - h * w));
        }

    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
//-------------------------------------------------------------
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y first
#define st string
#define ull unsigned long long
#define size(s) s.size()
//-------------------------------------------------------------
using namespace std;
//-------------------------------------------------------------
//st ans[2]={"NO","YES"};
//const int maxn=1000100;
//int abs()
//int swap()
//int sort()
//int sqrt()
//-------------------------------------------------------------
/*快排
int partition(int a[],int left,int right);
void quicksort(int a[],int left,int right){
	int q;
	if(left<=right){
		q=partition(a,left,right);
		quicksort(a,left,q-1);
		quicksort(a,q+1,right);
	}
}
int partition(int a[],int left,int right)
{
	int p=a[left];
	int i=left;
	int j=right+1;
	while(1){
		while(a[++i]<p)if(i>=right)break;
		while(a[--j]>p)if(j<=left)break;
		if(i>=j)break;
		else swap(a[i],a[j]);
	}
	if(j==left)return j;
	swap(a[left],a[j]);
	return j;
}
//-------------------------------------------------------------
二分
int binsearch(int x;int v[];int n){
	int low=0,high=n-1;
	int mid;
	while(low<=high){
		mid=(low+high)/2;
		if(x<v[mid]){
			high=mid-1;
		}
		else if(x>v[mid]){
			low=mid+1;
		}
		else return mid;
	}
	return -1;
}*/
//-------------------------------------------------------------
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)cout<<"bust\n";
	else cout<<"win\n";
	re 0;
}
//-------------------------------------------------------------


Measured memory_bytes: 256
import Control.Arrow ((&&&))
import Data.List (isPrefixOf, reverse)

isDream, isDreamer, isErase, isEraser :: String -> Bool
restOfDream, restOfDreamer, restOfErase, restOfEraser :: String -> String
[(isDream,   restOfDream),
 (isDreamer, restOfDreamer),
 (isErase,   restOfErase),
 (isEraser,  restOfEraser)] = map (isPrefixOf . reverse &&& drop . length) ["dream", "dreamer", "erase", "eraser"]


exist :: String -> Bool
exist [] = True
exist sna
  | isDream sna = exist $ restOfDream sna
  | isDreamer sna = exist $ restOfDreamer sna
  | isErase sna = exist $ restOfErase sna
  | isEraser sna = exist $ restOfEraser sna
  | otherwise = False

main :: IO ()
main = do
  ans <- getLine
  putStrLn $ if exist (reverse ans) then "YES" else "NO"


Measured memory_bytes: 7548
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    int x, y, m, n;
    cin >> m >> n >> x >> y;
    vector<int> a(m), b(n);
    for(int i = 0; i < m; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = x + 1; i <= y; i++){
        int ca = 0, z = i, cb = 0;
        for(int v: a) if(v < z) ca++;
        if(ca != a.size()) continue;
        for(int v: b) if(v >= z) cb++;
        if(cb == b.size()) return cout << "No War", 0;
    }
    cout << "War";
    return 0;
}




Measured memory_bytes: 256
num = int(input())

b1f1list = [0]*10
b1f2list = [0]*10
b1f3list = [0]*10

b2f1list = [0]*10
b2f2list = [0]*10
b2f3list = [0]*10

b3f1list = [0]*10
b3f2list = [0]*10
b3f3list = [0]*10

b4f1list = [0]*10
b4f2list = [0]*10
b4f3list = [0]*10

for i in range(num):
    b,f,r,v = (int(x) for x in input().split())

    if (b == 1):
        if (f == 1):
            b1f1list[r-1] = b1f1list[r-1]+v

        elif (f == 2):
            b1f2list[r-1] = b1f2list[r-1] + v

        elif (f == 3):
            b1f3list[r-1] = b1f3list[r-1] + v


    elif (b == 2):
        if (f == 1):
            b2f1list[r-1] = b2f1list[r-1]+v

        elif (f == 2):
            b2f2list[r-1] = b2f2list[r-1] + v

        elif (f == 3):
            b2f3list[r-1] = b2f3list[r-1] + v

    elif (b == 3):
        if (f == 1):
            b3f1list[r-1] = b3f1list[r-1]+v

        elif (f == 2):
            b3f2list[r-1] = b3f2list[r-1] + v

        elif (f == 3):
            b3f3list[r-1] = b3f3list[r-1] + v

    elif (b == 4):
        if (f == 1):
            b4f1list[r-1] = b4f1list[r-1]+v

        elif (f == 2):
            b4f2list[r-1] = b4f2list[r-1] + v

        elif (f == 3):
            b4f3list[r-1] = b4f3list[r-1] + v


for i in range(10) :
    print(" "+str(b1f1list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b1f2list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b1f3list[i]), end = "")
print("")
print("#"*20)

for i in range(10) :
    print(" "+str(b2f1list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b2f2list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b2f3list[i]), end = "")
print("")
print("#"*20)

for i in range(10) :
    print(" "+str(b3f1list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b3f2list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b3f3list[i]), end = "")
print("")
print("#"*20)

for i in range(10) :
    print(" "+str(b4f1list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b4f2list[i]), end = "")
print("")
for i in range(10) :
    print(" "+str(b4f3list[i]), end = "")
print("")



Measured memory_bytes: 5636
N = int(input())
A = list(map(int,input().split()))

nums = [0 for i in range(1,100010)]

S = sum(A)
for i in range(N):
    nums[A[i]] += 1

Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    if nums[B] != 0:
        plus = nums[B]*(C - B)
        S += plus
    print(S)
    nums[C] += nums[B]
    nums[B] = 0


Measured memory_bytes: 20988
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (1000000007)


//グラフ
#define MAXV (MAXN*3)
int Gv;
typedef struct edge
{
    int to;
    ll cost;
    struct edge* next;
}edge;


void Gadd(edge** es,int v, int to, ll cost)
{
    edge* e = malloc(sizeof(edge));
    e->to = to;
    e->cost = cost;
    e->next = es[v];
    es[v] = e;
}

// Que
typedef struct Que
{
    ll val;
    struct Que* next;
}Que;

void QuePush(Que** qr,ll val)
{
    Que* q = malloc(sizeof(Que));
    q->val = val;
    q->next = *qr;
    *qr = q;
}

//NULLチェックは外側で
ll QuePop(Que** qr)
{
    ll r = (*qr)->val;
    Que* f = *qr;
    *qr = (*qr)->next;
    free(f);
    return r;
}

edge* Ge[MAXV]; //vから出てる有向辺
int dr[MAXV];
int ans = INT_MAX;
int s,t;

void bfs(void)
{
    Que *q=NULL,*nq=NULL;
    QuePush(&q,s);
    dr[s] = 0;
    while(q!=NULL)
    {
        while(q!=NULL)
        {
            ll v = QuePop(&q);
            edge* e = Ge[v];
            while(e!=NULL)
            {
                if(dr[e->to]==0)
                {
                    dr[e->to] = dr[v]+1;
                    QuePush(&nq,e->to);
                }
                e = e->next;
            }
        }
        q = nq;
        nq = NULL;
    }
}

int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        u--;v--;
        Gadd(Ge,u,v+MAXN,0);
        Gadd(Ge,u+MAXN,v+MAXN+MAXN,0);
        Gadd(Ge,u+MAXN+MAXN,v,0);
    }
    scanf("%d %d",&s,&t);
    s--;t--;
    bfs();

    printf("%d\n",dr[t]==0?-1:dr[t]/3);

    return 0;
}


Measured memory_bytes: 13184
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var A = cin.nextLong();
            var B = cin.nextLong();
            var C = cin.nextLong();
            var D = cin.nextLong();
            var N = B - A + 1;

            var CD = Lcm(C,D);

            var A_C = (A-1) / C;
            var A_D = (A-1) / D;
            var A_CD = (A-1) / CD;
            var Aans = A_C + A_D - A_CD;

            var B_C = B / C;
            var B_D = B / D;            
            var B_CD = B / CD;
            var Bans = B_C + B_D - B_CD;

            var ans = N - (Bans - Aans);
            
            Console.WriteLine(ans);
        }

        // 最小公倍数
        static long Lcm(long a, long b)
        {
            return a * (b / Gcd(a, b));
        }

        // 最大公約数
        static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);  // 引数を入替えて自分を呼び出す
            long d = 0;
            do
            {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }
    }

    class Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EBallColoring {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<P> v(N);
        int minVal = INF;
        int maxVal = -INF;
        REP(i, N) {
            int x, y;
            cin >> x >> y;
            if (x > y) swap(x, y);
            v[i] = {x, y};
            if (x < minVal || y < minVal) {
                minVal = min(x, y);
            }
            if (x > maxVal || y > maxVal) {
                maxVal = max(x, y);
            }
        }

        int res = INF;

        // Rmax最大、 Bminが最小
        {
            set<int> R, B;
            REP(i, N) {
                int x, y;
                tie(x, y) = v[i];
                if (x > y) swap(x, y);
                R.insert(y);
                B.insert(x);
            }
            res = (*R.rbegin() - *R.begin()) * (*B.rbegin() - *B.begin());
        }

        // Rmax最大, Rmin最小
        {
            multiset<int> B;
            REP(i, N) {
                int x, y;
                tie(x, y) = v[i];
                if (x > y) swap(x, y);
                B.insert(x);
            }
            res = min(res, (maxVal - minVal) * (*B.rbegin() - *B.begin()));

            sort(v.begin(), v.end());
            REP(i, v.size()) {
                B.erase(B.find(v[i].first));
                B.insert(v[i].second);
                res = min(res, (maxVal - minVal) * (*B.rbegin() - *B.begin()));
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EBallColoring solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 22144
import math

n = int(input())
lst = [0,0,0,0,0]

for i in range(n):
    name = input()
    if name[0]=="M":
        lst[0]+=1
    elif name[0]=="A":
        lst[1]+=1
    elif name[0]=="R":
        lst[2]+=1
    elif name[0]=="C":
        lst[3]+=1
    elif name[0]=="H":
        lst[4]+=1
# print(lst)

P = [0,0,0,0,0,0,1,1,1,2]
Q = [1,1,1,2,2,3,2,2,3,3]
R = [2,3,4,3,4,4,3,4,4,4]

ans = 0
for i in range(10):
    ans += lst[P[i]]*lst[Q[i]]*lst[R[i]]
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200100;

int n, a[N], g[2][N];
vector < pair <int, int> > c[2];

int main() {

	scanf("%d", &n);

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

	for (int i = 0; i < n; i++) {
		g[i % 2][a[i]]++;
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			c[i].push_back(make_pair(g[i][j], j));
		}
		sort(c[i].rbegin(), c[i].rend());
	}

	int res = n;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (c[0][i].second != c[1][j].second) {
				res = min(res, n - c[0][i].first - c[1][j].first);
				break;
			}
		}
	}

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

	return 0;

}

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
const int mod = 100000;
int main()
{
    int W, H;
    while(scanf("%d %d", &W, &H), W || H) {
        int dp[105][105][2][2] = {};
        dp[0][0][0][0] = dp[0][0][1][0] = 1;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(i < H - 1) {
                    (dp[i + 1][j][0][0] += dp[i][j][1][1]) %= mod;
                    (dp[i + 1][j][0][1] += dp[i][j][0][0] + dp[i][j][0][1]) %= mod;
                }
                if(j < W - 1) {
                    (dp[i][j + 1][1][0] += dp[i][j][0][1]) %= mod;
                    (dp[i][j + 1][1][1] += dp[i][j][1][0] + dp[i][j][1][1]) %= mod;
                }
            }
        }
        int (*p)[2] = dp[H - 1][W - 1];
        cout << (p[0][0] + p[0][1] + p[1][0] + p[1][1]) % mod << endl;
    }
    return (0);
}


Measured memory_bytes: 3220
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>

using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = a*b;
    if(a>9 || b>9) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;
    int i = 0;
    for (; i < ((k < n)? k : n); i++)
      ans += x;
    for (; i < n; i++)
      ans += y;
    System.out.println(ans);
  }
}

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

int n;
vector<int> A;

bool solve(int i,int m)
{
    if(!m)
    {
        return true;
    }
    if(i>=A.size()||m<0)
    {
        return false;
    }
    return solve(i+1,m)||solve(i+1,m-A[i]);
}
int main()
{
    int q,m,i;
    cin>>n;
    A.resize(n);
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
        scanf("%d",&m);
        cout << ( solve(0,m) ? "yes" : "no" ) << endl;
    }

	return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 4;

int n;
int arr[N], sum[N];
vector<pair<int, int>> sol;

int add(int x, int y)
{
  sol.push_back({x, y});
  return x - y;
}

int main()
{
  while(scanf("%d", &n) != EOF){
    for(int i = 0 ; i < n ; i++)
      scanf("%d", arr + i);
    sort(arr, arr + n);
    int idx = 0;
    if(arr[0] >= 0) idx = 0;
    else if (arr[n - 1] < 0) idx = n - 2;
    else
      for(int i = 0 ; i + 1 < n ; i++)
        if(arr[i] * arr[i + 1] <= 0){
          idx = i;
          break;
        }
    sol.clear();
    int soFar = arr[0];
    for(int i = idx + 1 ; i + 1 < n ; i++)
      soFar = add(soFar, arr[i]);
    soFar = add(arr[n - 1], soFar);
    for(int i = 1 ; i <= idx ; i++)
      soFar = add(soFar, arr[i]);
    cout << soFar << endl;
    for(auto x: sol)
      cout << x.first << " " << x.second << endl;
  }
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
	string ls[]={"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts"};
	int t[38][38]={};
	int n; cin>>n;
	for(string s;cin>>s;){
		vector<int> ws;
		for(int i=0;i<s.size();i++){
			bool two=false;
			for(int j=0;j<12;j++){
				if(s.substr(i,2)==ls[j]){
					ws.push_back(26+j);
					i++;
					two=true;
					break;
				}
			}
			if(!two)
				ws.push_back(s[i]-'a');
		}
		for(int i=1;i<ws.size();i++)
			t[ws[i-1]][ws[i]]++;
	}
	
	for(int i=0;i<38;i++){
		int j=0;
		for(int k=0;k<38;k++)
			if(t[i][k]>t[i][j])
				j=k;
		cout<<(i<26?string(1,'a'+i):ls[i-26])<<" ";
		cout<<(j<26?string(1,'a'+j):ls[j-26])<<" ";
		cout<<t[i][j]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 896
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

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

    int cnt=0;

    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin>>A[i];

        cnt+=A[i];
    }
    if(N<cnt){
        cout<<-1<<endl;
    }else{
        cout<<N-cnt<<endl;
    }
}


Measured memory_bytes: 3632
#include <stdio.h>
#define MAX 100
#define INFTY 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX],num;

void dijkstra(int s){
  int i,u,v,mincost;
  int d[MAX],p[MAX],color[MAX];

  for(i=0; i<num; i++){
    d[i] = INFTY;
    color[i] = WHITE;
    d[s] = 0;
    p[s] = -1;
  }

  while(1){
    mincost = INFTY;
      for(i=0; i<num; i++){
	if(color[i] != BLACK && d[i] < mincost){
	  mincost = d[i];
	  u = i;
	}
      }
    if(mincost == INFTY) break;
    color[u] = BLACK;

    for(v=0; v<num; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[u] + M[u][v] < d[v]){
	  d[v] = d[u] + M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0; i<num; i++){
    printf("%d ",i);
    if(d[i] == INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}


int main(){
  int i,j,u,k,v,c;
  scanf("%d",&num);
  for(i=0; i<num; i++){
    for(j=0; j<num; j++){
      M[i][j] = INFTY;
    }
  }

  for(i=0; i<num; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra(0);

  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10
const int MOD = 1000000007;


ll dp[100100][13];

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

	for (int i = 0; i < S.size(); i++) {
		if (i == 0) {
			if (S[i] == '?') {
				for (int dec = 0; dec <10; dec++) {
					dp[0][dec]++;
				}
			}
			else {
				int dec = S[i] - 48;
				dp[0][dec]++;
			}
			continue;
		}
		if (S[i] == '?') {
			for (int dec = 0; dec < 10; dec++) {
				for (int k = 0; k < 13; k++) {
					dp[i][(10*k+dec)%13] += dp[i - 1][k];
					dp[i][(10 * k+dec) % 13] %=MOD;
				}
			}
		}
		else {
			int dec = S[i] - 48;
			for (int k = 0; k < 13; k++) {
				dp[i][(10 * k+dec) % 13] += dp[i - 1][k];
				dp[i][(10 * k+dec) % 13] %=MOD;

			}
		}

	}



	print(dp[S.size() - 1][5]);


	return 0;
}


Measured memory_bytes: 10624
from fractions import gcd
A, B = map(int, input().split())
g = gcd(A, B)

from collections import Counter
#最大公約数を素因数分解する
def factorize(n):
  d = Counter()
  m = 2
  while m*m <= n:
    while n%m == 0:
      n //= m
      d[m] += 1
    m += 1
  if n > 1:
    d[n] += 1
  return d

fs = factorize(g) # "1"以外の公約数
print(len(fs) + 1) # 公約数"1"を足す

Measured memory_bytes: 5176
n = int(input())
if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    big = 10**9 + 7
    a0 = 10
    b0 = 9
    c0 = 8
    a = 1
    b = 1
    c = 1
    for i in range(n):
        a = (a % big) * a0
        b = (b % big) * b0
        c = (c % big) * c0
    ans = a - b * 2 + c
    if ans < 0:
        ans += big
    print(ans % big)
        


Measured memory_bytes: 9160
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    r = [int(x) for x in sys.stdin.readline().split()][0]

    logger.debug('{}'.format(r))

    print(3 * r**2)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4"""
        output = """48"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """15"""
        output = """675"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """80"""
        output = """19200"""
        self.assertIO(input, output)


Measured memory_bytes: 6444
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, cnt(0); long long D, X, Y;
    std::cin >> N >> D;
    for(int i(0); i < N; ++i){
        std::cin >> X >> Y;
        if(X*X + Y*Y <= D*D) ++cnt;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3628
fun main (args : Array<String>) {
	val (a, b) = readLine()!!.split(" ")
	val A : Double = a.toDouble()
	val B : Double = b.toDouble()
	var result : Double = (A + B)
	return if( (result % 2) == 0.0 ) {
		println("${result.toInt()/2}")
	} else {
		println("IMPOSSIBLE")
	}	
}

Measured memory_bytes: 37996
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int main() {
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

	int sum = 0;
	int sug = 0;
	int aa = -1, bb = 1; // 설탕양, 총양

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			sum = a * i + b * j;
			sum *= 100;

			if (sum == 0) continue;
			for (int ii = 0; ii <= 100; ii++)
				for (int jj = 0; jj <= 100; jj++) {
					sug = ii * c + jj * d;
					if (sum + sug > f) continue;
					if (sum * e < sug * 100) continue;

					if ((ll)aa * (sum + sug) <= (ll)bb * sug) {
						aa = sug;
						bb = sum + sug;
					}
				}
		}
	}

	printf("%d %d", bb, aa);
}

Measured memory_bytes: 256
N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v

print(ans)

Measured memory_bytes: 257544
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
p=lmp()
a=sorted(p)
c=0
for i in range(n):
    if p[i]!=a[i]:
        c+=1
if c==2 or c==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 77400
#include<bits/stdc++.h>
using namespace std;
int ans[200001];
int main(){

 //   freopen("B1.inp","r",stdin);
 //   freopen("B1.out","w",stdout);
    int n,x;
    cin>>n>>x;
    if(x==1 || x == 2*n-1)cout<<"No";
    else {
        cout<<"Yes"<<endl;
        ans[n]=x;
        if(x>=n){
          int pos;
          for(int i = 1;i<=2*n-1-x;++i){
            ans[n+i] = x+i;
            pos = n+i+1;
          }
          int val = 1;
          while(pos<=2*n-1){
            ans[pos]=val;
            pos++,val++;
          }
          for(int i=1;i<=n-1;++i){
            ans[i] = val;
            val++;
          }
          for(int i = 1;i<=2*n-1;++i){
            cout<<ans[i]<<endl;
          }
        }
        else {
            ans[n] = x;
            int pos;
            int val;
            for(int i = n +1 ; i<=2*n-1 ;++i){
                ans[i] = x + i - n;
                val = ans[i] + 1;
            }
            pos=1;
            while(val<=2*n-1){
                ans[pos]=val;
                val++;pos++;
            }
            val = 1;
            for(int i = pos ; i<n;++i){
                ans[i]=val;
                val++;
            }
        for(int i=1;i<=2*n-1;++i)cout<<ans[i]<<endl;
        }
    }
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
ll a[26];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n;
	ll M=1e9+7,ans=1;
	string s;
	cin>>n>>s;
	fo(i,0,n)a[s[i]-'a']++;
	fo(i,0,26)ans=ans*(a[i]+1)%M;
	cout<<(ans-1+M)%M<<endl;
	return 0;
}


Measured memory_bytes: 512
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)


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

    int a;
    vector<int> v(100005, 0);
    ll sum = 0;
    rep(i, n) {
        cin >> a;
        sum += a;
        v[a]++;
    }

    int q;
    cin >> q;

    int b, c;
    rep(i, q) {
        cin >> b >> c;
        sum += (c-b) * v[b];
        cout << sum << endl;
        v[c] += v[b];
        v[b] = 0;
    }

    return 0;
}

Measured memory_bytes: 3744
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a= Console.ReadLine().Split(" ");
            Console.WriteLine(int.Parse(a[0]) * int.Parse(a[1]));
        }
    }
}

Measured memory_bytes: 27484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(100010);
	rep(i,n){
		int b;cin >> b;
		a.at(b)++;
	}
	int ans = 0, cnt = 0;
	rep(i,100001){
		if(a.at(i)){
			ans++;
			if(a.at(i) % 2 == 0) cnt++;
		}
	}
	if(cnt % 2 == 1) ans--;
	cout << ans << endl;
}


Measured memory_bytes: 640
n,k = gets.chomp.split(" ").map(&:to_i)

@h = {}
(0..2000).each do |n|
  @h[n] = 1;next if n == 0
  @h[n] = @h[n-1]*n
end

def f(number)
  @h[number]
end

def c(n,k)
  return 1 if n == 0 or k == 0
  return 0 if n < k
  f(n) /(f(n-k)*f(k))
end
k.times do |i|
  i+=1
  puts c(n-k+1, i)*c(k-1, i-1) % 1000000007
end

Measured memory_bytes: 8060
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

const ll INF = (ll)1e18 + 10;

class FordFulkerson {
public:
    FordFulkerson(ll n) : n_(n), graph_(n) {}

    // fromからtoへ向かう容量capの辺をグラフに追加する
    void addEdge(ll from, ll to, ll cap) {
        graph_[from].push_back({ to, cap, (ll)graph_[to].size() });
        graph_[to].push_back({ from, 0, (ll)graph_[from].size() - 1 });
    }
    
    // sからtへの最大流を求める
    ll getflow(ll s, ll t) {
        ll flow = 0;
        while (true) {
            used_.assign(n_, false);
            ll f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }

private:
    struct Edge { ll to, cap, rev; };
    ll n_;
    vector<vector<Edge>> graph_;
    vector<bool> used_;
    
    // 増加パスをdfsで探す
    ll dfs(ll v, ll t, ll f) {
        if (v == t) return f;
        used_[v] = true;
        for (auto &e : graph_[v]) {
            if (!used_[e.to] && e.cap > 0) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    graph_[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

int main() {
    ll N;
    cin >> N;
    FordFulkerson ff(N + 2);
    ll s = 0;
    for (ll i = 1; i <= N; i++) {
        ll a;
        cin >> a;
        s += max((ll)0, a);
        if (a <= 0) {
            ff.addEdge(0, i, -a);
        } else {
            ff.addEdge(i, N + 1, a);
        }

        for (ll j = i * 2; j <= N; j += i) {
            ff.addEdge(i, j, INF);
        }
    }
    cout << s - ff.getflow(0, N + 1) << endl;
}

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

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

bool solve(ll A, ll B, ll C, ll D) {
  if (B > D) return false;

  ll x = max(A - C - 1, 0LL);
  ll t = x / B;
  ll a = A - t * B;
  if (a - B < 0) return false;

  if (B <= C) return true;

  ll g = gcd(B, D);
  return B - g <= C;
}

int main(void) {
  ll T;
  cin >> T;

  while (T-- > 0) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (solve(A, B, C, D) ? "Yes" : "No") << endl;
  }
}

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

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string root[4] = { "","","","" };
	for (size_t i = 0; i < abs(ty-sy); i++)
	{
		if (ty > sy) {
			root[0] += "U";
			root[1] += "D";
		}
		else {
			root[0] += "D";
			root[1] += "U";
		}
	}
	for (size_t i = 0; i < abs(tx-sx); i++)
	{
		if (tx > sx) {
			root[0] += "R";
			root[1] += "L";
		}
		else {
			root[0] += "L";
			root[1] += "R";
		}
	}
	if (tx > sx) {
		root[2] += "L";
		root[3] += "R";
	}
	else {
		root[2] += "R";
		root[3] += "L";
	}
	for (size_t i = 0; i < abs(ty - sy)+1; i++)
	{
		if (ty > sy) {
			root[2] += "U";
			root[3] += "D";
		}
		else {
			root[2] += "D";
			root[3] += "U";
		}
	}
	for (size_t i = 0; i < abs(tx - sx)+1; i++)
	{
		if (tx > sx) {
			root[2] += "R";
			root[3] += "L";
		}
		else {
			root[2] += "L";
			root[3] += "R";
		}
	}
	if (ty > sy) {
		root[2] += "D";
		root[3] += "U";
	}
	else {
		root[2] += "U";
		root[3] += "D";
	}
	cout << root[0] << root[1] << root[2] << root[3] << endl;
}

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

int main()
{
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a==b)
	{
		cout << c << endl;
	}
	else if (a==c)
	{
		cout << b << endl;
	}
	else if (b==c)
	{
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
int main(){
  int i,j,x[N],cnt=1,n=0;
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
    if(x[i]==0) break;
    n++;
  }
  for(i=0;i<n;i++){
    printf("Case %d: %d\n",cnt,x[i]);
    cnt++;
  }
  return 0;
}


Measured memory_bytes: 2044
#include <iostream>

class NumInfo {
  private:
  	int _num;
  	int _plusNum;
  public:
  	int GetNum();
  	void SetNum(int num);
  	int GetPlusNum();
  	void SetPlusNum(int pluNum);
};

int NumInfo::GetNum() {
  return _num;
}

void NumInfo::SetNum(int num) {
  _num = num;
}

int NumInfo::GetPlusNum() {
  return _plusNum;
}

void NumInfo::SetPlusNum(int plusNum) {
  _plusNum = plusNum;
}


int main(void) {
  int num[5] = {0, 0, 0, 0, 0};
  NumInfo *numInfo = NULL;
  numInfo = new NumInfo[5];
  
  for(int ii = 0; ii < 5; ii++) {
    std::cin >> num[ii];
    numInfo[ii].SetNum(num[ii]);
  }
  
  int minIndex = 0;
  int minNum = 9;
  for(int ii = 0; ii < 5; ii++){
    int tmp = 0;
    int tmp2 = 0;
    int pluNum = 0;
    
    pluNum = num[ii] / 10;
    tmp = num[ii] % 10;
    if( tmp == 0 ) {
      tmp2 = pluNum * 10;
    }
    else {
      tmp2 = (pluNum + 1) * 10;
    }
    numInfo[ii].SetPlusNum( tmp2 );
    
    if( tmp != 0 ) {
    	if( tmp < minNum ) {
      		minNum = tmp;
      		minIndex = ii;
    	}
    }
  }
  
  int sum = 0;
  for(int jj = 0;jj < 5; jj++) {
    if( jj == minIndex ) {
      sum = sum + numInfo[jj].GetNum();
    }
    else {
      sum = sum + numInfo[jj].GetPlusNum();
    }
  }
  
  std::cout << sum;
  
  return 0;
}

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





int main() {
  int a,b;
  cin>>a>>b;
  if (a%3==0 || b%3==0 || (a+b)%3==0 ){
    cout<<"Possible"<<endl;
  }
  else {
    cout<<"Impossible"<<endl;
  }
  
}













Measured memory_bytes: 256
arr=[1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 3, 6, 9, 12, 15, 18, 21, 24, 27, 4, 8, 12, 16, 20, 24, 28, 32, 36, 5, 10, 15, 20, 25, 30, 35, 40, 45, 6, 12, 18, 24, 30, 36, 42, 48, 54, 7, 14, 21, 28, 35, 42, 49, 56, 63, 8, 16, 24, 32, 40, 48, 56, 64, 72, 9, 18, 27, 36, 45, 54, 63, 72, 81]
n = int(input())

if n in arr:
  print("Yes")
else:
  print("No")

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

signed main(void)
{
	ll n, money, now;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];

	money = 1000;
	rep(i, n - 1)
	{
		now = 0;
		if (a[i] < a[i + 1]) 
			now = money / a[i];
		money += now * (a[i + 1] - a[i]);
	}
	cout << money << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    char O[50], E[50];
    scanf("%s %s", O, E);
    int i=0, o_c=0, e_c=0;
    while((o_c==0)||(e_c==0)){
        if('a'<=O[i]&&O[i]<='z'){
            printf("%c", O[i]);
        }
        else{
            o_c++;
        }

        if('a'<=E[i]&&E[i]<='z'){
            printf("%c", E[i]);
        }
        else{
            e_c++;
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll N, C; cin >> N >> C;
    vll s(N), t(N), c(N);
    rep(i, N) cin >> s[i] >> t[i] >> c[i], c[i]--;

    vvll imos(C, vll(1e5 + 10));
    vvll tv_program(C, vll(1e5 + 10));

    rep(i, N) {
        imos[c[i]][s[i]]++;
        imos[c[i]][t[i]]--;
    }

    rep(i, C) rep(j, 1e5+5) {
        if (j == 0) tv_program[i][j] = imos[i][j];
        else tv_program[i][j] = tv_program[i][j-1] + imos[i][j];
    }

    rep(i, C) rep(j, 1e5+5) {
        if (tv_program[i][j] == 0 && tv_program[i][j+1]) tv_program[i][j] = 1;
    }

    ll maxn = 0;
    rep(j, 1e5+5) {
        ll total = 0;
        rep(i, C) {
            total += tv_program[i][j];
        }
        maxn = max(total, maxn);
    }
    cout << maxn << endl;
    return 0;
}

Measured memory_bytes: 50288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    //vl v(n,0);
    cout << 0 <<endl;
    ll ok=0,ng=n+1;
    string pre;
    string s;cin >> s;
    if(s=="Vacant")return 0;
    pre=s;
    ll q=19;
    while(q--){
        ll mid=(ok+ng)/2;
        cout << mid << endl;
        cin >> s;
        if(s=="Vacant")return 0;
        if(s==pre){
            if((mid-ok)%2)ng=mid;
            else ok=mid,pre=s;
        }
        else{
            if((mid-ok)%2)ok=mid,pre=s;
            else ng=mid;
        }
    }
    return 0;
}

Measured memory_bytes: 3832
N = int(input())
a = list(map(int, input().split()))
d = [0] * 10**5
ans = 0
for i in range(N):
    d[a[i]] += 1

for i in range(len(d)):
    if i == 0:
        ans = max(ans, d[i] + d[i + 1])
        continue
    elif i == len(d) - 1:
        ans = max(ans, d[i - 1] + d[i])
        continue
    ans = max(ans, d[i-1] + d[i] + d[i + 1])

print(ans)

Measured memory_bytes: 13964
N, M, C = map(int, input().split())
Blis = [int(x) for x in input().split()]
Alis = [x for x in range(N)]
k = 0
for i in range(N):
  Alis[i] = [int(x) for x in input().split()]
for i in range(N):
  total = 0
  for j in range(M):
    total = total + (Alis[i][j])*(Blis[j])
  total = total + C
  if total > 0:
    k = k + 1
print(k) 

Measured memory_bytes: 3064