akhauriyash/Code-Regression huggingface dataset:
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

map<string,int> mp;
string s;

int main()
{
    NO_TLE
    int n,m,mx=0;
    cin>>n;
    rep(i,n)
    {
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    rep(i,m)
    {
        cin>>s;
        mp[s]--;
    }
    for(auto it=mp.begin();it!=mp.end();++it)
    {
        if((it->second)>mx)
        {
            mx=(it->second);
        }
    }
    cout<<mx<<endl;
    return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int n, a[10000];


int main(){
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int in;
		cin >> in;
		while(in%2 == 0 ){
			ans++;
			in/=2;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define fr(n) for(int i=n-1;i>=0;i--)
#define chlo(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
#define vs vector<string>
#define int long long int
#define all(a) (a).begin(),(a).end()
#define sortall(x) sort(all(x))
#define itr(a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define zerbits(x) __builtinctzll(x)
#define mod 1000000007
#define sz(x) (int)x.size()
#define inf 1e18
#define W(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define INT_SIZE 32
#define pr pair<int,int>
#define deb(x) cout<<#x<<"="<<x<<endl;
#define F first
#define S second
#define pii pair<int,int>

int mpow(int exp, int base);
void aeh()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("aana.txt", "r", stdin);
	freopen("jj.txt", "w", stdout);
#endif
}
int32_t main()
{
//	aeh();
	int n;
	cin >> n;
	int w;
	cin >> w;
	vi a(n);
	vi b(n);
	fi(n)
	{
		cin >> b[i] >> a[i];
	}
	//dp[i][j] would tell the maximum value if the max weight is j and I can take the first I values only
	int dp[n + 1][w + 1];
	fi(n + 1) {
		fj(w + 1) {
			dp[i][j] = 0;
		}

	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			if (j < b[i - 1]) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - b[i - 1]] + a[i - 1]);
			// deb(dp[i][j]);
		}
	}
	cout << dp[n][w] << endl;
}


int mpow(int base, int exp)
{
	base %= mod;
	int result = 1;
	while (exp > 0)
	{
		if (exp & 1)result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

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

int main() {
  int N,l,r;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >>l >> r;
    sum += r - l +1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def mcm(M):
  n = len(M)
  m = [[0 for i in range(n)] for j in range(n)]
   
  for l in range(2, n+1):
    for i in range(0, n-l+1):
      j = i + l - 1
      def cost(i, k ,j):
        return m[i][k] + m[k+1][j] + M[i][0]*M[k][1]*M[j][1]
      m[i][j] = min(cost(i, k, j) for k in range(i, j))
   
  return m[0][n-1]
 
n = input()
M = []
 
for i in range(n):
  M.append(map(int, raw_input().split()))
print mcm(M)

Measured memory_bytes: 6480
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun May 31 18:08:11 2020

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  REP(i,s.size()){
      if (i%2==0)cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 592
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, a, b): (usize, usize, usize) = read();
    println!("{}", min(n*a, b));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int X;
  int N;
  int a = 0;
  int b = 0;
  set<int> s;
  cin>>X;
  cin>>N;
  for(int i = 0;i < N;i++){
    cin>>a;
    s.insert(a);
    //cout<<"A"<<a<<'\n';
  }
  for(int i = 0;i < 100;i++){
    if(s.find(X - i) == s.end()){
      b = X - i;
      break;
    }
    if(s.find(X + i) == s.end()){
      b = X + i;
      break;
    }    
  }
  cout<<b<<'\n';
  // for(int i = 0;i < N;i++){
  //   cin>>a;
  //   s.insert(a);
  //   //cout<<"A"<<a<<'\n';
  // }
  // for(int i = 0;i < 100;i++){
  //   //cout<<X - i<<' ';
  //   //cout<<X + i<<'\n';
  //   if(s.find(X - i) == s.end()){
  //     cout<<X - i<<'\n';
  //     //cout<<"B"<<'\n';
  //     //cout<<"B"<<X - i<<'\n';
  //     break;
  //   }
  //   if(s.find(X + i) == s.end()){
  //     cout<<X - i<<'\n';
  //     //cout<<"A"<<'\n';
  //     //cout<<"C"<<X + i<<'\n';
  //     break;
  //   }
  // }
}

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

int main(){
  int a,b;
  double h,m;
  cin >> a >> b >> h >> m;

  double ang_m = m * 6;//分針の角度(degree)
  double ang_h = h * 30 + m * 0.5;//時針の角度(degree)
  double ang = max(ang_h,ang_m) - min(ang_h,ang_m);//2本の針がなす角(degree)
  ang = ang * M_PI / 180;//radianに変換

  double ans = sqrt(a * a + b * b - 2 * a * b * cos(ang));

  printf("%.12lf",ans);

  return 0;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
const int tam = 1e6;
long long f[tam], finv[tam];

/*
    5 5 2 2
    o o o o o
    o o o o o
    o o o o o
    x x o o o
    x x o o o
*/

long long exp( long long b, long long e ) {
    long long ans = 1;
    while( e ) {
        if( e&1 ) {
            ans = (ans*b)%mod;
        }
        b = (b*b)%mod;
        e >>= 1;
    }
    return ans;
}

long long NcK( long long N, long long K ) {
    return ( (f[N]*finv[N-K])%mod * finv[K] )%mod;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    f[0] = finv[0] = 1;
    for( int i = 1; i < tam; i++ ) {
        f[i] = (f[i-1]*i)%mod;
        finv[i] = exp( f[i], mod-2 );
    }
    int w, h, a, b;
    cin >> h >> w >> a >> b;
    long long ans = 0;
    for( int x = b; x < w; x++ ) {
        long long y = h - a - 1, x1 = w-x-1;
        long long temp = ( NcK(y+x, x) * NcK( a-1 + x1, x1 ) )%mod;
        ans = (ans+temp)%mod;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if((A-B)%2){
        ll before, after;
        if(A < N-B+1){
            before = A;
            after = B;
        }else{
            before = N-B+1;
            after = N-A+1;
        }
        if(before+1==after){
            P(before);
        }else{
            P(before+(after-before-1)/2);
        }
    }else{
        P(abs(A-B)/2);
    }
}

Measured memory_bytes: 256
void main() {
	auto X = ri;
	if(X == 7 || X == 5 || X == 3) {
		writeln("YES");
	} else writeln("NO");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  int a[n];
  rep(i,n)cin >> a[i];
  ll dp[n+5];
  rep(i,n+5)dp[i]=1000000000;

  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n+2;i++){
    chmin(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    chmin(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout << dp[n-1] <<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;

const int MAXN = 1e5+5;

struct Node {
    int id;
    int number;
    bool operator<(const Node& b) const {
        return this->number < b.number;
    }
} a[MAXN];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        a[i].id = i;
        cin >> a[i].number;
    }
    std::sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) {
        cout << a[i].id << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#062-B
h,w=map(int,input().split())
p=[]
for i in range(h):
    t=list(input())
    p.append(t)
for i in range(w+2):
    print('#',end='')
print()

for i in range(h):
    print('#',end='')
    for j in range(w):
        print(p[i][j],end='')
    print('#')

for i in range(w+2):
    print('#',end='')
print()

Measured memory_bytes: 4596
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) // cerr<<(str)<<endl;
int main() {
  int n;
  cin >> n;
  vector<int> l(n + 1, 0), r(n + 1, 0);
  rep(i, 0, n) { cin >> l[i] >> r[i]; }
  sort(all(l), greater<int>());
  sort(all(r));
  ll ma = 0;
  ll sum = 0;
  rep(i, 0, n / 2 + 1) {
    sum += 2 * (l[i] - r[i]);
    ma = max(ma, sum);
    // cerr << sum << " " << ma << endl;
  }
  cout << ma;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int N, Z, W;
vector<int> cards;
int dp[2000][2];
 
int draw(int X_card, int Y_card, bool if_X_phasing){
	if(X_card == N - 1){
		int Y_card_num;
		if(Y_card == -1){
			Y_card_num = W;
		}else{
			Y_card_num = cards[Y_card];
		}
		return abs(cards[X_card] - Y_card_num);
	}else if(Y_card == N - 1){
		int X_card_num;
		if(X_card == -1){
			X_card_num = Z;
		}else{
			X_card_num = cards[X_card];
		}
		return abs(X_card_num - cards[Y_card]);
	}else if((dp[Y_card + 1][if_X_phasing] != -1) && if_X_phasing){
		return dp[Y_card + 1][if_X_phasing];
	}else if((dp[X_card + 1][if_X_phasing] != -1) && !if_X_phasing){
		return dp[X_card + 1][if_X_phasing];
	}else if(if_X_phasing){
		int ans = 0;
		for(int i = Y_card + 1; i < N; i++){
			ans = max(ans, draw(i, Y_card, false));
		}
		return dp[Y_card + 1][if_X_phasing] = ans;
	}else{
		int ans = 1e9;
		for(int i = X_card + 1; i < N; i++){
			ans = min(ans, draw(X_card, i, true));
		}
		return dp[X_card + 1][if_X_phasing] = ans;
	}
}
 
int main(){
	cin >> N >> Z >> W;
	for(int i = 0; i < N; i++){
		int input;
		cin >> input;
		cards.push_back(input);
	}
	for(int i = 0; i < 2000; i++){
		dp[i][0] = -1;
		dp[i][1] = -1;
	}
	cout << draw(-1, -1, true) << endl;
}

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

int main() {
	long long ans = 0;
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for (int &x : v)
		scanf("%d", &x);

	bool flag = true;
	if (v[0] != 0)
		flag = false;

	for (int i = 1; i < n; i++) {
		if (v[i] > v[i - 1]) {
			ans++;
			if (v[i] > v[i - 1] + 1)
				flag = false;
		} else {
			ans += v[i];
		}
	}

	if (!flag)
		ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
str = io.read()
if str=="SAT" then
  print(1)
elseif str=="FRI" then
  print(2)
elseif str=="THU" then
  print(3)
elseif str=="WED" then
  print(4)
elseif str=="TUE" then
  print(5)
elseif str=="MON" then
  print(6)
else
  print(7)
end

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K; 
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    A[i]--;
  }

  int L = 62;
  vector<vector<int>> next(L, vector<int>(N, -1));

  REP(i, N) next[0][i] = A[i];
  FOR(p, 1, L) REP(i, N){
    if(next[p-1][i] != -1) next[p][i] = next[p-1][next[p-1][i]];
  }

  int now = 0;
  RREP(p, L){
    if((K >> p)&1) now = next[p][now];
  }

  cout << now+1 << "\n";

  return 0;
}

Measured memory_bytes: 103256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n,m; cin >> n >> m;
    vector<int> a(m),b(m);
    vector<vector<int>> c(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        for(int j=0;j<b[i];j++){
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    vector<ll> dp((1<<n),LINF);
    dp[0] = 0;
    for(int mask=0;mask<(1<<n);mask++){
        for(int i=0;i<m;i++){
            int mask2 = mask;
            for(int j=0;j<b[i];j++){
                mask2 |= (1<<c[i][j]);
            }
            chmin(dp[mask2],dp[mask]+a[i]);
        }
    }
    if(dp[(1<<n)-1] == LINF){
        cout << -1 << endl;
        return 0;
    }
    cout << dp[(1<<n)-1] << endl;
}


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

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> p(N);
    for (int64_t& P : p) {
        cin >> P;
    }

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

    cout << accumulate(p.begin(), p.begin() + K, (int64_t)0) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (auto &&i : v) scanf("%d", &i);
    auto S = accumulate(v.begin(),v.end(), 0LL);
    if(S > n) puts("-1");
    else cout << n-S << "\n";
    return 0;
}

Measured memory_bytes: 3700
#include <iostream>

using namespace std;

bool search(unsigned long long* array, const int size, const unsigned long long val);

int main() {
	int n, q, count;
	unsigned long long* S;
	unsigned long long T;

	count = 0;
	cin >> n;
	S = new unsigned long long[n];
	for(int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for(int i = 0; i < q; i++) {
		cin >> T;
		if(search(S, n, T)) {
			count++;
		}
	}

	cout << count << endl;

	delete[] S;

	return 0;
}

bool search(unsigned long long* _array, const int _size, const unsigned long long val) {
	unsigned long long* array = _array;
	int size = _size;
	int index = size / 2;
	int z1index;

	while(1) {
		if(val == array[index]) {
			return true;
		} else if(val < array[index]) {
			if(1 == size) break;
			size = index;
			index = size / 2;
		}
		else{
			if(1 == size) break;
			array = &array[index];
			size -= index;
			index = size / 2;
		}
	}
	return false;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            char pos = 'A';

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                if (pos == input[0]) pos = input[2];
                else if (pos == input[2]) pos = input[0];
            }
            Console.WriteLine(pos);
        }
    }
}

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, L;
  cin >> N >> L;
  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++){
    int p, c;
    cin >> p >> c;
    P[i] = make_pair(p, c);
  }
  sort(P.begin(), P.end());
  vector<long long> left(N + 1, 0);
  for (int i = 0; i < N; i++){
    if (P[i].second == 0){
      left[i + 1] = left[i] + (P[i].first - (i + 1));
    } else {
      left[i + 1] = left[i] - (P[i].first - (i + 1));
    }
  }
  vector<long long> right(N + 1, 0);
  for (int i = N - 1; i >= 0; i--){
    if (P[i].second == 1){
      right[i] = right[i + 1] + (L - (N - 1 - i) - P[i].first);
    } else {
      right[i] = right[i + 1] - (L - (N - 1 - i) - P[i].first);
    }
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++){
    ans = max(ans, left[i] + right[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5064
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	int N;
	cin >> N;
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		for (int j = 0; j <= 10000; j++) {
			if (dp[i - 1][j] == 1) {
				dp[i][j + a] = 1;
				dp[i][j] = 1;
			}
		}
	}
	for (int i = 10000; i >= 0; i--) {
		if (i % 10 != 0) {
			if (dp[N][i] == 1) {
				cout << i;
				return 0;
			}
		}
	}
	cout << "0";
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
LL a[100010];
char op[100010];
LL dp[100010][3];

void init() {
}

void input() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		if (i < n-1) cin >> op[i+1];
	}
}

void solve() {
	REP(i, 100010) REP(j, 3) dp[i][j] = -1e15;
	dp[0][0] = a[0];
	FOR(i, 1, n){
		if(op[i] == '+'){
			dp[i][0] = max({
				dp[i-1][0]+a[i], 
				dp[i-1][1]+a[i], 
				// dp[i-1][2]+a[i]
				});
			dp[i][1] = max({
				dp[i-1][1]-a[i], 
				// dp[i-1][2]-a[i]
				});
			dp[i][2] = max({
				dp[i-1][2]+a[i]
				});
		}
		else{
			// dp[i][0] = max({
			// 	dp[i-1][0]-a[i], 
			// 	dp[i-1][1]-a[i], 
			// 	dp[i-1][2]-a[i]
			// 	});
			dp[i][1] = max({
				dp[i-1][0]-a[i], 
				// dp[i-1][1]+a[i], 
				// dp[i-1][2]+a[i]
				});
			dp[i][2] = max({
				dp[i-1][1]+a[i], 
				dp[i-1][2]+a[i]
				});
		}
	}
	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

int main() {
	init();
    input();
    solve();
	return 0;
}








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

int main() {
    vector<int> x(5);
    for(auto &e : x) cin >> e;
    for(int i = 0; i < 5; ++i) {
        if(x[i] == 0) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final long count = Arrays.stream(br.readLine().split("")).filter(i -> i.equals("1")).count();
        System.out.println(count);

    }
}

Measured memory_bytes: 27348
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int res = 0;
    rep(i,N-1){
        if(S[i+1] == S[i]) res++;
    }
    cout << min(res+2*K,N-1) << endl;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] % attack
                else:
                    pass


Measured memory_bytes: 64204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <stdbool.h>
#define PI 3.141592653589
#define N_MAX 100

int main()
{
  char buf[N_MAX];
  bool cards[4][13];
  int n,cd, num, i, j, k, l;
  for(i = 0; i < 4; i++)
    {
    for(j = 0; j < 13; j++)
      {
	cards[i][j] = false;
      }
    }
  scanf("%d",&n);
  for(k = 0; k < n; k++)
    {
      scanf("%s %d",buf,&num);
      if(buf[0] == 'S') l = 0;
      else if(buf[0] == 'H') l = 1;
      else if(buf[0] == 'C') l = 2;
      else if(buf[0] == 'D')  l = 3;
      else {printf("error\n"); exit(1);}
      cards[l][num-1] = true;
    }
   for(i = 0; i < 4; i++)
    {
    for(j = 0; j < 13; j++)
      {
	if(cards[i][j] == false)
	  {
	    switch(i)
	      {
	      case 0:
		{
		  printf("S");
		  break;
		}
	      case 1:
		{ 
		  printf("H");
		  break;
		}
	      case 2:
		{
		printf("C");
		break;
		}
	      case 3:
		{
		printf("D");
		break;
		}
	      default: break;
	      }
	    printf(" %d\n",j+1);
	  }
      }
    }
  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    while (a[i] > 0) {
      if (a[i] % 2 != 0) break;
      ans++;
      a[i] /= 2;
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
#include <cctype>
#include <cstdio>
using namespace std;

class State{
public:
  int f, x, y, bit, cost;

  State(int _f, int _x, int _y, int _bit, int _cost){
    f = _f;
    x = _x;
    y = _y;
    bit = _bit;
    cost = _cost;
  }

  bool operator<(const State &st)const{
    return cost > st.cost;
  }
};

int w, h, n, sx, sy;
char t[52][52];
char s[12][52][52];

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

bool closed[2][52][52][1024];

void solve(){
  priority_queue<State> open;
  memset(closed, 0, sizeof(closed));
  open.push(State(0, sx, sy, 0, 0));

  while(!open.empty()){
    State st = open.top();
    open.pop();

    if(closed[st.f][st.y][st.x][st.bit]){
      continue;
    }
    closed[st.f][st.y][st.x][st.bit] = true;

    if(t[st.y][st.x] == '&'){
      cout << st.cost << endl;
      return;
    }

    if(t[st.y][st.x] == '|'){
      open.push(State(!st.f, st.x, st.y, st.bit, st.cost + 1));
    }

    if(isalpha(t[st.y][st.x])){
      int sw = t[st.y][st.x] - (isupper(t[st.y][st.x]) ? 'A' : 'a');
      int nf = st.f;
      int nx = st.x;
      int ny = st.y;
      int nbit = st.bit ^ (1 << sw);
      int ncost = st.cost + 1;

      if(s[sw][st.y][st.x] == '*'){
	nf = !nf;
      }

      open.push(State(nf, nx, ny, nbit, ncost));
    }

    for(int i = 0; i < 4; i++){
      int nx = st.x + dx[i];
      int ny = st.y + dy[i];

      if(t[ny][nx] == '#') continue;

      int nf = (t[ny][nx] == '^' || isupper(t[ny][nx]) ? 1 : 0);

      for(int j = 0; (1 << j) <= st.bit; j++){
	if( !( st.bit & (1 << j) ) ) continue;
	if(s[j][ny][nx] == '*'){
	  nf = !nf;
	}
      }

      if(t[ny][nx] != '|' && st.f != nf) continue;

      open.push(State(st.f, nx, ny, st.bit, st.cost + 1));
    }
  }

  cout << -1 << endl;
}

int main() {
  while(cin >> w >> h){
    for(int i = 0; i < h; i++){
      cin >> t[i];

      for(int j = 0; j < w; j++){
	if(t[i][j] == '%'){
	  sx = j;
	  sy = i;
	}
      }
    }

    cin >> n;

    for(int i = 0; i < n; i++){
      for(int j = 0; j < h; j++){
	cin >> s[i][j];
      }
    }

    solve();
  }
}

Measured memory_bytes: 12232
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10000
#define STRLEN 20

int main(void){
    int row, col, n=0, count, ans = 0;
    scanf("%d %d %d", &col, &row, &n);
    char a[7][7];
    for(int i=0;i < col;i++){
            scanf("%s", a[i]);
    }


    for(int h=0;h < 1<<col;h++){
        for(int w=0; w < 1<<row;w++){
            count = 0;
            for(int i=0; i < col; i++){
                if((h>>i) % 2 == 0) continue;
                for(int l=0; l < row; l++){
                    if((w>>l) % 2 == 0) continue;
                    if(a[i][l] == '#') count++;
                }
            }
            if (count == n) ans++;
        }
    }

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

}


Measured memory_bytes: 1732
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string a[3];
    for (auto &i : a) cin >> i;
    for (int j = 0; j < 2; ++j) {
        if (a[j].back() != a[j+1][0]) {
            cout << "NO"; return 0;
        }
    };
    cout << "YES";
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans;
  if(s=="SUN") ans = 7;
  else
  if(s=="MON") ans = 6;
  else
  if(s=="TUE") ans = 5;
  else
  if(s=="WED") ans = 4;
  else
  if(s=="THU") ans = 3;
  else
  if(s=="FRI") ans = 2;
  else
  if(s=="SAT") ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int X=0;
	int MX=0;
	cin>>n;
	char s[n];
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')
		X++;
		MX=max(X,MX);
		if(s[i]=='D')
		abs(X--);
	}
	cout<<MX;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;
const ll MOD=1e9+7;


int main(){
  int min,sum;
  min=10;
  vector<int> v(5);
  vector<int> c(5);
  vector<int> x(5);
  REP(i,5){
  cin>>v[i];
    c[i]=v[i]%10;
    if(c[i]==0)c[i]=10;
    x[i]=10-c[i];
  }
  
 REP(i,5){
 if(c[i]<=min)min=c[i];
 }
  REP(i,5){
  sum+=v[i]+x[i];
  }
  sum-=(10-min);
  cout<<sum<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k,a,ans=0;
  cin >> n >> m;
  map<int, int> mp;
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a;
      mp[a]++;
    }
  }
  for(int i=1;i<=m;i++){
    if(mp[i]==n){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())
if M1==1 and D1==31:
    print(1)
elif M1==2 and D1==28:
    print(1)
elif M1==3 and D1==31:
    print(1)
elif M1==4 and D1==30:
    print(1)
elif M1==5 and D1==31:
    print(1)
elif M1==6 and D1==30:
    print(1)
elif M1==7 and D1==31:
    print(1)
elif M1==8 and D1==31:
    print(1)
elif M1==9 and D1==30:
    print(1)
elif M1==10 and D1==31:
    print(1)
elif M1==11 and D1==30:
    print(1)
elif M1==12 and D1==31:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut s = read::<String>().chars().collect::<Vec<_>>();
    let n = s.len();

    let mut answers = vec![0; n];
    for _ in 0..2 {
        let mut fall_poses = vec![];
        for i in 0..n - 1 {
            if s[i] == 'R' && s[i + 1] == 'L' {
                fall_poses.push(i);
            }
        }

        for i in 0..n {
            if s[i] == 'R' {
                let idx = fall_poses.lower_bound(&i);
                assert!(idx != fall_poses.len());
                if (fall_poses[idx] - i) % 2 == 0 {
                    answers[fall_poses[idx]] += 1;
                } else {
                    answers[fall_poses[idx] + 1] += 1;
                }
            }
        }
        answers.reverse();
        s.reverse();
        s = s
            .iter()
            .map(|&x| if x == 'R' { 'L' } else { 'R' })
            .collect::<Vec<_>>();
    }

    for ans in answers {
        print!("{} ", ans);
    }
    println!("");
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int N;
int A[12];
int main(){
	cin >> N;
	for(int i=0; i < N; i++) cin >> A[i];
	
	int Max = 0;
	for(int i = 0; i < N; ++i) 
        if( A[i] > Max ){
            Max = A[i];
}
	
	int sum = 0;  
    for(int i = 0; i < N; ++i) sum += A[i]; 

	if(Max < sum - Max){
cout << "Yes" << endl;
}
	else{
cout << "No" << endl;
}
    }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba")ou("Yes");
  else ou("No");
}

Measured memory_bytes: 256
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let s = scanner.Next() |> Seq.toList
    let tail arr =
        match arr with
        | [||] -> arr
        | x -> Array.tail x

    let rec f a =
        function
        | [] -> Seq.rev a
        | x::xs when x = 'B' -> f (tail a) xs
        | x::xs -> f (Array.append [|x;|] a) xs
    
    f [||] s
    |> Seq.iter (printf "%c")
    printfn ""
    0


Measured memory_bytes: 12112
#include <iostream>
#include <algorithm>
#include <math.h>
#define MAX 1000000
using namespace std;

int N;
int X[MAX];

int sum(int x){
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += (x - X[i]) * (x - X[i]);
  }

  return sum;
}

int main()
{
    int sumX = 0;
    int minX = 100;
    int maxX = 1;

    cin >> N;
    for(int i = 0; i < N; i++){
      cin >> X[i];
      sumX += X[i];

      if(X[i] < minX){
        minX = X[i];
      }else if(X[i] > maxX){
        maxX = X[i];
      }
    }

    float ave = (float)sumX / (float)N;

    int afloor = (int)floor(ave);
    int aceil = (int)ceil(ave);

    int minpos = min(sum(afloor), sum(aceil));

    cout << minpos << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,t,ans;
    scanf("%d %d %d",&a,&b,&c);
    t=a-b;
    t=max(0,t);
    ans=c-t;
    printf("%d",max(0,ans));
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

print(inp()*2*math.pi)

Measured memory_bytes: 10504
#include<cstdio>
#define M 100005
#define P 1000000007
char S[M];
void Add(int &x,int y){x=(1ll*x+y)%P;}
int cnt[1005];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",S);
	for(int i=0;i<n;i++)cnt[S[i]-'a']++;
	long long ans=1ll;
	for(int i=0;i<26;i++){
		ans=1ll*ans*(cnt[i]+1)%P;
	}
	printf("%lld\n",(ans-1+P)%P);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
typedef long long LL;
inline int rd() {int r;scanf("%d",&r);return r;}
 
struct Edge{int b,v,n;}e[2*N];
int siz[N],h[N],cnt,mark,g,n;
LL ans;
 
void link(int a,int b,int v) {
    e[++cnt] = (Edge){b,v,h[a]}, h[a] = cnt;
}
 
void dfs(int u,int f,int p) {
    siz[u] = 1;
    int mx = 0;
    for (int i=h[u];i;i=e[i].n) {
        int v = e[i].b, cp = e[i].v;
        if (v == f) continue;
        dfs(v, u, cp);
        siz[u] += siz[v];
        mx = max(mx, siz[v]);
    }
    mx = max(mx, n-siz[u]);
    if (siz[u]*2 == n) mark = p;
    if (mx*2 <= n) g = u;
    ans += 2LL * p * min(siz[u], n-siz[u]);
}
 
int main() {
    n = rd();
    for (int i=1;i<n;i++) {
        int a = rd(), b = rd(), c = rd();
        link(a, b, c);
        link(b, a, c);
    }
 
    dfs(1,1,0);
 
    if (!mark) {
        mark = 2147483647;
        for (int i=h[g];i;i=e[i].n)
            mark = min(e[i].v, mark);
    }
    cout << ans - mark << endl;
    return 0;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
int n,ans;
int a[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]); ans^=a[i];
	}
	if (ans==0) puts("Yes"); else puts("No");
}

Measured memory_bytes: 640
import collections
N = int(input())
def prime(N):
  a = []
  while N%2 ==0:
    a.append(2)
    N = N/2
  f = 3
  while f**2 <= N:
    if N%f ==0:
      a.append(f)
      N = N/f
    else:
      f += 2
  if N != 1:
    a.append(int(N))
  return(a)
M = collections.Counter(prime(N))
M_ls = list(M.values())
count = 0
for i in range(len(M_ls)):
  n = 1
  while M_ls[i] >= n*(n+1)/2:
    count += 1
    n += 1
    
print(count)

Measured memory_bytes: 9408
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int till = s.size() / 2;
  rep(i, till) {
    if (s[i] != s[s.size()-(1+i)]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3496
#include<stdio.h>
#include<vector>

using namespace std;

int main(){
	vector<int> num;
	int times=0;
	scanf("%d",&times);
	for(int i=0; i<times; i++){
		int action=0,input=0;
		scanf("%d",&action);
		if(action==0){
			scanf("%d",&input);
			num.push_back(input);
		}else if(action==1 && !(num.size()==0)){
			scanf("%d",&input);
			printf("%d\n",num[input]);
		}else if(action==2 && !(num.size()==0)){
			num.pop_back();
		}
	}
	return 0;
}



Measured memory_bytes: 3400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int n;
    std::cin >> n;
    std::vector<ll> a(n);
    rep(i,n) std::cin >> a[i];

    std::sort(a.begin(),a.end(),std::greater<ll>());

    ll ans = 0;
    for(int i=0; i<n-1; i++) ans += a[(i+2-1)/2];
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4820