akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  
  string S; cin >> S;
  ll n = S.size();
  ll i = 0;
  while (i < n) {
    ll p = i;
    while (S[i] == 'R') i++;
    ll q = i;
    while (i < n && S[i] == 'L') i++;
    ll r = i;
    for (ll j = p; j < q - 1; j++) {
      if (j > 0) cout << " ";
      cout << 0;
    }
    cout << " " << 1 + (q - p - 1) / 2 + (r - q - 1 + 1) / 2;
    cout << " " << 1 + (q - p - 1 + 1) / 2 + (r - q - 1) / 2;
    for (ll j = q + 1; j < r; j++) {
      cout << " 0";
    }
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt1=0,cnt2=0,cnt3=0;
    
    for(int i=0;i<n;i++){
        if(s[i]=='R') cnt1++;
        if(s[i]=='G') cnt2++;
        if(s[i]=='B') cnt3++;
    }
    ll ans=cnt1*cnt2*cnt3;
    for(int i = 1; i<=n; i++){
        for(int j = 0; j<n; j++){
            if(j-i<0 || j+i >=n){
                continue;
            }
            if(s[j-i] != s[j+i] && s[j] != s[j-i] && s[j]!=s[j+i]){
                ans--;
            }
        }
    }
    
    

    cout<<ans<<" ";

}

Measured memory_bytes: 3656
#include <iostream>

int a[3003];
long long dp[3003][3003];

int main(){
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    for(int len = 1; len <= n; len++){
        for(int i = 0; i + len <= n; i++){
            int j = i + len;
            if((n-len)%2 == 0){
                dp[i][j] = std::max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            }else{
                dp[i][j] = std::min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
            }
        }
    }
    std::cout << dp[0][n] << std::endl;
}


Measured memory_bytes: 70016
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;

#pragma warning(disable: 4996)

struct Node {
	LL bea = 0;
};

Node stree[MAX * 4];
string sss;
int gstart = 0;
int gend = 1111;
static int count_tn = 0;
struct TNode {
	int root, nstart, nend, mid;
	TNode() {}
	TNode(int r, int ns, int ne) {
		//++count_tn;
		//cout << count_tn << endl;
		root = r;
		nstart = ns;
		nend = ne;
		mid = (ns + ne) / 2;
	}
	TNode  getLeft() const {
		return  TNode(root * 2 + 1, nstart, mid);
	}
	TNode  getRight() const {
		return  TNode(root * 2 + 2, mid + 1, nend);
	}
};

TNode superRoot;

void refresh(Node & n0, Node & n1, Node & n2) {
	n0.bea = max(n1.bea, n2.bea);
}
void refresh(int root, int left, int right) {
	refresh(stree[root], stree[left], stree[right]);
}
LL zb[MAX];
void init(int root, int nstart) {
	stree[root].bea = zb[nstart];
	return;
}
void buildt(const TNode & tn) {
	if (tn.nstart == tn.nend) {
		init(tn.root, tn.nstart);
		return;
	}
	auto tn0 = tn.getLeft();
	auto tn1 = tn.getRight();
	buildt(tn0);
	buildt(tn1);
	refresh(tn.root, tn0.root, tn1.root);
}
void update(const TNode & tn, int change) {
	if (change < tn.nstart || change > tn.nend) return;
	if (tn.nstart == tn.nend) {
		init(tn.root, tn.nstart);
		return;
	}
	auto tn0 = tn.getLeft();
	auto tn1 = tn.getRight();
	update(tn0, change);
	update(tn1, change);
	refresh(tn.root, tn0.root, tn1.root);
}
 
LL query0(const TNode & tn, int b1, int b2 ) {
	if (b2 < tn.nstart || b1 > tn.nend) return 0;
	if (b1 <= tn.nstart && tn.nend <= b2) {
		return stree[tn.root].bea;
	}
	auto tn0 = tn.getLeft();
	auto tn1 = tn.getRight();
	auto r1 = query0(tn0, b1, b2 );
	auto r2 = query0(tn1, b1, b2 );
	return max(r1,r2);
}
LL za[MAX], zh[MAX];
void solve() {

	LL result = 0;
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> zh[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> za[i];
	}

	superRoot = TNode(0, 1, n);

	for (int i = 0; i < n; ++i) {
		int h = zh[i];
		LL b = query0(superRoot, 1, h) + za[i];
		 
		result = max(b, result);
		zb[h] = b;
		update(superRoot, h);

	}
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Measured memory_bytes: 10368
N = int(input())
ai = list(map(int,input().split()))

sumai = []
s = 0
for i in ai:
    s += i
    sumai.append(s)
lcut = 0 # l1 = sumai[lcut]
rcut = 2 #  r2 = sumai[N-1]-sumai[rcut]
l1 = sumai[lcut]
r2 = sumai[N-1]-sumai[rcut]
ans = []
for i in range(1,N-2):
    while abs(sumai[lcut]-(sumai[i]-sumai[lcut]))>abs(sumai[lcut+1]-(sumai[i]-sumai[lcut+1])):
        lcut += 1
    while abs((sumai[N-1]-sumai[rcut])-(sumai[rcut]-sumai[i]))>abs((sumai[N-1]-sumai[rcut+1])-(sumai[rcut+1]-sumai[i])):
        rcut += 1
    ans.append(max(sumai[lcut],sumai[i]-sumai[lcut],sumai[N-1]-sumai[rcut],sumai[rcut]-sumai[i])-min(sumai[lcut],sumai[i]-sumai[lcut],sumai[N-1]-sumai[rcut],sumai[rcut]-sumai[i]))
print(min(ans))

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

typedef long long LL;
const int N = 2e6+7, M = 1e9+7;

LL fac[N],invfac[N];

LL power(LL a, LL p) {
    if (p==0)   return 1;
    LL ans = power(a, p/2);
    ans = (ans * ans)%M;
    if(p%2) ans = (ans * a)%M;
    return ans;
}

void pre() {
    fac[0]= 1;
    for (int i=1; i<N; i++) fac[i] = (fac[i-1] * i)%M;
    invfac[N-1] = power(fac[N-1], M-2);
    for (int i=N-2; i>=0; i--)      invfac[i] = (invfac[i+1] * (i+1))%M;
}

LL C(int n, int r) {
    if ( r< 0 || r> n)  return 0;
    LL num = fac[n];
    LL denom = (invfac[r] * invfac[n-r])%M;
    return (num * denom)%M;
}

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

    pre();
    int r1, c1, r2, c2;
    cin>>r1>>c1>>r2>>c2;
    r1--; c1--;

    LL ans = C(r2+c2+2, r2+1) - C(r1+c2+2, r1+1) - C(r2+c1+2, r2+1) + C(r1+c1+2, r1+1);
    ans = (ans % M + M)%M;
    cout<<ans<<endl;
}


Measured memory_bytes: 31488
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;

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

	char C;

	cin >> C;

	cout << char(C + 1) << endl;


}


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

int dfs(int x, int y, int z){
    int count =0;
    if(x==0 && y==0) return 1;
    if(x>0){
        for(int i =z; i<10; i++){
            if(y-i>=0) count+=dfs(x-1, y-i, i+1);
        }
    }
    return count;
}

int main(void){
    int n, s;
    while(cin >> n >> s, n||s){
       cout << dfs(n, s, 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
import java.math.BigInteger;
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		BigInteger a,b;
		Scanner cin=new Scanner(System.in);
		a=cin.nextBigInteger();
		b=cin.nextBigInteger();
		System.out.println(a.remainder(b));
	}
}



Measured memory_bytes: 26712
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb, cc, dd, gg, ans = 0;
	cin >> aa >> bb >> cc >> dd;
	gg = gcd(cc, dd);
	gg = cc / gg;
	gg *= dd;
	
	ans += bb / cc;
	ans += bb / dd;
	ans -= bb / gg;
	
	ans -= (aa - 1) / cc;
	ans -= (aa - 1) / dd;
	ans += (aa - 1) / gg;
	
	ans = bb - aa - ans + 1;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>

#include <stdio.h>
#include <string.h>


using namespace std;

int main(int argc, char* argv[])
{
  int n, i, r, l;
  string str;
 
  cin >> n >> str;
 
  r = l =0;
  for(i = 0; i < n; i++){
    if(str[i] == '('){
      l++;
    }else{
      if(l > 0){
        l--;
      }else{
        r++;
      }
    }
  }
  for(i = 0; i < l; i++) str = str + ")";
  for(i = 0; i < r; i++) str = "(" + str;
  cout << str <<endl;
  
  return 0;
}


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

if m==1:
    print(1)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
l=factorization(m)
ans=1
for p,b in l:
    com1=1
    com2=1
    for i in range(b):
        com1*=(b+n-1-i)
        com2*=(1+i)
    ans*=(com1//com2)%mod


print(ans%mod)


Measured memory_bytes: 3188
N = int(input())
S = input()

rc = 0
gc = 0
bc = 0

for si in S:
    if si == 'R':
        rc += 1
    elif si == 'G':
        gc += 1
    else:
        bc += 1


bad = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + (j-i)
        if k > N-1:
            # continue
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            # print('bad', i,j,k,S[i],S[j],S[k])
            bad += 1

ans = rc * gc * bc
# print(ans)
ans -= bad
print(ans)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

int main()
{
    ll x;
    cin>>x;
    for(ll i=0;i<=1000;i++)
    {
        for(ll j=0;j<=1000;j++)
        {
            ll p=i*i*i*i*i;
            ll q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            j=-j;
            p=i*i*i*i*i;
            q=j*j*j*j*j;
            if(p-q==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
            i=-i;
        }
    }
    return 0;
}


Measured memory_bytes: 3568
main :: IO ()
main = getLine >>= \s -> putStrLn $ show $ solve l s

solve :: String -> String -> Int
solve []     _  = 0
solve _      [] = 0
solve (x:xs) (y:ys)
  | x /= y    = 1 + solve xs ys
  | otherwise = solve xs ys

l = "CODEFESTIVAL2016"

Measured memory_bytes: 380
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint d(N);
    rep(i, N) cin >> d[i];
    ll ans = 0;
    rep(i, N) {
        REP(j, i + 1, N) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#define INF 100000000
#define ll long long
using namespace std;

class Bit{
private:
  ll *par, *rk, size;
public:
  Bit(ll size){
    par = new ll[size];
    rk = new ll[size];
    for(ll i = 0; i < size; i++){
      par[i] = i;
      rk[i] = 0;
    }
  }
  ll find(ll x){
    if(x == par[x])
      return x;
    else
      return par[x] = find(par[x]);
  }
  void merge(ll x,ll y){
    x = find(x);
    y = find(y);
    if(rk[x] > rk[y]){
      par[y] = x;
    }else if(rk[x] < rk[y]){
      par[x] = y;
    }else{
      par[y] = x;
      rk[x]++;
    }
  }
  bool same(ll x, ll y){
    return find(x) == find(y);
  }
};
int main(){
  ll V, E;
  cin >> V >> E;
  Bit bit(V);
  priority_queue< pair<ll, pair<ll,ll> >, vector< pair<ll, pair<ll,ll> > >, greater< pair<ll, pair<ll,ll> > > > pq;
  for(ll i = 0; i < E; i++){
    ll s,t,w;
    cin >> s >> t >> w;
    pq.push(make_pair(w, make_pair(s,t)));
  }
  ll cost = 0;
  for(ll i = 0; i < V - 1; i++){
    while(1){
      if(bit.same(pq.top().second.first, pq.top().second.second)){
	pq.pop();
      }else{
	break;
      }
    }
    bit.merge(pq.top().second.first, pq.top().second.second);
    cost += pq.top().first;
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 6052
#include <iostream>
#include <algorithm>

using namespace std;

const int N_MAX = 1000;
const int MOD = 1e9 + 7; // = 1000000007;

int main(void){
    int n;
    cin >> n;

    int primeCnt[N_MAX + 1];
    for(int i = 0; i <= n; i++){
        primeCnt[i] = 0;
    }

    for(int i = 1; i <= n; i++){
        int num = i;
        for(int j = 2; j <= i; j++){
            while(num % j == 0){
                primeCnt[j]++;
                num /= j;
            }
        }
    }

    long long res = 1LL;
    for(int i = 2; i <= n; i++){
        res *= (primeCnt[i] + 1);
        res %= MOD;
    }

    cout << res << endl;
    
    return 0;
}


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

int humming[1000001];
void hum(void)
{
  int i;
  int f, c;
  for (i = 1; i <= 1000000; i++){
    c = i;
    while (1){
      f = 0;
      if (c % 2 == 0){
        c /= 2;
        f++;
      }
      if (c % 3 == 0){
        c /= 3;
        f++;
      }
      if (c % 5 == 0){
        c /= 5;
        f++;
      }
      if (f == 0){
        break;
      }
    }
    if (c == 1){
      humming[i] = 1;
    } else {
      humming[i] = 0;
    }
  }
}

int main(void)
{
  hum();
  int m, n;
  int cut;
  int i;

  while (1){
    cin >> m;
    if (m == 0){
      break;
    }
    cin >> n;
    cut = 0;
    for (i = m; i <= n; i++){
      cut += humming[i];
    }
    cout << cut << endl;
  }

  return (0);
}

Measured memory_bytes: 5064
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
    int n;
    scanf("%d",&n);
    char s[200005]={};
    scanf("%s",s);
    int black[200005]={};
    int white[200005]={};
    black[0]=0;
    white[0]=0;
    REP(i,n){
        black[i+1]=black[i]+(s[i]=='#');
        white[i+1]=white[i]+(s[i]=='.');
    }
    int score[200005]={};
    REP(i,n+1){
        score[i]=black[i]+white[n]-white[i];
    }
    int min=514514;
    REP(i,n+1){
        if(min>score[i])min=score[i];
    }
    printf("%d\n",min);
    return 0;
}

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

int main(void){
    string s, t;

    cin >> s >> t;

    rep(i, s.size()){
        string x = s;
        rep(j, s.size() - 1){
            x[j+1] = s[j];
        }
        x[0] = s[s.size()-1];
        if(x == t){
            cout << "Yes" << endl;
            return 0;
        }
        s = x;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<endl;
  }
  cout<<'}'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1e7;
//------------------------------------------------------------
ll N,ans=0;

struct node
{
  ll id,x,y;
}city[INF];

struct  edge
{
  ll fcity, tcity, length;
  bool operator < (const edge &e) const
  {
    return length<e.length;
  }
}road[INF];


bool cmpx(node a, node b)
{
  return a.x<b.x;
}
bool cmpy(node a, node b)
{
  return a.y<b.y;
}

vector<ll> tree(INF);

ll find(ll num)
{
  return num==tree[num] ? num : tree[num]=find(tree[num]);
}

void solve()
{
    cin >> N;

    rep(i,0,N)
    {
      cin >> city[i].x >> city[i].y;
      city[i].id=i;
      tree[i]=i;
    }

    int m;

    m=0;
    sort(city,city+N,cmpx);
    rep(i,0,N-1)
    {
      road[m] = (edge){city[i].id, city[i+1].id, city[i+1].x-city[i].x};
      ++m;
    }

    sort(city,city+N,cmpy);
    rep(i,0,N-1)
    {
      road[m] = (edge){city[i].id, city[i+1].id, city[i+1].y-city[i].y};
      ++m;
    }

    sort(road, road+m);

    rep(i,0,m)
    {
      if(find(road[i].fcity)!=find(road[i].tcity))
      {
        ans+=road[i].length;
        tree[tree[road[i].fcity]] = tree[road[i].tcity];

      }
    }

    print(ans);

    return;
}



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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b){
        b==c ? cout<<"No" : cout<<"Yes";
    }else if(b==c){
        c==a ? cout<<"No" : cout<<"Yes";
    }else if(c==a){
        a==b ? cout<<"No" : cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 256
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl
 
const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
 
 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
 
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;

void solve(){
   ll a,b,c,d; cin>>a>>b>>c>>d;
    cout<<max(a*c,max(b*d,max(a*d,b*c)))<<endl;
}
int main(){
    fastio();
    //write code
    int t; t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX = 100000;
const ll inf = 5e18;

int main() {
	fastio;
	ll n,x,sum=0;
	cin>>n;
	f(i,1,n+1){
		if( !(i%3 == 0 || i%5 == 0) ) sum+=i;
	}
	cout<<sum<<"\n";
return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a = min(a,b);
    c = min(c,d);
    int ans = a+c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
////////////
//||||| ||//
//   || ||//
//||||||||//
//|| ||   //
//|| |||||//
////////////
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   MAX 1000000
#define   eps 1e-8
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
//S.order_of_key(x)[Give me the position of x]
//S.find_by_order(x)[Give me the x th element in set]
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b) {return (a * b) / __gcd(a, b);}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c = 0, d, e, f = 0, g, h, i, j, k, m, n, o, p, s, t, v, w, x = 0, y, z, l;
    ll cnt = 0, l1 = 0, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2, str3 = "", str4 = "";
    ll ide = 0, idx = 0, Q;
    scll(n);
    c=0;
    ll ans=0;
    for(i=0;i<n;i++)
    {
    	scll(a);
    	c=max(c,a);
    	ans+=c-a;
    }

    cout<<ans<<'\n';

    return 0;
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }

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

  ll ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i].first * min(m - cnt, a[i].second);
    cnt += a[i].second;
    if (cnt >= m) break;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int t=INT_MAX,n,ans;
main()
{
        cin>>n;
        vector<int> v(n);
        rep(i,n)
        {
                cin>>v[i];
                if(t>v[i])ans++;
                t=min(t,v[i]);
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 1152
import sys
readline = sys.stdin.readline

# もっとも早い日に貪欲に働いたパターン
# もっとも遅い日に貪欲に働いたパターン
# 上記でX回目の仕事が同じ日であればその日は必ず働く必要がある

N,K,C = map(int,readline().split())
S = readline().rstrip()

fast = [0] * K
ind = 0
cnt = 0
while cnt < K: # K回働くまで
  if S[ind] == "o":
    fast[cnt] = ind
    cnt += 1
    ind += (C + 1)
  else:
    ind += 1

late = [0] * K
ind = len(S) - 1
cnt = K - 1
while 0 <= cnt:
  if S[ind] == "o":
    late[cnt] = ind
    cnt -= 1
    ind -= (C + 1)
  else:
    ind -= 1
    
ans = []
for i in range(K):
  if fast[i] == late[i]:
    ans += [fast[i] + 1]
    
for a in ans:
  print(a)

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

  string S; cin >> S;
  map<char,int> mp;
  sort(S.begin(),S.end());

  for(int i = 0;i < S.size();i++){
    mp[S[i]]++;
  }

  string s = "abcdefghijklmnopqrstuvwxyz";

  for(int i = 0;i < s.size();i++){
    if(mp[s[i]] == 0){
      cout << s[i] << endl;
      return 0;
    }
  }

  cout << "None" << endl;
  return 0;
}


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

ll sum(ll x){
	return (x * (x + 1) / 2) % (int)(1e9 + 7);
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		int before = 0, after = 0;
		for (int j = i - 1; j >= 0; j--){
			if(a[j] < a[i]){
				before++;
			}
		}
		for (int j = i + 1; j < n; j++){
			if(a[j] < a[i]){
				after++;
			}
		}
		ans += (sum(k - 1) * before + sum(k) * after) % (int)(1e9 + 7);
		ans %= (int)(1e9 + 7);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include <algorithm>
#include <functional>

using namespace std;


int main(){
  unsigned int N,Y;
  cin>>N;
  cin>>Y;
  for(unsigned int ans10000 =0;ans10000<=N;ans10000++){
    for(unsigned int ans5000=0;ans5000<=N-ans10000;ans5000++){
      unsigned int ans1000=N-ans10000-ans5000;
  if(ans10000*10000+ans5000*5000+ans1000*1000==Y){
        cout<<ans10000<<" "<<ans5000<<" "<<ans1000<<endl;
    	return 0;
      }
    }
  }
 cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}
      
  

    
      
  
  
  
  

Measured memory_bytes: 384
#include<cstdio>
int e(int p,int q)
{
    if(q==0)
        return p;
    return e(q,p%q);
}
int main(void)
{
    int k,sum=0;
    scanf("%d" ,&k);
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
        {
            int g=e(i,j);
            for(int l=1;l<=k;l++)
                sum+=e(g,l);
        }
    printf("%d" ,sum);
    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <queue>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  int N, a;
  cin >> N;

  deque<int> q;
  for( int i=0; i<N; i++ ){
    cin >> a;
    if( i % 2 == 0 ){
      q.push_back(a);
    } else {
      q.push_front(a);
    }
  }
  if( N % 2 == 0 ){
    cout << q.front();
    q.pop_front();
    while( !q.empty() ){
      cout << ' ' << q.front();
      q.pop_front();
    }
  } else {
    cout << q.back();
    q.pop_back();
    while( !q.empty() ){
      cout << ' ' << q.back();
      q.pop_back();
    }
  }
  cout << endl;
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

int main() {

	string s, t;
	cin >> s >> t;

	int ns = s.length(), nt = t.length();

	int dp[ns][nt];

	dp[0][0] = s[0] == t[0];

	tik(i,1,nt) {
		if(s[0] == t[i] || dp[0][i-1] == 1)
			dp[0][i] = 1;
		else
			dp[0][i] = 0;
	}

	tik(i,1,ns) {
		if(t[0] == s[i] || dp[i-1][0] == 1)
			dp[i][0] = 1;
		else
			dp[i][0] = 0;
	}

	tik(i,1,ns) {
		tik(j,1,nt) {
			if(s[i] == t[j])
				dp[i][j] = dp[i-1][j-1]+1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	string res = "";

	// tik(i,0,ns) {
	// 	tik(j,0,nt) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	int i = ns-1, j = nt-1;

	while(i > 0 || j > 0) {
		if(i >0 && j > 0) {
			if(dp[i-1][j-1] == dp[i][j] - 1 && dp[i][j] > dp[i-1][j] && dp[i][j] > dp[i][j-1]) {
				res += s[i];
				--i;
				--j;
				//continue;
			}
			else {
				if(dp[i-1][j] > dp[i][j-1])
					--i;
				else
					--j;
			}
			continue;
		}
		else if(i > 0) {
			if(dp[i][j] > dp[i-1][j])
				res += s[i];
			--i;
		}
		else {
			if(dp[i][j] > dp[i][j-1])
				res += t[j];
			--j;
		}
	}

	if(s[0] == t[0])
		res += s[0];

	reverse(all(res));

	cout << res;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	ll n = s.size();
	ll ans = n * (n - 1) / 2 + 1;
	VL al(26, 0);
	rep(i, n) {
		al[s[i] - 'a']++;
	}
	rep(i, 26) {
		ans -= al[i] * (al[i] - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::array<long, 3> xs;
  Solver() {
    S002 r;
    r >= xs;
  }
  void solve() {
    std::sort(xs.begin(), xs.end());
    bool res = xs[0] == 5 and xs[1] == 5 and xs[2] == 7;
    puts(res ? "YES" : "NO");
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

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

	ll ans = 1145141919810893;
	for (int i = 1; i <= 100; i++) {
		ll tmp = 0;
		for (int j = 0; j < N; j++) {
			tmp += (X[j] - i) * (X[j] - i);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>

using namespace std;

const double PI=3.14159265358979323846264;

int N;
int r[8];
bool used[8];

int r2[8];
int c[8];
int M;
double solve(){
	for(int i=0;i<M;i++){
		if(i!=M-1) c[i]=r2[i]*r2[i+1];
		else c[i]=r2[i]*r2[0];
	}
	double lb=0,ub=PI;
	double theta[8];
	for(int stage=0;stage<100;stage++){
		double mid=(ub+lb)/2;
		double sum=0;
		double cos1=cos(mid);
		double lambda=cos1*c[0];
		sum+=mid;
		theta[0]=mid;
		bool ok=true;
		for(int i=1;i<M;i++){
			double ccos=lambda/c[i];
			if(abs(ccos)>1){
				ok=false;
				break;
			}
			double theta_=acos(ccos);
			sum+=theta_;
			theta[i]=theta_;
		}
		if(ok==false){
			if(mid>PI/2) ub=mid;
			else lb=mid;
			continue;
		}
		if(sum>PI*2){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	
	double sum=0;
	for(int i=0;i<M;i++) sum+=theta[i];
	if(abs(sum-PI*2)>1e-9) return -1;
	double cos1=cos(lb);
	double res=0;
	for(int i=0;i<M;i++){
		res+=sin(theta[i])*c[i];
	}
	return res;
}

double ans=0;

void dfs(int num){
	if(num>=3){
		M=num;
		double tmp=solve();
		ans=max(ans,tmp);
	}
	if(num==N) return;
	for(int i=0;i<N;i++){
		if(used[i]==false){
			used[i]=true;
			r2[num]=r[i];
			dfs(num+1);
			used[i]=false;
		}
	}
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",r+i);
	}
	dfs(0);
	printf("%.9f\n",ans/2);
	return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int m,f,r;
		char a;

		while(true) {
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();

			if(m == -1 && f == -1 && r == -1) break;
						else if(m == -1 || f == -1) a = 'F';
			else if(m + f >= 80) a = 'A';
			else if(m + f >= 65) a = 'B';
			else if(m + f >= 50 || (m + f >= 30 && r >= 50)) a = 'C';
			else if(m + f >= 30) a = 'D';
			else a = 'F';

			System.out.println(a);
		}

	}
}



Measured memory_bytes: 26360
n = int(input())
flg = True
count = 0
while count < n:
    flg = True
    count += 1
    x = count
    if x % 3 == 0:
        print(" {}".format(count), end="")
        continue
    while x != 0 and flg:
        if x % 10 == 3:
            print(" {}".format(count), end="")
            flg = False
        x = x // 10
print("")




Measured memory_bytes: 5876
#include <iostream>

using namespace std;

int main()
{
	int x;
	cin >> x;
	int now = 0;
	for (int i = 1; i < 360; i++) {
		now += x;

		if (now % 360 == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << 360 << endl;

	return 0;
}

Measured memory_bytes: 3620
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let minus = a.iter().filter(|&&v| v < 0).count();
    let sum = a.iter().map(|&v| v.abs()).sum::<i64>();

    if minus & 1 == 0 {
        println!("{}", sum);
    } else {
        println!("{}", sum - 2 * a.iter().map(|&v| v.abs()).min().unwrap());
    }
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int GCD(long long M, long long N) {
	
    while(N != 0) { 
        long long r = M % N; 
        M = N; 
        N = r; 
    } 
    return M;
}

int LCM(long long m, long long n) {
    return m * n / GCD(m, n);
}

int main() { 
    long long m, n; 

    while( cin >> m >> n ) {

    cout << GCD(m, n) << " " << LCM(m, n) << "\n"; 
    
	}
    return 0; 
} 


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


void solve(long long H){
    ll ans = 0;
    ll num = 1;
    while(H){
        ans += num;
        H /= 2;
        num *= 2;
    }
    cout<<ans<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<ll>v;
    for(int i=0; ;i++){
        int x=pow(2,i);
        v.push_back(x);
        if(x>100)break;
    }
    int n;
    cin>>n;
    int id=lower_bound(v.begin(),v.end(),n)-v.begin();
    if(n==v[id])cout<<v[id]<<endl;
    else cout<<v[id-1]<<endl;
}


Measured memory_bytes: 4064
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

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

    ll ans = H * W;
    ll s[3];
    for (int i = 0; i < 2; ++i) {
        for (ll h = 1; h < H; ++h) {
            // まずは縦割り
            s[0] = h * W;
            s[1] = (H - h) * (W / 2);
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);

            // 次いで横割り
            s[0] = h * W;
            s[1] = ((H - h) / 2) * W;
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
        }
        // 板チョコを90度回す
        swap(H, W);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int N;
Graph G;
vector<vector<ll>> dp;

void dfs(int v, int p){
  ll white = 1;
  ll black = 1;
  for (int nv : G[v]){
    if (nv == p) continue;
    dfs(nv, v);
    white *= (dp[nv][0] + dp[nv][1]) % MOD;
    white %= MOD;
    black *= dp[nv][1] % MOD;
    black %= MOD;
  }
  dp[v][0] = black;
  dp[v][1] = white;
}

int main() {
  cin >>N;
  G.assign(N, vector<int>());
  rep(i, N-1){
    int x,y; cin >>x >>y; x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dp.assign(N, vector<ll>(2, 0));
  // dp[i][j] := 頂点iを色jで塗る塗り方
  // 0: black, 1: white
  dfs(0, -1);
  ll res = dp[0][0] + dp[0][1];
  res %= MOD;
  cout <<res <<endl;
}


Measured memory_bytes: 18176
//==========================================
// ABC140c
//
// 2019/09/07
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<long> b(n-1);
  for(int i=0; i<n-1; i++) cin >> b[i];

  long cnt=0; 
  for(int i=0; i<n-1; i++)
  {
    if(i==0)
    {
     cnt=b[i];
    }
    else
    {
      if(b[i-1]>=b[i]) cnt+=b[i];
      else cnt+=b[i-1];
    }
  }
  cnt+=b[n-2];
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long a,b;
	scanf("%ld %ld",&a,&b);
	if((a +b)%2 ==0)
	{
		printf("%ld",(a+b)/2);
	}
	else
	{
		printf("IMPOSSIBLE");
	}
	return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, a) for (ll i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  string S;
  cin >> S;
  int N = S.length();
  int rlast;
  vector<int> RL;
  int L = 0, R = 1, count = 1;
  for (int i = 1; i < N; i++) {
    if (S[i] == 'R') {
      if (L > 0) {
        RL.push_back(L);
        L = 0;
        count++;
      }
      R++;
    } else {
      if (R > 0) {
        RL.push_back(R);
        R = 0;
        count++;
      }
      L++;
    }
  }
  RL.push_back(L);

  int now = 0, r, l;
  vector<int> ans(N, 0);
  for (int i = 0; now < N; i += 2) {
    r = RL[i];
    l = RL[i + 1];
    ans[now + r - 1] = (r + 1) / 2 + l / 2;
    ans[now + r] = (l + 1) / 2 + r / 2;
    now += r + l;
  }
  FORV(a, ans) cout << a << " ";
  cout << endl;
  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1480