akhauriyash/Code-Regression huggingface dataset:
#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 ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int n, L[maxn], R[maxn], mode;
ll ans;
multiset<pii> st, ts;

inline void add(int l, int r)
{
	st.insert(mp(l, r));
	ts.insert(mp(r, l));
}

inline void rem(int l, int r)
{
	st.erase(st.find(mp(l, r)));
	ts.erase(ts.find(mp(r, l)));
}

ll solve()
{
	int nowl, nowr, pos = 0;
	ll res = 0;
	fori (i, 0, n)
	{
		if (mode)
		{
			nowl = st.rbegin()->ff;
			nowr = st.rbegin()->ss;
			rem(nowl, nowr);
			if (nowl <= pos && pos <= nowr)
				continue;
			if (pos < nowl)
			{
				res += (nowl - pos);
				pos = nowl;
			}
			if (nowr < pos)
			{
				res += (pos - nowr);
				pos = nowr;
			}
		}
		else
		{
			nowr = ts.begin()->ff;
			nowl = ts.begin()->ss;
			rem(nowl, nowr);
			if (nowl <= pos && pos <= nowr)
				continue;
			if (pos < nowl)
			{
				res += nowl - pos;
				pos = nowl;
			}
			if (nowr < pos)
			{
				res += pos - nowr;
				pos = nowr;
			}
		}
		mode ^= 1;
	}
	return res + abs(pos);
}

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

	cin >> n;
	fori (i, 0, n)
		cin >> L[i] >> R[i];
	fori (i, 0, n)
		add(L[i], R[i]);
	ans = max(ans, solve());
	fori (i, 0, n)
		add(L[i], R[i]);
	mode = 1;
	ans = max(ans, solve());
	cout << ans << endl;
}

Measured memory_bytes: 10496
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }


int main(){
    string a,b;
    cin>>a>>b;
    int x,y;
    cin>>x>>y;
    string xx;
    cin>>xx;
    if(xx==a) x--;
    else if(xx==b) y--;
    cout<<x<<" "<<y<<endl;
}

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

int main(void){
	char a[10],b[10],c[10];
	int alen,blen;

	scanf("%s %s %s",a,b,c);
	alen=strlen(a);
	blen=strlen(b);
	if(a[alen-1]==b[0]){
		if(b[blen-1]==c[0]){
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}


Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    d = LI()
    d.sort()

    ans = d[N//2] - d[N//2-1]
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 22208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
template <typename F,typename T>
struct SegTree{
  // 二項演算merge,単位元identify
  T identity;
  F merge; 
  int size;
  vector<T> dat;
  
  // 二項演算fと単位元idを渡して宣言する
  SegTree(F f,T id):merge(f),identity(id){}

  // データの要素の数nを渡して初期化、sizeはnより大きい2の冪乗
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // 配列を渡して0(n)で初期化
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }
  
  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  // index kの要素をaに変更
  void update(int k,T a){
    k += size - 1;
    dat[k] += a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // 区間[a,b)に対するクエリに答える。(k,l,r)=(0,0,size)
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
};

int main()
{
  int n,q; cin >> n >> q;
  vl a(n); rep(i,n) cin >> a[i];
  auto f = [](ll a, ll b){ return a+b;};
  ll id = 0;
  SegTree<decltype(f), ll> seg(f, id);
  seg.init(n);
  seg.build(a);
  while(q-- > 0) {
    ll t, x, y; cin >> t >> x >> y;
    if(t == 0) {
      seg.update(x, y);
    }
    else {
      cout << seg.query(x, y, 0, 0, seg.size) << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 19368
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
void print(const vector<int>&xs){
  for(const auto x:xs)printf("%ld,",x);
  printf("\n");
}
int N,M;
main(){
  cin>>N>>M;
  vector<int>A(N),length;
  for(auto&x:A)cin>>x;
  A[0]%=M;
  for(int i=1;i<N;++i)A[i]=(A[i-1]+A[i])%M;
  A.push_back(0);
  A.push_back(0x3f3f3f3f);
  sort(A.begin(),A.end());
  int prev=A[0],len=1;
  for(int i=1;i<A.size();++i){
    if(A[i]==prev){
      ++len;
    }else{
      length.push_back(len);
      prev=A[i];
      len=1;
    }
  }
  int sum=0;
  for(int i=0;i<length.size();++i){
    int x=length[i];
    if(x==1)continue;
    sum+=(x*(x-1))/2;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 2032
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}
/*
input!{n: i64, s: String}

macro_rules! input_init {
    () => {
        let mut _input = Input::new();
    }
}

macro_rules! input {
    ($var: v : $ty: t) => {
        let v = t;
    };
}
*/

fn dfs(u: usize, e: &[Vec<usize>], r: &mut Vec<usize>, f: &mut[bool]) {
    if f[u] { return; }
    f[u] = true;
    for v in &e[u] {
        dfs(*v, e, r, f);
    }
    r.push(u);
}

fn run() {
    let mut ip = Input::new();
    let n = ip.read::<usize>();
    let m = ip.read::<usize>();
    let mut e = vec![Vec::<usize>::new(); n];
    for _ in 0..m {
        let u = ip.read::<usize>();
        let v = ip.read::<usize>();
        e[u].push(v);
    }
    let mut r = Vec::<usize>::new();
    let mut f = vec![false; n];
    for u in 0..n {
        dfs(u, &e, &mut r, &mut f);
    }
    r.reverse();
    for u in r {
        println!("{}", u);
    }
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	//int t; 
      //  cin>>t;
        //while(t--){
          int n,k;
          cin>>n>>k;
          cout<<(int)(log10(n)/log10(k))+1<<"\n";
	return 0;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n, k;
    cin >> n >> k;
    vector<ll> h(n+1);
    for(ll i=0; i<n; i++)
        cin >> h[i+1];

    vector<vector<ll>> dp(k+1, vector<ll>(n+1, 1e18));

    dp[0].assign(n, 0);
    for(ll i=1; i<=n; i++) {
        vector<vector<ll>> dq = dp;
        fill(dp.begin(), dp.end(), vector<ll>(n, 1e18));

        for(ll j=0; j<i; j++) {
            for(ll kk=0; kk<=k; kk++) 
                dp[kk][i] = min(dp[kk][i], max(0ll, h[i]-h[j]) + dq[kk][j]);
            for(ll kk=0; kk<k; kk++)
                dp[kk+1][j] = dq[kk][j];
        }
    }

    ll r = 1e18;
    for(ll kk=0; kk<=k; kk++)
        for(ll j=0; j<n+1; j++)
            r = min(r, dp[kk][j]);

    cout << r << endl;
}


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

int main(){ 
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout<<c<<endl;
	}
	else{
		if(b==c){
			cout<<a<<endl;
		}
		else{
			if(a==c){
				cout<<b<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
C = [0] * 4
for _ in range(N):
    s = str(input())
    if s == 'AC':
        C[0] += 1
    elif s == 'WA':
        C[1] += 1
    elif s == 'TLE':
        C[2] += 1
    elif s == 'RE':
        C[3] += 1

print ('AC x', C[0])
print ('WA x', C[1])
print ('TLE x', C[2])
print ('RE x', C[3])


Measured memory_bytes: 9212
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int d[100010];
signed main(void)
{
  int k;
  cin >> k;

  priority_queue<PII, vector<PII>, greater<PII>> que;
  que.push({0, 1});
  REP(i, k) d[i] = INF;
  d[1] = 1;

  while(que.size()) {
    PII p = que.top(); que.pop();
    // cout << p.first << " " << p.second << endl;
    int nxt = (p.second + 1) % k;
    if(d[nxt] > d[p.second] + 1) {
      d[nxt] = d[p.second] + 1;
      que.push({d[nxt], nxt});
    }
    nxt = (p.second * 10) % k;
    if(d[nxt] > d[p.second]) {
      d[nxt] = d[p.second];
      que.push({d[nxt], nxt});
    }
  }
  cout << d[0] << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<stdio.h>

#define MAX 100000
 struct Node { int p, l,r;};
 struct  Node T[MAX];
int n,k=0,D[MAX];
int getdep(int k);
void print(int k);
int main(){
  int i,j,d,sec,c,l;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p =-1;
    T[i].l=-1;
    T[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&sec,&d);

    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[sec].l=c;
      else T[l].r =c;
      l = c;
      T[c].p=sec;
    }
  }for(i=0;i<n;i++){
    D[i] = getdep(i);
    if(D[i]>k) k=D[i];
  }
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}
int getdep(int k){

  int depth=0;
  for(;T[k].p!=-1;depth++) k=T[k].p;
  return depth;
}
void print(int k){
  int i,c;
  printf("node %d: ",k);
  printf("parent = %d, ",T[k].p);
  printf("depth = %d, ",D[k]);
  if ( T[k].p ==-1) printf("root, ");
  else if(T[k].l ==-1) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c= T[k].l;c !=-1;i++,c=T[c].r){
    if(i !=0)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}



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

int main(){
    long long N;
    cin >> N;
    string ans = "";
    while(N){
        N--;
        ans += ('a' + (N % 26));
        N /= 26;
    }
    reverse(ans.begin() , ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
N = int(input())
H = list(map(int,input().split()))
INF = 100000000
dp = [INF] * N
dp[0] = 0
for i in range(1, N):
    if i == 1:
        dp[i] = min(dp[i],dp[i-1] + abs(H[i]-H[i-1]))
    else:
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])


Measured memory_bytes: 52336
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int parent,left,right;};

Node T[MAX];
int n,D[MAX];

void rec(int u,int p) {
    D[u] = p;
    if ( T[u].left != NIL ) rec(T[u].left, p+1);
    if ( T[u].right != NIL ) rec(T[u].right, p);
}

void print(int u) {
    int i;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent <<", ";
    cout << "depth = " << D[u] << ", ";
    if ( T[u].parent == NIL ) cout << "root, ";
        else if ( T[u].left == NIL ) cout << "leaf, ";
        else cout << "internal node, ";
    cout << '[';
    i = T[u].left;
    while ( i != NIL ) {
        if ( T[i].right == NIL) cout << i;
        else cout << i << ", ";
        i = T[i].right;
    }
    cout << ']' << endl;
}

int main()
{
    scanf("%d",&n);
    int i,j,d,v,c,l,r;
    for ( i = 0; i < n; i++ ) T[i].parent = T[i].left = T[i].right = NIL;
    for ( i = 0; i < n; i++ ) {
        cin >> v >> d;
        for ( j = 0; j < d; j++ ) {
            cin >> c;
            if ( j == 0 )  { T[v].left = c; T[c].parent = v; l = c; }
            else {
                T[l].right = c;
                T[c].parent = v;
                l = c;
            }
        }
    }

    for ( i = 0; i < n; i++ ) {
        if ( T[i].parent == NIL ) break;
    }

    rec(i,0);

    for ( i = 0; i < n; i++ )  print(i);

    return 0;
}



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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x;
    cin >> x;
    print(x >= 30 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      StringBuilder buf = new StringBuilder();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          buf.append(tree.getRoundPath());
        }
      }

      System.out.print(buf);

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  String getRoundPath() {
    buf.setLength(0);

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    return buf.toString();
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126500
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = Integer.parseInt(s.substring(0,1));
        int b = Integer.parseInt(s.substring(1,2));
        int c = Integer.parseInt(s.substring(2,3));
        int d = Integer.parseInt(s.substring(3));
        if(a+b+c+d==7){
            System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
        }else if(a-b+c+d==7){
            System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
        }else if(a+b-c+d==7){
            System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
        }else if(a+b+c-d==7){
            System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
        }else if(a-b-c+d==7){
            System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
        }else if(a+b-c-d==7){
            System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
        }else if(a-b+c-d==7){
            System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
        }else if(a-b-c-d==7){
            System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
        }
    }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m, a[5], c[5];
int d[3];
void solve(){
	cin >> n >> m;
	fill(d,d+3,-1);
	bool ok = 1;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> c[i];
		a[i]--;
		if(d[a[i]] != -1 && d[a[i]] != c[i]){
			ok = 0;
		}
		d[a[i]] = c[i];
	}
	
	if(!ok){
		cout << -1 << endl;
		return;
	}
	if(n == 1){
		if(d[0] == -1) cout << 0 << endl;
		else cout << d[0] << endl;
		return;
	}
	if(n == 2){
		for(int i = 10; i < 100; i++){
			if((d[1]==-1||i%10==d[1]) && (d[0]==-1||(i/10) == d[0])){
				cout << i << endl;
				return;
			}
		}
	}
	for(int i = 100; i < 1000; i++){
		if((d[2]==-1||i%10==d[2]) && (d[1]==-1||(i%100)/10==d[1]) && (d[0]==-1||(i/100)==d[0])){
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int i;
  long long int n,k,c=0;
  cin>>n>>k;
  vector<int>h(n);
  for(i=0;i<n;i++){
    cin>>h[i];
    c+=h[i];
  }
  sort(h.begin(),h.end());
  for(i=0;i<min(k,n);i++){
    c-=h[n-i-1];
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
li = list(map(int,input().split()))	
count = 0
flag = True

while flag==True:
	for i in range(N):
		if li[i]%2!=0:
			flag=False
		else:
			li[i] = li[i] // 2
	if flag==True:
		count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}

char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){

  string A,B,C;
  cin>>A>>B>>C;
  if((A[A.length()-1]==B[0])&&(B[B.length()-1]==C[0])) cout<<"YES";
  else cout<<"NO";
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#define ll long long

using namespace std;

ll q,a,b; 

int main(){
	
	cin>>q;
	while(q){
		cin>>a>>b;
		if(a==1&&b==1){
			cout<<0<<endl;
			q--;continue;
		}
		ll min1=min(a,b);
		ll x=sqrt(a*b)+100;
		while(x*x>(a*b)-1)x--;
		ll ans=2*x;
		if(x>=min1)ans--;
		if(x==((a*b)-1)/x)ans--;
		cout<<ans<<endl;

		q--;
	}


	return 0;
}



Measured memory_bytes: 256
/*input
3 1
1 2
1 3
2 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

vector<int> edge[maxn];
int in[maxn];
vector<int> dad[maxn];
int ans[maxn];
set<pii> st;

int depth[maxn];

int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	m+=n-1;

	REP(i,m){
		int u,v;
		cin>>u>>v;
		u--;v--;
		edge[u].pb(v);
		in[v]++;
		dad[v].pb(u);
	}
	REP(i,n){
		st.insert(MP(in[i],i));
	}

	while(SZ(st)){
		int cur=st.begin()->S;
		st.erase(st.begin());
		depth[cur]=0;
		ans[cur]=-1;
		for(int p:dad[cur]){
			if(depth[p]+1>depth[cur]){
				depth[cur]=depth[p]+1;
				ans[cur]=p;
			}
		}
		// cout<<cur<<' '<<ans[cur]<<'\n';

		for(int v:edge[cur]){
			st.erase(MP(in[v],v));
			in[v]--;
			st.insert(MP(in[v],v));
		}
	}
	REP(i,n) cout<<ans[i]+1<<"\n";
	return 0;
}


Measured memory_bytes: 28160
def main():
    import copy

    num, quantity = map(int, input().split())
    nums = list(map(int, input().split()))
    nums.sort()
    
    if quantity == 0:
        print(num)
        return
    
    i = 0

    minus_num = copy.copy(num)
    plus_num = copy.copy(num)

    while i < len(nums):
        if num not in nums:
            print(num)
            return
        
        if minus_num not in nums:
            print(minus_num)
            return
        
        if plus_num not in nums:
            print(plus_num)
            return
        
        minus_num = minus_num - 1
        plus_num = plus_num + 1

main()

Measured memory_bytes: 9192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;

int main() {
	ll A, B, C;
	scanf("%lld%lld%lld", &A, &B, &C);
	ll withPoison = min(C, A+B+1);
	printf("%lld\n", withPoison+B);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, k;
	cin >> n >> k;
	ll num = pow(k - 1, n - 1);
	printf("%lld\n", k * num);
	return 0;
}


Measured memory_bytes: 384
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/09.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    string s; cin >> s;
    int rtn = -INF;
    int tmpmax = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            ++tmpmax;
            rtn = max(rtn, tmpmax);
        } else {
            rtn = max(rtn, tmpmax);
            tmpmax = 0;
        }
    }
    cout << rtn << endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    ans += a[0] - 1;
    int point = 2;

    REPN(i, 1, n) {
        if (a[i] == point) {
            point++;
            continue;
        }
        if (a[i] < point) continue;
        if(a[i] % point == 0) {
            ans += a[i] / point - 1;
        } else {
            ans += a[i] / point;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

// ---- ----

#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int INT;

int n, m;
INT b[1'000'001], ans, MOD = 998244353;

int main() {
	cin >> n;
	inc(i, n) {
		int a; cin >> a;
		b[a] += a;
		ans -= a;
		m = max(m, a);
	}
	
	inc1(i, m) { for(int j = 2 * i; j <= m; j += i) { b[i] += b[j]; } b[i] *= b[i]; }
	dec1(i, m) { for(int j = 2 * i; j <= m; j += i) { b[i] -= b[j]; } ans += b[i] / i; }
	
	cout << (ans / 2) % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=1e5;


int main(){
    string S;
    cin>>S;
    if(S.find("AC")!=std::string::npos){
        cout<<"Yes"<<endl;
    }else{
        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 pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
    int a,b; cin>>a>>b;
    cout<<max(0,a-2*b)<<endl;

}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

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

    ll N;
    cin >> N;

    Vl x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    ll ans = 0.0;
    for (int i = 0; i < N; i++) {
        ans += x[i];
    }

    ans /= N;

    ll tmp1 = 0, tmp2 = 0;
    for (int i = 0; i < N; i++) {
        ll u = x[i] - ans;
        ll v = x[i] - (ans + 1);
        tmp1 += u * u;
        tmp2 += v * v;
    }

    cout << min(tmp1, tmp2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    cin>>n;
    if(n>=30) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3624
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut ret: HashSet<usize> = HashSet::new();
    if n == 19999 {
        ret = (2..29999).step_by(2).collect();
        ret.extend((3..30000).step_by(6));
    } else if n == 3 {
        ret.extend([2, 5, 63].iter())
    } else if n == 4 {
        ret.extend([2, 5, 20, 63].iter())
    } else if n == 5 {
        ret.extend([2, 4, 6, 3, 9].iter())
    } else if n == 6 {
        ret.extend([2, 4, 6, 12, 3, 9].iter())
    } else {
        ret.extend([2, 4, 6, 3, 9].iter());
        let n = n - 5;
        for k in 0..2500 {
            let d = n - 2 * k;
            if d % 3 != 0 || d / 3 >= 5000 {
                continue;
            }
            let m = d / 3;
            ret.extend((8..30001).step_by(2).take(3 * m));
            ret.extend((15..30000).step_by(6).take(2 * k));
            break;
        }
    };
    assert_eq!(ret.len(), n);
    println!(
        "{}",
        ret.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 3540
s = list(input())

if s.count("N") == 0 and s.count("S") > 0:
    print("No")
elif s.count("S") == 0 and s.count("N") > 0:
    print("No")
elif s.count("W") == 0 and s.count("E") > 0:
    print("No")
elif s.count("E") == 0 and s.count("W") > 0:
    print("No")
else:
    print("Yes")


"""
if s.count("N") > 0 and s.count("S") > 0 and s.count("W") > 0 and s.count("E"):
    print("Yes")
elif s.count("N") == 0 and s.count("S"):
    print("Yes")
elif s.count("W") == 0 and s.count("W"):
    print("Yes")
else:
    print("No")
"""


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(N == 0){
			Console.WriteLine(A[0] == 1 ? 1 : -1);
			return;
		}
		
		long Inf = (1L << 60);
		long[] cap = new long[N + 1];
		
		cap[0] = 1 - A[0];
		if(cap[0] <= 0){
			Console.WriteLine(-1);
			return;
		}
		for(int i=1;i<=N;i++){
			cap[i] = Math.Min(Inf, cap[i - 1] * 2 - A[i]);
			if(i == N){
				cap[i] = cap[i - 1] * 2;
			}
			if(i < N && cap[i] <= 0){
				Console.WriteLine(-1);
				return;
			}
		}
//Console.WriteLine(String.Join(" ",cap));		
		if(cap[N] < A[N]){
			Console.WriteLine(-1);
			return;
		}
//Console.WriteLine(String.Join(" ",cap));		
		
		long[] cnt = new long[N + 1];
		cnt[N] = A[N];
		for(int i=N-1;i>=0;i--){
			long nd = cnt[i + 1];
			if(nd > cap[i] * 2){
				Console.WriteLine(-1);
				return;
			}
			cnt[i] = A[i] + Math.Min(cap[i], nd);
		}
		
		
		long tot = 0;
		for(int i=0;i<=N;i++){
			tot += cnt[i];
		}
		Console.WriteLine(tot);
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 29308
N = int(input()) 
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
  print(0)
  exit()
 
upp = 10**18
ans = 1
#print(A)
for a in A:
  ans *= a
  if ans > upp:
    ans = -1
    break
 
print(ans)

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int max = 0;
  int f = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == 'I') f++;
    else f--;
    if(max < f) max = f;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp
  * Structure and Class - Dice III
  */
object Main {

  case class Dice(numbers: IndexedSeq[Int]) {
    def apply(number: Int): Int = {
      numbers(number)
    }

    def rotateTo(direction: Char): Dice = {
      direction match {
        case 'N' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))
        case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))
        case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))
        case 'E' => Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))
      }
    }

    def find(number: Int): Int = {
      numbers.indexWhere(_ == number)
    }

    def adjustWith(dice: Dice): Dice = {
      val operationsToTop = Seq("", "N", "W", "E", "S", "NN")
      val operationsToFront = Seq("S", "", "WSE", "ESW", "SEEN", "N")
      val dice2 = operationsToTop(this.find(dice(0))).foldLeft(this)(_.rotateTo(_))
      val dice3 = operationsToFront(dice2.find(dice(1))).foldLeft(dice2)(_.rotateTo(_))
      dice3
    }
  }

  def main(args: Array[String]): Unit = {
    val dice1 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val dice2 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    if (dice1 == dice2.adjustWith(dice1))
      println("Yes")
    else
      println("No")
  }
}

Measured memory_bytes: 44084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll x = b * 100 + 0.0005;
  ll ans = a * x / 100;
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if( a != b && b != c && c != a )
    {
        cout << "No" << endl;
        return 0;
    }
    else if( a == b && b == c )
    {
        cout << "No" << endl;
        return 0;
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}


LL n, a, b, c, d;

int main() {
  GLL(n);
  GLL(a);
  GLL(b);
  GLL(c);
  GLL(d);

  LL target = b-a;
  for (LL m = 0; m < n; m++) {
    LL lowerbound = -d*m + c*(n-1-m);
    LL upperbound = -c*m + d*(n-1-m);
    if ( lowerbound <= target && upperbound >= target ) {
      printf("YES\n");
      return 0;
    }
  }

    
  printf("NO\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, m, x;
    cin >> n >> m >> x;

    int ans = 100000;
    vector<bool> z(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        z[a] = true;
    }

    int v = x;
    int score = 0;
    while (v--) {
        if (z[v]) score++;
    }
    chmin(ans, score);
    v = x;
    score = 0;
    while (v++ && v<=n) {
        if (z[v]) score++;
    }
    chmin(ans, score);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 4005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    string s;
    cin>>s;

    int q;
    cin>>q;

    int cnt=0;

    string beg,en;

    while(q--){
        int num;
        cin>>num;
        if(num==1){
            cnt++;
        }
        else{
            int n1;
            cin>>n1;

            char ch;
            cin>>ch;

            if(n1==1){
                if(cnt%2==0){
                    beg+=ch;
                }
                else{
                    en+=ch;
                }
            }
            else{

                if(cnt%2==0){
                    en+=ch;
                }
                else{
                    beg+=ch;
                }

            }



        }
    }

    if(cnt%2==0){
        reverse(beg.begin(),beg.end());
        cout<<beg;
        cout<<s<<en;
    }
    else{
        reverse(en.begin(),en.end());
        cout<<en;
        reverse(s.begin(),s.end());
        cout<<s<<beg;
    }
    return;
}
// how r u bro

Measured memory_bytes: 3940
N, K = map(int, input().split())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7
 
pos = sorted(v for v in X if v >= 0)
neg = sorted(-v for v in X if v < 0)
if N == K:
    ans = 1
    for x in X:
        ans *= x
        ans %= MOD
    print(ans % MOD)
    exit()
ok = False  # True: ans>=0, False: ans<0
if pos:
    #正の数があるとき
    ok = True
else:
    #全部負-> Kが奇数なら負にならざるをえない。
    ok = (K % 2 == 0)
 
ans = 1
if ok:
    # ans >= 0
    if K % 2 == 1:
        #Kが奇数の場合初めに1つ正の数を掛けておく
        #こうすれば後に非負でも負でも2つずつのペアで
        #考えられる
        ans = ans * pos.pop() % MOD
 
    # 答えは非負になる→二つの数の積は必ず非負になる．
    cand = []
    while len(pos) >= 2:
        x = pos.pop() * pos.pop()
        cand.append(x)
 
    while len(neg) >= 2:
        x = neg.pop() * neg.pop()
        cand.append(x)
 
    cand.sort(reverse=True) # ペアの積が格納されているので必ず非負
    # ペア毎に掛けていく
    for i in range(K // 2):
        ans = ans * cand[i] % MOD
else:
    # ans <= 0
    cand = sorted(X, key=lambda x: abs(x))
    for i in range(K):
        ans = ans * cand[i] % MOD
 
print(ans)

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

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = input[0];
            var L = input[1];

            var min = Math.Abs(L);
            var result = 0;
            for (int i = 1; i <= N; i++)
            {
                if (Math.Abs(L + i - 1) < Math.Abs(min))
                {
                    min = L + i - 1;
                }
                result += L + i - 1;
            }
            Console.WriteLine(result - min);
        }
    }
}

Measured memory_bytes: 13396