akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)

const int MAXN = 2e2+3;
const int MOD = 1e9+7;
const LL INF = 1e18+1;

int N;
char S[MAXN][MAXN];
int ans;
int vis[MAXN];
int C[MAXN];

void dfs(int u, vector<int>& r) {
    fori(v,N) {
        if(vis[v]) continue;
        if(S[u][v] == '0') continue;
        vis[v] = 1;
        r.pb(v);
        dfs(v,r);
    }
}

vector<vector<int> > findCC() {
    vector<vector<int>> ret;
    fori(u,N) {
        if(vis[u]) continue;
        vector<int> r;
        dfs(u,r);
        ret.pb(r);
    }

    return ret;
}

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    fori(i,N) cin >> S[i];

    auto cc = findCC();
    int ok = 1;
    for(auto V: cc) {
        int tmp = -1;
        for(auto u: V) {
            fori(i,N) {
                vis[i] = 0;
                C[i] = 0;
            }

            C[u] = 1;
            vis[u] = 1;
            int k = 1;

            queue<int> qu;
            qu.push(u);
            int ok = 1;

            while(ok && qu.size()) {
                int v = qu.front();
                qu.pop();

                fori(t,N) {
                    if(S[v][t] == '0') continue;
                    if(vis[t]) {
                        if(abs(C[t]-C[v]) != 1) {
                            ok = 0;
                            break;
                        }
                    } else {
                        C[t] = C[v]+1;
                        k = max(k,C[t]);
                        vis[t] = 1;
                        qu.push(t);
                    }
                }
            }

            if(!ok) continue;
            tmp = max(tmp, k);
        }


        if(tmp == -1) RETURN(-1);
        ans += tmp;
    }

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


Measured memory_bytes: 256
i=input()
n=int(i.split()[0])
k=int(i.split()[1])

rsp=input()
r=int(rsp.split()[0])
s=int(rsp.split()[1])
p=int(rsp.split()[2])

T=input()
rel=[]
for i in range(len(T)):
  temp=0
  if T[i]=="r":
    temp=p
  elif T[i]=="s":
    temp=r
  elif T[i]=="p":
    temp=s

  if i >= k and T[i]==T[i-k] and rel[i-k]!=0:
    temp=0
  rel.append(temp)

print(sum(rel))

Measured memory_bytes: 4212
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.ArrayList;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();

            int plusResult = A + B;
            int minusResult = A - B;
            int timesResult = A * B;

            List<Integer> resultList = new ArrayList<>();
            resultList.add(plusResult);
            resultList.add(minusResult);
            resultList.add(timesResult);

            List<Integer> sortResultList = resultList.stream().sorted().collect(Collectors.toList());
            out.println(sortResultList.get(sortResultList.size() - 1));
        }

    }
}



Measured memory_bytes: 27220
#include<stdio.h>

int main(void){
  int N,M;
  long long ans;
  scanf("%d%d",&N,&M);
  if(N==1 && M==1) ans=1;
  else if(N==1 || M==1) ans=N*M-2;
  else ans=(long long)(N-2)*(M-2);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */


void solve(){
    //START
    string S,T;
    cin >> S >> T;

    REP(i,S.length()+1){
      if(S==T){
        cout << "Yes" << endl;exit(0);
      }else{
        S = S[S.length()-1] + S;
        S.pop_back();
      }
    }
    cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}



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

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

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

  sort(A.begin(), A.end());

  vector<pair<long, int>> actions(M);
  for (int j = 0; j < M; j++) {
    int B;
    long C;
    cin >> B >> C;

    actions[j] = make_pair(C, B);
  }

  sort(actions.begin(), actions.end(), greater<pair<long, int>>());

  queue<long> cards;
  for (int j = 0; j < M; j++) {
    pair<long, int> action = actions[j];
    for (int k = 0; k < action.second; k++) {
      cards.push(action.first);

      if (cards.size() == N) {
        break;
      }
    }

    if (cards.size() == N) {
      break;
    }
  }

  long long total = 0;
  for (int i = 0; i < N; i++) {
    if (!cards.empty() && A[i] < cards.front()) {
      total += cards.front();
      cards.pop();
    } else {
      total += A[i];
    }
  }

  cout << total << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
string to_string(string s) {return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;


int main()
{
    _boost;
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n));
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    int M=(1<<n);
    vector<LL> dp(M,0);
    dp[0]=1;
    for(int mask=0;mask<M;mask++)
    {
        for(int b=0;b<n;b++)
        {
            if((1<<b)&mask )continue;
            int nmask=mask|(1<<b);
            int k=bp(mask);
            if(a[k][b])
                dp[nmask]=(dp[nmask]+dp[mask])%MOD;
        }
    }
    cout<<dp[M-1];

}




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

using namespace std;

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


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

long int modcomb(long int a, long int b, long int mod){
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}



int main(){
    const long int mod = 998244353;
    long int n, m, k;
    cin >> n >> m >> k;
    if(m == 1){
        if(n - 1 == k) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    
    long int a1 = modcomb(n - 1, 0, mod);
    long int a2 = m * modpow(m - 1, n - 0 - 1, mod);
    a2 %= mod;
    // cout << a1 << " " << a2 << endl;
    long int inv2 = modpow(m - 1, mod - 2, mod);
    long int ans = (a1 * a2) % mod;
    for (long int i = 1; i <= k; i++){
        long int inv1 = modpow(i, mod - 2, mod);
        a1 = (((a1 * (n - i)) % mod) * inv1) % mod;
        a2 = (a2 * inv2) % mod;
        ans += (a1 * a2) % mod;
        ans %= mod;
        // cout << a1 << " " << a2 << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
import sys

S = sys.stdin.readline().strip()
ls = len(S)

mod = 2019
S = S[::-1]

acum = [0] * (ls+1)
counter = {0: 1}
for i, s_i in enumerate(S):
    acum[i+1] = (acum[i] + int(s_i) * pow(10, i, mod)) % mod
    if acum[i+1] not in counter:
        counter[acum[i+1]] = 0
    counter[acum[i+1]] += 1
# print(counter)

# mod が同じものになっている桁の組み合わせなら2019の倍数
ans = 0
for value, count in counter.items():
    ans += count * (count - 1) // 2

print(ans)

Measured memory_bytes: 75852
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod=1e9+7;
int n,m;
ll dp[(int)1e5+10];
char book[(int)1e5+10];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int i,j,a;
    memset(dp,0,sizeof(dp));
    memset(book,0,sizeof(book));
    cin>>n>>m;
    for(i=0;i<m;i++)
        cin>>a,book[a]=1;
    dp[0]=1;
    for(i=1;i<=n;i++)
    {
        if(i>=1 && book[i-1]==0)
            dp[i]=(dp[i]+dp[i-1])%mod;
        if(i>=2 && book[i-2]==0)
            dp[i]=(dp[i]+dp[i-2])%mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main(){
  int w,d;
  int a[11],b[11];
  bool use[11];

  while(cin >> w >> d, w||d){
    int ans = 0;
    for(int i=0;i<w;i++){
      cin >> a[i];
      ans += a[i];
    }
    for(int j=0;j<d;j++){
      cin >> b[j];
      ans += b[j];
      use[j] = false;
    }

    for(int i=0;i<w;i++)
      for(int j=0;j<d;j++){
	if(!use[j] && a[i] == b[j]){
	  ans -= a[i];
	  use[j] = true;
	  break;
	}
      }
    cout << ans << endl;
  }
}
  
    

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))

OK=10**9
NG=0

while OK-NG>1:
    mid=(OK+NG)//2

    ANS=0
    for a in A:
        ANS+=(a-0.01)//mid

    if ANS<=K:
        OK=mid
    else:
        NG=mid
print(OK)


Measured memory_bytes: 30952
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def factorization(n):  # => {p:count,...}
    fac = {}
    for i in range(2, int(n ** .5) + 1):
        count = 0
        while n % i == 0:
            n //= i
            count += 1
        if count > 0:
            fac[i] = count
    if n > 1:
        fac[n] = 1
    return fac


def C(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = list(range(n, n - r, -1))
    for k in range(2, r + 1):
        fac = factorization(k)
        for key, value in fac.items():
            for _ in range(value):
                for i, o in enumerate(over):
                    if o % key == 0:
                        over[i] //= key
                        break
    ret = 1
    for o in over:
        ret *= o
        ret %= mod
    return ret


ans = 1
for c in factorization(m).values():
    ans *= C(c + n - 1, c, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 3188
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
    input[0] = input[0].split(" ");
	var a = parseInt(input[0][0], 10);
  	var aft = a;
    var b = parseInt(input[0][1], 10);
    var bft = b;
  	var aso = new Array(100000);
    var bso = new Array(100000);
    var ans = 1;
    aso[0] = 0;
    aso[1] = 0;
    bso[0] = 0;
    bso[1] = 0;
	for(var i=2; i<=100000; i++){
      aso[i] = 0;
      bso[i] = 0;
      for(var j=0; j<1; j){
        if(a%i == 0){
           a = a/i;
           aso[i] += 1;
        }else{
           j = 1;
        }
      }
      for(var j=0; j<1; j){
        if(b%i == 0){
           b = b/i;
           bso[i] += 1;
        }else{
           j = 1;
        }
      }
    }
  for(var i=2; i<=100000; i++){
    if(aso[i] != 0 && bso[i] != 0){
      for(var j=0; j<Math.max(aso[i], bso[i]); j++){
        ans *= i;
      }
  }else if(aso[i] != 0){
      for(var j=0; j<aso[i]; j++){
        ans *= i;
      }
  }else if(bso[i] != 0){
      for(var j=0; j<bso[i]; j++){
        ans *= i;
      }
  }
  }
  /*
  var max = 0;
  if(max < ans){
    max = ans;
  }
  if(max < aft){
     max = aft;
  }
  if(max < bft){
    max = bft;
  }
  */
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 25672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void)
{
	map<int, int>table;
	vector<int>table2;
	
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		table[a] ++;
	}

	for (auto x : table) {
		table2.push_back(x.second);
	}

	sort(table2.begin(), table2.end());

	int num = table2.size();

	int ans = 0;

	for (int i = 0; i < num - k; i++)
	{
		ans += table2[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10748
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

vi primes;
vector<bool> composite;

void prime_sieve(ll lim) {
	composite = vector<bool>(lim+1);
	for (int num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	prime_sieve(min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10436
#include<iostream>
#include <string>

using namespace std;

int main()
{
	cin.tie(0);ios::sync_with_stdio(false);
	/* ====================================== */
	int a[3], b[3];
	cin >> a[0] >> b[0] >> a[1] >> b[1] >> a[2] >> b[2];
	string n = "NO";
	string y = "YES";
	int count0, count1, count2, count3;
	count0 = 0;count1 = 0;count2 = 0;count3 = 0;

	for(int i = 0; i < 3; i++){
		if(a[i] == 1){
			count0++;
		}else if(a[i] == 2){
			count1++;
		}else if(a[i] == 3){
			count2++;
		}else if(a[i] == 4){
			count3++;
		}
	}
	for(int i = 0; i < 3; i++){
		if(b[i] == 1){
			count0++;
		}else if(b[i] == 2){
			count1++;
		}else if(b[i] == 3){
			count2++;
		}else if(b[i] == 4){
			count3++;
		}
	}
	if(count0 > 2 || count1 > 2 || count2 > 2 || count3 > 2){
		cout << n;
	}else{
		cout << y;
	}

	/* ====================================== */
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

inf = float("inf")
dp = [inf] * N
dp[0] = 0
dp[1] = abs(A[0]-A[1])
         
for i in range(2, N):
    dp[i] = min(dp[i], dp[i-1]+abs(A[i]-A[i-1]))
    dp[i] = min(dp[i], dp[i-2]+abs(A[i]-A[i-2]))
        
print(dp[N-1])  

Measured memory_bytes: 52208
#include<stdio.h>
int main()
{
  long n,a[100001],i,sum=0;
  scanf("%ld",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%ld",&a[i]);
  }
  for(i=1;i<=n;i++)
  {
    sum=sum^a[i];
  }
  if(sum==0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
      Scanner in=new Scanner(System.in);
      // BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=in.nextInt();
       Map<Integer,int[][]>map=new HashMap<>();
       for(int i=0;i<n;i++){
       	int a=in.nextInt();
       	int[][] arr=new int[a][2];
       	for(int j=0;j<a;j++){
       		arr[j]=new int[]{in.nextInt()-1,in.nextInt()};
       	}
       	map.put(i,arr);
       }

       int res=0;
       for(int i=0;i<(1<<n);i++){
       	boolean b=true;
       	for(int j=0;j<n;j++){
       		if((i&1<<j)==0){continue;}
       		for(int[] t:map.get(j)){
       			if((t[1]==0&&(i&1<<t[0])!=0)||(t[1]==1&&(i&1<<t[0])==0)){
       				b=false;break;
       			}
       		}
       	}
       	if(b){
       			res=Math.max(res,Integer.bitCount(i));
       		}
       }
       out.write(res+"");
       out.flush();
      }
        }
    


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll a = 0, b = 0, c = 0, n = 0, m = 0;
int ar1[100000] = {}, ar2[100000] = {};
string str;
vector<int> vec;


int main() {

	cin >> a;
	cout << 180 * (a - 2) << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int n; cin >> n;
    vector<vector<int>> flag(n, vector<int>(10));
    rep(i, n)rep(j, 10) cin >> flag[i][j];

    vector<vector<ll>> p(n, vector<ll>(11));
    rep(i, n)rep(j, 11) cin >> p[i][j];
    
    ll ans = -10000000000;
    for(int bit = 0; bit < (1 << 10); bit++){
        vector<int> count(n, 0);
        ll sum = 0;
        bool chosed = false;

        rep(i, 10){
            if(bit & (1 << i)){
                chosed = true; 
                rep(j, n){
                    if(flag[j][i]) count[j]++;
                }
            }
        }
        rep(i, n) sum += p[i][count[i]];
        if(chosed) ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, long long A, long long B){
    long long q = N / (A+B);
    long long r = N % (A+B);
    long num = q * A + min(r, A);
    cout << num << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    func(N, A, B);
    return 0;
}


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

int main(){
    long long int blue, red, num;
    cin >> num >> blue >> red;

    long long int per = blue + red;
    long long int times = num / per;
    long long int hanpa = num % per;

    long long int result = blue * times;
    if(hanpa > blue) result += blue;
    else result += hanpa;

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
const bool TEST=0;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
int n ;
string b;
bool ope(bool an_1,bool bn_1,bool an_2){
	return (an_1)?((!bn_1)^an_2):(bn_1^an_2);
}
void pri(string a ){
	for(char &x:a){
		x=x?'S':'W';
	}
	cout<<a;
}
bool build(int x){
	string a;
	a.push_back((x&2)>>1);
	a.push_back(x&1);
	for(int i = 2;i<n;i++){
		bool tmp=ope(a[i-1],b[i-1],a[i-2]);
		a.push_back(tmp);
		IF printf("i:%d,ope %d %d %d : %d\n",i,a[i-1],b[i-1],a[i-2],tmp);
	}
	if(a[1]==ope(a[0],b[0],a[n-1])&&a[0]==ope(a[n-1],b[n-1],a[n-2])){
		pri(a);
		return 1;
	}
	else return 0;
}
void sol(){
	cin>>n>>b;
	for(char &x:b){
		x=x=='o'?1:0;
	}

	IF {build(3);
	return ;
	}
	for(int i = 0 ;i< 4;i++){
		if(build(i)){
			exit(0);
		}
	}
	cout<<-1<<endl;
}
int main()
{
	sol();
	return 0;
}
//D.cc
//generated automatically at Sat Feb 18 21:17:19 2017
//by xsthunder


Measured memory_bytes: 640
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[100010], b[100010];
signed main() {
	int n, m;
	cin >> n >> m;
	int l = 1, r = n;
	rep(i, m) {
		cin >> a[i] >> b[i];
	}
	rep(i, m) {
		if (a[i] > l)l = a[i];
		if (b[i] < r)r = b[i];
	}
	cout << max((ll)0,r - l + 1) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define endl "\n"
#define PI 3.141592653
double calangle(double h, double m)  
{  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;   
    double  hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    double angle = abs(hour_angle - minute_angle);   
    //angle = min(360 - angle, angle);  
  
    return angle;  
}  
int main()
{
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double angle=calangle(h,m);
  double result = cos ( angle * PI / 180.0 );
  //cout<<cos(angle)<<endl;
  //double  ans = sqrt((pow(a,2))+(pow(b,2))-(2*a*b*result));
  cout<<setprecision(20)<<sqrt((pow(a,2))+(pow(b,2))-(2*a*b*result))<<endl;
}


Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <cstring>
#include <cassert>

int N;
int a[100002], b[100002], c[100002];

// ボトムアップに解く
int solveBottomUp() {
  // DP
  int dp[100002][3]; // dp[i][j] := i日目にjを選んだ時の幸福度最大値
  memset(dp, 0, sizeof(dp)); // 0で初期化しておく
  
  // 1日目は先に埋めておく
  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  // DP更新
  for (int i = 2; i <= N; i++) {
    // i日目に0(A)を選んだ時の幸福度最大値
    //  = 前日にB,Cを選んだ時の最大値のmax + i日目にAを選ぶ最大値
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a[i];

    // i日目に1(B)を選んだ時の幸福度最大値
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + b[i];

    // i日目に2(C)を選んだ時の幸福度最大値
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  // N日目にA,B,Cを選んだ時の最大値の最大値を取る
  int result = std::max(dp[N][0], std::max(dp[N][1], dp[N][2]));

  return result;
}


// トップダウンに解く
int memo[100002][3]; // memo[i][j] := i日目にjを選んだ時の幸福度最大値
int solveRecursive(int n, int action) {
  int &cache = memo[n][action];
  if (cache != -1) return cache;
  if (n == 0) return 0;
  if (action == 0) {
    return cache = std::max(solveRecursive(n-1, 1), solveRecursive(n-1, 2)) + a[n];
  }
  if (action == 1) {
    return cache = std::max(solveRecursive(n-1, 0), solveRecursive(n-1, 2)) + b[n];
  }
  if (action == 2) {
    return cache = std::max(solveRecursive(n-1, 0), solveRecursive(n-1, 1)) + c[n];
  }
  assert(0);
  return -1;
}
int solveTopDown() {
  memset(memo, -1, sizeof(memo)); // -1で初期化しておく
  int result_a = solveRecursive(N, 0);
  int result_b = solveRecursive(N, 1);
  int result_c = solveRecursive(N, 2);
  return std::max(result_a, std::max(result_b, result_c));
}

int main(void) {
  std::cin >> N;
  // 入力の受け取り
  for (int i = 1; i <= N; i++) { // 1-indexで入れる
    std::cin >> a[i] >> b[i] >> c[i];
  }

  std::cout << solveTopDown() << std::endl;

  return 0;
}

Measured memory_bytes: 10604
r, c = map(int, input().split())

table = list()


for i in range(r):
    table.append(list(map(int, input().split())))
    table[i].append(sum(table[i]))

table.append([])
for j in range(c+1):
    sum = 0
    for i in range(r):
        sum += table[i][j]
    table[r].append(sum)

for i in range(r+1):
    print("%d"%table[i][0],end = "")
    for j in range(1, c+1):
        print(" %d"%table[i][j],end = "")
    print("")



Measured memory_bytes: 6236
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int>l(n);
	for (auto& e : l)cin >> e;

	sort(l.begin(), l.end());

	int cnt = 0;
	for (int i = 0; i < n - 2; ++i) {
		for (int j = i + 1; j < n - 1; ++j) {
			for (int k = j + 1; k < n; ++k) {
				int a_b = l[i] + l[j];
				int b_c = l[i] + l[j];
				int c_a = l[k] + l[i];
				if (l[i]<b_c&&l[j]<c_a&&l[k]<a_b)++cnt;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import math
abc=list(map(int, input().split())) 
a=abc[0]
b=abc[1]
c=abc[2]
answer1=c-a-b
answer2=answer1**2-4*a*b
if(answer1<0):
    print('No')
else:
    if(answer2>0):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


long long x, k, d;

int main()
{
	scanf("%lld%lld%lld", &x, &k, &d);
	
	if (x < 0) x = -x;
	
	long long count = x / d;
	if (count >= k) {
		long long ans = x - k * d;
		printf("%lld\n", ans);
		return 0;
	}
	
	long long left = k - count;
	long long numA = x - count * d;
	long long numB = numA - d;
	if (numB < 0) numB = -numB;
	if (left % 2 == 0)
		printf("%lld\n", numA);
	else
		printf("%lld\n", numB);
	
	return 0;
}




Measured memory_bytes: 1732
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static ArrayList<Double> x = new ArrayList<Double>();
	static ArrayList<Double> y = new ArrayList<Double>();
	
	public static void main(String[] args) {
		read();
		solve();
	}
	
	static void read(){
		while(sc.hasNext()){
			String[] in = sc.next().split(",");
			x.add(Double.parseDouble(in[0]));
			y.add(Double.parseDouble(in[1]));
		}
	}
	
	static void solve(){
		int n = x.size();
		double px = 0, py = 0;
		for(int i = 0; i < x.size() && i < y.size(); i++){
			px += x.get(i);
			py += y.get(i);
		}
		px = px/n; py = py/n;
		ArrayList<Double> tri = new ArrayList<Double>();
		for(int i = 0; i < x.size()-1 && i < y.size()-1; i++){
			double a = Math.hypot(px-x.get(i), py-y.get(i));
			double b = Math.hypot(px-x.get(i+1), py-y.get(i+1));
			double c = Math.hypot(x.get(i+1)-x.get(i), y.get(i+1)-y.get(i));
			double z = (a+b+c)/2;
			tri.add(Math.sqrt(z*(z-a)*(z-b)*(z-c)));
		}
		double a = Math.hypot(px-x.get(0), py-y.get(0));
		double b = Math.hypot(px-x.get(x.size()-1), py-y.get(y.size()-1));
		double c = Math.hypot(x.get(x.size()-1)-x.get(0), y.get(y.size()-1)-y.get(0));
		double z = (a+b+c)/2;
		tri.add(Math.sqrt(z*(z-a)*(z-b)*(z-c)));
		double res = 0;
		for(int i = 0; i < tri.size(); i++){
			res += tri.get(i);
		}
		System.out.println(res);
	}

}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

ll N, M;
vector<vector<ll>> G;
vector<ll> deg;

ll dp[100100];

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    cin >> N >> M;
    G.assign(N, vector<ll>());
    deg.assign(N, 0);

    rep (i, M) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        deg[y]++;
    }

    queue<ll> que;
    rep (i, N) {
        if (deg[i] == 0) {
            que.push(i);
        }
    }

    // dp table
    // init dp table
    // init condition
    // loop
    while (!que.empty()) {
        ll v = que.front();
        que.pop();

        for (auto next : G[v]) {
            deg[next]--;
            if (deg[next] == 0) {
                que.push(next);
                chmax(dp[next], dp[v]+1);
            }
        }
    }

    ll ans = 0;
    rep (i, N) {
        chmax(ans, dp[i]);
    }

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

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

/*
 * @title StronglyConnectedComponents
 */
class StronglyConnectedComponents{
	int num,is_2sat,half,max_id;
	vector<vector<int>> edge,redge;
	vector<int> label,visited,order;
	inline void dfs(int curr){
		visited[curr] = 1;
		for(int next:edge[curr]) if(!visited[next]) dfs(next);
		order.push_back(curr);
	}
	inline void rdfs(int curr,int id){
		visited[curr] = 1;
		label[curr] = id;
		for(int next:redge[curr]) if(!visited[next]) rdfs(next,id);
	}
	inline int rev(int i) { return i < half ? i + half : i - half; }
public:
	StronglyConnectedComponents(const int n, bool is_2sat=0):num(n),max_id(0),is_2sat(is_2sat){
		if(is_2sat) num*=2;
		edge.resize(num);
		redge.resize(num);
		label.resize(num);
		visited.resize(num);
		half=num/2;
	}
	inline int operator[](int idx) {
		return label[idx];
	}
	inline void make_edge(const int from,const int to) {
		edge[from].push_back(to);
		redge[to].push_back(from);
	}
    //xがflg_xならばyがflg_y
	inline void make_condition(int x, bool flg_x, int y, bool flg_y) {
		if (!flg_x) x = rev(x);
		if (!flg_y) y = rev(y);
		make_edge(x, y);
		make_edge(rev(y), rev(x));
	}
    //is_2sat=1のときに、2satを満たすかを返却する
	inline bool solve(void) {
		for(int i = 0; i < num; ++i) visited[i] = 0;
		for(int i = 0; i < num; ++i) if(!visited[i]) dfs(i);
		for(int i = 0; i < num; ++i) visited[i] = 0;
		reverse(order.begin(),order.end());
		for(int i:order) if(!visited[i]) rdfs(i,max_id++);
		if(!is_2sat) return true;
		for (int i = 0; i < num; ++i) if (label[i] == label[rev(i)]) return false;
		return true;
	}
    vector<vector<int>> topological_sort(void) {
        vector<vector<int>> ret(max_id);
        for(int i=0;i<num;++i) ret[label[i]].push_back(i);
        return ret;
    }
	int is_true(int i) {
		return label[i] > label[rev(i)];
	}
	void print(void) {
		for(auto id:label) cout << id << " ";
		cout << endl;
	}
};


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    StronglyConnectedComponents scc(N);
    while(M--) {
        int u,v; cin >> u >> v;
        scc.make_edge(u,v);
    }
    scc.solve();
    auto vv=scc.topological_sort();
    cout << vv.size() << "\n";
    for(auto& v:vv) {
        cout << v.size();
        for(auto& e:v) cout << " " << e;
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 81484
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

ll pow(ll A, ll P){
	ll a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	ll adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	vector<ll> B;
	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			ll sum = 0;
			for(int l=i;l<=j;l++){
				sum += A[l];
			}
			B.push_back(sum);
		}
	}
	ll x = 0;
	for(int m=39;m>=0;m--){
		int count = 0;
		for(int i=0;i<(int)B.size();i++){
			ll xdash = x + pow(2,m);
			if((xdash & B[i]) == xdash) count++;
		}
		if(count >= K) x += pow(2,m);
	}
	cout << x << endl;
}

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

int fn(int a)
{
	if(a==3) return 100000;
	else if(a==2) return 200000;
	else if(a==1) return 300000;
	else return 0;
}

int main()
{
	int x,y;
	cin>>x>>y;
	int res = fn(x) + fn(y);
	if(x==1 && y==1) cout<<1000000;
	else cout<<res;
	return 0;
}

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

struct Card{char suit, value;};

void bubble(struct Card A[], int N){
    for(int i=0; i<N; i++){
        for(int j=N-1; j>=i+1; j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j]; A[j]=A[j-1]; A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i=0; i<N; i++){
        int minj=i;
        for (int j=i; j<N; j++){
         if(A[j].value<A[minj].value) minj=j;
    }
    Card t= A[i]; A[i] = A[minj]; A[minj]=t;
    }
} 
        
    
void print(struct Card A[],int N){
    for(int i=0; i<N; i++){
        if(i>0)cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[],int N){
    for (int i=0; i<N; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin>> N;
    for(int i=0; i<N; i++){
        cin>>C1[i].suit>> C1[i].value;
}

for(int i=0; i<N; i++)C2[i]=C1[i];


bubble(C1,N);
selection(C2,N);

print (C1,N);
cout << "Stable" << endl;
print(C2,N);
if(isStable(C1,C2,N)){
    cout << "Stable"  << endl;
} else{
    cout << "Not stable" << endl;
}
return 0;

}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if(abs(N - M) <= 1) {
    cout << "Brown\n";
  }
  else {
    cout << "Alice\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void make(int *a,int b)
{
	int i;
	for(i=0;i<10;i++)
	{
		a[i]=b%2;
		//printf("%d ",a[i]);
		b=b>>1;
	}
	
}
int maxof(int *a)
{
	int n,i=0;
	int max=a[0];
	for(;i<1023;i++)
	{
		if(a[i]>max)
		max=a[i];
	}
	return max;
}
int bothOpen(int *a,int *b)
{
	int sum=0,i;
	for(i=0;i<10;i++)
	{
		if(a[i]&&b[i])sum++;
	 } 
	return sum;
}
int main()
{
	int sumProfit[1023];							
	int p[100][11];		
	int n,j,k,convey[10],i;						
	int f[100][10];
	int a[10];							//随机产生的数组 
	while(scanf("%d",&n)!=-1)
	{									
		for(i=0;i<n;i++)
		{
			for(j=0;j<10;j++)
			scanf("%d",&f[i][j]);
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<11;j++)
			scanf("%d",&p[i][j]);
		}
		
		for(i=1;i<1024;i++)
		{
			sumProfit[i-1]=0;
			make(a,i);
			for(j=0;j<n;j++)
			{
				for(k=0;k<10;k++)
				convey[k]=f[j][k];
				
				sumProfit[i-1]+=p[j][bothOpen(a,convey)];
			}
			
			
		} 
		printf("%d\n",maxof(sumProfit));
	}
}

Measured memory_bytes: 888
S=input()
N=len(S)
s1=S[:N//2]
s2=S[N//2+1:]

def f(s):
  n=len(s)
  out=True
  for i in range(n//2):
    if s[i]!=s[-i-1]:
      out=False
  return out

if f(s1)==True and f(s2)==True and f(S)==True:
  print('Yes')
else:
  print('No')

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,le=0,cntt,anss=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      rep(i,n)cin>>a[i];
      cnt=0;
      cntt=0;
      rep(ri,n){
        cnt+=a[ri];
        cntt^=a[ri];
        if(cnt==cntt)anss++,ans+=anss;
        else{
          while(cnt!=cntt){
            cnt-=a[le];
            cntt^=a[le];
            le++;
            anss--;
          }
          anss++;
          ans+=anss;
        }
      }
      Cout(ans);
    
       
return 0;
}


Measured memory_bytes: 1920
#include <cstdio>

const int BALL_NUMBER = 10;
bool state[1];

void back_track(int* list, int n_ptr,int left_top, int right_top) {
	// print
	//printf("ptr=%d, left=%d, right=%d\n", n_ptr, left_top, right_top);
	// find solution
	if (n_ptr == BALL_NUMBER) {
		state[0] = true;
		return;
	}
	// is ever found solution
	if (state[0]) {
		return;
	}
	// do left pattern
	if (list[n_ptr] > left_top)
		back_track(list, n_ptr + 1, list[n_ptr], right_top);
	// do right pattern
	if (list[n_ptr] > right_top)
		back_track(list, n_ptr + 1, left_top, list[n_ptr]);
	return;
}

int main(int argc, char *argv[]) {
	int dataN;
	fscanf(stdin, "%d", &dataN);
	
	for (int i = 0; i < dataN; i++) {
		int ball[10];
		state[0] = false;
		for (int j = 0; j < BALL_NUMBER; j++) {
			fscanf(stdin, "%d", &ball[j]);
		}
		// search
		back_track(ball, 0, -1, -1);
		// print result
		if (state[0])
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 0
from itertools import combinations
import numpy as np
N,M,X = map(int, input().split())
matrix = np.array([list(map(int, input().split())) for _ in range(N)])

min_price = 1e9
for n in range(N):
  for texts in combinations(matrix, n+1):
    summation = np.sum(texts, axis=0)
    price = summation[0]
    if all(summation[1:] >= X):
      if price < min_price:
        min_price = price

print(min_price if min_price < 1e9 else -1)

Measured memory_bytes: 27340
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a[205];
int main() {
	scanf("%d", &n);
	n *= 2;
	int i;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	int ans = 0;
	for (i = 0; i < n; i += 2) ans += a[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> p;
	for(int i=1;i<=n;++i)
	{
		int d;
		cin>>d;
		p.push_back({d,1});
	}
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		p.push_back({y,x});
	}
	sort(p.begin(), p.end());
	int ans=0;
	int c=n;
	for(int i=p.size()-1;i>=0;--i)
	{
		int r=min(p[i].S,c);
		c-=r;
		ans+=r*p[i].F;
	}
	cout<<ans;
}

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

const int N = 1005, M = 200233;
int n, m;
bool ok1[M], ok2[M], visit[N];
vector<pair<int, int>> G[N], rG[N];
void dfs(int x) {
  visit[x] = true;
  for (auto y : G[x]) if (!visit[y.first]) dfs(y.first);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    G[x].emplace_back(y, i);
    rG[y].emplace_back(x, i);
  }
  for (int x = 1; x <= n; x++) {
    for (int j = 1; j <= n; j++) visit[j] = false;
    dfs(x);
    for (auto y : rG[x]) ok1[y.second] = visit[y.first];
    for (int j = 1; j <= n; j++) visit[j] = false;
    visit[x] = true;
    for (auto y : G[x]) ok2[y.second] |= visit[y.first], dfs(y.first);
    reverse(G[x].begin(), G[x].end());
    for (int j = 1; j <= n; j++) visit[j] = false;
    visit[x] = true;
    for (auto y : G[x]) ok2[y.second] |= visit[y.first], dfs(y.first);
  }
  for (int i = 1; i <= m; i++) {
    puts(ok1[i] == ok2[i] ? "same" : "diff");
  }
}


Measured memory_bytes: 7808