akhauriyash/Code-Regression huggingface dataset:
# B Multiplication 2

n = int(input())
a = list(map(int, input().split()))

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(0)
    exit()

if ans > 10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21424
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int x; cin >> x;
  vector<int> vec{1};
  FOR(i, 2, sqrt(x)+1) {
    int now = 1;
    REP(j, 2) now *= i;
    while (now <= x) {
      vec.push_back(now);
      now *= i;
    }
  }
  sort(ALL(vec));
  cout << vec.back() << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
S = []
for _ in range(N):
    string = sorted(input())
    string = "".join(string)
    S.append(string)

S_counter = Counter(S)

ans = 0
for i in S_counter.values():
    if i != 1:
        number = cmb(i, 2)
        ans = ans + number

print(ans)


Measured memory_bytes: 24064
n,m = gets.chomp.split.map(&:to_i)
as = n.times.map{gets.chomp}
bs = m.times.map{gets.chomp}
ans_flag = true
catch(:break_loop_b) do
  (0..n-m).each do|i|
    (0..n-m).each do|j|
      ans_flag = true
      catch(:break_loop_a) do
        (0..m-1).each do|x|
          (0..m-1).each do|y|
            if as[i+x][j+y] != bs[x][y]
              ans_flag = false
              throw :break_loop_a
            end
          end
        end
      end
      throw :break_loop_b if ans_flag == true
    end
  end
end
puts ans_flag ? "Yes" : "No"

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

int main() {
    
   string s,t;
   cin>>s>>t;
   if(t.length()-s.length()==1 && (s+t[t.length()-1]==t))
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3632
using System;

class Program
{
	static void Main()
	{
		var input = Console.ReadLine();

		var answer = default(int?);
		for (var i = input.Length - 1; i > 0 && answer.HasValue == false; --i) {
			if ((i & 0x01) == 0x00) {
				var number = i / 2;
				if (input.Substring(0, number) == input.Substring(number, number)) {
					answer = i;
				}
			}
		}

		Console.WriteLine(answer.Value);
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
int a,c=0,d=0;
string b;
cin>>a;
cin>>b;
for(int i=0;i<a;i++){
if(b[i]=='(' )c++;
if(b[i]==')'){
d++;
if(c>=1){
c--;
d--;
}
}
}
for(int i=0;i<d;i++)printf("(");
cout<<b;
for(int i=0;i<c;i++)printf(")");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define LARGE 1000000000
#define MOD 100000
int n, ans = 0;
int len[19];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> len[i];
	sort(len, len + n);
	reverse(len, len + n);
	for (int i = 1; i < n; i++)ans += len[i];
	if (ans <= len[0])cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

//チーズ
/*
int H, W, N, ans, tag, si, sj;
char MAP[1009][1009];
int dp[1009][1009];

bool inmap(int i, int j) {
return ((i >= 0 && i <= H - 1) && (j >= 0 && j <= W - 1));
}
bool pass(int i, int j) {
return (MAP[i][j] != 'X');
}

int DFS(int i, int j) {
if (dp[i][j] != LARGE)return dp[i][j];
if (MAP[i][j] - '0' == tag) {
si = i; sj = j;
return 0;
}

if (inmap(i + 1, j) && pass(i + 1, j)) dp[i][j] = min(dp[i][j], DFS(i + 1, j) + 1);
if (inmap(i - 1, j) && pass(i - 1, j)) dp[i][j] = min(dp[i][j], DFS(i - 1, j) + 1);
if (inmap(i, j + 1) && pass(i, j + 1)) dp[i][j] = min(dp[i][j], DFS(i, j + 1) + 1);
if (inmap(i, j - 1) && pass(i, j - 1)) dp[i][j] = min(dp[i][j], DFS(i, j - 1) + 1);
cout << i << " " << j << " " << dp[i][j] << endl;
return dp[i][j];
}

int main() {
cin >> H >> W >> N;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> MAP[i][j];
if (MAP[i][j] == 'S') {
si = i; sj = j;
}
}
}

for (int i = 1; i <= N; i++) {
cout << i << " " << si << " " << sj << endl << endl;
for (int j = 0; j < H; j++) {
for (int k = 0; k < W; k++) {
dp[j][k] = LARGE;
}
}
tag = i;
ans += DFS(si, sj);

}

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


Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math


a,b = map(int,input().split())

ans = 0
if a > b:
    ans += a
    a -= 1

else:
    ans += b
    b -= 1

ans += max(a,b)
print(ans)


Measured memory_bytes: 19840
#include <iostream>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D)
    cout << "Left" << endl;
    else if (A + B < C + D)
    cout << "Right" << endl;
    else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
//Author: ZindagiMeBasAishHiChahiye
//WA/TLE
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)    for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ll          long long
#define N 1000005
// ll po(ll a,ll b,ll m){
// 	a%=m;
// 	if(b==0) return 1;
// 	if(b%2) return (a*(po((a*a)%m,b/2,m)%m)%m)%m;
// 	return po((a*a)%m,b/2,m)%m;
// }

// bool check(ll a,ll b,ll n){
// 	if(a<0||b<0) return false;
// 	if(a>=n||b>=n) return false;
// 	return true;
// }

void solve(){
	ll n;
	cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	ll an=0;
	rep(i,1,n){
		if(a[i]<a[i-1]){
			an+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<an;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1,z=1;
	// cin>>TESTS;
	while(TESTS--){
		// time
		// cout<<"Case #"<<z<<": ";
		// z++;
		solve();
		time

	}
	return 0;
}

Measured memory_bytes: 4752
#include <stdio.h>
#include<stdlib.h>
#include<string.h>

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

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int temp = 0;
	temp = a;
	a = b;
	b = temp;
	int tnp = 0;
	tnp = a;
	a = c;
	c = tnp;
	printf("%d %d %d", a, b, c);
	
}


Measured memory_bytes: 128
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
	    int ans[]=new int[n+1];
	    for(int a=1;a<101;a++){
	        for(int b=1;b<101;b++){
	            for(int c=1;c<101;c++){
	                int val=a*a+b*b+c*c+a*b+b*c+a*c;
	                if(val>n) continue;
	                else ans[val]++;
	            }
	        }
	    }
	    for(int i=1;i<=n;i++)
	    System.out.println(ans[i]);
		
		
	}
		static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if (A*B*C==175 && A*B+B*C+C*A==95 && A+B+C==17) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;
typedef int64_t ll;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n; cin >> n;

  ll f[93];
  f[0] = 2;
  f[1] = 1;

  for (int i = 2; i <= 92; ++i) {
    f[i] = f[i-1] + f[i-2];
  }

  std::cout << f[n] << std::endl;

  return 0;
}



Measured memory_bytes: 256
H, W = map(int, input().split())
SS = [list(input().strip()) for _ in range(H)]

from itertools import product

for h, w in product(range(H), range(W)):
  if SS[h][w] != '#':
    bom = 0
    for dh, dw in product([-1, 0, 1], repeat=2):
      bh, bw = h+dh, w+dw
      if bh < 0 or H-1 < bh:
        continue
      if bw < 0 or W-1 < bw:
        continue
      if SS[bh][bw] == '#':
        bom += 1
    SS[h][w] = str(bom)
print(*[''.join(s) for s in SS], sep='\n')
    

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


bool	is_valid(bitset<15> bit, int N, 
			const vector<bitset<15>> &honest_vec, 
			const vector<bitset<15>> &unkind_vec)
{
	for (int i = 0; i < N; ++i) {
		if (!bit.test(i)) continue;
		if ((bit & honest_vec.at(i)) != honest_vec.at(i))
			return false;
		if ((~bit & unkind_vec.at(i)) != unkind_vec.at(i))
			return false;
	}
	return true;
}

int	main()
{
	int	N;
	cin >> N;
	vector<bitset<15>> honest_vec(N, 0);
	vector<bitset<15>> unkind_vec(N, 0);
	int	A;
	int	x, y;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		for (int j = 0; j < A; ++j) {
			cin >> x >> y;
			if (y == 1)
				honest_vec.at(i).set(x-1);
			else
				unkind_vec.at(i).set(x-1);
		}
	}
	size_t	max_honest = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bitset<15> bit(i);
		if (is_valid(bit, N, honest_vec, unkind_vec)) {
			if (max_honest < bit.count()) max_honest = bit.count();
		}
	}
	cout << max_honest << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int mod=1e9+7;

int32_t main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    for(int i=0;i<min(n,m);i++){
        cout<<s[i]<<t[i];
    }
    if(n>m)cout<<s[n-1]<<endl;
    else if(n<m)cout<<t[m-1]<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;


string a, b;
int dp[3001][3001];
pair < int , int > pr[3001][3001];
int main() {
    cin >> a >> b;
    pr[0][0] = {-1, -1};
    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(a[i] == b[j]){
                if(i == 0 || j == 0){
                    dp[i][j] = 1;
                }
                else{
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                pr[i][j] = {i - 1, j - 1};
            }
            else {
                if(i > 0 && j > 0){
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                    if(dp[i - 1][j] > dp[i][j - 1]){
                        pr[i][j] = {i - 1, j};
                    }
                    else {
                        pr[i][j] = {i, j - 1};
                    }
                }
                else if(i > 0){
                    dp[i][j] = dp[i - 1][j];
                    pr[i][j] = {i - 1, j};
                }
                else if(j > 0){
                    dp[i][j] = dp[i][j - 1];
                    pr[i][j] = {i, j - 1};
                }
            }
        }
    }
    string ans = "";
    int x = int(a.size() - 1), y = int(b.size()) - 1;
    while(x >= 0 && y >= 0){
        if(a[x] == b[y]){
            ans += a[x];
        }
        pair < int , int > t = pr[x][y];
        x = t.first;
        y = t.second;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}


Measured memory_bytes: 105856
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
    ll i,j,k,n,m,a,r;
    cin>>n;
    vector<ll>v1;
    ll pref_xor=0;
    fl(i,n) {
        cin>>j;
        v1.pb(j);
        pref_xor^=j;
    }
    fl(i,n) {
        v1[i]=pref_xor^v1[i];
    }
    fl(i,n) cout<<v1[i]<<" ";
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 5288
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0
for k in range(60):
    A_0 = 0
    A_1 = 0
    for i in range(N):
        if A[i]>>k&1:
            A_1 += 1
        else:
            A_0 += 1
    num = A_1 * A_0
    ans += (num * 2 ** k)
ans %=  mod
print(ans)


Measured memory_bytes: 122936
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int r; cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
x =input()
x = int(x)
y = []
for i in range(x):
    z = input()
    z = int(z)
    y.append(z)
y = sorted(y)
sum = 0
left =[]
right = []
center = y[0]
for i in range(int(x/2)):
    left.append(y[2*i+1])
    if x <= 2*i+2: break
    right.append(y[2*i+2])
b = len(left)
prev = y[0]
for i in range(b):
    if not left: break
    a =left.pop()
    sum += abs(prev - a)
    prev = a
    if not left : break
    a= left.pop(0)
    sum += abs(prev - a)
    prev = a
b = len(right)
prev = y[0]
for i in range(b):
    if not right: break
    a =right.pop()
    sum+= abs(prev-a)
    prev = a
    if not right : break
    a= right.pop(0)
    sum+= abs(prev-a)
    prev = a
suma = sum
y.reverse()
sum = 0
left =[]
right = []
center = y[0]
for i in range(int(x/2)):
    left.append(y[2*i+1])
    if x <= 2*i+2: break
    right.append(y[2*i+2])
b = len(left)
prev = y[0]
for i in range(b):
    if not left: break
    a =left.pop()
    sum += abs(prev - a)
    prev = a
    if not left : break
    a= left.pop(0)
    sum += abs(prev - a)
    prev = a
b = len(right)
prev = y[0]
for i in range(b):
    if not right: break
    a =right.pop()
    sum+= abs(prev-a)
    prev = a
    if not right : break
    a= right.pop(0)
    sum+= abs(prev-a)
    prev = a

if sum < suma : sum = suma
print(sum)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()



int main() {
    //ll ans = 0;
    int n = 0;
    vi v;
    vl ansv1, ansv2;

    cin>>n;

    v.resize(n);
    
    REP(i,n) cin>>v[i];

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

    int loop = 0;
    for(loop = 0; loop<round((float)n/2); loop++)
    {
        ansv1.emplace_back(v[n-loop-1]);
        ansv1.emplace_back(v[loop]);
        ansv2.emplace_back(v[loop]);
        ansv2.emplace_back(v[n-loop-1]);
    }

    //DEBUG_VEC(ansv1);
    //DEBUG_VEC(ansv2);

    ll ans1 = 0, ans2 = 0;
    FOR(i,1,n-1)
    {
        ans1 += abs(ansv1[i] - ansv1[i-1]);
    }
    ans1 += abs(ansv1[n-1] - ansv1[0]);

    FOR(i,1,n-1)
    {
        ans2 += abs(ansv2[i] - ansv2[i-1]);
    }
    ans2 += abs(ansv2[n-1] - ansv2[0]);

    cout << max(ans1,ans2) << endl;
}

Measured memory_bytes: 2668
#include<bits/stdc++.h>
using namespace std;
int main()
{
  vector<int> in(3);
  vector<int> flag(3,0);
  int max=0,mid=0,min=101;
  int count=0;
  for(int i=0; i<3; i++)
    cin >> in.at(i);
  for(int i=0; i<3; i++){
    if(max<in.at(i)){
      max=in.at(i);
      count++;
    }
  }
  flag.at(count-1)++;
  count=0;
  for(int i=0; i<3; i++){
    if(min>in.at(i)){
      min=in.at(i);
      count++;
    }
  }
  flag.at(count-1)++;                                                                                
  for(int i=0; i<3; i++){
    if(flag.at(i)==0)
      mid=in.at(i);
  }
  cout << (max-mid)+(mid-min) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), k = in.ni();
        int[] A = in.ni(n);
        boolean[] dp = new boolean[k+1];
        dp[0] = false;
        for (int i = 1; i <= k; i++) {
            boolean flag = false;
            for(int a: A){
                if(i<a) break;
                if(!dp[i-a]){
                    flag = true;
                    break;
                }
            }
            dp[i] = flag;
        }
        out.println(dp[k]?"First":"Second");
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22740
/*input
3 7 7
#...#.#
..#...#
.#..#..
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=305;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1234567;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
char arr[maxn][maxn];
int ans[maxn][maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    vector<int> v;
    int cur=1;
    REP(i,h){
        int cnt=0;
        REP(j,w){
            cin>>arr[i][j];
            if(arr[i][j]=='#') ++cnt;
        }
        if(cnt==1){
            REP(j,w) ans[i][j]=cur;
            ++cur;
        }
    }
    REP(i,h){
        int cnt=0,f=-1;
        REP(j,w){
            if(arr[i][j]=='#' and f==-1) f=j;
            if(arr[i][j]=='#') ++cnt;
        }
        if(cnt==1 or cnt==0) continue;
        for(int j=0;j<=f;j++) ans[i][j]=cur;
        for(int j=f+1;j<w;j++){
            if(arr[i][j]=='#') ++cur;
            ans[i][j]=cur;
        }
        ++cur;
    }
    REP(i,h){
        int cnt=0;
        REP(j,w){
            if(arr[i][j]=='#') ++cnt;
        }
        if(cnt>0) continue;
        REP(j,w){
            for(int k=i+1;k<h;k++){
                if(ans[k][j]!=0){
                    ans[i][j]=ans[k][j];
                    break;
                }
            }
            if(ans[i][j]!=0) continue;
            for(int k=i-1;k>=0;k--){
                if(ans[k][j]!=0){
                    ans[i][j]=ans[k][j];
                    break;
                }
            }   
            //if(ans[i][j]!=0) assert(false);             
        }
        
    }
    REP(i,h){
        REP(j,w) cout<<ans[i][j]<<' ';
        cout<<'\n';
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	int ans=min((n+h-1)/h,(n+w-1)/w);
	printf("%d\n",ans);
	return 0;
}


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

#define ll long long 

#define file_io 0

ll i,t,j;
ll n,k,h[100005],dp[100005];

int main(){
	if (file_io){
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}
	
	scanf("%lld%lld",&n,&k);
	
	for (i=1; i<=n; ++i){
		scanf("%lld",&h[i]);
	}
	
	dp[1]=0;
	for (i=2; i<=n; ++i){
		dp[i]=2e9;
		for (t=max(1ll,i-k); t<i; ++t){
			dp[i]=min(dp[t]+abs(h[i]-h[t]),dp[i]);
		}
	}
	
	printf("%lld\n",dp[n]);
	
	return 0;
}

Measured memory_bytes: 1664
from sys import stdin

readline = stdin.readline

_, *aa = map(int, open(0).read().split())
r = 0
mi = 1000000000
m = 0
for a in aa:
    if a < 0:
        m += 1
    b = abs(a)
    r += b
    if b < mi:
        mi = b
print(r - mi * 2 * (m % 2))


Measured memory_bytes: 14116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct RMQ {
	using type1 = int;
	using type2 = int;
	static type1 id1() { return INT_MAX; }
	static type2 id2() { return -1; }
	static type1 op1(const type1& l, const type1& r) { return min(l, r); }
	static type1 op2(const type1& l, const type2& r) { return r != -1 ? r : l; }
	static type2 op3(const type2& l, const type2& r) { return r != -1 ? r : l; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::type1;
	using T2 = typename M::type2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		push(node);
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RMQ> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> a(H, vector<int>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    int N = 0;
    vector<int> y1(0);
    vector<int> x1(0);
    vector<int> y2(0);
    vector<int> x2(0);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] % 2 == 1 && j != W - 1) {
                a[i][j]--;
                a[i][j + 1]++;
                N++;
                y1.push_back(i + 1);
                x1.push_back(j + 1);
                y2.push_back(i + 1);
                x2.push_back(j + 2);
            }
            else if (a[i][j] % 2 == 1 && j == W - 1 && i != H - 1) {
                a[i][j]--;
                a[i + 1][j]++;
                N++;
                y1.push_back(i + 1);
                x1.push_back(j + 1);
                y2.push_back(i + 2);
                x2.push_back(j + 1);
            }
            else if (i == H - 1 && j == W - 1) {
                break;
            }
        }
    }

    cout << N << endl;
    for (int i = 0; i < y1.size(); i++) {
        cout << y1[i] << " " << x1[i] << " " << y2[i] << " " << x2[i] << endl;
    }
}

Measured memory_bytes: 5224
#include <iostream>
using namespace std;
int main () {
    int r, c;
    cin >> r >> c;
    int s[101][101] = {0};
    for (int i = 0; i < r; i++)
        for (int j = 0; j < c; j++) {
            cin >> s[i][j];
            s[r][j] += s[i][j];
            s[i][c] += s[i][j];
            s[r][c] += s[i][j];
        }
 
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j < c; j++) 
            cout << s[i][j] << " ";
        cout << s[i][c] << "\n";        
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  int n0 = n;
  if (n == 3) {
    cout << "2 5 63\n";
    return 0;
  }
  int c2 = min((n - 2) / 2, 15000 / 2 - 1);
  vi v;
  for (int i = 0; i < c2; ++i) {
    int t = 2 + 2 * i;
    v.push_back(t);
    v.push_back(30000-t);
  }
  n -= 2 * c2;
  int c3 = min(n / 2, 15000 / 6);
  for (int i = 0; i < c3; ++i) {
    int t = 3 + 6 * i;
    v.push_back(t);
    v.push_back(30000-t);
  }
  n -= 2 * c3;
  if (n) {
    v.push_back(30000);
    --n;
  }
  if (n) {
    v.push_back(15000);
    --n;
  }
  ll sum = 0;
  for (int x : v) {
    cout << x << ' ';
    sum += x;
  }
  assert(sum % 6 == 0);
  sort(v.begin(), v.end());
  assert(v.size() == n0);
  int d = 0;
  for (int i = 0; i < v.size(); ++i) {
    d = __gcd(d, v[i]);
    assert(v[i] > 0 && v[i] <= 30000);
    assert(v[i] % 2 == 0 || v[i] % 3 == 0);
    if (i + 1 < v.size()) assert(v[i] != v[i + 1]);
  }
  assert(d == 1);
  cerr << d << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        int[] num = new int[n];
        String line1 = sc.nextLine();
        String[] line1sp = line1.split(" ");
        for(int i = 0; i< n; i++) {
            num[i] = Integer.parseInt(line1sp[i]);
        }
        int count = 0;
        for(int i = 0; i < n; i++) {
            int min = i;
            for(int j = i; j < n; j++) {
                if(num[j] < num[min]) {
                    min = j;
                }
                if(min != i && j == n-1) {
                    int a = num[min];
                    num[min] = num[i];
                    num[i] = a;
                    count += 1;
                }
            }
        }
        for(int i = 0; i < n; i++) {
            System.out.print(num[i]);
            if(i == n-1) {
                System.out.println("");
            }else {
                System.out.print(" ");
            }
        }
        System.out.println(count);
    }
 }
 


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

using namespace std;
   
        
      


    void solve(){
         int n, w ;
         cin>>n>>w;
         vector<int>values(n);
         vector<int>weights(n);
         for(int i = 0; i < n;++i) cin>>weights[i]>>values[i];
        int sum = 0;
         for(int x : values) sum += x;
         vector<long long> dp (sum+1,(long long )1e18);
         dp[0] = 0;
         for(int i = 0;i<n;++i){
             for(int temp = sum - values[i];temp>=0;--temp){
                    
                        dp[temp + values[i] ] = min(dp[temp + values[i] ], dp[temp] + weights[i]);
                    
             }
         }    
         int an = 0;
            for(int i = 0;i<=sum;++i){
                if(dp[i]<=w) an = max(an,i);
            }

        
        cout<<an<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3908
N = int(input())
T = 0
for i in range(N):
	c = 0
	if ((i+1)%2)==1:
		for j in range(N):
			if ((i+1)%(j+1)) == 0:
				c += 1
		if c >= 8:
			T += 1
                
print (int(T))


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

const int maxn = 2e5 + 100;
int n;
int a[maxn];
map<int, int> b;
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    // Failed to predict input format
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        b[i - a[i]]++;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += b[a[i] + i];
        b[i - a[i]]--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21436
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2!=0){
            if(s[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(s[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(i => i);

        int a = 0, b = 0;
        for (int i = 0; i < input.Count(); i++)
        {
            if (i % 2 == 0)
            {
                a += input.ElementAt(i);
            }
            else
            {
                b += input.ElementAt(i);
            }
        }
        Console.WriteLine(a - b);
    }

}

Measured memory_bytes: 13396
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    int d;cin >> d;
    int count = 0;
    rep(i, n) {
        int a,b;cin  >> a >> b;
        if(a*a+b*b<=d*d) count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n;
    scanf("%lld", &n);
    vector<ll> a(n);
    vector< vector<ll> > dp(n, vector<ll>(n));
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", a.begin() + i);
        dp.at(i).at(i) = a.at(i);
    }
    for (ll i = 1; i < n; ++i) for (ll j = 0; j < n - i; ++j) {
        if (i % 2) dp.at(j).at(j + i) = min(dp.at(j + 1).at(j + i) - a.at(j), dp.at(j).at(j + i - 1) - a.at(j + i));
        else dp.at(j).at(j + i) = max(dp.at(j + 1).at(j + i) + a.at(j), dp.at(j).at(j + i - 1) + a.at(j + i));
    }
    printf("%lld\n", dp.at(0).back() * (n % 2 ? 1 : -1));
    return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

vector <int> as;

void solve(void){
    int N, M, X;
    cin >> N >> M >> X;
    rep(M, i) {
        int A; cin >> A;
        as.pb(A);
    }
    int ans = 0;
    rep(M, i) {
        if (as[i] < X) ans++;
        else break;
    }

    cout << min(ans, M-ans) << '\n';
}

int main(void){
  solve();
  return 0;
}


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

#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &c:v)
        cin>>c;
    int ans=0;
    for(int i=1;i<n;i++){
        if(v[i]<v[i-1])
        {
            ans+=v[i-1]-v[i];
            v[i]=v[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

const int MAXN = 100010;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x*f;
}

int a[MAXN][4], b[MAXN];
int C[MAXN], n;
int fo, fe, io, ie;
bool vis[MAXN];

inline void Add(int x) {
	while(x <= n) {
		C[x]++;
		x += x&(-x);
	}
}

inline int Query(int x) {
	int res = 0;
	while(x) {
		res += C[x];
		x -= x & (-x);
	}
	return res;
}

int main() {
	n = read<int>();
	for(int j = 1; j <= 3; j++) 
		for(int i = 1; i <= n; i++)
			a[i][j] = read<int>();
	for(int i = 1; i <= n; i++) {
		int x1 = a[i][1]%3, x2 = a[i][2]%3, x3 = a[i][3]%3;
		int y1 = (a[i][1]-1)/3, y2 = (a[i][2]-1)/3, y3 = (a[i][3]-1)/3;
		//printf("%d %d %d\n", x1, x2, x3);
		if(y1 != y2 || y1 != y3 || y2 != y3) {
			printf("No\n");
			return 0;
		}
		if(x1 == 1 && x2 == 2 && x3 == 0) {
			b[i] = a[i][3]/3;
			if(vis[b[i]]) {
				printf("No\n");
				return 0;
			}
			if((b[i]&1)^(i&1)) {
				printf("No\n");
				return 0;
			}
			vis[b[i]] = true;
		}
		else if(x1 == 0 && x2 == 2 && x3 == 1) {
			b[i] = a[i][1]/3;
			if(vis[b[i]]) {
				printf("No\n");
				return 0;
			}
			if((b[i]&1)^(i&1)) {
				printf("No\n");
				return 0;
			}
			vis[b[i]] = true;
			if(i & 1) fo++;
			else fe++;
		}
		else {
			printf("No\n");
			return 0;
		}
	}
	/*for(int i = 1; i <= n; i++)
		printf("%d ", b[i]);
	printf("\n");*/
	//printf("%d %d\n", fo, fe);
	memset(C, 0, sizeof(C));
	for(int i = 1; i <= n; i += 2) {
		io += Query(n)-Query(b[i]);
		Add(b[i]);
	}
	memset(C, 0, sizeof(C));
	for(int i = 2; i <= n; i += 2) {
		ie += Query(n)-Query(b[i]);
		Add(b[i]);
	}
	//printf("%d %d\n", io, ie);
	if((io&1)^(fe&1)) {
		printf("No\n");
		return 0;
	}
	if((ie&1)^(fo&1)) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<int, int> o, e;
  rep(i, n){
    int v;
    cin >> v;
    if(i % 2 == 0) e[v]++;
    else o[v]++;
  }

  pair<int, int> po(-1, -1), pos(-1, -1), pe(-1, -1), pes(-1, -1);
  int to = 0, te = 0;
  for(auto p : o){
    to += p.second;
    if(po.second < p.second){
      pos = po;
      po = p;
    }else if(pos.second < p.second){
      pos = p;
    }
  }
  for(auto p : e){
    te += p.second;
    if(pe.second < p.second){
      pes = pe;
      pe = p;
    }else if(pes.second < p.second){
      pes = p;
    }
  }
  int ans;
  if(po.first != pe.first){
    ans = to - po.second + te - pe.second;
  }else{
    int ans1 = 1001001001, ans2 = 1001001001;
    if(pos.first == -1 && pes.first == -1){
      ans1 = to - po.second + te;
    }else if(pos.first == -1){
      ans1 = to - po.second + te;
    }else if(pes.first == -1){
      ans1 = to + te - pe.second;
    }else{
      ans1 = to - po.second + te - pes.second;
      ans2 = to - pos.second + te - pe.second;
    }
    ans = min(ans1, ans2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <numeric>

#define long long long

long solve(std::string s)
{
	long v = 0;
	for (int i = 0; i < (1 << (s.size()-1)); i++) {
		int tail = 0;
		for (int j = 0; j < s.size(); j++) {
			if ((1 << j) & i) {
				v += std::stoll(s.substr(tail, j - tail + 1));
				tail = j + 1;
			}
		}

		std::string s2 = s.substr(tail);
		v += std::stoll(s2);

	}

	return v;
}

int main()
{
	std::string s;
	std::cin >> s;

	std::cout << solve(s) << std::endl;

	return 0;
}

Measured memory_bytes: 256
N,S=int(input()),""
for _ in range(N):S+=input()[0]
M,A,R,C,H=S.count("M"),S.count("A"),S.count("R"),S.count("C"),S.count("H")
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;


int main(){
    int N,M;
    cin >> N >> M;
    vector<bool> ok(N+1,true);
    
    int a;
    for(int i=0;i<M;i++){
        cin >> a;
        ok[a] = false;
    }

    vector<int> dp(N+1);
    dp[0] = 1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(N,now+2);next++){
            if(ok[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if (a > b) std::swap(a, b);
    if (b > c) std::swap(b, c);
    if (a > b) std::swap(a, b);
    
    cout << a <<" "<< b <<" "<< c << endl;
    
    return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 1000000007;


signed main(){

    string s;
    cin >> s;

    ll n = s.size();

    ll ans = 0;
    ll pre = -1;
    for(int i = 0;i < n;i++){
        if(pre == -1){
            pre = s[i];
            ans++;
            if(i == n-2 && s[i] == s[i+1]){
           
                break;
            }
        }else{
            if(pre != s[i]){
                ans++;
                pre = s[i];
                if(i == n-2 && s[i] == s[i+1]){
                    
                    break;
                }
            }else{
                i++;
                ans++;
                pre = -1;
            }
        }
    }
    cout << ans << endl;
    
    


    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc037.contest.atcoder.jp/tasks/agc037_a

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  for(i=0;i<n;i++){
    cin>>buf;
    for(j=0;;j++){
      if(buf%2!=0)break;
      buf/=2;
    }
    chmin(result,j);

  }
  cout<<result<<endl;
  


  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int RL = 0, LR = 0, cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) cnt++;
        else if (s[i] == 'R') RL++;
        else LR++;
    }

    while (k) {
        if (RL) {
            cnt++;
            RL--;
        }
        if (LR) {
            cnt++;
            LR--;
        }
        k--;
    }

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

Measured memory_bytes: 512