akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

string B(int N, int m, vector<int>& b, vector< vector<int> >& A) {
	int i, j;

	for (i = 0; i < m; i++)
		for (int j = 0; j < m; j++)
			if (find(b.begin(), b.end(), A[i][j]) != b.end())
				A[i][j] = 0;
	
	for (i = 0; i < m; i++) {
		j = 0;
		while (j < m && A[i][j] == 0)
			j++;
		if (j == m)
			return "Yes";
		j = 0;
		while (j < m && A[j][i] == 0)
			j++;
		if (j == m)
			return "Yes";
	}
	
	i = 0;
	while (i < m && A[i][i] == 0)
		i++;
	if (i == m)
		return "Yes";
	i = 0;
	while (i < m && A[i][m - i - 1] == 0)
		i++;
	if (i == m)
		return "Yes";
	return "No";
}

int main() {
	int N, m = 3;
	vector< vector<int> > A(m, vector<int>(m));
	for (int i = 0; i < m; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++)
		cin >> b[i];
	cout << B(N, m, b, A);
	return 0;
}

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

int n, a, b;
int x, y, z;
int p[102];

int main(){

	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> p[i];

	for (int i = 0; i < n; i++){
		if (p[i] <= a)x++;
		else if (p[i] > b)z++;
		else y++;
	}

	cout << min(min(x, y), z) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
struct Card{
    char suit;
    int value;
};

void BubbleSort(Card C[], int N){
    Card tmp;
    for(int i = 0; i < N; i++){
        for(int j = N-1; j >=i + 1; j--){
            if(C[j].value < C[j-1].value){
                tmp = C[j];
                C[j] = C[j-1];
                C[j-1] = tmp;
            }
        }
    }
}
void SelectionSort(Card C[], int N){
    Card tmp;
    int minj;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(C[j].value < C[minj].value){
                minj = j;
            }
        }
        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }
}

void printResult(Card C[], int N){
    for(int i = 0; i < N; i++){
        if(i != 0){
            printf(" "); 
        }
        printf("%c", C[i].suit);
        printf("%d", C[i].value);
    }
    printf("\n");
}

int main(void){
    int n, flg;
    Card C1[100], C2[100];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf(" %c",&C1[i].suit);
        scanf("%d",&C1[i].value);
        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }
    BubbleSort(C1, n);
    SelectionSort(C2, n);
    printResult(C1, n);
    printf("Stable\n");
    printResult(C2, n);

    flg = 1;
    for(int i = 0; i < n; i++){
        if(C1[i].suit != C2[i].suit){
            printf("Not stable\n"); 
            flg = 0; 
            break;
        }
    }
    if(flg){
        printf("Stable\n");
    }

    return 0;   
}


Measured memory_bytes: 2736
#include <iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int n,num,cnt=0;
cin>>n;
for(int i=0; i<n; i++){
    cin>>num;

    if( num%2==1 && i%2==0 ){
        cnt++;
    }
}
cout<<cnt;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

int books[30000];
int memo[30000][3][4];

int main(){
	int T, n;
	string s;
	cin >> T;
	rep(t, T){
		memset(books, 0, sizeof(books));
		cin >> n;
		cin >> s;
		rep(i, n * 4){
			if(s[i] == 'Y'){
				int d = 0;
				if(i >= n * 2) d++;
				int i2 = i % (2 * n);
				books[(i2+1)/2] |= (1 << d);
			}
		}
		fill(&memo[0][0][0], &memo[29999][2][3] + 1, INF);
		memo[0][0][books[0]] = 0;
		queue<PPP> que;
		que.push(PPP(0, PP(0, P(0, books[0]))));
		while(!que.empty()){
			PPP ppp = que.front();
			que.pop();
			int cost = ppp.first;
			int pos = ppp.second.first;
			int p = ppp.second.second.first;
			int b = ppp.second.second.second;
			if(pos == n && p == 0 && b == 0){
				cout << cost << endl;
				break;
			}
			if(b == 0 && memo[pos+1][p][books[pos+1]] == INF){
				memo[pos+1][p][books[pos+1]] = cost + 1;
				que.push(PPP(cost + 1, PP(pos+1, P(p, books[pos+1]))));
			}
			if(p <= 1){
				if(memo[pos][0][b & 2] == INF){
					memo[pos][0][b & 2] = cost + 1;
					que.push(PPP(cost + 1, PP(pos, P(0, b & 2))));
				}
				if(memo[pos][1][b & 2] == INF){
					memo[pos][1][b & 2] = cost + 1;
					que.push(PPP(cost + 1, PP(pos, P(1, b & 2))));
				}
			}
			if(p >= 1){
				if(memo[pos][2][b & 1] == INF){
					memo[pos][2][b & 1] = cost + 1;
					que.push(PPP(cost + 1, PP(pos, P(2, b & 1))));
				}
				if(memo[pos][1][b & 1] == INF){
					memo[pos][1][b & 1] = cost + 1;
					que.push(PPP(cost + 1, PP(pos, P(1, b & 1))));
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int n,m;
int G[52][52];
int path[52],top;
bool chk[52];
vector<int> lst[52];
bool dfs(int p,int u,int to) {
	if(u==to) return true;
	for(int v=1;v<=n;v++) {
		if(!G[u][v]||v==p) continue;
		path[top++]=G[u][v];
		if(dfs(u,v,to)) return true;
		top--;
	}
	return false;
}
int main() {
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n-1;i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		G[a][b]=G[b][a]=i;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		top=0;
		dfs(a,a,b);
		for(j=0;j<top;j++) lst[i].push_back(path[j]);
	}
	ll res=0;
	for(i=0;i<1<<m;i++) {
		memset(chk,0,sizeof(chk));
		int c=0;
		for(j=0;j<m;j++) {
			if(i>>j&1) {
				c++;
				for(int k=0;k<sz(lst[j]);k++) {
					chk[lst[j][k]]=true;
				}
			}
		}
		int t=n-1;
		for(j=1;j<=n-1;j++) if(chk[j]) t--;
		if(c%2) res-=1ll<<t;
		else res+=1ll<<t;
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,d;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=="AC")
		{
			a++;
		}
		else if(s=="TLE")
		{
			c++;
		}
		else if(s=="WA")
		{
			b++;
		}
		else d++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
}

Measured memory_bytes: 3764
import numpy as np

def main():
    nl = list(map(int, input().split(" ")))
    apple = list(range(nl[1], nl[0]+nl[1]))
    mi = np.array(list(map(abs, apple)))
    index = np.argsort(mi)

    s = 0
    for i in index[1:]:
        s += apple[i]
    print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12484
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            var c = int.Parse(Console.ReadLine());
            var dict = new HashSet<string>();
            for (var i = 0; i < c; i++)
            {
                var l = Console.ReadLine().Split(' ');
                if (l[0] == "insert")
                    dict.Add(l[1]);
                else if (dict.Contains(l[1]))
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
        }
    }


Measured memory_bytes: 48732
#include<stdio.h>
int main()
{
	int a[102]={0},x,n;
	int i,t;
	scanf("%d%d",&x,&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);  //从1开始 
		a[t]=1;
	}
	i=0;
	while(1)
	{
		if(x-i>=0&&a[x-i]==0)
		{
			printf("%d",x-i);
			break;
		}
		if(x+i<=101&&a[x+i]==0)
		{
			printf("%d",x+i);
			break;
		}
		i++;
	}
	return 0;
}

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

int main() {
	int q;
	cin >> q;
	
	for (int i=0; i<q; ++i) {
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		
		int ans = (c - a + 1) * (d - b + 1);
		for (int y=1; y<=8; y+=2) {
			for (int x=2; x<=8; x+=2) {
				if (a <= y && y <= c && b <= x && x <= d) --ans;
			}
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 3204
//#include "stdc++.h"
#include <bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =1000000007 ;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define pi 3.141592653589793238462
#define int  long long
vector<pair<int,int> > adj[100001];int col[100001];
void dfs(int u,int p)
{
    int v,w;
    for(int i=0;i<adj[u].size();i++)
    {
        v=adj[u][i].first;
        w=adj[u][i].second;
        if(v!=p)
        {
            if(w%2)
                col[v]=(!col[u]);
            else
                col[v]=col[u];
            dfs(v,u);
        }
    }
    
}
int32_t main()
{
    IOS;
    int n;int u,v,w;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v>>w;
        adj[u].pb(m1(v,w));
        adj[v].pb(m1(u,w));
    }
    col[1]=1;
    dfs(1,0);
    for(int i=1;i<=n;i++)
        cout<<col[i]<<endl;
    return 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	typename vector< T > :: const_iterator it;
	for( it = v.begin(); it != v.end(); it++ ) {
		if( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	typename set< T > :: const_iterator it;
	for ( it = v.begin(); it != v.end(); it++ ) {
		if( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	typename map< F , S >::const_iterator it;
	for( it = v.begin(); it != v.end(); it++ ) {
		if( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
vi a={0,2,5,5,4,5,6,3,7,6};
int n, m;
vi A;
vi ans;
int dp[11000];
int fun(int N){
	if(N<0){
		return -1;
	}
	if(dp[N]!=-1){
		return dp[N];
	}
	if(N==0){
		return dp[N]=0;
	}
	else{
		int dig=-1;
		for(int i=0;i<A.size();i++){
			int temp=fun(N-a[A[i]]);
			if(temp==-1)continue;
			if(temp>dig){
				dig=temp;
			}
		}
		if(dig==-1){
			return dp[N]=-1;
		}
		else{
			return dp[N]=1+dig;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	A.resize(m);
	REP(i,0,m){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	fun(n);
	int I=n;
    while(I>0){
    	int ind=-1;
    	for(int i=0;i<A.size();i++){
    		if(I<a[A[i]])continue;
    		if(dp[I-a[A[i]]]==(dp[I]-1)){
    			ind=i;
    		}
    	}
    	ans.PB(A[ind]);
    	I-=a[A[ind]];
    }
    REP(i,0,ans.size()){
    	cout<<ans[i];
    }
    cout<<"\n";

	return 0;
}




Measured memory_bytes: 640
import static java.lang.Math.multiplyExact;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        Long[] a = new Long[n];
        Long limit = (long)Math.pow(10,18);

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextLong();
        }

        Arrays.sort(a);

        if (a[0] == 0){
            System.out.print(0);
            System.exit(0);
        }

        Long result = a[0];

        for (int i = 1; i < n; i++) {
            try {
                result = multiplyExact(result,a[i]);
            } catch (Exception e) {
                System.out.print(-1);
                System.exit(0);
            }
            if (result > limit) {
                System.out.print(-1);
                System.exit(0);
            }
        }
        System.out.print(result);
    }
}


Measured memory_bytes: 53052
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ***********************************/
/******* Main ****************************************/
void Main() {
  int n;
  ll x, min_ = inf, max_ = -inf, sum_ = 0;
  cin >> n;
  while (n--) {
    cin >> x;
    min_ = min(min_, x);
    max_ = max(max_, x);
    sum_ += x;
  }
  cout << min_ << " " << max_ << " " << sum_ << endl;
}

/*********************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

************************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int c;
  c = a * b / 2 * 2;
  if (a * b == c){
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }


}

Measured memory_bytes: 3604
import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  [n,m] <- getIntList
  as <- getIntList
  bcs <- getIntTuples
  let as' = sortBy (comparing Down) as
  let bcs' = sortBy (comparing Down `on` snd) bcs
  print $ f as' bcs' n

f _ _ 0 = 0
f as [] n = sum $ take (fromIntegral n) as
f as@(a:xs) bcs@((b,c):ys) n
  | n < 0 = undefined
  | a > c =
--      trace ("a = "++show(a)++show(as))
      a + f xs bcs (n-1)
  | b > n = n*c
  | otherwise =
--      trace ("(b,c) = "++show(b,c)++show(bcs))
      b*c + f as ys (n-b)

Measured memory_bytes: 52988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if (2 * c <= a + b) {
        int t = min(x,y);
        x -= t, y -= t;
        ans += t * 2 * c;
    }
    if (2 * c <= a) {
        ans += 2 * c * x;
        x = 0;
    }
    if (2 * c <= b) {
        ans += 2 * c * y;
        y = 0;
    }
    ans += a * x + b * y;
    cout << ans << endl;
}


Measured memory_bytes: 256
function Main(arg) {
 
    arg = arg.split("\n")[0];
    var H = arg.split(" ")[0]-0;
    var W = arg.split(" ")[1]-0;
    var A = arg.split(" ")[2]-0;
    var B = arg.split(" ")[3]-0;

    var tmp = new Array(W).fill(0);
    var ans = [];
    for (var i = 0; i < H; i++){
        for (var j = 0; j < W; j++){

            if (j < A && i < B) {
                tmp[j] = 1;
            }
            else if(j >= A && i < B) {
                tmp[j] = 0;
            }
            else if(j < A && i >= B) {
                tmp[j] = 0;
            }
            else if(j >= A && i >= B) {
                tmp[j] = 1;
            }

        }
        ans[i] = tmp.slice();
        tmp.fill(0);
    }

    for (var i = 0; i < H; i++) {
        console.log(ans[i].join(""));
    }
}

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


Measured memory_bytes: 31124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int a,b,c;
  string s;
  cin >> a >> b;
  cout << (a*3+b)/2 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

Measured memory_bytes: 116744
a,b,e = (gets+gets+gets).split.map(&:to_i)

# abc
# def
# ghi

1.upto(100){|c|
    sum = a+b+c
    h=sum-b-e
    i=sum-a-e
    f=sum-c-i
    d=sum-e-f
    g=sum-a-d
    next if g+h+i!=sum || g+e+c!=sum
    puts [a,b,c]*" "
    puts [d,e,f]*" "
    puts [g,h,i]*" "
    exit
}

Measured memory_bytes: 1916
//404 Not Found {=}7 (o)7 (x)7
#include<bits/stdc++.h>
using namespace std;
#define apppend push_back
#define endl "\n"
#define dbug(x) cout<<#x<<"="<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 1e5, inf = 1e9, mod= 1e9+7;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout << setprecision(30);
    int a,b;
    cin >> a >> b;
    for(int i = 0;i<max(a,b);i++)
        cout << (a<b?a:b);
    return 0;
}

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

int main(){

    pair<int,int> freq[101]={make_pair(0,0)};

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            int x;
            cin >> x;
            freq[x].first=i+1;
            freq[x].second=j+1;
        }
    }

    int n;
    cin >> n;
    int row[3]={0},columns[3]={0},diagonal=0;
    for(int i=0; i<n; i++){
        int x; 
        cin >> x;
        if(freq[x].first!=0){
            row[freq[x].first-1]++;
            columns[freq[x].second-1]++;
            if(freq[x].first==freq[x].second || abs(freq[x].first-freq[x].second)==2) diagonal++;
        }
    }
    if(row[0]==3 || row[1] == 3 || row[2]==3 || columns[0]==3 || columns[1]==3 || columns[2]==3 || diagonal>=3) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d",$n);
$a_li = explode(" ",trim(fgets(STDIN)));
$re = '';



for($i=count($a_li)-1;$i>=0;$i-=2){
 echo $a_li[$i]." ";
}

if(count($a_li)%2==0){
 for($i=0;$i<count($a_li);$i+=2){
 echo $a_li[$i]." ";
}
}else{
for($i=1;$i<count($a_li);$i+=2){
 echo $a_li[$i]." ";
}
}


//for($i=0;$i<strlen($re);$i++){
  //echo $re[$i]." ";
//}


    



Measured memory_bytes: 25076
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC118D2
{
    class MainClass
    {
        static int[] s;
        static int[] a;
        static int[] dp;
        static int[] w = new int[10] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            a = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            Array.Sort(a, delegate (int x, int y)
            {
                return w[x].CompareTo(w[y]);
            });

            dp = new int[s[0]+1];
            int digit = Dp(s[0]);
            //Console.WriteLine(digit);
            Array.Sort(a, delegate (int x, int y)
            {
                return y.CompareTo(x);
            });

            string ans = "";
            int weight = s[0];
            for (int i = 0; i < digit; i++)
            {

                for(int j = 0; j < s[1]; j++)
                {
                    if (weight - w[a[j]] >= 0)
                    {
                        //Console.WriteLine("weight: " + weight + " a[j]: " + a[j]);
                        if (Dp(weight) == Dp(weight- w[a[j]]) + 1)
                        {
                            ans += a[j].ToString();
                            weight -= w[a[j]];
                            //Console.WriteLine("assigned");
                            break;
                        }
                        else
                        {
                            //Console.WriteLine("skipped");
                        }
                    }

                }
            }

            Console.WriteLine(ans);




        }



        public static int Dp(int m)
        {
            //Console.WriteLine(m);
            if (m == 0) {
                return 0;
            }

            if (dp[m] != 0)//calcurated
            {
                return dp[m];
            }
            else
            {
                int M = s[1];
                int tmp = -1;
                int ans = -1;
                for (int i = 0; i < M; i++)
                {
                    int dptmp = m - w[a[i]];
                    if (dptmp >= 0)
                    {
                        tmp = Dp(dptmp) + 1;
                    }
                    ans = Math.Max(ans, tmp);
                }
                dp[m] = ans;
                return ans;
            }
        }
    }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;


int main() {
    ll n;
    cin >> n;
    ll div = 10LL, ans = 0LL;
    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        if(n < div) break;
        ans += floor((long double)n / div);
        div *= 5LL;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;



int main()
{
    godspeed
    string s;
    ll ans=0;
    //  ll  t,n,i,j;
    ll i,t,n,j,k,d,x,l;
    cin>>s;
    for(i=0;s[i];i++)
    {
        ans+=(s[i]-'0');
    }
    if(ans%9==0)
        cout<<"Yes"<<endl;
      else  cout<<"No"<<endl;


    return 0;
}





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

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索 """

    ok = mn
    ng = mx
    while ok+1 < ng:
        mid = (ok+ng) // 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

for _ in range(INT()):
    a, b, c, d = MAP()

    # そもそも無理
    if a < b or d < b:
        No()
        continue
    
    # b個減ってd個増える繰り返しなので、このgより細かく値が動くことはない
    g = gcd(b, d)

    # cより大きくてb未満が存在するかどうか
    mn = bisearch_min(-INF, INF, lambda m: a%g + g*m > c)
    mx = bisearch_max(-INF, INF, lambda m: a%g + g*m < b)
    if mn > mx:
        Yes()
    else:
        No()


Measured memory_bytes: 5168
n = input()
int_n = int(n)
# len(n)桁のうち、オール9、もしくは1つを除いて9、が答え候補。候補を全探索

le = len(n)
nines = 10 ** le - 1
if nines == int_n:
    print(le*9)
    exit()

ans = 0

for i in range(le):
    for dif in range(1, 10):
        candi = nines - dif * 10 ** i
        if 9 * le - dif >= ans and candi <= int_n:
            ans = 9 * le - dif

print(ans)


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

int x[100010]={0};

int main(void){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		x[a]++;
		x[a+1]++;
		x[a+2]++;
	}

	sort(x, x+100010);
	reverse(x, x+100010);
	cout << x[0] << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long[] x = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
        }
        long ans = 0L;
        for (int i = 1; i < n; i++) {
            long d = x[i] - x[i-1];
            ans += Math.min(a*d, b);
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 50356
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<complex>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<ll> x(n);
	vector<ll> y(n);
	vector<ll> z(n);
	REP(i,n) cin>>x[i]>>y[i]>>z[i];
	ll ans=-INF*INF;
	REP(i,2) {
		REP(j,2) {
			REP(k,2) {
				priority_queue<ll> q;
				REP(l,n) {
					ll sum=0;
					if(i==0) sum+=x[l];
					else sum-=x[l];
					if(j==0) sum+=y[l];
					else sum-=y[l];
					if(k==0) sum+=z[l];
					else sum-=z[l];
					q.push(sum);
				}
				ll buf=0;
				REP(l,m) {
					buf+=q.top();
					q.pop();
				}
				ans=max(ans,buf);
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
              int a,b,c;
              scanf("%d%d%d",&a,&b,&c);
               int ispoor=0;
               if(a==b && b!=c) ispoor=1;
               if(b==c && c!=a) ispoor=1;
               if(c==a && a!=b) ispoor=1;
               if(ispoor){
                         puts("Yes");
                }else{
                         puts("No");
                }
                return 0;
}
        

Measured memory_bytes: 128
from collections import Counter

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

cnt = Counter(prime_factorize(n))
z = []
for k, v in cnt.items():
    for i in range(1, v+1):
        z.append(k**i)
z = list(set(z))
z.sort()

ans = 0
for pe in z:
    if n%pe == 0:
        n /= pe
        ans += 1
print(ans)

Measured memory_bytes: 9536
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

import numpy as np

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

c = 0

def div(a):
    global c
    for i in a:
        if i%2==1:
            print(c)
            sys.exit()

    ll = list(map(lambda x : x/2, a))
    c += 1
    div(ll)

div(a)


Measured memory_bytes: 12388
#include <stdio.h>
int main(void){
    int n,d;
    scanf("%d%d",&n, &d);
    int range = d*2+1;
    int count = 0;
    int tmp = n;
    while(tmp>0){
        tmp = tmp -range;
        count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
 
int main(int argc, char **argv) {
	cin >> n;
	int res = 1;
	while (res * 2 <= n) res *= 2;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
struct dsu
{
	vector<lli>par;
	vector<lli>s;
	lli n;
	dsu(){}
	dsu(int _n)
	{
		n=_n;
		par.assign(n+1,0);
		s.assign(n+1,0);
		for(lli i=0;i<=n;i++)
		{
			par[i]=i;
			s[i]=1;
		}
	}
	lli find(lli k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
	void unite(lli u,lli v)
	{
		lli p1=find(u);
		lli p2=find(v);
		if(p1==p2)
			return;
		if(s[p1]>=s[p2])
		{
			s[p1]+=s[p2];
			par[p2]=p1;
		}
		else
		{
			s[p2]+=s[p1];
			par[p1]=p2;
		}
	}
};
int main()
{
		#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	lli n,m;
	cin>>n>>m;
	vector<plli>vec(m);
	dsu uf(n);
	fr(i,m)
	{
		lli x,y;
		cin>>x>>y;
		vec[i]={x,y};
		uf.unite(x,y);
	}
	lli comp=0;
	lli mx=0;
	fr(i,n)
	{
		if(uf.find(i+1)==i+1)
		{
			mx=max(mx,uf.s[i+1]);

		}

	}
	cout<<mx<<endl;


	
	
	
	
}


Measured memory_bytes: 9532
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	s = input()
	t = input()
	if s == t:
		return n
	for i in range(1, n+1):
		r = s + t[-i:]
		if r[-n:] == t:
			return i+n
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<iomanip>
#include<cctype>
#include<climits>
#include<queue>
#include<utility>
#include<functional>
#include<memory>
using namespace std;
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

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

  int a, b, c;
  
  cin >> a >> b >> c;
  map< int, int > cnt;
  cnt[a]++;
  cnt[b]++;
  cnt[c]++;

  if (cnt[5] == 2 && cnt[7] == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import queue
h,w=map(int,input().split())
m=[]
block=0
for i in range(h):
    m.append(list(input()))
    block+=m[-1].count('#')
q=queue.Queue()
q.put((0,0))
m[0][0]=0
while not q.empty():
    i,j=q.get()
    if i+1<h and m[i+1][j]=='.':
        m[i+1][j]=m[i][j]+1
        q.put((i+1,j))
    if i-1>=0 and m[i-1][j]=='.':
        m[i-1][j]=m[i][j]+1
        q.put((i-1,j))
    if j+1<w and m[i][j+1]=='.':
        m[i][j+1]=m[i][j]+1
        q.put((i,j+1))
    if j-1>=0 and m[i][j-1]=='.':
        m[i][j-1]=m[i][j]+1
        q.put((i,j-1))
if m[h-1][w-1]=='.':
    print(-1)
else:
    print(h*w-m[h-1][w-1]-block-1)



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

using namespace std;

typedef long long ll;

ll n, x, y;
ll d[2005][2005];
ll ans[2005];

int main()
{
    scanf("%lld%lld%lld", &n, &x, &y);
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            d[i][j] = max(i - j, j - i);
        }
    }
    d[x][y] = d[y][x] = 1;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            d[i][j] = min(d[i][j], d[i][x] + d[x][j]);
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            d[i][j] = min(d[i][j], d[i][y] + d[y][j]);
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = i + 1; j <= n; j++)
        {
            ans[d[i][j]]++;
        }
    }
    for(ll i = 1; i < n; i++)
    {
        printf("%lld\n", ans[i]);
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  ll n, k;
  cin >> n >> k;

  ll a = n % k;

  rep(i, 10) {
    a = min(a, abs(a - k));
  }

  cout << a << endl;

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
E = list([list(map(int, input().split())) for _ in range(M)])

E = sorted(E, key=lambda x: x[1])

removed = -1
ret = 0

for e in E:
    if e[0] > removed:
        ret += 1
        removed = e[1] - 1

print(ret)


Measured memory_bytes: 29664
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int t; cin >> t;
	while (t--) {
		int X, Y, B, P;
		cin >> X >> Y >> B >> P;
		int ans = X * B + Y * P;
		chmax(B, 5LL);
		chmax(P, 2LL);
		chmin(ans, (int)(0.8 * (X * B + Y * P)));
		cout << ans << endl;

	}

	return 0;
}




Measured memory_bytes: 3172
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int first = 0;
    int second = 0;
    int third = 0;

    while (sc.hasNext()) {
      int m = sc.nextInt();
      if (m > first) {
        third = second;
        second = first;
        first = m;
      } else if (m > second) {
        third = second;
        second = m;
      } else if (m > third) {
        third = m;
      }
    }

    System.out.println(first);
    System.out.println(second);
    System.out.println(third);
  }
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(h.at(i)>=k)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 640
Q = int(input())

ans = []
for _ in range(Q):
    A, B = map(int, input().split())

    if A == B:
        ans.append(2 * A - 2)
        continue

    C = (A * B)**0.5
    D = int(C)

    if D**2 == A * B:
        D -= 1

    F = 2 * D - 1
    if D * (D + 1) >= A * B:
        F -= 1

    ans.append(F)

print(*ans, sep='\n')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new long[n];
            var r = ReadSplit();
            var total = 0L;
            for (int i = 0; i < n; i++)
            {
                l[i] = r[i].Long();
                if (total == 0)
                {
                    total = l[i];
                }
                else
                {
                    total = total ^ l[i];
                }
            }
            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                sb.Append(total ^ l[i]);
                sb.Append(" ");
            }
            WriteRead(sb.ToString());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n= sc.nextInt();
        int c=0;
        for (int i=1;i<n;i++){
            for (int j=1;j<n;j++){
                if ((i*j)<n)
                    c++;
                else
                    break;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 36324
#include <cstdio>

char s[100005];

int main() {
	int n, a, b, aa = 0, bb = 0;
	scanf("%d%d%d%s", &n, &a, &b, s);
	for(int i = 0;i < n;i++) {
		if(s[i] == 'c') puts("No");
		else if(s[i] == 'a') {
			if(aa + bb < a + b) {
				puts("Yes");
				aa++;
			}
			else puts("No");
		}
		else {
			if(aa + bb < a + b and bb < b) {
				puts("Yes");
				bb++;
			}
			else puts("No");
		}
	}
}


Measured memory_bytes: 640