akhauriyash/Code-Regression huggingface dataset:
//【ライブラリここから】
// 1. 入力の容易化（https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8）
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//【ライブラリここまで】

fn main() {
    input! {n: i64, a: [i64; n]}
    let mut result: i64 = 0;
    let mut max_val: i64 = 0;
    for val in a {
        if val < max_val {
            result += max_val - val;
            max_val = max_val;
        } else {
            max_val = val;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 3588
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,n;
	long long t[100],x,y,b,sai;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%lld",&t[i]);
	}
	sai=t[0];
	for(i=1;i<n;i++)	{
		if(sai>t[i])	{
			x=sai;	y=t[i];
		}
		else {
			x=t[i];	y=sai;
		}
		while(1)	{
			b=x%y;
			if(b==0)	break;
			x=y;	y=b;
		}
//		printf("y=%lld\n",y);
		sai=sai*(t[i]/y);
	}
	printf("%lld\n",sai);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int a = 0, b = 0;
    for (int i = 0; i < S.size(); i++) {
        a += S[i] - '0';
        b += i == 0 ? S[i]-'0'-1 : 9;
    }
    cout << max(a, b) << endl;
    return 0;
}


Measured memory_bytes: 384
N, K = [int(v) for v in input().strip().split(" ")]
A = [int(v) for v in input().strip().split(" ")]

visited = set()
epoch = [0] * N
round = -1

# try
now = 0
epoch[0] = -1
visited.add(now)
for i in range(K):
    now = A[now] - 1
    if now not in visited:
        visited.add(now)
        epoch[now] = i
    else:
        round = i - epoch[now]
        break

K -= (i + 1)

K = K % round

for _ in range(K):
    now = A[now] - 1

print(now + 1)

Measured memory_bytes: 41148
#include<cstdio>
#define INF 0x3f3f3f3f
long long sum,min_b=INF;
long long min(long long a,long long b){
	return a>b?b:a;
}
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		long long a,b;
		scanf("%lld %lld",&a,&b);
		sum+=a;
		if(a>b) min_b=min(min_b,b);
	}
	if(min_b==INF) sum=INF;
	printf("%lld",sum-min_b);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int n;
    cin>>n;
    rep(i,n){//JCEAPM
        string member,str;
        cin>>member>>str;
        reverse(all(member));
        rep(i,member.size()){
//            cout<<str<<endl;
            if(member[i] == 'J'){
                str = string(1,str[str.size()-1])+str.substr(0,str.size()-1);
            }else if(member[i] == 'C'){
                str = str.substr(1,str.size()-1)+string(1,str[0]);
            }else if(member[i] == 'E'){
                if(str.size()%2==0){
                    str = str.substr(str.size()/2,str.size()/2)+str.substr(0,str.size()/2);
                }
                else{
                    str = str.substr(str.size()/2+1,str.size()/2)+str[str.size()/2]+str.substr(0,str.size()/2);
                }
            }else if(member[i] == 'A'){
                reverse(all(str));
            }else if(member[i] == 'P'){
                rep(j,str.size()){
                    if(isdigit(str[j])){
                        if(str[j] == '0')str[j] ='9';
                        else str[j]--;
                    }
                }
            }else if(member[i] == 'M'){
                rep(j,str.size()){
                    if(isdigit(str[j])){
                        if(str[j] == '9')str[j] = '0';
                        else str[j]++;
                    }
                }
            }
        }
        cout<<str<<endl;
    }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,p[200005];
vector<ll>v[200005];
map<ll,ll>viz;
map<ll,ll>ans;
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=0;i<m;i++)
{ ll x,y;
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
for(ll i=2;i<=n;i++)
{
    p[i]=-1;
}
queue<ll>q;
q.push(1);
viz[1]=1;
p[1]=-1;
while(!q.empty()){
ll x=q.front();
for(auto it : v[x]){
    if(viz[it]!=1){
        viz[it]=1;
        p[it]=x;
        q.push(it);
    }
}
q.pop();
}
for(ll i=2;i<=n;i++)
{
    if(p[i]==-1){
        rc("No");
    }
}
cout<<"Yes"<<endl;
for(ll i=2;i<=n;i++)
{
    cout<<p[i]<<endl;
}
}


Measured memory_bytes: 21492
#include <stdio.h>

int scan(int a[],int b[]){
	int i;
	for(i=0;i<4;i++){
		if(scanf("%d",&a[i])==EOF){
			return 1;
		}
	}
	
	for(i=0;i<4;i++){
		if(scanf("%d",&b[i])==EOF){
			return 1;
		}
	}
	
	return 0;
	
}

int checkHit(int a[],int b[]){
	int sum=0;
	int i;
	for(i=0;i<4;i++){
		sum+=(a[i]==b[i]);
	}
	
	return sum;
}

int serch(int x,int a[]){
	int i;
	for(i=0;i<4;i++){
		if(x==a[i]){
			return 1;
		}
	}
	
	return 0;
}

int checkBlow(int a[],int b[]){
	int sum=0;
	int i;
	for(i=0;i<4;i++){
		sum+=serch(a[i],b);
	}
	
	return sum;
}

int main(){
	int a[4],b[4];
	int i;
	int hit,blow;
	while(1){
		if(scan(a,b)){
			break;
		}
		
		hit=checkHit(a,b);
		blow=checkBlow(a,b)-hit;
		printf("%d %d\n",hit,blow);
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int X, N;
	cin >> X >> N;
	vector<int> p;
	rep(i, N) {
		int a = 0;
		cin >> a;
		p.push_back(a);
	}

	int ans = 0, diff = int(1e7);
	rep(i, -1000, 1000) {
		bool skip = false;
		rep(j, p.size()) {
			if (p[j] == i) skip = true;
		}

		if (skip) continue;
		if (abs(X - i) < diff) {
			ans = i;
			diff = abs(X - i);
		}
	}

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


Measured memory_bytes: 3632
M, D = map(int, input().split())
# print(M, D)

def mul_day(d):
    d1 = d % 10
    d10 = (d // 10) % 10
    if d1 < 2 or d10 < 2:
        return -1
    return d1 * d10

ans = 0

for i in range(2, M + 1):
    for j in range(2, D + 1):
        if i == mul_day(j):
            ans += 1

print(ans)


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

def bsearch(target, S, N):
    left = 0
    right = N
    while left < right:
        mid = (right + left) // 2
        mid_value = S[mid]
        if mid_value == target:
            return 1
        elif mid_value > target:
            right = mid
            continue
        elif mid_value < target:
            left = mid + 1
            continue
    return 0

N = int(input())
S = list(map(int,input().split()))
Q = int(input())
T = list(map(int,input().split()))

cnt = 0

for t in T:
    cnt += bsearch(t, S, N)

print(cnt)




Measured memory_bytes: 16176
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  int cc; scanf("%d", &cc);
  while(cc --> 0){
    unsigned int n[9];

    REP(i,9) scanf("%xu", n + i);

    unsigned int key = 0;

    REP(i,32){
      long long sum = 0;
      REP(j,8){
	sum += (n[j] ^ key);
      }
      if((sum & (1u << i)) != ((n[8] ^ key) & (1u << i))){
	key |= (1u << i);
      }
    }

    printf("%x\n", key);
  }
  return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N); for (int i = 0; i < N; i++) cin >> H[i];
    sort(H.begin(), H.end(), greater<int>());
    if (N <= K) {
        cout << 0 << endl;
    } else {
        long long ans = 0;
        for (int i = 0; i < N; i++) {
            if (i >= K) {
                ans += H[i];
            }
        }
        cout << ans << endl;
    }
    
}  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    string W,T;
    cin >> W;
    
    int cnt = 0;
    while(cin >> T) {
        if(T == "END_OF_TEXT") {
            break;
        }
        
        transform(T.begin(), T.end(), T.begin(), ::tolower);
        
        if(T == W) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3148
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <limits>
#include <vector>

using namespace std;

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = std::vector< Edge< T > >;
template< typename T >
using Graph = std::vector< Edges< T > >;

template < typename T >
struct WarshallFloyd {
  const T INF; // dijkstraとINFの値を揃えるため、型Tの最大値の半分を使う
  const int V; // 頂点数
  Graph<T> g;
  std::vector<std::vector<T>> dist;
  WarshallFloyd(Graph<T> &g): INF(std::numeric_limits<T>::max()/2), V(g.size()), g(g), dist(V, std::vector<T>(V, INF)) { init(); }
  WarshallFloyd(Graph<T> &g, int V): INF(std::numeric_limits<T>::max()/2), V(V), g(g), dist(V, std::vector<T>(V, INF)) { init(); }
  void init() {
    for (int i = 0; i < V; ++i) {
      dist[i][i] = 0;
      for (auto &e: g[i]) dist[i][e.to] = e.cost;
    }
    for (int k = 0; k < V; ++k) {
      for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
          if (dist[i][k] == INF || dist[k][j] == INF) continue;
          T d = dist[i][k]+dist[k][j];
          if (dist[i][j] > d) dist[i][j] = d;
        }
      }
    }
  }
  bool has_negative_cycle() {
    for (int i = 0; i < V; ++i) {
      if (dist[i][i] < 0) return true;
    }
    return false;
  }
};

typedef long long ll;
int h, w;
int id(int i, int j) { 
  return (w+2)*i+j;
}

int main() {
  cin >> h >> w;
  vector<vector<char>> grid(h+2, vector<char>(w+2, '#'));
  for (int i = 0; i < h; ++i) { 
    string s; cin >> s;
    for (int j = 1; j <= w; ++j) { 
      grid[i+1][j] = s[j-1];
    }
  }
  Graph<int> g((h+2)*(w+2));
  for (int i = 1; i <= h; ++i) { 
    for (int j = 1; j <= w; ++j) { 
      if (grid[i][j] == '#') continue;
      if (grid[i][j+1] == '.') {
        g[id(i,j)].emplace_back(id(i,j), id(i,j+1));
        g[id(i,j+1)].emplace_back(id(i,j+1), id(i,j));
      }
      if (grid[i+1][j] == '.') {
        g[id(i,j)].emplace_back(id(i,j), id(i+1,j));
        g[id(i+1,j)].emplace_back(id(i+1,j), id(i,j));
      }
    }
  }
  WarshallFloyd<int> wf(g);
  int ans = 0;
  for (int i = 0; i < (h+2)*(w+2); ++i) {
    for (int j = 0; j < (h+2)*(w+2); ++j) {
      if (i == j) continue;
      if (wf.dist[i][j] == wf.INF) continue;
      ans = max(ans, wf.dist[i][j]);
    }
  }
  cout << ans << endl;
}



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

int coin_throw(int dice, int k) {
	int count = 0;
	while (dice < k) {
		dice *= 2;
		count++;
	}
	return count;
}

double factorial(int n) {
	int ans = 1;
	for (int i = 0; i < n; i++)
		ans *= 2;
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	double sum = 0;
	for (int i = 1; i <= n; i++)
		sum += 1 / factorial(coin_throw(i, k));
	double ans = sum / n;
	cout << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
#define INF 999999999
typedef long long ll;
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<ll> h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(i, 101) {
        rep(j, 101) {
            ll height = -2;

            rep(k, n) {
                if(h[k] > 0) {
                    ll tmp = h[k] + abs(i - x[k]) + abs(j - y[k]);
                    if(height == -2){
                        height = tmp;
                    }
                    else {
                        if(height != tmp) {
                            height = -1;
                            break;
                        }
                    }
                }
            }

            if(height == -1) continue;

            rep(k,n){
                if(h[k] == 0){
                    if(height > abs(i - x[k]) + abs(j - y[k])){
                        height = -1;
                        break;
                    }
                }
            }
            if(height == -1) continue;
            cout << i << " " << j << " " << height << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


VV G;
V deg;

void dfs(int u, int p=-1, int d=0) {
  int cnt = 0;
  for (int v : G[u]) if (v != p) {
    dfs(v, u, d+1);
    ++cnt;
  }
  chmax(deg[d], cnt);
}


int main() {
  int n; cin >> n;
  G.assign(n, V());
  vector<P> E(n-1);
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
    E[i] = {a, b};
  }

  Pll ans = {INFll, INFll};
  rep(i, n) {
    deg.assign(n, -1);
    dfs(i);
    int x = 0;
    ll y = 1;
    for (; deg[x]>0; ++x) y *= deg[x];
    chmin(ans, {x+1, y});
  }
  for (auto [u, v] : E) {
    deg.assign(n, -1);
    dfs(u, v);
    dfs(v, u);
    int x = 0;
    ll y = 2;
    for (; deg[x]>0; ++x) y *= deg[x];
    chmin(ans, {x+1, y});
  }
  
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 26276
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,k,n,m,c,cnt,t,a,p;
    double mn=1000000000*1.0;
    vector<double>v;
    double x;
    cin>>n>>t>>a;
    for(i=0;i<n;i++)
    {
        cin>>k;
        x=t-(0.006*k);
        x=abs((a*1.0)-x);
        v.push_back(x);
    }
    for(i=0;i<n;i++)
    {
        
       if(v[i]<mn)
       {
           mn=v[i];
           p=i;
       }
    }

    cout<<p+1<<endl;




    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = 0;
		N = sc.nextInt();
		
		int[] nums = new int[N];
		
		int minus = 0;
		int min = 1000000000;
		int abs = 0;
		long sum = 0;
		
		for(int i=0; i < N; i++){
			nums[i] = sc.nextInt();
			abs = Math.abs(nums[i]);
			sum += abs;
			if(abs < min) {
				min = abs;
			}
			if(nums[i] < 0) {
				minus++;
			}
		}
		
		sc.close();
		
		if(minus % 2 == 0) {
			System.out.println(sum);
		}else {
			System.out.println(sum - 2 * min);
		}

	}

}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  int tm = min(A, B);
  vector<int> dvs;
  for(int i = 1; i <= tm; ++i) {
    if(A % i == 0 && B % i == 0) {
      dvs.push_back(i);
    }
  }
  sort(dvs.begin(), dvs.end(), [](const auto& l, const auto& r) { return l > r; });
  cout << dvs[K - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    if(d > 0 && d*d > 4 * a * b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int LL;
typedef vector<int> VI;

int main() {
  int A, B;
  cin >> A >> B;
  cout << (A==B ? A+B : ((A>B ? A : B)*2-1)) << endl;
}

Measured memory_bytes: 256
a,b,k=map(int, input().split())

if a<=k:
    k = k-a
    a=0
else:
    a = a-k
    print(a,b)
    exit()
    
if b<=k:
    b = k-b
    b=0
else:
    b = b-k
    print(a,b)
    exit()

print(a,b)


Measured memory_bytes: 38384
#include <cstdio>
#include <vector>
#include <stack>

int main()
{
    int N, p;
    scanf("%d", &N);
    
    std::vector<std::stack<int>> G(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &p);
        G[p - 1].push(i);
    }

    std::vector<int> res(N, -1);
    std::stack<int> st;
    for (int t = 0; t < 2; t++) {
        for (int i = 0; i < N; i++) {
            while (!G[i].empty()) {
                st.push(G[i].top()); G[i].pop();
            }
            if (res[i] == -1 && !st.empty()) {
                res[i] = st.top(); st.pop();
            }
        }
    }
    for (int i = 0; i < N; i++) {
        printf("%d\n", res[i] + 1);
    }    
    return 0;
}

Measured memory_bytes: 70552
N=int(input())
c=input()
ans=0
if len(set(list(c)))==1:
    ans=0
    print(ans)
else:
    #最小の分割店を見つける
    ans=100000000000000000
    W=0
    R=c.count("R")
    for i in range(N):
        if c[i]=="W":
            W+=1
        elif c[i]=="R":
            R-=1
        if max(R,W)<ans:
            ans=max(R,W)
    print(ans)    


Measured memory_bytes: 73104
S = input()
ans = 0

for bit in range(1 << (len(S) - 1)):
    left = 0
    sum_list = []
    for i in range(0, len(S) + 1):
        if (bit >> i) & 1:
            sum_list.append(int(S[left : i + 1]))
            left = i + 1
        elif i == len(S):
            sum_list.append(int(S[left:i]))
    ans += sum(sum_list)
print(ans)


Measured memory_bytes: 3316
#include <iostream>

using ll = long long int;
long long int mod = 1e9 + 7;
ll primesum[100010];

void fillprimesum()
{
    int n = 1e5;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 2*i; j <= n; j += i)
        {
            primesum[j] += i-primesum[i];
        }
    }
}

long long int binpow(long long int a, long long int b)
{
    ll ans = 1;
    b %= mod;
    for (; b > 0; b >>= 1)
    {
        if (b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
    }

    return ans;
}

int main()
{
    fillprimesum();
    long long int ans = 0;
    long long int n, k;
    std::cin >> n >> k;

    for (ll i = 1; i <= k; ++i)
    {
        ll left = i - primesum[i];
        ans += ((left * binpow(k/i, n)) % mod);
        ans %= mod;
    }

    std::cout << ans;
}


Measured memory_bytes: 4392
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    a = LI()
    ans = 0
    for i in range(n):
        ans ^= a[i]
    tmp = []
    for j in range(n):
        tmp.append(ans ^ a[j])
    print(*tmp)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 107932
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int A,B,C;
	SCD3(A,B,C);
	
	int k = 0;
	while(true){
		if ((A%2 == 1) or (B%2 == 1) or (C%2 == 1)){
			PRINTD(k);
			return 0;
		}
		
		if ((A==B) and (B==C) and (C==A) and (A%2==0)){
			PRINTD(-1);
			return 0;
		}
		
		int A2,B2,C2;
		A2 = B/2 + C/2;
		B2 = C/2 + A/2;
		C2 = A/2 + B/2;
		
		A = A2; B = B2; C = C2;
		k++;
	}
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    print((h2-h1)*60+(m2-m1)-k);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3692
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int):
    ns0 = len(range(K, N+1, K))
    ret = ns0 ** 3

    if K % 2 == 0:
        ns1 = len(range(K//2, N+1, K))
        ret += ns1 ** 3

    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    print(result)

if __name__ == '__main__':
    main()


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

const int N = 500009;

long long a[N] = {};
string st;

int main() {
    cin >> st;
    int n = st.length();
    a[0] = 0;
    for (int i = 0, j = 1; i < n; i++, j++) {
        if (st[i] == '<') {
            a[j] = a[j - 1] + 1;
        }
        else {
            a[j] = a[j - 1] - 1;
        }

        if (i > 0 && st[i] != st[i - 1] && a[j - 1] != 0) {
            a[j] = 0;
        }
    }

    for (int i = 0; i <= n; i++) {
        fprintf(stderr, "%3lld%c", a[i], " \n"[i == n]);
    }

    for (int i = 1; i <= n; i++) {
        if (a[i] < 0 && a[i - 1] > a[i] && a[i] < a[i + 1]) {
            int offset_left = -a[i];
            int offset_right = 0;
            int left_limit = i;
            int right_limit = i;

            for (int j = i - 1; j >= 0 && st[j] == '>' && a[j] <= a[j + 1] + offset_left; j--) {
                left_limit--;
            }

            if (a[i] + offset_left >= a[i + 1]) {
                offset_right = (a[i] + offset_left) - a[i + 1] + 1;
                for (int j = i + 1; j <= n && st[j - 1] == '<'; j++) {
                    right_limit++;
                }
            }

            for (int j = i; j >= left_limit; j--) {
                a[j] += min((long long) offset_left, a[j + 1] + 1 - a[j]);
            }

            for (int j = i + 1; j <= right_limit; j++) {
                a[j] +=  offset_right;
            }

            i = right_limit;
        }
    }

    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        fprintf(stderr, "%3lld%c", a[i], " \n"[i == n]);
        ans += a[i];
    }

    fprintf(stderr, "  ");
    for (int i = 0; i < n; i++) {
        fprintf(stderr, "%3c%c", st[i], " \n"[i == n - 1]);
    }

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


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

class UnionFind{
  vector<int> par, rank;
public:
  UnionFind(int n=1){
    par.resize(n);
    for(int i=0;i<n;i++)par[i] = i;
    rank = vector<int>(n,0);
  }

  int find(int x){ return par[x] = par[x]==x?x:find(par[x]); }

  bool same(int x, int y){ return find(x) == find(y); }

  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(rank[x] < rank[y])par[x] = y;
    else{
      par[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
};

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

int main(){
  int w,h,n,x,y,goal = -1;
  string g[1010];

  cin >> w >> h;

  UnionFind uf(h*w);
  for(int i=0;i<h;i++){
    cin >> g[i];
    for(int j=0;j<w;j++){
      if(g[i][j] == 't')goal = i*w + j;
      if(g[i][j] != '#'){
	for(int d=0;d<4;d++){
	  int ny = i+dy[d], nx = j+dx[d];
	  if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
	  if(g[ny][nx] !='#')uf.unite(i*w+j,ny*w+nx);
	}
      }
    }
  }

  cin >> n;
  int ans = -1;
  for(int i=0;i<=n;i++){
    if(i){
      cin >> x >> y;
      g[y][x] = '.';
      for(int d=0;d<4;d++){
	int ny = y+dy[d], nx = x+dx[d];
	if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
	if(g[ny][nx] !='#')uf.unite(y*w+x,ny*w+nx);
      }
    }

    if(ans<0 && uf.same(0,goal))ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12752
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import heapq
import bisect
import copy
# import math
def warshall_floyd(d, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i * N +j] = min(d[i * N +j], d[i * N + k] + d[k * N + j])
    return d

MOD = 10**9 + 7

def main():
    n = getN()
    for i in range(50001):
        if (i * 1.08) // 1 == n:
            print(i)
            return

    print(":(")

if __name__ == '__main__':
    main()



Measured memory_bytes: 39024
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;

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

  cin >> N;

  cout << N * N * N << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
 int W, H, a, b, c;
 cin >> W >> H >> a >> b >> c;
  
 if (W < a || H < b || a <= 0 || b <= 0) {
  cout << "No" << endl;
 }
 else if (W < (a + c) || H < (b + c) || 0 > (a - c) || 0 > (b - c)) {
  cout << "No" << endl;
}
 
 else
  cout << "Yes" << endl;
 
}


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

void print_array(int *A, int N)
{
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N - 1)
			cout << " ";
	}
	cout << endl;
}

void insertion_sort(int *A, int N)
{
	print_array(A, N);
	for (int i = 1; i < N; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		print_array(A, N);
	}
}

int main()
{
	int N, A[100];

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

	insertion_sort(A, N);
}



Measured memory_bytes: 3112
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;



int main(){

	
	fastio;
	int a,b,c;
	cin >> a >> b >> c;

	cout << max(c-(a-b), 0) << endl;

	return 0;
 }	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=2305843009213693951;//巨大な定数
const int dx[]={0,1,0,-1};//x方向のベクトル
const int dy[]={1,0,-1,0};//y方向のベクトル

int main(){
    //入力
    ll h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    vector<vector<char>> S(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>S[i][j];
        }
    }

    //1-indexedなので0-indexedに直す
    ch--;
    cw--;
    dh--;
    dw--;

    //BFS用のqueue
    //HとWには移動1で行けるH座標とW座標
    //H2とW2には移動2で行けるH座標とW座標
    queue<ll> H,H2,W,W2;

    //初期地点をH,Wに追加
    H.push(ch);
    W.push(cw);

    //最低何回の魔法でたどり着けるかを記録する
    //巨大な数INFで初期化する
    vector<vector<ll>> T(h,vector<ll>(w,INF));

    //初期地点は0回の魔法でたどり着く
    T[ch][cw]=0;

    //BFSをする
    while(!H.empty()){
        while(!H.empty()){
            //現在の座標
            ll nh=H.front();
            ll nw=W.front();

            //queueから削除
            H.pop();
            W.pop();

            //移動A
            for(int i=0;i<4;i++){
                //移動先の座標
                ll th=nh+dx[i];
                ll tw=nw+dy[i];

                //範囲外になってないかチェック
                if(th>=h||th<0||tw>=w||tw<0){
                    continue;
                }

                //壁かチェック
                if(S[th][tw]=='#'){
                    continue;
                }

                //魔法の回数が多い場合更新
                if(T[th][tw]>T[nh][nw]){
                    T[th][tw]=T[nh][nw];
                    H.push(th);
                    W.push(tw);
                }
            }

            //移動B
            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    //移動先の座標
                    ll th=nh+i;
                    ll tw=nw+j;

                    //範囲外になってないかチェック
                    if(th>=h||th<0||tw>=w||tw<0){
                        continue;
                    }

                    //移動先が壁かチェック
                    if(S[th][tw]=='#'){
                        continue;
                    }

                    //魔法の回数が多い場合更新
                    if(T[th][tw]>T[nh][nw]+1){
                        T[th][tw]=T[nh][nw]+1;
                        H2.push(th);
                        W2.push(tw);
                    }
                }
            }
        }
        //移動1が終わったので、移動1から1回の魔法で行ける移動2を調べる
        swap(H,H2);
        swap(W,W2);
    }

    //ゴールに到達出来ない場合
    if(T[dh][dw]==INF){
        cout<<-1<<endl;
    }

    //到達できる場合
    else{
        cout<<T[dh][dw]<<endl;
    }
}

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

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

  swap(x,y);
  swap(x,z);

  cout << x << ' ' << y << ' ' << z << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
 
 
int main()
{
	    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
   ll n,w;
   cin>>n>>w;
   vector<pair<ll,ll>>v;
   ll x,y;
   ll sum=100000;
   for(int i=0;i<n;i++)
   {
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        // sum+=y;
   }
   vector<ll>v1(sum+1,INT_MAX),v2(sum+1,INT_MAX);
     v1[0]=0;
     v2[0]=0;
   for(ll i=0;i<n;i++)
   {
 
   	      for(ll j=0;j<v[i].second;j++)
   	      	v2[j]=v1[j];
   	     for(ll j=v[i].second;j<=sum;j++)
   	     {
              v2[j]=min(v1[j],v[i].first+v1[j-v[i].second]);
   	     }
   	       
      	        for(ll k=0;k<=sum;k++){
               v1[k]=v2[k];
               // cout<<v1[k]<<" ";
           }
           // cout<<endl;
   	     v2.clear();
   }
   ll p=0;
   for(int i=sum;i>=0;i--)
   {
   	  if(v1[i]<=w)
   	  {
   	  	p=i;
   	  	break;
   	  }
   }
   cout<<p<<endl;
 
	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
        return;
    }
        cout << "No\n";

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3652
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let a = scan::<i32>();
    let b = scan::<i32>();
    let h = scan::<i32>();
    println!("{}", (a+b)*h/2);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll N, K;
    cin>>N>>K;
    vector<ll> A(N);
    vector<ll> B(N+1, 0);
  	if(K>=100){
      	rep(i, N){
          	if(i>0)cout<<" ";
          	cout<<N;
        }
      	return 0;
    }
    rep(i, N){
        cin>>A[i];
      	ll mi=max((ll)0, i-A[i]);
        ll ma=min(N-1, i+A[i]);
      	B[mi+1]++;
      	if(ma+2<=N)B[ma+2]--;
    }
  	rep(i, N){
      	B[i+1]+=B[i];
      	A[i]=B[i+1];
    }
  	/*rep(i, N){
      	if(i>0)cout<<" ";
      	cout<<A[i];
    }
      	cout<<endl;*/
    rep(j, K-1){
      	rep(i, N+1){
          	B[i]=0;
        }
      	rep(i, N){
      		ll mi=max((ll)0, i-A[i]);
        	ll ma=min(N-1, i+A[i]);
      		B[mi+1]++;
      		if(ma+2<=N)B[ma+2]--;
    	}
  		rep(i, N){
      		B[i+1]+=B[i];
          	A[i]=B[i+1];
    	}
      	/*rep(i, N){
      		if(i>0)cout<<" ";
      		cout<<A[i];
    	}
      	cout<<endl;*/
    }
  	rep(i, N){
      	if(i>0)cout<<" ";
      	cout<<A[i];
      
    }
}
     

Measured memory_bytes: 6436
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	 static int divisors(long x) {
		    long limit = x;
		    int numberOfDivisors = 0;

		    if (x == 1) return 1;

		    for (int i = 1; i < limit; ++i) {
		        if (x % i == 0) {
		            limit = x / i;
		            if (limit != i) {
		                numberOfDivisors++;
		            }
		            numberOfDivisors++;
		        }
		    }

		    return numberOfDivisors;
		} 
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt();
		int c=0,c1=0,c2=0,c3=0;
		String ac = "AC";
		String wa = "WA";
		String tle = "TLE";
		String re = "RE";
		for(int i=0;i<n;i++) {
			String se = s.next();
			if(se.contentEquals(ac))c++;
			else if(se.contentEquals(wa))c1++;
			else if(se.contentEquals(tle))c2++;
			else if(se.contentEquals(re))c3++;
			
		}
		System.out.println("AC x "+c);
		System.out.println("WA x "+c1);
		System.out.println("TLE x "+c2);
		System.out.println("RE x "+c3);
	}
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int alph_min[30] = {0};
    map<char,int> alph[n];
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.length()){
            alph[i][s[j]]++;
        }
    }
    int cnt;
    for(auto itr = alph[0].begin();itr!=alph[0].end();itr++){
        char key = itr->first;
        cnt = alph[0][key];
        for(int i = 1; i < n; i++){
            
            if(alph[i].find(key)==alph[i].end()) {
                cnt = 0;
                continue;
            }
            cnt = min(cnt,alph[i][key]);
        }
        rep(i,cnt){
            cout << itr->first;
        }
    }
    cout << endl;
    return 0;
}

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


int main() {
	
	int N, sum=0;
	cin >> N;
	vector<int> v(N), c(N);
	for(auto &i:v) cin >> i;
	for(auto &i:c) cin >> i;
	for(int i=0; i<N; i++){
		sum += max(0, v.at(i)-c.at(i));
	}
	cout << sum << endl;
	
	
	return 0;
}

Measured memory_bytes: 256