akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(M);

	for (auto &x : X) {
		cin >> x;
	}
	sort(X.begin(), X.end());

	vector<int> D(M - 1);

	for (int i = 0; i + 1 < M; ++i) {
		D[i] = X[i + 1] - X[i];
	}
	sort(D.rbegin(), D.rend());

	if (M < N) {
		cout << 0 << endl;
	}
	else {
		long long ans = X.back() - X.front() - accumulate(D.begin(), D.begin() + N - 1, 0LL);
		cout << ans << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
ll dp[100010][2];
int main()
{
    cout << fixed << setprecision(30);
    string S;
    cin >> S;
    ll n = S.size();
    dp[0][0] = 1;
    loop(i, n)
    {
        if (S[i] == '1')
        {
            dp[i + 1][1] += dp[i][1] * 3;
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][0] += dp[i][0] * 2;
            dp[i + 1][1] %= mod;
            dp[i + 1][0] %= mod;
        }
        else
        {
            dp[i + 1][1] += dp[i][1] * 3;
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] %= mod;
            dp[i + 1][0] %= mod;
        }
    }
    ll ans = dp[n][0] + dp[n][1];
    ans %= mod;
    putout(ans);
    return 0;
}


Measured memory_bytes: 5316
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r;
    cin >> r;
    int a = 3 * r * r;
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
static const int MAX = 100;
#define INF (1 << 30);

int store[MAX][MAX] = {{}};

struct matrix {
  int row;
  int col;
};

int nMul(matrix x, matrix y) { return x.row * x.col * y.col; }

matrix mult(matrix x, matrix y) {
  matrix mat;
  mat.row = x.row;
  mat.col = y.col;
  return mat;
}

int main() {
  matrix mat[MAX];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mat[i].row;
    cin >> mat[i].col;
  }

  int mcm[MAX][MAX] = {0};

  for (int j = 1; j < n; j++) {
    for (int i = j-1; i >= 0; i--) {
      int minimum = INF;
      for (int k = i; k < j; k++) {
        int joint = nMul(mult(mat[i], mat[k]), mult(mat[k+1], mat[j]));
        int tmp = mcm[i][k] + mcm[k+1][j] + joint;
        minimum = min(minimum, tmp);
      }
      mcm[i][j] = minimum;
    }
  }

  cout << mcm[0][n-1] << endl;
}

Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

long long int b[2001][2001];

int main()
{
    long long int n, x;
    cin >> n >> x;
    long long int a[2001];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        b[i][0] = a[i];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < n; j++){
            int moto = i - j;
            if(moto < 1) moto += n;
            b[i][j] = min(b[i][j - 1], a[moto]);
        }
    }
    // b[i][j]は魔法j回以下つかったときにスライムiを得るためのスライムを捕まえるのにかかる最短時間
    long long int ans = (long long int)pow(mod, 2);
    for(int i = 0; i < n; i++){
        // iは魔法を使う回数
        long long int result = x * i;
        for(int j = 1; j <= n; j++){
            result += b[j][i];
        }
        ans = min(ans, result);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int N , K;

    cin >> N >> K;
    if( N% K == 0)cout << '0' << endl;
    else cout << '1' << endl;


}


Measured memory_bytes: 256
n,q = map(int, input().split())
s = input()
counter = 0
countlist = [0] * 2

for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        counter += 1
    countlist += [counter]

for i in range(q):
    l, r = map(int, input().split())
    print(countlist[r] - countlist[l])

Measured memory_bytes: 6096
module Main where
import Data.Char
int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = tail . words
printer = unlines . (:[]) . show

solver :: [String] -> Integer
solver ss = pattern ptn 3
  where
    ptn = map toInteger [
      length $ filter ((=='M') . head) ss,
      length $ filter ((=='A') . head) ss,
      length $ filter ((=='R') . head) ss,
      length $ filter ((=='C') . head) ss,
      length $ filter ((=='H') . head) ss
      ]

pattern :: [Integer] -> Int -> Integer
pattern [] 0 = 1
pattern [] _ = 0
pattern (m:ptn) select = 
  if m > 0 && select > 0 then
    m * pattern ptn (select-1)
      + pattern ptn select
  else
    pattern ptn select




Measured memory_bytes: 40188
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
        ll a,b,c;
        cin>>a>>b>>c;
        ll d = c-a-b;
        if (d<0) {
                cout<<"No\n";
                return 0;
        }
        bool res = 4*a*b < d*d;
        cout<<(res?"Yes\n":"No\n");
}


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

const int N = 5000;

std::string names[N];
int len[N],n,ans = 0;
std::string music;

int main()
{
	std::cin >> n;
	for(int i = 1;i <= n;i++)
		std::cin >> names[i] >> len[i];
	std::cin >> music;

	bool flag{0};
	for(int i = 1;i <= n;i++) {
		if(flag) ans += len[i];
		if(names[i] == music) flag =  1;
	}
	std::cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int check_palindrome(int x) {
        char buf[6];
        int i, len = 0;
        snprintf(buf, 6, "%d", x);
        len = strlen(buf);
        for (i = 0; i < len; i++) {
                //printf("%c %c\n", buf[i], buf[len -i]);
                if (buf[i] != buf[len -1 - i])
                        return 0;
        }
        //printf("%d\n", x);
        return 1;
}
int main(void) {
        int i, start, end, result;
        result = 0;
        scanf("%d %d", &start, &end);
        for (i = start; i <= end; i++) {
                if (check_palindrome(i) == 1)
                        result++;
        }
        printf("%d\n", result);

}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <tuple>
#include <ctime>
#include <cmath>
#include <fstream>
#include <sstream>
using namespace std;
#define INF 1000000007
#define PB push_back
#define MP make_pair
#define X first
#define Y second

typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef queue<int> QI;
typedef queue<PII> QII;
typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef set<int> SI;
typedef set<PII> SII;
typedef long long ll;


int main() {
	ios_base::sync_with_stdio(0);
	int N;
	cin >> N;
	VI V;
	for(int i=0;i<N;i++)
	{
		int k; cin >> k; V.PB(k-i-1);
	}
	int median;
	VI M=V;
	sort(M.begin(),M.end());
	if(N%2==0)
	{
		median=M[N/2-1];
	}
	else
	{
		median=M[(N-1)/2];
	}
	ll counter=0;
	for(int i=0;i<N;i++)
	{
		counter+=(ll) abs(V[i]-median);
	}
	cout << counter << endl;
return 0;
}



Measured memory_bytes: 1908
#include <iostream>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int i,j;
    while(h>=3&&w>=3){
        for(i=1;i<=w;i++){
            cout<<"#";
        }
        cout<<"\n";
        for(j=1;j<=h-2;j++){
            cout<<"#";
            for(i=1;i<=w-2;i++){
                cout<<".";
            }
            cout<<"#\n";
        }
        for(i=1;i<=w;i++){
            cout<<"#";
        }
        cout<<"\n\n";
        cin>>h>>w;
    }
}

Measured memory_bytes: 3032
#[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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      s: u64,
    }

    const BASE: u64 = 1e9 as u64;

    let x1 = 0;
    let y1 = 0;
    let x2 = BASE;
    let y2 = 1;

    let m = s%BASE;
    let x3 = if m == 0 { 0 } else { BASE - m };
    let y3 = (s + x3) / BASE;
    assert!((s+x3)%BASE == 0);
    if x2 == x3 && y2 == y3 {
        panic!();
    }
    assert!(y3 <= BASE);
    puts!("{} {} {} {} {} {}\n", x1, y1, x2, y2, x3, y3);
}


Measured memory_bytes: 4352
#include<iostream>
#include<unordered_map>
#include<vector>
#include<string>

using namespace std;

int main(){
  int n;
  cin>>n;
  unordered_map <string,int> m;
  vector<string> v(n);
  int i=0;
  bool f=true;
  while(n--){
    string s;
    cin>>s;
    if(m.count(s)==1){
      cout<<"No"<<endl;
      f=false;
      break;
    }
    m[s]=1;
    v[i]=s;
    if(i==0){
      i++;
      continue;
    }
    int x=v[i-1].size();
    string p=v[i-1];
    if(p[x-1]!=s[0]){
      cout<<"No"<<endl;
      f=false;
      break;
    }
    i++;
  }
  
  if(f){
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();

        int a[] = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt();
        }

        int sum[] = new int[n];
        for (int i = 0; i < q; i++) {
            sum[a[i]-1]++;
        }

        for (int i = 0; i < n; i++) {
            if (q - sum[i] < k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
	}
}


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


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int count = 0;
		int countf = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'a' && count < A + B) {
				System.out.println("Yes");
				count++;
			}
			else if(S[i] == 'b' && count < A + B && countf < B) {
				System.out.println("Yes");
				count++;
				countf++;
			}
			else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 24076
#include <stdio.h>
int main(void){
    int a,b,c,d,min=3000;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+c<=min) min=a+c;
    if(a+d<=min) min=a+d;
    if(b+c<=min) min=b+c;
    if(b+d<=min) min=b+d;
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,nowx,nowy,nowt;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	while(n--){
		int t,x,y;
		cin>>t>>x>>y;
		int sol=abs(x-nowx)+abs(y-nowy);
		if(t-nowt<sol){
			cout<<"No";
			return 0;
		}
		if(t-nowt>sol && (t-nowt-sol)%2==1){
			cout<<"No";
			return 0;
		}
		nowt=t;
		nowx=x;
		nowy=y;
	}
	cout<<"Yes";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T, T> > > & G){     
  using Pa = pair<T, T>;
  vector<T> D(siz(G),LINF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    T spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(auto&& e:G[v]){
      int u=e.first;//頂点番号
      T c=e.second;//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n,m,s;cin>>n>>m>>s;
  VV<PL> e(n*5010,V<PL>(0));
  rep(i,0,m){
    ll u,v,a,b;cin>>u>>v>>a>>b;
    --u;--v;

    rep(j,a,5010){
      e[j+5010*u].eb(5010*v+j-a,b);
      e[j+5010*v].eb(5010*u+j-a,b);
    }
  }

  rep(i,0,n){
    int c,d;cin>>c>>d;
    rep(j,0,5010-c){
      e[5010*i+j].eb(5010*i+j+c,d);
    }
  }


  V<ll> dis=dijkstra(min(5009,s),e);

  rep(i,1,n){
    ll ans=LINF;
    rep(j,0,5010){
      chmin(ans,dis[5010*i+j]);
    }
    cout<<ans<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 44476
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1000000007;

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


int main() {
	string s;
	cin >> s;
	vector<int> a, b, c, d;
	rep(i, sz(s)) {
		if (s[i] == 'A') a.push_back(i);
		else if (s[i] == 'B') b.push_back(i);
		else if (s[i] == 'C') c.push_back(i);
		else {
			b.push_back(i);
			d.push_back(i);
		}
	}
	ll ans = 0;
	rep(i, sz(b)) {
        bool flag;
        if(lower_bound(d.begin(),d.end(),b[i])!=d.end()&&*lower_bound(d.begin(),d.end(),b[i])==b[i]) flag=true;
        else flag=false;
		auto itea = lower_bound(a.begin(), a.end(), b[i]);
		auto itead = lower_bound(d.begin(), d.end(), b[i]);
        
		auto itec = upper_bound(c.begin(), c.end(), b[i]);
		auto itecd = upper_bound(d.begin(), d.end(), b[i]);
      
      if(flag){
        ans+=(ll)(itea-a.begin())*(ll)(c.end()-itec)*modpow((ll)3,(ll)(sz(d)-1),INF);
      ans%=INF;
        ans+=(ll)(itea-a.begin())*(ll)(d.end()-itecd)*modpow((ll)3,(ll)(sz(d)-2),INF);
      ans%=INF;
        ans+=(ll)(itead-d.begin())*(ll)(c.end()-itec)*modpow((ll)3,(ll)(sz(d)-2),INF);
      ans%=INF;
        ans+=(ll)(itead-d.begin())*(ll)(d.end()-itecd)*modpow((ll)3,(ll)(sz(d)-3),INF);
        ans%=INF;
      }else{
       ans+=(ll)(itea-a.begin())*(ll)(c.end()-itec)*modpow((ll)3,(ll)(sz(d)),INF);
      ans%=INF;
        ans+=(ll)(itea-a.begin())*(ll)(d.end()-itecd)*modpow((ll)3,(ll)(sz(d)-1),INF);
      ans%=INF;
        ans+=(ll)(itead-d.begin())*(ll)(c.end()-itec)*modpow((ll)3,(ll)(sz(d)-1),INF);
      ans%=INF;
        ans+=(ll)(itead-d.begin())*(ll)(d.end()-itecd)*modpow((ll)3,(ll)(sz(d)-2),INF);
        ans%=INF;
      }
    }
	cout << ans << endl;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k;
    cin >> k >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll dis = abs(a[0] - (a[n - 1] - k));
    for(int i = 1; i < n; i++) {
        dis = max(dis, abs(a[i] - a[i - 1]));
    }
    cout << k - dis << endl;
}


Measured memory_bytes: 1920
//Chandigarh University 
//author:- shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
#define endl "\n"
#define lli long long int
#define vint vector<long long int>
#define vvint vector< vector<long long int> >
#define pub push_back
#define ppb pop_back
using namespace std;
int main() {
	lli n;
	cin>>n;
	lli a[n];
	for(lli i=0;i<n;i++)
	{
		cin>>a[i];
	}
	lli sum=0;
	for(lli i=0,p=1;i<n;i++)
	{
		if(a[i]==p)
		{
			p++;
		}
		else
		{
			sum++;
		}
	}
	if(sum==n)
		cout<<-1;
	else
		cout<<sum;

	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 3005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  pair<ll, ll> arr[n + 5];

  for (ll i = 1; i <= n; i++) {
    cin >> arr[i].first;
    arr[i].second = i;
  }

  sort(arr + 1, arr + n + 1);
  for (ll i = 1; i <= n; i++)
    cout << arr[i].second << " ";

  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

#define _GLIBCXX_DEBAC
typedef long long ll;
using namespace std;


int main() {
	long long a, b;
	cin >> a >> b;
	for (int i = 1; i <= b; i++) {
		if ((a * i) % b == 0) {
			cout << a * i;
			break;
		}
	}
		return 0;
}









Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V;
	List<int>[] es;
	void Solve()
	{
		V = F;
		es = MakeArray(V, _ => new List<int>());
		for (var i = 0; i < V - 1; i++)
		{
			var I = G;
			I[0]--; I[1]--;
			es[I[0]].Add(I[1]);
			es[I[1]].Add(I[0]);
		}
		var u = ArgMax(Distance(0));
		var d = Distance(u).Max();
		WriteLine(d % 3 == 1 ? "Second" : "First");
	}
	int ArgMax(int[] a) { int m = int.MinValue, mi = 0; for (var i = 0; i < a.Length; i++) if (m < a[i]) { m = a[i]; mi = i; } return mi; }
	int[] Distance(int r)
	{
		var dist = new int[V];
		var st = new Stack<Tuple<int, int, int>>();
		st.Push(new Tuple<int, int, int>(r, -1, 0));
		while (st.Count > 0)
		{
			var t = st.Pop();
			int u = t.Item1, p = t.Item2, d = t.Item3;
			dist[u] = d;
			foreach (var v in es[u]) if (v != p) st.Push(new Tuple<int, int, int>(v, u, d + 1));
		}
		return dist;
	}
}


Measured memory_bytes: 51464
import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  char[] input;

  private static char[] simplify(char[] chseq) {
    StringBuilder ret = new StringBuilder();

    int i = 0;
    while (i < chseq.length) {
      char ch = chseq[i];
      i++;
      while(i < chseq.length && chseq[i] == ch) i++;
      ret.append(ch);
    }

    return ret.toString().toCharArray();
  }

  private static char[] putStone(char[] chseq) {
    int i = 0;
    char[] ret = new char[chseq.length - 1];
    while (i < ret.length) {
      ret[i] = chseq[i];
      i++;
    }
    return ret;
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String inStr = in.next();

    int cnt = 0;

    char[] chseq = inStr.toCharArray();
    chseq = simplify(chseq);
    if (chseq.length != 1) {
      cnt = chseq.length - 1;
    }

    System.out.println(cnt);
  }
}

Measured memory_bytes: 13896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication25 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            var result = Method(s);
            Console.WriteLine(result);
        }

        private static string Method(string s) {

            return s.Replace(",", " "); 
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct S {
    ll sy, sx, ty, tx;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, w;
    cin >> h >> w;
    vector<vector<ll>> a(h, vector<ll>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    vector<S> vs;
    rep(i, h - 1) {
        rep(j, w) {
            if (a[i][j] % 2 != 0) {
                vs.push_back((S){i + 1, j + 1, i + 2, j + 1});
                a[i + 1][j]++;
            }
        }
    }
    rep(i, w - 1) {
        if (a[h - 1][i] % 2 != 0) {
            vs.push_back((S){h, i + 1, h, i + 2});
            a[h - 1][i + 1]++;
        }
    }
    printf("%lld\n", sz(vs));
    rep(i, sz(vs)) printf("%lld %lld %lld %lld\n", vs[i].sy, vs[i].sx, vs[i].ty, vs[i].tx);
    return 0;
}


Measured memory_bytes: 8432
#include<stdio.h>
#include<algorithm>
#include<string.h>

char S[100010] = {0};
bool mem[100] = {0};

int main()
{
    scanf("%s",S);
    for(int i = 0; i < strlen(S); i++)
    {
        mem[S[i] - 'a'] = true;
    }
    for(int i = 0; i < 'z' - 'a' + 1; i++)
    {
        if(!mem[i])
        {
            printf("%c\n",'a' + i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

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

int main(){
    int A; cin >> A;
    int B; cin >> B;
    if(A==1 && B==2) cout << 3;
    if(A==1 && B==3) cout << 2;
    if(A==2 && B==1) cout << 3;
    if(A==2 && B==3) cout << 1;
    if(A==3 && B==1) cout << 2;
    if(A==3 && B==2) cout << 1;
}

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  for(int i=0;i<K;i++){
    if(A>=B) B *= 2;
    else if(B>=C) C *= 2;
  }
  
  if(A<B && B<C) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int x[10000], H, W; string S;
int main() {
    cin >> W >> H;
    for (int i = 0; i < H; i++) {
        cin >> S; for (int j = 0; j < W; j++)if (S[j] == 'W')x[j + 1] += 1;
    }
    for (int i = 1; i <= W; i++)x[i] += x[i - 1];
    int SUM = x[H];
    int minid = 0, maxn = 10000000;
    for (int i = 0; i <= W; i++) {
        int cnt = (i*H - x[i]);
        int P = SUM - x[i]; cnt += P;
        if (maxn > cnt) { minid = i; maxn = cnt; }
    }
    cout << minid << ' ' << minid + 1 << endl;
    return 0;
}

Measured memory_bytes: 3248
st = input().split()
N = int(st[0])
x = int(st[1])
A = input().split()
a = []
for i in range(N):
     a.append(int(A[i]))   
a.append(0)
a.append(0)
ret = 0
for i in range(N):
    if a[i] + a[i + 1] > x :
        d1 = max((a[i] + a[i + 1]) - x,0)
        ret +=  min(a[i+1],d1)
        a[i+1] -=  min(a[i+1],d1)
        d1 = max((a[i] + a[i + 1]) - x,0)
        ret +=  min(a[i],d1)
        a[i] -=  min(a[i],d1)
print(ret)

Measured memory_bytes: 14800
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;

int main(){
	cin >> n;
	p(180*n-360);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=401000;
ll dp[N][5][5],tmp[5][5],tmp2[5][5];
int pt[N],md,mv,n,u,v,lef[N];
PII cen;
VI e[N];

void dfs(int u,int f,int dep) {
	pt[dep]=u;
	if (dep>md) {
		md=dep; mv=u; cen=mp(pt[dep/2],pt[(dep+1)/2]);
	}
	for (auto v:e[u]) {
		if (v==f) continue;
		dfs(v,u,dep+1);
	}
}
void gao(int u,int f,int d) {
	if (d==md/2) {
		//printf("gg %d %d\n",u,md);
		lef[u]=1;
		return;
	}
	dp[u][0][0]=1;
	for (auto v:e[u]) {
		if (v==f) continue;
		gao(v,u,d+1);
		rep(L,0,3) rep(R,0,3) tmp[L][R]=tmp2[L][R]=0;
		if (lef[v]) {
			tmp[1][0]=1;
			tmp[0][1]=1;
			tmp[0][0]=1;
		} else {
			rep(L,0,3) rep(R,0,3) {
				tmp[L][0]=(tmp[L][0]+dp[v][L][R])%mod;
				tmp[0][R]=(tmp[0][R]+dp[v][L][R])%mod;
				tmp[0][0]=(tmp[0][0]+dp[v][L][R])%mod;
			}
		}
		rep(L,0,3) rep(R,0,3) rep(fL,0,3) rep(fR,0,3)
			tmp2[min(L+fL,2)][min(R+fR,2)]=(tmp2[min(L+fL,2)][min(R+fR,2)]+dp[u][L][R]*tmp[fL][fR])%mod;
		rep(L,0,3) rep(R,0,3) dp[u][L][R]=tmp2[L][R];
	}
	//rep(i,0,4) printf("gg %d %d %lld\n",u,i,dp[u][i]);
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d%d",&u,&v);
		e[u].pb(v);
		e[v].pb(u);
	}
	md=-1;
	dfs(1,0,0);
	md=-1;
	dfs(mv,0,0);
	if (cen.fi==cen.se) {
		gao(cen.fi,0,0);
		printf("%lld\n",dp[cen.fi][1][1]*powmod(2,mod-2)%mod);
	} else {
		//puts("dup center");
		gao(cen.fi,cen.se,0);
		gao(cen.se,cen.fi,0);
		rep(L,0,3) rep(R,0,3) tmp[L][R]=tmp2[L][R]=0;
		rep(L,0,3) rep(R,0,3) {
			tmp[L][0]=(tmp[L][0]+dp[cen.fi][L][R])%mod;
			tmp2[0][R]=(tmp2[0][R]+dp[cen.se][L][R])%mod;
		}
		printf("%lld\n",tmp[1][0]*tmp2[0][1]%mod);
	}
}


Measured memory_bytes: 66048
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  int k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int aum=0;
  for(int i=0;i<k;i++)aum+=a[i];
  cout<<aum<<endl;
}
  

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n;
signed main(){
  cin>>n;
  int a = 0,ii;
  repd(i,1,n+1){
    a += i;
    if(a >= n){
      ii = i;break;
    }
  }
  int x = a - n;
  repd(i,1,ii+1){
    if(i == x)continue;
    cout << i << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,a[N];
ll pre[322][N],bk[322][N];
set<int>s;
void solve()
{
    ll ans=0;
    for(int x=1;x<n;x++)
        for(int y=1;y<x;y++)
    {
        ll res=0;
        if((n-1-x)%(x-y)!=0) continue;
        for(int k=x;k<n;k+=x-y)
            res+=a[k],s.insert(k);
        for(int k=n-1-x;k>=0;k-=x-y)
        {
            if(s.count(k)) {res=0;break;}
            res+=a[k];
        }
        s.clear();
        ans=max(ans,res);
    }
    printf("%lld\n",ans);
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    if(n<500) {solve();return 0;}
    ll ans=0;
    int t=sqrt(n);
    for(int i=1;i<=t;i++)
    {
        for(int j=i;j<n;j+=i)
            pre[i][j]=a[j];
        for(int j=i;j<n;j++)
            pre[i][j]+=pre[i][j-1];
        for(int j=n-1-i;j>=0;j-=i)
            bk[i][j]=a[j];
        for(int j=n-1-i;j>=0;j--)
            bk[i][j]+=bk[i][j+1];
    }
    for(int i=1;i<n;i++)
    {
        int x=i,y=n-1-i,s=y-x;
        if(s<0)
        {
            int l=1,r=1;
            while(l<=y&&l<i)
            {
                if(y%l==0)
                {
                    ll res=0;
                    if(l<=t)
                        res=bk[l][i]+pre[l][n-1-i];
                    else
                    {
                        for(int j=i;j<n;j+=l)
                            res+=a[j];
                        for(int j=n-1-i;j<n;j-=l)
                            res+=a[j];
                    }
                    ans=max(ans,res);
                }
                l=r+1;
                if(l>y) break;
                r=y/(y/l);
            }
        }
        else if(s>0)
        {
            int l=1,r=1;
            while(l<=y)
            {
                if(y%l==0&&s%l!=0&&l<i)
                {
                    ll res=0;
                    if(l<=t)
                        res=bk[l][i]+pre[l][n-1-i];
                    else
                    {
                        for(int j=i;j<n;j+=l)
                            res+=a[j];
                        for(int j=n-1-i;j<n;j-=l)
                            res+=a[j];
                    }
                    ans=max(ans,res);
                }
                l=r+1;
                if(l>y) break;
                r=y/(y/l);
            }
        }
    }
    printf("%lld\n",ans);
}
/*
a=6,b=4
11
0 -4 0 -99 31 14 -15 -39 43 18 0
*/


Measured memory_bytes: 495488
s = input()
if s=="SUN":
  print(7)
elif s=="MON":
  print(6)
elif s=="TUE":
  print(5)
elif s=="WED":
  print(4)
elif s=="THU":
  print(3)
elif s=="FRI":
  print(2)
elif s=="SAT":
  print(1)


Measured memory_bytes: 2940
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,d=[parseInt(readline()) for i in 1:4]
    println(min(a,b)+min(c,d))
end
main()

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

int main() {
int  N;
    cin >> N ;
 int A[300000];
  for (int i=0; i<3*N; i++){
  cin >> A[i] ;
  }
sort (A,A+3*N,greater<int>()) ;
  
long long sum =0;
  for (int i=1; i<2*N; i+=2){
  sum +=A[i];
  }

  cout << sum << endl;  
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
template<typename T> T gcd_(T a,T b){ return (a%b)?gcd_(b,a%b):b; }
int main(){
    int n;
    cin >> n;
    vector<int> a(n),l(n),r(n),g(n);
    rep(i,n)cin >> a[i];
    l[0]=a[0];
    for(int i=1;i<n;++i)l[i]=gcd_(l[i-1],a[i]);
    r[n-1]=a[n-1];
    for(int i=n-2;i>=0;--i)r[i]=gcd_(r[i+1],a[i]);
    g[0]=r[1];
    g[n-1]=l[n-2];
    for(int i=1;i<n-1;++i)g[i]=gcd_(l[i-1],r[i+1]);
    cout << *max_element(g.begin(),g.end()) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	const ll mod = 1000000007;
	ll N;
	ll A[100001];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	ll ans = 1;
	ll hat[3];
	fill(hat, hat+3, 0);
	for(int i = 0; i < N; i++){
		int degree = 0;
		// 番号iの帽子がなりうる色数を数える
		for(int c = 0; c < 3; c++){
			if(A[i] == hat[c]){
				degree++;
			}
		}
		
		// 番号iの帽子の色を決め打つ
		for(int c = 0; c < 3; c++){
			if(A[i] == hat[c]){
				hat[c]++;
				break;
			}
		}
		ans *= degree;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 1e5 + 5;
const double Pi = acos(-1.0);
const int maxn = 2e5 + 5;
LL gcd(LL a, LL b){
    return b ? gcd(b,a%b) : a;
}
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL n,x;
    cin>>n>>x;
    cout<<3 * (n - gcd(n,x))<<"\n";
}


Measured memory_bytes: 256
/***************************************************
 * Problem Name : B.cpp
 * Problem Link :
 * Contest Name :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2018-10-27
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
void fun (int a, int b, int k) {
    for (int i = 1; i <= k; i++) {
        if (i % 2 == 1) {
            if (a % 2 == 0) {
                b += (a / 2);
                a = a / 2;

            } else {
                a--;
                b += (a / 2);
                a = a / 2;
            }

        } else {
            if (b % 2 == 0) {
                a += (b / 2);
                b = b / 2;

            } else {
                b--;
                a += (b / 2);
                b = b / 2;
            }
        }
    }

    cout << a << " " << b << "\n";
}
int main () {
    __FastIO;
    int a, b, k;
    cin >> a >> b >> k;
    fun (a, b, k);
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    div = pow(10, 9) + 7
    # ans = []
    splitB = [0, 1]
    prev = 1
    for i in range(2, K+1):
        prev = (prev*(K-i+1))//(i-1)
        splitB.append(prev % div)
    if K == 0:
        splitB[0] = 1
        splitB[1] = 0

    splitR = [0, 1]
    prev = 1
    for i in range(2, N-K+1):
        prev = (prev*(N-K-i+1))//(i-1)
        splitR.append(prev % div)
    if N-K == 0:
        splitR[0] = 1
        splitR[1] = 0

    # print(N, K)
    # print(splitB)
    # print(splitR)
    for i in range(1,K+1):
        v = 0
        if i <= K and i <= N-K:
            v += 2*(splitR[i] % div)*(splitB[i] % div)
        if i <= K and i+1 <= N-K:
            v += (splitR[i+1] % div)*(splitB[i] % div)
        if i <= K and 0 <= i-1 <= N-K:
            v += (splitR[i-1] % div)*(splitB[i] % div)
        # ans.append(v)
        print(v % div)
        # AB, BA, ABA, BAB, ABAB,BABA,ABABA

if __name__ == '__main__':
    main()

Measured memory_bytes: 41968
// C - Marks
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N,K; cin>>N>>K;
	vector<int> A(N);
	rp(i, 0, K) cin>>A[i];
	rp(i, K, N){
		cin>>A[i];
		puts(A[i-K] < A[i]? "Yes":"No");
	}
}


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

using namespace std;

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

	int n, m;
	cin >> n >> m;

	priority_queue<long long> pq;
	long long a;

	for(int i = 0; i < n; i++) {
		cin >> a;
		pq.push(a);
	}

	while(m--) {
		long long x = pq.top();
		pq.pop();
		pq.push(x/2);
	}

	long long ans = 0;

	while(!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}

	cout << ans << '\n';

	return 0;
} 

Measured memory_bytes: 1400
n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
b=list(accumulate(a))
l=0
r=2
ans=10**18
for i in range(1,n-2):
    while b[i]-b[l]>b[l+1]:
        l+=1
    while b[-1]-b[r]>b[1+r]-b[i]:
        r+=1
    p=b[l]
    q=b[i]-b[l]
    rr=b[r]-b[i]
    s=b[n-1]-b[r]
    ans=min(ans,abs(max(p,q,rr,s)-min(p,q,rr,s)))
    
print(ans)

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

int main() {
	int a=0;
	double x = 0;
	long double ans = 0;
	cin >> a;
	for (int i = 0; i < a;i++) {
		double b = 0;
		string c;
		cin >> b >> c;
		if (c=="JPY") {
			
			ans += b;
		}
		else {
			 b *= 380000;
			ans += b;
		}
	}
	std::cout << ans << std::endl;
}

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

char s[100005];
int qt[2];
int main()
{
    scanf("%s",s);
    int n = strlen(s);
    bool ok = 0;
    qt[0]++;
    for(int i = 1; i < n ; i++)
    {
        if(s[i] != s[i-1])
        {
            ok ^= 1;
        }
        qt[ok]++;
    }

    int ans = 0;
    for(int i = n-1; i >= 0 ; i--)
    {
        if(s[i] == 'g')
        {
            if(qt[0] - qt[1] > 1)
            {
                ans++;
                qt[0]--;
                qt[1]++;
            }
        }
    }


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


    return 0;
}

Measured memory_bytes: 384