akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}
vector<ll> mFacts, mInvFacts;
ll modFact(int n){ return mFacts[n]; }
ll modInvFact(int n){ return mInvFacts[n]; }
ll modInv(int n, ll m){ return modPow(n, m - 2, m); }
ll modC(int n, int k, ll m){ return modFact(n) * modInvFact(k) % m * modInvFact(n - k) % m; }
void init(int n, ll m){
    mFacts.resize(n + 1);
    mInvFacts.resize(n + 1);
    mFacts[0] = 1;
    for(int i = 1; i <= n; i++){
        mFacts[i] = mFacts[i - 1] * i % m;
    }
    mInvFacts[n] = modInv(mFacts[n], m);
    for(int i = n - 1; i >= 0; i--){
        mInvFacts[i] = mInvFacts[i + 1] * (i + 1) % m;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    init(1e6, M);
    int n, m;
    cin >> n >> m;
    map<int, int> fs;
    int last = sqrt(m);
    for(int i = 2; i <= last; i++){
        while(m % i == 0){
            fs[i]++;
            m /= i;
        }
    }
    if(m > 1){
        fs[m]++;
    }
    printde(fs);
    ll ans = 1;
    for(auto& p : fs){
        ans = ans * modC(n - 1 + p.second, p.second, M) % M;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 16508
import java.util.*;
class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		sc.close();

		x = x ^ y;
		y = x ^ y;
		x = x ^ y;

		x = x ^ z;
		z = x ^ z;
		x = x ^ z;

		System.out.println(x + " " + y + " " + z);
	}
}

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

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

  int ans = 0;
  for (int i = 1; i < N; ++i) {
    string X = S.substr(0, i);
    string Y = S.substr(i);

    map<char, int> m;
    rep(j, X.size()) {
      m[X[j]] = 1;
    }

    int count = 0;
    rep(j, Y.size()) {
      if (m[Y[j]] == 1) {
        count++;
        m[Y[j]]++;
      }
    }

    ans = max(ans, count);
  }

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

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int main(){
    
    int N, M, v[1005];
    scanf("%d %d ", &N, &M);
    
    double voto = 0;
    
    for (int i = 0; i < N; ++i){
        scanf("%d", &v[i]);
        
        voto += v[i]; 
    }
    
	double coisa = voto/(4*M);
	int a = 0, certo = 0;
    
    for (int j = 0; j < N; ++j){
        if (v[j] >= coisa)
		    a += 1;

	    if (a == M){
		    certo = 1;
		    break;
	    }
    }
    

    if (certo == 1)
        printf("Yes\n");
    else 
        printf("No\n");

    return 0;
}

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

int main(){
	int n,b,f,r,v;  //??¶????\????????????¨?±?????????°
	int a[4][3][10]={0};
	int i,j,x,y;
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(x=0;x<10;x++)
					cout<<" "<<a[i][j][x];
			cout<<endl;
		}
		if(i==3)
			break;
		cout<<"####################\n";
	}
}
	

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
     int n;
     cin>>n;
     int a[n];
     int ct[100005]={0};
     for(int i=0;i<n;i++){cin>>a[i];ct[a[i]]++;}
     int res=0;
     for(int i=0;i<n;i++)
     {
          res+=max(0,ct[a[i]]-1);
          ct[a[i]]=-1;
     }
     if(res%2)res++;
     cout<<n-res;
     

}















 














 
 

















Measured memory_bytes: 1024
N, M = map(int, raw_input().split())
a = []
b = []
for i in range(N):
    _a, _b = map(int, raw_input().split())
    a.append(_a)
    b.append(_b)
c = []
d = []
for i in range(M):
    _c, _d = map(int, raw_input().split())
    c.append(_c)
    d.append(_d)

dist = [[float("inf")] * M for i in range(N)]
for i in range(N):
    for j in range(M):
        dist[i][j] = abs(a[i] - c[j]) + abs(b[i] - d[j])
for i in range(N):
    print dist[i].index(min(dist[i])) + 1



Measured memory_bytes: 6144
def main():
    n = int(input())
    a = 0
    b = 0
    c = 0

    for i in range(n):
        aa,bb,cc = map(int,input().split())
        a,b,c = max(b,c)+aa, max(a,c)+bb, max(a,b)+cc

    print(max(a,b,c))

main()


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

	long long m = 0, a = 0, r = 0, c = 0, h = 0;

	REP(i, n) {
		cin >> str;
		if (str[0] == 'M') {
			m++;
		}
		if (str[0] == 'A') {
			a++;
		}
		if (str[0] == 'R') {
			r++;
		}
		if (str[0] == 'C') {
			c++;
		}
		if (str[0] == 'H') {
			h++;
		}
	}
 
	long long ans;
	
	ans = m * a * r + m * a * c+ m * a * h + m * r * c +  m * r * h + m * c * h + a * r * c +a * r * h + a * c * h + r * c * h;

	ANS(ans);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[3000],mem[3000][3000];
int n;
double rec(int index,int cnt)
{
    if(cnt>n/2)
        return 0;
    if(index==n)
        return 1;
    if(mem[index+1][cnt]==-1.0)
    mem[index+1][cnt]=rec(index+1,cnt);
    if(mem[index+1][cnt+1]==-1.0)
    mem[index+1][cnt+1]=rec(index+1,cnt+1);
    return a[index]*mem[index+1][cnt] + (1-a[index])*mem[index+1][cnt+1];
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int j=0;j<3000;j++)
        for(int i=0;i<3000;i++)
        mem[j][i]=-1.0;
cout<<fixed<<setprecision(9)<<rec(0,0);
return 0;
}

Measured memory_bytes: 70784
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
  s[i], t[i] = map(str, input().split())
t = [int(s) for s in t]
x = input()

total_t = sum(t)
end = s.index(x)
total_ex = sum(t[0:end+1])

print(total_t - total_ex)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint a(n);
  for(auto&& e:a) cin>>e;
  vecint b(n+1);
  for(auto&& e:a) {
    ++b[e];
  }
  boost::sort(b);
  vecint ps(n+1);
  boost::partial_sum(b, begin(ps));
  vecint num(n+1);
  int j = 0;
  for(auto&& i:irange(1,n+1)) {
    while (j <= n && b[j] <= i) ++j;
    int sum = ps[j-1] + (n+1-j) * i;
    num[i] = sum / i;
  }
  vecint res(n+1);
  for(auto&& i:irange(0,n+1)) {
    res[num[i]] = i;
  }
  for(int i=n-1; i>=0; --i) {
    res[i] = max(res[i], res[i+1]);
  }
  for(auto&& i:irange(1,n+1)) {
    cout<<res[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}


vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b;
    vector<ll> c(1000010,0);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(),a.end());
    
    //b.push_back(a[0]);
    
    for(ll i=0;i<n;i++){
        if(i!=n-1){
            if(a[i+1]!=a[i]){
                b.push_back(a[i]);
            }else{
                c[a[i]]=1;
                while(i!=n-1){
                    if(a[i+1]!=a[i]) break;
                    i++;
                }
            }
        }else{
            b.push_back(a[i]);
        }
    }
    
    sort(b.begin(),b.end());
    
    for(ll i=0;i<b.size();i++){
        vector<ll> aaa;
        aaa=divisor(b[i]);
        /*
        for(int j=0;j<aaa.size();j++){
            cout << aaa[j] << " ";
        }
        cout << endl;
        */
        bool flag=true;
        for(ll j=0;j<aaa.size();j++){
            if(c[aaa[j]]==1){
                flag=false;
            }
        }
        if(flag){
            ans++;
            //cout << i << endl;
        }
        c[b[i]]=1;
    }
    
    cout << ans << endl;
    
    return 0;
}











Measured memory_bytes: 14564
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    nok=0
    for i in range(N):
        if a[i]==nok+1:
            nok+=1
#        print("#",i,nok)
    print(-1 if nok==0 else N-nok)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26228
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
N = int(input())

P = factorization(N)

flag = 0

for i in range(len(P)):
  for j in range(40):
    P[i][1] = P[i][1] - (j + 1)
    if P[i][1] >= 0:
      flag += 1
    else:
      break
if N == 1:
  print(0)
else:
  print(flag)    

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

int main(){
	int a,b;
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0){
			break;
		}
		for(int i = 1; i <= a; i++){
			for(int j = 1; j <= b; j++){
				if(i == 1||j == 1||i == a||j == b){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
package main

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

type Node struct {
	link []([]int)
}

func getInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

var nodes []Node
var dArr []int

func dfs(nodeNum int) {
	for _, _v := range nodes[nodeNum].link {
		if _v[0] != 0 && dArr[_v[0]] <= 0 {
			dArr[_v[0]] = dArr[nodeNum] + _v[1]
			dfs(_v[0])
		}
	}
}

func main() {
	var n int
	var u, v, w int
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n = getInt(sc)

	// Init
	nodes = make([]Node, n)
	queue := make(chan int, n)
	dArr = make([]int, n)

	for i := 0; i < n-1; i++ {
		u = getInt(sc)
		v = getInt(sc)
		w = getInt(sc)
		// isContains := false
		// for _, _v := range nodes[u-1].link {
		// 	if _v[0] == v-1 {
		// 		isContains = true
		// 		break
		// 	}
		// }
		// if isContains {
		// 	continue
		// }
		nodes[u-1].link = append(nodes[u-1].link, []int{v - 1, w})
		nodes[v-1].link = append(nodes[v-1].link, []int{u - 1, w})
	}

	queue <- 0

	for len(queue) > 0 {
		cur := <-queue
		for _, _v := range nodes[cur].link {
			if _v[0] != 0 && dArr[_v[0]] <= 0 {
				dArr[_v[0]] = dArr[cur] + _v[1]
				queue <- _v[0]
			}
		}
	}

	// dfs(0)

	for _, _v := range dArr {
		// fmt.Print(_v)
		// fmt.Print(" : ")
		if _v%2 == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
	}
}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    if(K > (n - 1) * (n - 2) / 2){
        cout << "-1\n";
        return 0;
    }
    vector<P> vec;
    rep(i,n-1){
        vec.emplace_back(i, n-1);
    }
    int rem = (n - 1) * (n - 2) / 2 - K;
    rep(i,n-1){
        if(rem <= n-2-i){
            rep(j,rem){
                vec.emplace_back(i, i + j + 1);
            }
            break;
        }else{
            rem -= n-2-i;
            rep(j,n-2-i){
                vec.emplace_back(i, i + j + 1);
            }
        }
    }
    cout << (int)vec.size() << "\n";
    for(auto& p : vec){
        cout << p.fi + 1 << " " << p.se + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
string s, t;
cin >> s >> t;
int a = t.size();
string p = t.erase(a - 1);
if(s == p){
	cout << "Yes" << '\n';
	}
else{
	cout << "No" << '\n';
	}
return 0;
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
//        N = 200_000;


        boolean[] seen = new boolean[1000_002];
        Set<Integer> a = new ConcurrentSkipListSet<>();

        Set<Integer> toRemove = new TreeSet<>();

        for (int i = 0; i < N; ++i) {
            int x = fs.nextInt();
//            int x = i + 1;
            if (a.contains(x)) {
                toRemove.add(x);
            }
            a.add(x);
            seen[x] = false;
        }


        for (Iterator<Integer> it = a.iterator(); it.hasNext(); ) {
            int num = it.next();
            if (seen[num]) {
                continue;
            }
            seen[num] = true;
            int start = num;
            for (int j = start + num; j <= 1000_001; j += num) {
                if (a.contains(j)) {
                    a.remove(j);
                }
            }
        }

        for (int el: toRemove) {
            a.remove(el);
        }


        System.out.println(a.size());
   }
}


Measured memory_bytes: 72724
import heapq

N, M = map(int, input().split(" "))
A = [-int(_) for _ in input().split(" ")]

heapq.heapify(A)

for i in range(M):
    heapq.heappush(A, -(-heapq.heappop(A)// 2))
    
print(-sum(A))

Measured memory_bytes: 14180
import sys
from collections import Counter
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
MOD = 10**9+7
CA = Counter(A)
ans = 0
if N % 2 == 0:
    if all(CA[2*i+1] == 2 for i in range(N//2)):
        ans = pow(2, N//2, MOD)
else:
    if CA[0] == 1 and all(CA[2*i+2] == 2 for i in range(N//2)):
        ans = pow(2, N//2, MOD)
print(ans)

Measured memory_bytes: 55516
// n×mの行列Aとm×1の列ベクトルbを読み込み、Aとbの積 c(n×1)を出力するプログラム

#include <cstdio>
 
int main(){
    int n, m, sum;
    scanf("%d%d",&n,&m);
    int a[n][m],b[m],c[n];
    int i,j;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d",&b[i]);
    }
    for(i = 0; i < n; i++){
        c[i] = 0;
        for(j = 0; j < m; j++){
            c[i] = c[i] + a[i][j] * b[j];
        }
    }
    for(int i = 0; i < n; i++){
        printf("%d\n",c[i]);
    }
    return 0;
}


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

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');

        int n;
        n = int.Parse(input[0]);
        string[] s = new string[n];
        int t = 0;
        int ans = 0;
        int x = 0;
        int y = 0;
        int z = 0;

        for (int i = 0; i < n; i++)
        {
            s[i] = Console.ReadLine();
            t = s[i].Length;
            for (int j = 1; j < t; j++)
            {
                if (s[i][j - 1] == 'A' && s[i][j] == 'B') ans++;
            }
            if (s[i][0] == 'B')
            {
                if (s[i][t - 1] == 'A') z++;
                else y++;
            }
            else
            {
                if (s[i][t - 1] == 'A') x++;
            }
        }
        DebugWL(x + " " + y + " " + z);
        bool f = false;
        if (x == 0 && y == 0) f = true;

        t = Math.Min(x, y);
        ans += t;
        x = Math.Max(x - t, 0);
        y = Math.Max(y - t, 0);

        t = Math.Max(x, y);
        ans += Math.Min(z, t);
        if (z > t)
        {
            ans += z - t;
            if (f && ans > 0) ans--;
        }

        Console.WriteLine(ans);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 13228
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin>>n;
	unordered_map<string, int> map;
	ll ans=0;
	rep(i,n){
		string s;
		cin>>s;
		sort(&s[0],&s[s.length()]);
		if(map.find(s) != map.end()){
			ans+=map.at(s);
			map[s]++;
		}
		else map[s]=1;
	}

	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 10660
#include<cstdio>
long long abs(long long x){
    if(x<0)
        return -x;
    else
        return x;
}
int main(){
    long long x,y;
    scanf("%lld%lld",&x,&y);
    long long b=abs(x-y);
    if(b<=1){
        printf("Brown\n");
    }
    else{
        printf("Alice\n");
    }
    return 0;
}


Measured memory_bytes: 128
while True:
    rec = list(map(int,input().split(" ")))
    if rec[0] ==0 and rec[1] ==0: break
    for i in range(rec[0]):
        for j in range(rec[1]):
            if i !=0 and i != rec[0]-1 and  j != 0 and j != rec[1]-1:
                print(".",end="")
            else:
                print("#",end="")
        print("")
    print("")

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

typedef long long ll;

using namespace std;

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

const int INF = 1 << 10;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> s.at(i).at(j);
  // グラフ作成
  int cur = 0;
  int n = 0;
  vector<vector<int>> temp(h, vector<int>(w, -1));
  rep(i, h) {
    rep(j, w) {
      if (s.at(i).at(j) == '.') {
        temp.at(i).at(j) = cur++;
        n++;
      }
    }
  }
//  // デバッグ出力
//  cout << "temp" << endl;
//  rep(i, h) {
//    rep(j, w) {
//      if (j != 0) {
//        cout << ",";
//      }
//      cout << temp.at(i).at(j);
//    }
//    cout << endl;
//  }
  vector<vector<int>> G(n, vector<int>());
  rep(i, h) {
    rep(j, w) {
      int ij = temp.at(i).at(j);
      if (ij == -1) {
        continue;
      }
      rep(k, 4) {
        int nx = j + dx[k];
        int ny = i + dy[k];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
          continue;
        }
        int z = temp.at(ny).at(nx);
        if (z == -1) {
          continue;
        }
        G.at(ij).push_back(z);
      }
    }
  }
//  // デバッグ出力
//  cout << "G" << endl;
//  rep(i, n) {
//    rep(j, G.at(i).size()) {
//      if (j != 0) {
//        cout << ",";
//      }
//      cout << G.at(i).at(j);
//    }
//    cout << endl;
//  }
  // コスト計算
  vector<vector<int>> c(n, vector<int>(n, INF)); // コスト1で初期化
  rep(i, n) {
    rep(j, n) {
      if (i != j) {
        continue;
      }
      c.at(i).at(j) = 0;
    }
  }
  rep(i, n) {
    for (int x : G.at(i)) {
      c.at(i).at(x) = 1;
    }
  }
//  // デバッグ出力
//  cout << "cost" << endl;
//  rep(i, n) {
//    rep(j, n) {
//      if (j != 0) {
//        cout << ",";
//      }
//      int v = c.at(i).at(j);
//      if (v == INF) {
//        cout << "INF";
//      } else {
//        cout << v;
//      }
//    }
//    cout << endl;
//  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
      }
    }
  }
//  // デバッグ出力
//  cout << "cost2" << endl;
//  rep(i, n) {
//    rep(j, n) {
//      if (j != 0) {
//        cout << ",";
//      }
//      cout << c.at(i).at(j);
//    }
//    cout << endl;
//  }
  // 出力のために最大値を取得
  int res = 0;
  rep(i, n) {
    rep(j, n) {
      res = max(res, c.at(i).at(j));
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4224
// C - Same Integers
// https://atcoder.jp/contests/abc093/tasks/arc094_a
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b >> c;
  ans = a + b + c;
  vlli d = {a, b, c};
  SORTR(d);
  k = d[0] * 3;
  count = k - ans;
  if (count % 2 == 0)
  {
    count /= 2;
    cout << count << endl;
  }
  else
  {
    count = (count + 1) / 2 + 1;
    cout << count << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int sz = S.size();

  if (N >= sz)
    cout << S << endl;
  else
    cout << S.substr(0, N) << "..." << endl;
}

Measured memory_bytes: 3632
//D - Knapsack 1

#include <iostream>
using namespace std;

class Item{
private:
public:
  int weight, value;
};

int main() {
  int n, max_weight;
  cin >> n >> max_weight;
  Item item[n];
  int w, v;
  long long dp[n][max_weight+1];

  for (int i = 0; i < n; i++) {
    cin >> w >> v;
    item[i].weight = w;
    item[i].value = v;
  }

  //初期化
  for (int i = 0; i < n; i++){
    for (int w = 0; w < max_weight+1; w++){
      if (w - item[i].weight >= 0){
        dp[i][w] = item[i].value;
      } else {
        dp[i][w] = 0;
      }
    }
  }

  for (int i = 1; i < n; i++) {
    for (int w = 1; w < max_weight+1; w++) {
      dp[i][w] = dp[i-1][w];
      if (w - item[i].weight >= 0) {
        dp[i][w] = max(dp[i][w], dp[i - 1][w - item[i].weight] + item[i].value);
      }
    }
  }
  cout << dp[n-1][max_weight]<< endl;
}

Measured memory_bytes: 78336
#include<cstdio>
#include<vector>


using namespace std;
using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n);
		int ans=0;

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

		printf("%s\n", ans?"first":"second");
	}

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

    int n = sc.nextInt();
    String s = sc.next();
    char[] colors = s.toCharArray();

    char color = colors[0];
    StringBuilder res = new StringBuilder("" + colors[0]);
    for (int i = 1; i < colors.length; i++) {
      if (colors[i] != color) {
        res.append(colors[i]);
        color = colors[i];
      }
    }
    String resStr = res.toString();
    System.out.println(resStr.length());
  }
}


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

using namespace std;

class LowLink
{
    using Graph = std::vector<std::vector<int>>;
    using P = std::pair<int, int>;
    std::vector<int> order;
    int next = 0;
    Graph G;
    std::set<P> bridges;

    void add(int a, int b)
    {
        bridges.insert(P(min(a, b), max(a, b)));
    }
    int dfs(int cur, int pre)
    {
        int res = order[cur] = next++;
        for (const auto &to : G[cur])
        {
            if (to == pre)
                continue;
            if (order[to] >= 0)
                res = std::min(res, order[to]);
            else
            {
                int low = dfs(to, cur);
                if (low > order[cur])
                    add(cur, to);
                res = std::min(res, low);
            }
        }
        return res;
    }

  public:
    LowLink(int _v) : G(_v, std::vector<int>()), order(_v, -1) {}
    void addEdge(int s, int t)
    {
        G[s].push_back(t);
    }
    std::set<P> bridge()
    {
        dfs(0, -1);
        return bridges;
    }
};

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

    int V, E;
    cin >> V >> E;
    LowLink link(V);
    while (E--)
    {
        int s, t;
        cin >> s >> t;
        link.addEdge(s, t);
        link.addEdge(t, s);
    }
    auto st = link.bridge();
    for (auto p : st)
    {
        cout << p.first << " " << p.second << endl;
    }
}



Measured memory_bytes: 4568
#include<stdio.h>
void gcd(int,int);

int main(){
  int x,y,z;

  scanf("%d %d",&x,&y);
  if(x<y){
    z=y;
    y=x;
    x=z;
  }
  gcd(x,y);

  return 0;
}
void gcd(int x,int y){
  int z=y;
  while(z!=0){
    y=z;
    z=x%y;
    x=y;
  }
  printf("%d\n",y);
}



Measured memory_bytes: 2140
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int p;
  int cnt = 0;
  rep(i,n){
    cin >> p;
    if(p != i+1) cnt++;
  }
  if(cnt <= 2) printf("YES\n");
  else printf("NO\n");
  return 0;
}


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

int main(void){
    int n;string a,b,c;
    cin >> n >> a >> b >> c;
    int sum = 0;
    for(int i = 0;i < n;i++){
        int num = 0;
        if(a[i] == b[i])num++;
        if(a[i] == c[i])num++;
        if(b[i] == c[i])num++;
        if(num < 3)sum += 2-num;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		String signboard = "CODEFESTIVAL2016";
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		
		if (S.length() != signboard.length()) throw new IllegalArgumentException();
		
		int replace = 0;
		for(int i=0; i<S.length(); i++)
		{
			if (S.charAt(i) != signboard.charAt(i))
			{
				replace++;
			}
		}
		System.out.println(replace);
	}

}

Measured memory_bytes: 9680
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func upperBound(a []int, x int, n int) int {
	l := 0
	h := n
	for l < h {
		mid := (l+h)/2
		if x >= a[mid] {
			l = mid + 1
		} else {
			h = mid
		}
	}
	return l
}

func lowerBound(a []int, x int, n int) int {
	l := 0
	h := n
	for l < h {
		mid := (l + h)/2
		if x <= a[mid] {
			h = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// func binarySearch(target int, ints []int) bool {
// 	low := 0
// 	high := len(ints)-1
// 	for low <= high {
// 		mid := (low + high)/2
// 		guess := ints[mid]
// 		if guess == target {
// 			return true
// 		}
// 		if guess > target {
// 			high = mid - 1
// 		} else {
// 			low = mid + 1
// 		}
// 	}
// 	return false
// }

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	q := nextInt()
	for i := 0; i < q; i++ {
		k := nextInt()
		fmt.Printf("%d %d\n", lowerBound(a, k, n), upperBound(a, k, n))
	}
}



Measured memory_bytes: 5900
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    uint64_t A;
    long double B;
    cin >> A >> B;
    uint64_t result = A * B;
    cout << result;
    return 0;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <algorithm>
using namespace std;
static long long int num[200010];
long long int a[200010],b[200010];
long long int i,n;
long long int sum=0;
long long int temp;
int main()
{
    for(i=0;i<200001;i++)
        a[i]=num[i]=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        num[a[i]]++;
    }
    for(i=0;i<n;i++)
        b[i]=a[i];
    sort(b,b+n);
    temp=-1;
    //for(i=0;i<n;i++)
        //printf("%lld %lld\n",a[i],num[a[i]]);
    for(i=0;i<n;i++)
    {
        if(b[i]!=temp)
        {
            sum+=num[b[i]]*(num[b[i]]-1)/2;
            temp=b[i];
        }
    }
    for(i=0;i<n;i++)
        printf("%lld\n",sum-(num[a[i]]-1));
    return 0;
}


Measured memory_bytes: 7168
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#define fi first
#define se second
using namespace std;

typedef pair<int, int> P;
const int MAXN = 1e3 + 5;

int vis[3 * MAXN][3 * MAXN];
int x1[MAXN], x2[MAXN], y1[MAXN], y2[MAXN];
int n, w, h;
int Next[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};

int compress(int *x1, int *x2, int w)
{
    vector<int> xs;

    for(int i = 0; i < n; i ++){
        for(int j = -1; j <= 1; j ++){
            if(1 <= x1[i] + j && x1[i] + j <= w) xs.push_back(x1[i] + j);
            if(1 <= x2[i] + j && x2[i] + j <= w) xs.push_back(x2[i] + j);
        }
    }

    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());

    for(int i = 0; i < n; i ++){
        x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }

    return xs.size();
}
int main()
{

    while(scanf("%d%d", &w, &h)){
        if(w + h == 0)
            break;
        memset(vis, 0, sizeof(vis));
        scanf("%d", &n);

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

        w = compress(x1, x2, w);
        h = compress(y1, y2, h);

        for(int i = 0; i < n; i ++)
            for(int j = x1[i]; j <= x2[i]; j ++)
                for(int k = y1[i]; k <= y2[i]; k ++)
                    vis[j][k] = 1;
/*for(int i = 0; i < h; i ++){
    for(int j = 0; j < w; j ++)
        cout << vis[j][i] << " ";
    cout <<endl;
}*/
        int ans = 0;

        for(int i = 0; i < w; i ++)
        for(int j = 0; j < h; j ++)
            if(!vis[i][j]){
                ans ++;

                queue<P> q;

                q.push(P(i, j));

                while(!q.empty()){
                    P p = q.front();
                    q.pop();
                    for(int i = 0; i < 4; i ++){
                        int tx = p.fi + Next[i][0], ty = p.se + Next[i][1];

                        if(0 <= tx && tx < w && 0 <= ty && ty < h && !vis[tx][ty]){
                            vis[tx][ty] = 1;
                            q.push(P(tx, ty));
                        }
                    }

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





Measured memory_bytes: 38684
package main

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


func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  txt := sc.Text()
  txtArr := strings.Split(txt, " ")
  N := make([]int, 3)
  for i, v := range txtArr {
    N[i], _ = strconv.Atoi(v)
  }
  if N[1]-N[0] == N[2]-N[1] {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}


Measured memory_bytes: 640
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define bublic public
#define kektor vector
#define x1 x1228
#define y1 y1228
#define pii pair<int, int>
#define pp pair
#define left left1
#define right right1
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rand() (rand() << 15 | rand())
 
using namespace std;
 
typedef long long ll;
 
const int maxn = 4e5, mod = 998244353, inf = 1e18;
const double eps = 1e-9, pi = acos(-1);
int n, a, b, k, ans = 0, power[maxn]; 

int add(int p1, int p2) {
	return (p1 + p2) % mod; 
}

int mul(int p1, int p2) {
	return (p1 * p2) % mod; 
}

int fp(int a, int b) {
    if (b == 0) return 1; 
    int tmp = fp(a, b / 2);
    tmp = mul(tmp, tmp); 
    if (b % 2) tmp = mul(a, tmp);
    return tmp;
}

int inv(int a) {
	return fp(a, mod - 2); 
}

int C_n_k(int n1, int k1) {
    return mul(power[n1], mul(inv(power[n1 - k1]), inv(power[k1])));
}

void solve() {
	cin >> n >> a >> b >> k; 
	power[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        power[i] = mul(power[i - 1], i);
    }
	for (int A = 0; A <= n; ++A) {
		int B = k - A * a;
		if (B < 0 || B % b != 0) continue;
		B /= b;
		if (B > n) continue; 
		ans = add(ans, mul(C_n_k(n, A), C_n_k(n, B)));
	}
	cout << ans; 
}             
 
signed main() {
    //  freopen("bricks.in", "r", stdin);
    //  freopen("bricks.out", "w", stdout);
    #ifdef offline_judge
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif
    srand(228);
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}   

Measured memory_bytes: 3328
n,m=map(int,input().split())
ab=[]
for i in range(n):
  a,b=map(int,input().split())
  ab.append((a,b))
cd=[]
for i in range(m):
  c,d=map(int,input().split())
  cd.append((c,d))

ans=-1

for (a,b) in ab:
  f=10**9
  for i,(c,d) in enumerate(cd):
    distance=abs(a-c)+abs(b-d)
    if f>distance:
      f=distance
      ans=i+1
    #print(distance)
  print(ans)

Measured memory_bytes: 3064
import java.util.*;
//System.out.println("")

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(); 
        int b = sc.nextInt(); 
        int c = sc.nextInt(); 
        int d = sc.nextInt(); 
        int e = sc.nextInt(); 
        int f = sc.nextInt(); 
        double max = -1;
        int max_sugar = 0;
        int max_sum = 0;
        
        for(int s=0; 100*s*a<=f; s++){
            for(int t=0; 100*t*b<=f; t++){
                int meltable_sugar = (a*s + b*t) * e; 
                int sum_water = 100*s*a + 100*t*b;
                
                for(int u=0; u*c<=f; u++){
                    for(int v=0; v*d<=f; v++){
                        int sum_sugar = c*u + d*v;
                        int sum = sum_sugar + sum_water;
                        if(sum_sugar > meltable_sugar) continue;
                        if(sum > f) continue;
                        if(max < 100 * sum_sugar / (double)sum){
                            max = 100 * sum_sugar / (double)sum;
                            max_sugar = sum_sugar;
                            max_sum = sum;
                        }
                    }
                }
            }
        }
        System.out.println(max_sum +" "+ max_sugar);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int N;
	scanf("%d",&N);

	int tmp;
	int num_2 = 0,num_4 = 0,num_odd = 0;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		if(tmp%2 == 0){
			if(tmp%4 == 0){

				num_4++;
			}else{

				num_2++;
			}
		}else{

			num_odd++;
		}
	}


	if(num_2 == 0){

		if(num_4 >= num_odd-1){

			printf("Yes\n");

		}else{

			printf("No\n");
		}

	}else{ //num_2 > 0

		//2,2,2,,4,3,4,3,..

		if(num_odd == 0){

			printf("Yes\n");

		}else{

			if(num_4 >= num_odd){

				printf("Yes\n");
			}else{

				printf("No\n");
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int M = max(max(A, B), C);
    cout << (M * 9 + A + B + C) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main() {
	int prime[10000];
	int i,j,k,n;
	prime[0]=prime[1]=2;


	for(i=2;j<10000;i++){
		for(k=0;k<j;k++){
			if(i%prime[k]==0)break;
		}
		if(k>=j){
			prime[j]=i;
			j++;
		}
	}
	
	for(i=1;i<10000;i++){
		prime[i]+=prime[i-1];	
	}
	
	while(1){
		scanf("%d", &n);
		if(n==0) break;
		printf("%d\n", prime[n-1]);
	}
	return 0;
}


Measured memory_bytes: 2100
import heapq
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    mx = -heapq.heappop(a)
    heapq.heappush(a, -(mx // 2))
print(-sum(a))

Measured memory_bytes: 14180
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,A;
	cin>>N>>A;
	cout << N*N-A << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    int p, q, r;

    cin >> p >> q >> r;

    cout << min(min(p + q, q + r), p + r);

    return 0;
}

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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return abs(a.X-b.X)<eps?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return a.Y==b.Y?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};


struct C{
  P p; D r;
  C(const P& p,D r):p(p),r(r){}
};

pair<P,P> crosspointCC(C c1,C c2) {
  P p1=c1.p,p2=c2.p;
  D r1=c1.r,r2=c2.r;
  P A = conj(p2-p1), B = (r2*r2-r1*r1-(p2-p1)*conj(p2-p1)), C = r1*r1*(p2-p1);
  P D1 = B*B-(D)4.0*A*C;
  P z1 = (-B+sqrt(D1))/((D)2.0*A)+p1, z2 = (-B-sqrt(D1))/((D)2.0*A)+p1;
  if(z2<z1)swap(z1,z2);
  return pair<P,P>(z1, z2);
}

vector<C> cs;

int main(){
  rep(i,2){
    D x,y,r;
    cin>>x>>y>>r;
    cs.push_back(C(P(x,y),r));
  }
  pair<P,P> res=crosspointCC(cs[0],cs[1]);
  printf("%.10Lf %.10Lf %.10Lf %.10Lf\n", res.fi.X,res.fi.Y,res.se.X,res.se.Y);
	return 0;
}

Measured memory_bytes: 3352