akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(void){
    string str;
    cin >> str;
    int out = 0;

    for(int i=0;i<4;i++){
    	if(str[i]=='+'){
    		out++;
    	}else if(str[i]=='-'){
    		out--;
    	}
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????°
		int num = Integer.parseInt(bf.readLine());
		
		//??????????´?
		int[] array = new int[num];
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		for(int i=0;i<num;i++){
			array[i]=Integer.parseInt(arrayString[i]);
		}		
		bubbleSort(array,num);
	}
	
	private static void bubbleSort(int[] array, int num) {
		boolean flag=true;
		int count=0;
		
		while(flag){
			flag=false;
			for(int i=num-1;i>=1;i--){
				if(array[i]<array[i-1]){
					int tmp=array[i];
					array[i]=array[i-1];
					array[i-1]=tmp;
					flag=true;
					count++;
				}
			}
		}
		
		for(int i=0;i<array.length;i++){
			System.out.printf("%d",array[i]);
			if(i!=array.length-1){
				System.out.printf(" ");
			}
		}
		System.out.println("");
		System.out.println(count);
	}
}

Measured memory_bytes: 24788
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class Main {

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

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		int[][] cnt = new int[N][N];
		for (int i = 0; i < M; ++i) {
			int L = sc.nextInt() - 1;
			int R = sc.nextInt() - 1;
			++cnt[L][R];
		}
		for (int i = N - 2; i >= 0; --i) {
			for (int j = 0; j < N; ++j) {
				cnt[i][j] += cnt[i + 1][j];
			}
		}
		for (int i = 1; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cnt[j][i] += cnt[j][i - 1];
			}
		}
		for (int i = 0; i < Q; ++i) {
			int p = sc.nextInt() - 1;
			int q = sc.nextInt() - 1;
			System.out.println(cnt[p][q]);
		}
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


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

void input(int*, int);

#define MAX 200100

int main()
{
	int k, n;
	int data[MAX];
	int sum, max;
	int i, m;
	int dif;

	sum = max = 0;

	scanf("%d %d", &k, &n);
	input(data,n);

	for (i = 0, m=i+1; i < n; i++,m++)
	{
		if (m == n)
			m = 0;

		dif = abs(data[i] - data[m]);
		sum += dif;

		if (max < dif)
			max = dif;
		
		data[i] += k;
	}

	printf("%d\n", sum - max);

	return 0;
}

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

Measured memory_bytes: 896
n = gets.to_i
a = gets.split.map(&:to_i)

x = 0
n.times do |i|
  if i.even?
    x += a[i]
  else
    x -= a[i]
  end
end

answer = []
last = x
answer << x
(n-1).times do |j|
  last = a[j] * 2 - last
  answer << last
end

puts answer.join(" ")

Measured memory_bytes: 14084
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin (aka white_space)
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    ll n,m;
    cin>>n>>m;
    map<ll,ll>mm;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        mm[i]=x;
    }
    vector<ll>adj[100005];
    for(int i=0;i<m;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    ll cnt=0;
    for(int i=1;i<=n;i++){
        ll now=mm[i];
        bool ok=1;
        for(int j=0;j<(int)adj[i].size();j++){
            if(mm[adj[i][j]]>=now) {
                ok=0;
                break;
            }
        }
        if(ok)cnt++;
    }
    cout << cnt <<endl;
    return 0;
}
///Alhamdulillah


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


void bfs(queue<pair<ll,ll>>& q,vector<list<ll>>& g, vector<ll>& flag){
    while(!q.empty()){
        ll f = q.front().first;
        ll x = q.front().second;
        q.pop();
        print("#",f,">",x)
        for(auto&& y: g[x]){
            print("$",x,">",y)
            if(flag[y] > flag.size()){
                flag[y] = x;
                q.push(pair<ll,ll>(x,y));
            }
        }
    }
    print(flag);
}

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

    ll n,m;

    cin >> n >> m;

    vector<list<ll>> g(n,list<ll>());
    vector<ll> flag(n,n+1);
    flag[0] = 0;
    
    for(int i=0; i<m; i++){
        ll a,b;
        cin >> a >> b;

        a--;b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<pair<ll,ll>> q;
    for(auto&& x : g[0]){
        q.push(pair<ll,ll>(0,x));
        flag[x] = 0;
    }

    bfs(q,g,flag);

    cout << "Yes" << endl;

    for(int i=1; i<n; i++)
        cout << flag[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 20556
S = input()
A,B,K = map(int,S.split())

if ((B+1-A)/2 >= K):
	for iA in range(A,A+K):
		print(iA)
	for iB in range((B-K+1),B+1):
  		print(iB)
       	
else:
  	for i in range(A,B+1):
	  	print(i)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<set>
#include<math.h>
using namespace std;

int N, M, C;
vector<int> B;
vector<int> pass;

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

    for(int i = 0; i < M; i++) B.push_back(0);

    int tmp;
    int score;

    for(int i = 0; i < M; i++) cin >> B[i];
    for(int i = 0; i < N; i++){
        score = C;
        for(int j = 0; j < M; j++){
            cin >> tmp;
            score += tmp * B[j];
        }
        if(score > 0) pass.push_back(0);
    }

    cout << pass.size() << "\n";

    return 0;
}

Measured memory_bytes: 256
Module Module1

    Sub main()
        Dim user1 = Split(Console.ReadLine(), " ")
        Dim target = user1(0)
        Dim yousosu As Long = CLng(user1(1))


        ' 本来であればここでの条件は不要
        If yousosu = 0 Then

            Console.WriteLine(target)
            Exit Sub
        End If

        Dim user2 = Split(Console.ReadLine(), " ")
        Dim lista2 As Long() = Array.ConvertAll(user2, Function(j As String) CLng(j))
        Dim suretsu = New List(Of Long)(lista2)

        Dim result As Long = target

        ' 対象値より減算し続け存在しないか、また同時に相対値のチェックも行う
        For i = 0 To Math.Floor(yousosu)

            'Console.WriteLine(i & ": " & (target - i).ToString & " , " & target + i & ", " & suretsu.Contains(target + i).ToString)

            If Not suretsu.Contains(target - i) Then
                'Console.WriteLine("★" & i)
                result = target - i
                Exit For
            ElseIf Not suretsu.Contains(target + i) Then
                'Console.WriteLine("☆" & i)
                result = target + i
                Exit For
            End If
        Next

        Console.WriteLine(result)
    End Sub
  end module

Measured memory_bytes: 28856
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int n = r * 100 + g * 10 + b;

        _out.println((n % 4 == 0 ? "YES" : "NO"));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21712
N, A, B = map(int, input().split())
L = list(map(int, input().split()))

num = [0 for x in range(N)]
total = [0 for x in range(N)]

for i, v in enumerate(L):
    for j in reversed(range(1, i + 1)):
        new_v = total[j - 1] + v
        if(new_v > total[j]):
            total[j] = new_v
            num[j] = num[j - 1]
        elif(new_v == total[j]):
            num[j] = num[j] + num[j - 1]

    if(v > total[0]):
        total[0] = v
        num[0] = 1
    elif(v == total[0]):
        num[0] = num[0] + 1

total = [x / (i + 1) for i, x in enumerate(total)]
total = total[(A - 1):B]
num = num[(A - 1):B]

maxV = max(total)
maxNum = sum([j for i, j in zip(total, num) if i == maxV])
print(maxV)
print(maxNum)


Measured memory_bytes: 3064
import sys
import itertools
import numpy as np

read = sys.stdin.read #標準入力から複数行取得するための関数です。 readlines() が結果を行単位で分割してリストで返すのに対して、 read() は結果をそのまま1つの文字列として取得します。
readline = sys.stdin.readline #標準入力から1行取得するための関数です。
readlines = sys.stdin.readlines #標準入力から複数行取得するための関数です。戻り値はリストで、入力された文字列が1行ずつ要素として格納されています。
# .bufferはbytes を返すのでさらに少しだけ速いようですが、あまり差はありません。

N = int(readline())
S = set(read().split())

print(len(S))

Measured memory_bytes: 56012
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n-k], fact[k]));
}



void solve()
{
    int n, k;
    cin >> n >> k;
    int i;
    int a[n];
    fori(i, 0, n)
        cin >> a[i];
    sort(a, a+n);
    int sum=0;
    fori(i, 0, k)
        sum+=a[i];
    cout << sum << endl;
}
signed main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        // cout << solve() << endl;
        solve();
    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.parseInt(br.readLine());
        for(int i=0;i<count;i++) {
            String[] line = br.readLine().split(" ");
            List<Integer> list = new ArrayList<Integer>();
            list.add(new Integer(line[0]));
            list.add(new Integer(line[1]));
            list.add(new Integer(line[2]));
            Collections.sort(list);
            double cor = Math.sqrt(Math.pow(list.get(0).doubleValue(),2) + Math.pow(list.get(1).doubleValue(),2)); 
            double ex  = list.get(2).doubleValue();
            if(cor == ex) System.out.println("YES");
            else  System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22372
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int a = Integer.parseInt(scan.next());
    		int b = Integer.parseInt(scan.next());
    		int c = Integer.parseInt(scan.next());
    		int[] abc= {a,b,c};
    		
    		int five=0;
    		int seven=0;
    		for(int i: abc) {
    			if (i==5) {
    				++five;
    			}else if(i==7){
    				++seven;
    			}
    		}
    		if (five==2 && seven==1) {
    			System.out.print("YES");
    		}else {
    			System.out.print("NO");
    		}
    }
     
    }

Measured memory_bytes: 20948
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << ' ' << 2*(a+b) << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    cout<<"Yes\n";
   else cout<<"No\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m; cin>>n>>m;
    vector<llong> x(n,0);
    vector<llong> y(n,0);
    vector<llong> z(n,0);
    REP(i,n) cin>>x[i]>>y[i]>>z[i];
    llong ans=0;
    vector<llong> a(n,0); //x+y+z
    vector<llong> b(n,0); //x+y-z
    vector<llong> c(n,0); //x-y+z
    vector<llong> d(n,0); //x-y-z
    vector<llong> e(n,0); //-x+y+z
    vector<llong> f(n,0); //-x+y-z
    vector<llong> g(n,0); //-x-y+z
    vector<llong> h(n,0); //-x-y-z
    REP(i,n)
    {
        a[i]=x[i]+y[i]+z[i];
        b[i]=x[i]+y[i]-z[i];
        c[i]=x[i]-y[i]+z[i];
        d[i]=x[i]-y[i]-z[i];
        e[i]=-x[i]+y[i]+z[i];
        f[i]=-x[i]+y[i]-z[i];
        g[i]=-x[i]-y[i]+z[i];
        h[i]=-x[i]-y[i]-z[i];
    }
    llong suma=0,sumb=0,sumc=0, sumd=0, sume=0, sumf=0, sumg=0, sumh=0;
    sort(a.begin(),a.end(),greater<llong>());
    sort(b.begin(),b.end(),greater<llong>());
    sort(c.begin(),c.end(),greater<llong>());
    sort(d.begin(),d.end(),greater<llong>());
    sort(e.begin(),e.end(),greater<llong>());
    sort(f.begin(),f.end(),greater<llong>());
    sort(g.begin(),g.end(),greater<llong>());
    sort(h.begin(),h.end(),greater<llong>());

    REP(i,m)
    {
        suma+=a[i];
        sumb+=b[i];
        sumc+=c[i];
        sumd+=d[i];
        sume+=e[i];
        sumf+=f[i];
        sumg+=g[i];
        sumh+=h[i];
    }
    ans=max({suma,sumb,sumc,sumd,sume,sumf,sumg,sumh});
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int read();
int n, m;
void Add(int &x, int y) { (x += y) >= m ? x -= m : y; }
struct P {
    int l, r;
} p[1003];
bool cmp(P a, P b) { return a.l == b.l ? a.r < b.r : a.l < b.l; }
bool check(int x, int y) {
    int t = x * x + y * y;
    return t >= n * n && t <= 4 * n * n;
}

int f[1003][1003];
int solve(int sum) {
    int c1 = 0, c2 = 0;
    f[0][0] = 1;
    for (int i = 1; i <= (n << 1); ++i) {
        if (!p[i].r) {
            ++c1;
            for (int j = 0; j <= min(sum, c2); ++j) {
                int x = p[i].l + 1 - (c1 + j - 1);
                f[i][j] = 1ll * f[i - 1][j] * x % m;
            }
        } else {
            f[i - 1][++c2] = 0;
            for (int j = 0; j <= min(sum, c2); ++j) {
                int x = p[i].r + 1 - (n + sum + (c2 - 1 - j));
                f[i][j] = 1ll * f[i - 1][j] * x % m;
                if (j > 0) {
                    x = p[i].l + 1 - (c1 + j - 1);
                    Add(f[i][j], 1ll * f[i - 1][j - 1] * x % m);
                }
            }
        }
    }
    return f[n << 1][sum];
}

int main() {
    n = read(), m = read();
    int L = n, R = 2 * n - 1;
    for (int i = 0; i < n; ++i) {
        while (check(L - 1, i)) L--;
        while (!check(R, i)) R--;
        p[i + 1] = (P){L - 1, R};
    }
    for (int i = n; i < (n << 1); ++i) {
        while (!check(R, i)) R--;
        p[i + 1] = (P){R, 0};
    }

    sort(p + 1, p + 1 + (n << 1), cmp);
    int res = 0;
    for (int i = 0, t = 1; i <= n; ++i)
        Add(res, 1ll * t * solve(i) % m), t = m - t;
    printf("%d\n", res);
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    for(int i=0; i<N; i++) cin >> T[i] >> A[i];
    
    ll t, a;
    t = T[0]; a = A[0];
    
    for(int i=1; i<N; i++){
        if(T[i]>=t && A[i]>=a){
            t = T[i]; a = A[i];
        }
        else if(T[i]<t && A[i]>=a){
            if(t%T[i]==0){
                ll tmp = t/T[i];
                t = T[i]*tmp;
                a = A[i]*tmp;
            }
            else {
                ll tmp = t/T[i]+1;
                t = T[i]*tmp;
                a = A[i]*tmp;
            }
        }
        else if(T[i]>=t && A[i]<a){
            if(a%A[i]==0){
                ll tmp = a/A[i];
                t = T[i]*tmp;
                a = A[i]*tmp;
            }
            else {
                ll tmp = a/A[i]+1;
                t = T[i]*tmp;
                a = A[i]*tmp;
            }
        }
        else if(T[i]<t && A[i]<a){
            ll t1=t, a1=a, t2=t, a2=a;
            if(t1%T[i]==0){
                ll tmp = t1/T[i];
                t1 = T[i]*tmp;
                a1 = A[i]*tmp;
            }
            else {
                ll tmp = t1/T[i]+1;
                t1 = T[i]*tmp;
                a1 = A[i]*tmp;
            }
            if(a2%A[i]==0){
                ll tmp = a2/A[i];
                t2 = T[i]*tmp;
                a2 = A[i]*tmp;
            }
            else {
                ll tmp = a2/A[i]+1;
                t2 = T[i]*tmp;
                a2 = A[i]*tmp;
            }
            if(a<=a1 && t<=t1){
                a = a1; t = t1;
            }
            else if(a<=a2 && t<=t2){
                a = a2; t = t2;
            }
        }
        //cout <<"T[i]="<< T[i] <<" t="<< t <<" A[i]="<< A[i] <<" a="<< a << endl;
    }
    cout << t+a << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
const int inf=2e9;
int n,a[55],t[15],ans,s[15][2];
bool b[15],f[25];
vector <int> v;
int main()
{
	for (int i=0;i<=12;++i)
	{
		s[i][0]=i;
		s[i][1]=(24-i)%24;
	}
	f[0]=true;
	cin>>n;
	if (n>=24)
	{
		cout<<0;
		return 0;
	}
	for (int i=1;i<=n;++i)
	{
		cin>>a[i];
		if (a[i]==0) 
		{
			cout<<0;
			return 0;
		}
		t[a[i]]++;
	}
	if (t[12]>=2)
	{
		cout<<0;
		return 0;
	}
	for (int i=1;i<=11;++i)
	{
		if (t[i]>=3)
		{
			cout<<0;
			return 0;
		}
		else if (t[i]==2)
		{
			b[i]=true;
			f[i]=f[24-i]=true;
		}
	}
	for (int i=0;i<=n;++i)
	{
		if (!b[a[i]])
		{
			v.push_back(a[i]);
		}
	}
	int y=v.size();
	for (int i=0;i<1<<y;++i)
	{
		int res=inf;
		bool u[25];
		memcpy(u,f,sizeof(u));
		for (int j=0;j<y;++j)
		{
			if (i & (1<<j))
			{
				u[s[v[j]][1]]=true;
			}
			else
			{
				u[s[v[j]][0]]=true;
			}
		}
		for (int j=0;j<24;++j)
		{
			for (int k=j+1;k<24;++k)
			{
				if (u[j] && u[k])
				{
					res=min(res,min(abs(k-j),24-abs(k-j)));
				}
			}
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
// const int k_mod = 1e9 + 7;
const int k_mod = 998244353;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	int a;
	int b;
} P;

/*
 * @fn modpow
 * @brief O(logn): a^n % mod
 * @param a: 基数
 * @param n: 指数
 * @param mod: 法
 */
ll modpow( ll a, ll n, ll mod ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main( void ){
	ll N, maximum = 0; cin >> N;
	vector <ll> v( N, 0 );
	rep( i, 0, N ){
		ll input; cin >> input;
		if (i == 0 && input != 0){
			cout << 0 << endl;
			return 0;
		}
		v[ input ]++;
		maximum = max( maximum, input );
	}
	bool can = ( v[ 0 ] == 1 );
	rep( i, 0, maximum + 1 )
	if (v[ i ] == 0)
		can = false;
	if (!can){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	rep( i, 1, N )
		ans = ( ans * modpow( v[ i - 1 ], v[ i ], k_mod )) % k_mod;
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

char c[MAXN];

void solve(){
	int n;
	scanf("%d%s", &n, &c[0]);
	ll cnt = 0ll;
	ll cur = 1ll;
	REP(i, 0, 2 * n) {
		if (c[i] == 'W') {
			if (cnt == 0) {
				printf("0\n");
				return;
			}
			else if (cnt % 2 == 0) {
				cur = (cur * cnt) % MOD;
				cnt--;
			} else {
				cnt++;
			}
		} else {
			if (cnt % 2 == 0) {
				cnt++;
			} else {
				cur = (cur * cnt) % MOD;
				cnt--;
			}
		}
	}
	if (cnt > 0) {
		cur = 0ll;
	}
	REPN(i, 1, n) {
		cur = (cur * i) % MOD;
	}
	cout << cur << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
macro_rules! scan {
    ($t:ty,,) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty,,$n:expr) => {
        (0..$n).map(|_| scan!($t,,)).collect::<Vec<_>>()
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (h, _) = scan!(usize, usize);
    let mut graph = scan!(i64,,10);
    let arr = scan!(i64,,h);

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                let d = graph[i][k] + graph[k][j];
                if d < graph[i][j] {
                    graph[i][j] = d
                }
            }
        }
    }

    let mut ans = 0;
    for row in arr {
        for col in row {
            if col >= 0 {
                ans += graph[col as usize][1]
            }
        }
    }

    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}

#define N 1000000000000000000

void solve()
{

ll n;
cin>>n;
ll a[n];
ll ans=1;
bool flag1=0,flag=1;
for(auto &x:a)
{
cin>>x;
if(!x)
flag1=1;
}
for(ll i=0;i<n-1;i++)
{
    ans*=a[i];
    if((N/ans)<a[i+1])
    {
        flag=0;
        break; ;
    }
}
if(flag1)
    cout<<0;
else
{
    if(flag)
        cout<<ans*a[n-1];
    else
        cout<<-1;
}
}
int main()
{
   fastio
   ll t=1;
   while(t--)
   solve();
   return 0;
}


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

static const int MAX = 500;
int main() {
	int H, W;
	static char a[MAX][MAX];
	cin >> H >> W;
	for (int i = 0;i < H;i ++) for (int j = 0;j < W;j ++) cin >> a[i][j];
	
	for (int i = 0;i < H;i ++) {
		for (int j = 0;j < W;j ++) {
			if (i < H - 1 && (i == 0 || j % 2 == 0 || a[i][j] == '#')) cout << '#';
			else cout << '.';
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0;i < H;i ++) {
		for (int j = 0;j < W;j ++) {
			if (i > 0 && (i == H - 1 || j % 2 == 1 || a[i][j] == '#')) cout << '#';
			else cout << '.';
		}
		cout << endl;
	}
	cout << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

予め、赤と青が重ならず連結なパターンを用意しておく
これを用意さえしておけば答えは簡単に求められるので
一つの例として、次のようなものを考えてみよう
######
#.#.#.
#.#.#.
#.#.#.
......
これなら後で紫に変えるのは非常に簡単だね
*/

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void){
  char s[10],t[10],u[10];
  int a,b;
  scanf("%s%s%d%d%s",s,t,&a,&b,u);
  strcmp(s,u)==0 ? printf("%d %d",a-1,b) :printf("%d %d",a,b-1);
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	vector<int> val(n);
	read(val, n);
	sort(all(val));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i; j++){
			for(int z = 0; z < j; z++){
				if(val[i] < val[j] + val[z] and val[i]!=val[j] and val[i] != val[z] and val[j] != val[z]){
					ans ++;
					// cout<<i<<" "<<j<<" "<<z<<" "<<val[i]<<" "<<val[j]<<" "<<val[z]<<"\n";
				}
			}
		}
	}
	cout<<ans<<"\n";

}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var price = ToInt32(input[0]);
        var num = ToInt32(input[1]);
        var hateNum = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var hateNumSet = new HashSet<int>();
        for(var i = 0; i < num; i++)
        {
            hateNumSet.Add(hateNum[i]);
        }
        for(var i = 1; i < int.MaxValue; i++)
        {
            var isHate = false;
            for(var j = 0; j<i.ToString().Length; j++)
            {
                if (hateNumSet.Contains(ToInt32(i.ToString().Substring(j, 1)))) { isHate = true;break; }
            }
            if (isHate) continue;
            if (price <= i) { WriteLine(i);break; }
        }
    }
}


Measured memory_bytes: 15444
/*
* @Author: _dp95
* @Date:   2020-04-13 07:06:33
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*100 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

ll d[MAX][MAX] ;
vector< vector< ll > > edges ;

signed main( ){
  timesaver ;
  for( ll i = 0 ; i < MAX ; i++ ){
    for( ll j = 0 ; j < MAX ; j++ )
      d[i][j] = INF ;
  }
  ll n, m ;
  cin >> n >> m ;
  for( ll i = 0 ; i < m ; i++ ){
    ll x, y, w ;
    cin >> x >> y >> w ;
    edges.pb({x,y,w});
    d[x][y] = d[y][x] = w ;
  }
  for (ll k = 1; k <= n; ++k) {
    for (ll i = 1; i <= n; ++i) {
        for (ll j = 1; j <= n; ++j) {
            if (d[i][k] < INF && d[k][j] < INF)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 
        }
    }
  }
  for( int i = 0 ; i <= n ; i++ )
    d[i][i] = 0 ;
  ll ans(0) ;
  for( auto g : edges ){
    ll x = g[0], y =g[1], w = g[2] ;
    ll f = 1 ;
    for( ll i = 1 ; i <= n ; i++ )
      for( ll j = 1 ; j <= n ; j++ ){
        if( d[i][j] == (d[i][x] + d[j][y] + w ) )
          f = 0 ;
      }
    ans += f ;
  }
  cout << ans << nl ;
}

Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

    int n;
    cin >> n;

    vector<vector<int> > a(n, vector<int>(3));
    REP(i, n) REP(j, 3) cin >> a[i][j];

    vector<vector<int> > dp(n + 1, vector<int>(3, 0));

    REP(i, n) REP(j, 3) REP(k, 3) {
        if (j == k) continue ;
        chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
    }

    int ans = 0;
    REP(i, 3) chmax(ans, dp[n][i]);

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

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    string s;
    int a[3] = {0};
    int i;
    
    cin >> s;

    a[int(s[0])-97]++;
    a[int(s[1])-97]++;
    a[int(s[2])-97]++;
    
    if((a[0]  == 1) && (a[1] == 1) && (a[2] == 1)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
int main()
{
     ios;
     ll n;
     cin >> n;
     ll ans = 1;
     for (ll i = 1; i * i <= n; ++i)
          if (n % i == 0)
               ans = i;
     cout << (n / ans + ans - 2) << '\n';
     return 0;
}

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

int main()
{
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(), a.end());
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        a.at(2) *= 2;
    }

    cout << a.at(0) + a.at(1) + a.at(2) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class SegmentTree:
  __slots__ = ['ide','n','seg','segfunc']

  def __init__(self,size,func,element):
    self.segfunc = func
    self.ide = element
    # self.size = sizeを超える最小の2冪の数
    self.n = 2 ** (n-1).bit_length()
    # 全てのnodeの数は(2*n-1)個
    # 上にn-1個,最下段にn個
    self.seg = [self.ide] * (2*self.n-1)

  def apply(self,array):
    arraysize = len(array)
    # 配列埋め込み
    for i in range(arraysize):
      self.seg[self.n-1+i] = array[i]
    # 上にあげる
    for i in range(self.n-2,-1,-1):
      self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2])

  def update(self,k,x):
    k += self.n -1
    self.seg[k] = x
    while k:
      k = (k-1)//2
      self.seg[k] = self.segfunc(self.seg[2*k+1],self.seg[2*k+2])

  def query(self,l,r):
    # 半開区間[l,r)
    l += self.n-1; r += self.n-1
    vl = vr = self.ide
    while l < r:
      if l & 1 == 0:
        vl = self.segfunc(vl,self.seg[l])
        l += 1
      if r & 1 == 0:
        vr = self.segfunc(vr,self.seg[r-1])
      l = (l-1)//2; r = (r-1)//2
    return self.segfunc(vl,vr)

def segor(a,b):
  return a|b

n = int(input())
st = SegmentTree(n,segor,0)
S = input()
data = [0] * n
for i,si in enumerate(S):
  k = ord(si)-ord("a")
  data[i] = 1 << k
st.apply(data)
Q = int(input())
for _ in range(Q):
  typo,a,b = input().split()
  if typo == "1":
    st.update(int(a)-1,1 << (ord(b)-ord("a")))
  if typo == "2":
    print(bin((st.query(int(a)-1,int(b))))[2:].count("1"))
  


Measured memory_bytes: 73784
#include<stdio.h>

int main(void)
{
	
	char masu1[4];
	char masu2[4];
	char masu3[4];
	
	scanf("%s",masu1);
	scanf("%s",masu2);
	scanf("%s",masu3);
	
	printf("%c",masu1[0]);
	printf("%c",masu2[1]);
	printf("%c",masu3[2]);

	return 0;
}

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

long long N, M;

long long mod = 1e9+7;
vector<int> primes;

long long pow(long long a, long long x){
    if(x==0){
        return 1;
    }else if(x == 1){
        return a % mod;
    }
    return pow(a*a%mod, x/2) * (x % 2 ? a : 1) % mod;
}

long long fac(long long n){
    if(n == 0){
        return 1;
    }
    return n % mod * fac(n - 1) % mod;
}

long long inv(long long x){
    return pow(x, mod - 2);
}

long long C(long long n, long long r){
    return fac(n) % mod * inv(fac(r)) % mod * inv(fac(n-r)) % mod;
}

int main(){
    cin >> N >> M;
    for(int p = 2; M > 1; p++){
        int cnt = 0;
        while(M % p == 0){
            cnt++;
            M /= p;
        }
        if(cnt != 0){
            primes.push_back(cnt);
        }
    }
    long long ans = 1;
    for(int i = 0; i < primes.size(); i++){
        ans *= C(primes[i] + N - 1, N - 1);
        ans %= mod;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] t = new int[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.nextInt();
		}

		int count = 0;
		for (int i = 0; i < q; i++) {
			for (int j = 0; j < n; j++) {
				if (t[i] == s[j]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);

	}

}



Measured memory_bytes: 40708
S = input()
if S[0] != 'A':
    print('WA')
    exit()
c_count = 0
for i in range(2,len(S)-1):
    if S[i] == 'C':
        c_count += 1
if c_count != 1:
    print('WA')
    exit()
for i in range(1,len(S)):
    if S[i] == 'C':
        continue
    if S[i].isupper():
        print('WA')
        exit()
print('AC')

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

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

  if (s.size() < t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  int a;
  vector<string> x;
  for (int i = 0; i <= s.size() - t.size(); i ++) {
    if (s[i] == t[0] || s[i] == '?') {
      a = 1;
      for (int j = 1; j < t.size(); j ++) {
        if (s[i+j] != '?' && s[i+j] != t[j]) a = 0;
      }
      if (a) {
        string y = "";
        for (int j = 0; j < s.size(); j ++) {
          if (j == i) {
            y += t;
            j += t.size() - 1;
          }
          else if (s[j] == '?') y += 'a';
          else y += s[j];
        }
        x.push_back(y);
      }
    }
  }
  if (!x.empty()) {
    sort(x.begin(), x.end());
    cout << x[0] << endl;
    return 0;
  }

  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cins(int, 3, a);
    Sort(a);
    int k = ((a[0] % 2) ^ (a[1] % 2)) ? a[2]+1 : a[2];
    Cout((3*k - (a[0]+a[1]+a[2])) / 2);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, m;
bool node[51][51];
int check(int i, int j) {
	node[i][j] = false;
	node[j][i] = false;

	bool flag[51];
	REP(k, 0, n) flag[k] = false;

	queue<int> Q;
	Q.push(0);
	flag[0] = true;
	while (!Q.empty()) {
		int q = Q.front();
		Q.pop();
		
		REP(y, 0, n) {
			if (node[q][y] && !flag[y]) {
				Q.push(y);
				flag[y] = true;
			}
		}
	}
	
	node[i][j] = true;
	node[j][i] = true;

	REP(k, 0, n) {
		if (!flag[k]) return 1;
	}
	return 0;
}

int main()
{
	REP(i, 0, n) REP(j, 0, n) node[i][j] = false;
	cin >> n >> m;
	REP(i, 0, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		node[a][b] = true;
		node[b][a] = true;
	}

	int cnt = 0;
	REP(i, 0, n) {
		REP(j, i + 1, n) {
			if (node[i][j]) cnt += check(i, j);
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{    
    double q;    
    while(scanf("%lf", &q)!= EOF && q != -1) 
    {        
        double x, a;
        x=q/2;
        while(1){
            if(fabs(x*x*x-q)<0.00001*q) 
            break;
            x=x-((x*x*x-q)/(3*x*x));
            x = x;
            }                      
            printf("%.7f\n",x);
            } 
            return 0;
            }


Measured memory_bytes: 1984
/***********************************************
#
#      Filename: b.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-04-29 21:24:00
***********************************************/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, W;
    cin >> N >> W;
    map<int, int> mp;
    mp[W] = 0;
    int wi, vi;
    for (int i = 0; i < N; ++ i) {
        cin >> wi >> vi;
        map<int, int> pre(mp);
        for (auto it = pre.begin(); it != pre.end(); ++ it) {
            int w = (*it).first;
            int v = (*it).second;
            if (w - wi >= 0) {
                mp[w-wi] = max(mp[w-wi], v + vi);
                //cout << mp[w-wi];
            }
        }
    }
    int ans = -1;
    for (auto it = mp.begin(); it != mp.end(); ++ it) {
        ans = max((*it).second, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512