akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, h;
  int a,b, maxa = 0;
  vector<int> vec;
  
  scanf("%d%d",&n,&h);

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

    maxa = max(maxa, a);
    vec.push_back(b);
  }
  vec.push_back(0);
  sort(vec.begin(), vec.end(), greater<int>());

  int sum = 0;
  
  for(int i=0;i<=n;i++){
    if(maxa >= vec[i]){
      printf("%d\n",i + (h - sum + maxa - 1)/maxa);
      return 0;
    }
    sum += vec[i];

    if(h <= sum){
      printf("%d\n",i+1);
      return 0;
    }
  }

  
  
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int &x : a) cin >> x;
  for (int &x : b) cin >> x;

  int j = 0;
  int64_t sa = 0, sb = 0;
  while (j < m && sb + b[j] <= k) {
    sb += b[j++];
  }

  int ans = j;
  for (int i = 0; i < n; ++i) {
    sa += a[i];
    while (j > 0 && sa + sb > k) {
      sb -= b[--j];
    }
    if (sa + sb <= k) {
      ans = max(ans, i + 1 + j);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4780
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#include <boost/multiprecision/cpp_int.hpp>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
typedef boost::multiprecision::cpp_int integer;
using namespace std;

vector<int> sieve_of_eratosthenes(int n) { // enumerate primes in [2,n] with O(n log log n)
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (int k = i+i; k <= n; k += i)
                is_prime[k] = false;
    vector<int> primes;
    for (int i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}
integer sq(integer x) { return x*x; }
integer cubed(integer x) { return x*x*x; }
integer norm(integer s, vector<int> const & primes) {
    for (int p : primes) {
        if (s < p) break;
        while (s % cubed(p) == 0) {
            s /= cubed(p);
        }
    }
    assert (s >= 1);
    return s;
}
integer inv(integer s, vector<int> const & primes) {
    integer t = 1;
    for (int p : primes) {
        if (s % p == 0) {
            if (s % sq(p) == 0) {
                t *= p;
                s /= sq(p);
            } else {
                t *= sq(p);
                s /= p;
            }
        }
    }
    if (s != 1) {
        integer r = sqrt(s);
        if (s == r * r) {
            t *= r;
        } else {
            t *= s * s;
        }
    }
    assert (t >= 1);
    return t;
}

int main() {
    // input
    int n; scanf("%d", &n);
    vector<ll> s(n); repeat (i,n) scanf("%lld", &s[i]);
    // compute
    vector<int> primes = sieve_of_eratosthenes(pow(*whole(max_element, s), 1/3.) + 3);
    map<integer, int> f;
    repeat (i,n) {
        integer x = norm(s[i], primes);
        f[x] += 1;
    }
    int ans = 0;
    set<integer> used;
    for (auto it : f) {
        integer x; int cnt; tie(x, cnt) = it;
        if (used.count(x)) continue;
        integer y = inv(x, primes);
        if (f.count(y)) {
            used.insert(y);
            ans += max(cnt, f[y]);
        } else {
            ans += cnt;
        }
    }
    if (f.count(1)) {
        ans -= f[1];
        ans += 1;
    }
    // output
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = LLONG_MAX;

int ans1,ans2;
int main(){
  double a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  double ret=0.0;
  //xcは砂糖の入れる量
  for(int xc=0;xc<=(3000)/c;xc++){
    for(int xd=0;xd<=(3000)/d;xd++){
      double pc=xc*c;double pd=xd*d;
      double ep=pc+pd;
      for(int xa=0;xa<=30;xa++){
        for(int xb=0;100*(xb*b+xa*a)+(pc+pd)<=f;xb++){
          double pa=xa*a;double pb=xb*b;
          //溶解おうばー
          if(ep>(e*(pa+pb)))continue;

          double temp=(pc+pd)/(100*(pa+pb)+pc+pd);
          if (temp> ret){
            ret=temp;
            ans1=100*(pa+pb)+pc+pd,ans2=pc+pd;
          }
        }
      }

    }
  }
  if(ans1==0)cout<<a*100<<" "<<'0'<<endl;
  else cout<<ans1<<" "<<ans2<<endl;
}


Measured memory_bytes: 256
while 1:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(0, H):
        print("#", end="")
        for j in range(1, W - 1):
            if i == 0 or i == H - 1:
                print("#", end="")
            else:
                print(".", end="")

        print("#")
    print("")

Measured memory_bytes: 8932
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
// #define int long long

const int K = 1e5 + 5, N = 105;

int dp[K];
int n, a[N], k;
				
int32_t main() {
	fast_cin();  
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int cur_stones = 0; cur_stones <= k; cur_stones++) {
		int &ans = dp[cur_stones];
		ans = 0;
		bool ok = false;
		for (int i = 1; i <= n; i++) {
			if (cur_stones - a[i] >= 0) {
				ok |= (dp[cur_stones - a[i]] == 0);
			}
		}
		if (ok) ans = 1;
	}
	int ans = dp[k];
	if (ans == 1) {
		cout << "First";
	} else {
		cout << "Second";
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
using namespace std;
int l,r,cnt,ans=1e9,vis[2100];
int a[2100];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
signed main(){
	l=read(),r=read();
	for(int i=l;i<=r;i++){
		if(!vis[i%2019]){
			vis[i%2019]=1;
			a[++cnt]=i%2019;
		}
		else break;
	}
	for(int i=1;i<=cnt;i++)
		for(int j=i+1;j<=cnt;j++)
			if(a[i]*a[j]%2019<ans)
				ans=a[i]*a[j]%2019;
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {

  def isMatch(arr:Array[Char], t:String, k:Int):Boolean = {
    for(i <- 0 until t.length) {
      if(t.charAt(i) != arr(i+k) && arr(i+k) != '?')
        return false
    }
    true
  }
  def construct(arr:Array[Char], t:String, k:Int):Unit = {
      for(i <- 0 until t.length) {
        arr(i+k) = t.charAt(i)
      }
  }

  val in = new BufferedReader(new InputStreamReader(System.in))
  val s, t = in.readLine

  val ans = {
    val arr = s.toCharArray
    var isMatched = false

    for(i <- s.length - t.length to 0 by -1) {
      if(isMatch(arr, t, i)) {
        if(!isMatched) {
          construct(arr, t, i)
          isMatched = true
        }
      }
    }

    if(isMatched) {
      for(i <- 0 until s.length) {
        if(arr(i) == '?') {
          arr(i) = 'a'
        }
      }
      arr.mkString
    }
    else "UNRESTORABLE"
  }

  println(ans)
}

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

int n;
vector<int> p, q;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	p.push_back(2);
	int t = 0;
	int x = 3;
	while(t < n){
//		for(auto i : p)
//			cout << i << " ";
//		cout << "\n";
		bool f = true;
		for(int i=0; p[i]*p[i]<=x; ++i)
			if(x % p[i] == 0) f = false;
		if(f){
			p.push_back(x);
			if(x % 5 == 1){
				++t;
				q.push_back(x);
			}
		}
		++x;
	}
	for(int i=0; i<n; ++i)
		cout << q[i] << (i != n-1 ? " " : "\n");
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, M: int):
    def fact(n):
        ret = 1
        for i in range(2, n + 1):
            ret *= i
            ret %= MOD
        return ret
    if abs(N - M) > 1:
        ret = 0
    else:
        ret = fact(N) * fact(M)
        if N == M:
            ret *= 2
    print(ret % MOD)
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;

typedef struct {
  int parent, left, right;
} node;

const int MAX_N = 26;
int N;
node nodes[MAX_N];

int getSibling(int id) {
  if (nodes[id].parent == -1) return -1;

  if (nodes[nodes[id].parent].left == id && nodes[nodes[id].parent].right != -1)
    return nodes[nodes[id].parent].right;

  if (nodes[nodes[id].parent].left != -1 && nodes[nodes[id].parent].right == id)
    return nodes[nodes[id].parent].left;

  return -1;
}

int getDegree(int id) {
  int c = 0;

  if (nodes[id].left != -1)
    c++;

  if (nodes[id].right != -1)
    c++;

  return c;
}

int getDepth(int id) {
  int d = 0;
  while (nodes[id].parent != -1) {
    id = nodes[id].parent;
    d++;
  }
  return d;
}

int getHeight(int id, int height) {
  if (id == -1) return height-1;
  return max(getHeight(nodes[id].left, height+1),
             getHeight(nodes[id].right, height+1));
}

string getType(int id) {
  if (nodes[id].parent == -1)
    return "root";

  if (nodes[id].left != -1 || nodes[id].right != -1)
    return "internal node";

  return "leaf";
}

void solve() {
  for (int i = 0; i < N; i++) {
    cout << "node " << i
         << ": parent = " << nodes[i].parent
         << ", sibling = " << getSibling(i)
         << ", degree = " << getDegree(i)
         << ", depth = " << getDepth(i)
         << ", height = " << getHeight(i, 0)
         << ", " << getType(i)
         << endl;
  }
}

int main() {
  for (int i = 0; i < MAX_N; i++) {
    node n;
    n.parent = n.left = n.right = -1;
    nodes[i] = n;
  }

  cin >> N;

  for (int i = 0; i < N; i++) {
    int id, l, r;
    cin >> id >> l >> r;
    nodes[id].left = l;
    nodes[id].right = r;
    nodes[l].parent = nodes[r].parent = id;
  }

  solve();

  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int N = scan.nextInt();
	int A = scan.nextInt();

	N %= 500;

	if(N <= A){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


Measured memory_bytes: 20560
#import 
s=input()
t=input()
#=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

cnt = 0
for i in range(len(s)):
    if s[i] != t[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 9204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        ss: [chars; n]
    }
    let mut ans = 0;
    let mut na = 0;
    let mut nb = 0;
    let mut all_ab = true;
    for s in ss.iter() {
        let mut a = false;
        let fb= s[0] == 'B';
        let fa = s[s.len() - 1] == 'A';
        if fa && fb {
            na += 1;
            nb += 1;
        } else if fa || fb {
            all_ab = false;
            if fa {
                na += 1;
            } else {
                nb += 1;
            }
        }
        for &c in s.iter() {
            if c == 'A' {
                a = true;
            } else if c == 'B' && a {
                ans += 1;
                a = false;
            } else {
                a = false;
            }
        }
    }
    if na > 0 && all_ab {
        ans += na - 1;
    } else {
        ans += std::cmp::min(na, nb);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
H,W = map(int, input().split())
A = [input() for h in range(H)]
A = [list(a) for a in A if '#' in a]
w = 0
while w < W:
    for a in A:
        if a[w]=='#':
            break
    else:
        for a in A:
            a.pop(w)
        W -= 1
        w -= 1
    w += 1
for a in A:
    print(''.join(a))

Measured memory_bytes: 3064
/***
 *      __  __            _    _       _
 *     |  \/  |          | |  | |     | |
 *     | \  / |_ __      | |  | |_ __ | | ___ __   _____      ___ __
 *     | |\/| | '__|     | |  | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \
 *     | |  | | |     _  | |__| | | | |   <| | | | (_) \ V  V /| | | |
 *     |_|  |_|_|    (_)  \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_|
 *
 *
***/
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
/*---------------for_stuff-------------------*/
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
/*---------------pair_stuff------------------*/
#define MP make_pair
#define ii pair<int,int>
#define iii pair<int,ii>
#define fi first
#define se second
/*--------------vector_stuff-----------------*/
#define pb push_back
#define ppb pop_back
/*--------------modulo_stuff-----------------*/
const ll mod=1000000007;
/*--------------map_stuff--------------------*/
// why do you think I should write something in this part? :v

ll a,b,c,q;
int main() {
//    freopen(".inp","r",stdin);
//    freopen(".out","w",stdout);
	scanf("%lld", &q);
	while(q--) {
		scanf("%lld %lld", &a, &b);
		c=sqrt(a*b);
		if (a==b) printf("%lld\n", c*2-2);
		else printf("%lld\n", c*2-(c>=a)-(c>=b)-(c*(c+1)>=a*b)-(c*c==a*b));
	}
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString as BS
import qualified Data.Map.Strict as Map
import Control.Applicative

main :: IO ()
main = do
  n <- readLn
  loop n Map.empty

splitSpace :: BS.ByteString -> [BS.ByteString]
splitSpace = BS.split 32

loop 0 _   = return ()
loop n dic = do
  [c, s] <- splitSpace <$> BS.getLine
  case c of
    "insert" -> loop (n - 1) (Map.insert s n dic)
    "find" -> do
      putStrLn (if Map.member s dic then "yes" else "no")
      loop (n - 1) dic



Measured memory_bytes: 215300
#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int arr[x];
	int z;
	for (int i = 1 ; i <= x ; i++)
	{
		cin >> z;
		arr[z - 1] = i;
	}
	for (int i = 0 ; i < x ; i++)
	{
		cout << arr[i] << " ";
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    const int dx = tx - sx, dy = ty - sy;

    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << 'D' << string(dx + 1, 'R') << string(dy + 1, 'U') << 'L';
    cout << 'U' << string(dx + 1, 'L') << string(dy + 1, 'D') << 'R';

    return 0;
}


Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl cnt(2019,0);

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    int ex = 1;
    int num = 0;
    for(int i = S.size()-1; i >= 0; i--) {
            num = (num + ex * (S[i] - '0')) % 2019;
            ex = (ex * 10) % 2019;

            cnt[num]++;
    }
    for(auto x:cnt) ans += x*(x-1)/2;
    ans += cnt[0];
    cout << ans << endl;
}

Measured memory_bytes: 3696
import math
a ,b= map(int,input().split())
ans ,x , y ,c = 0 ,int(math.sqrt(a * a)) ,int(math.sqrt(b * b)),0
if x == 0:
    if b < a:
         c += 1 
elif y == 0:
    c += 1
    if a < b:
        c -= 1
if (a < 0 and b < 0) and (a > b):
    ans = abs(x - y)
    c += 2
elif (a < 0 and b > 0) or (a > 0 and b < 0):
    ans = abs(x - y)
    c += 1
else:
    ans = abs(x - y)
    if a > b and a > 0 and b > 0:
        c += 2
print(ans + c)

Measured memory_bytes: 3064
a, b, c = input().split()
misort = [a, b, c]
for i in range(3):
    for j in range(i + 1, 3):
        if misort[i] > misort[j]:
            tmp = misort[j]
            misort[j] = misort[i]
            misort[i] = tmp
            
a, b, c = misort
print(a, b, c)


Measured memory_bytes: 5564
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int s;
  cin >> s;
  int s1=s/100, s2=s%100;
  if(s1<13 && s1>0)
  {
    if(s2<13&&s2>0)
      cout<<"AMBIGUOUS"<<endl;
    else
      cout<<"MMYY"<<endl;
  }
  else
  {
     if(s2<13&&s2>0)
       cout<<"YYMM"<<endl;
    else
      cout<<"NA"<<endl;
  }
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL D[100];
LL A[100][100];

LL ans = 0;

void solve(){
	vector<LL> sunuke(N+1,0);
	for(int i=0;i<K;i++){
		for(int j=0;j<D[i];j++){
			sunuke[A[i][j]]++;
		}
	}
	for(int i=1;i<=N;i++){
		ans += (sunuke[i]==0);
	}
}
 
int main(){
    cin >> N >> K;
    for(int i=0;i<K;i++){
    	cin >> D[i];
    	for(int j=0;j<D[i];j++) cin >> A[i][j];
    }

    solve();

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

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
int main() {
string str, t;
cin >> str >> t;
int ans = 0;
if(str[0] == t[0]) 
  ans++;
if(str[1] == t[1]) 
  ans++;
if(str[2] == t[2]) 
  ans++;
cout << ans ;
return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include<vector>  
#include<algorithm>  
#include<string>
using namespace std;
int main()
{
	string a, b; 
	cin >> a >> b; 
	if (a.size()>b.size())
	{
		cout << "GREATER" << endl; 

	} 
	else if (a.size() < b.size())
	{
		cout << "LESS" << endl;
	} 
	else
	{
		for (int i = 0; i < a.size(); i++)
		{
			if (a.at(i)!=b.at(i))
			{
				if (a.at(i)>b.at(i))
				{
					cout << "GREATER" << endl; 
					break;
				} 
				else if (a.at(i)<b.at(i))
				{
					cout << "LESS" << endl; 
					break;
				}
			} 
			if (i==a.size()-1)
			{
				cout << "EQUAL" << endl;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
    String str = String.valueOf(a);
    int[] manieth = new int[3];
    int answer = 0;

    for (int i = 0; i < str.length(); i++) {
      String num = String.valueOf(str.charAt(i));
      manieth[i] = Integer.parseInt(num);
    }
    if (manieth[0] < manieth[1] || manieth[0] == manieth[1] && manieth[1] < manieth[2]) {
      answer = manieth[0] + 1;
    } else {
      answer = manieth[0];
    }
    System.out.print(answer);
    System.out.print(answer);
    System.out.print(answer);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;


const int N = 2e5 + 5;

int n;
char s[N];
Zi pw2[N], F[1000];

Zi solve(int d) {
	Zi rt = 0;
	int hd = d >> 1;
	for (int i = 0; i < hd; i++) {
		if (s[i] == '1') {
			rt += pw2[hd - i - 1];
		}
	}
	int dt = 1;
	for (int i = 0; i < n && dt; i++) {
		int r = i % d;
		char x = '0';
		if (r >= hd) {
			x = s[r - hd] ^ 1;
		} else {
			x = s[r];
		}
		if (x > s[i]) {
			dt = 0;
		} else if (x < s[i]) {
			break;
		}
	}
	return rt += dt;
}

int pos = 0;
vector<int> D;

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	pw2[0] = 1;
	for (int i = 1; i <= n; i++)
		pw2[i] = pw2[i - 1] + pw2[i - 1];
	for (int i = 1; i <= n; i++) {
		if (!((n << 1) % i) && (n % i)) {
			F[pos++] = solve(i);
			D.push_back(i);
		}
	}
	int n2 = n << 1;
	F[pos++] = solve(n2);
	D.push_back(n2);
	for (int i = 0; i < (signed) D.size(); i++) {
		for (int j = i + 1; j < (signed) D.size(); j++) {
			if (!(D[j] % D[i])) {
				F[j] -= F[i];
			}
		}
	}
	Zi ans = 0;
	for (int i = 0; i < (signed) D.size(); i++)
		ans += F[i] * D[i];
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
  int i;
  int n, m, k;
  int ans;

  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);

  ans = 0;
  for (i = 0; i <= n; i++) {
    if (((k - m*i > 0) && (n - i * 2 > 0) && ((k - m*i) % (n - i * 2) == 0) && ((k - m*i) / (n - i * 2) <= m)) ||
      ((k - m*i < 0) && (n - i * 2 < 0) && ((-k + m*i) % (-n + i * 2) == 0) && ((-k + m*i) / (-n + i * 2) <= m))) {
      ans = 1;
      break;
    }
  }

  printf(ans ? "Yes\n" : "No\n");

  return(0);
}

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

/*
struct Edge
{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, X, M;
    cin >> N >> X >> M;
    vector<int> occur(M, -1);
    ll A = X;
    occur[A] = 0;
    int start_loop = 0;
    int second = 0;
    int loop_size = 0;
    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        A = (A * A) % M;
        cnt++;
        if (occur[A] != -1)
        {
            loop_size = cnt - occur[A];
            second = cnt;
            start_loop = occur[A];
            break;
        }
        else
        {
            occur[A] = cnt;
        }
    }

    A = X;
    for (int i = 0; i < start_loop; i++)
    {
        A = (A * A) % M;
    }

    vector<ll> loop_sum(loop_size + 1);
    for (int i = start_loop; i < second; i++)
    {
        loop_sum[i - start_loop + 1] = loop_sum[i - start_loop] + A;
        A = (A * A) % M;
    }

    // cerr << loop_sum.size() << endl;

    if (second >= N)
    {
        A = X;
        ll ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += A;
            A = (A * A) % M;
        }
        cout << ans << endl;
    }
    else
    {
        A = X;
        ll ans = 0;
        for (int i = 0; i < start_loop; i++)
        {
            ans += A;
            A = (A * A) % M;
        }
        ans += (N - start_loop) / loop_size * loop_sum[loop_size];
        cerr << ans << endl;
        ll rem = (N - start_loop) % loop_size;
        ans += loop_sum[rem];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3948
s=input()
t=input()

l1,l2 = len(s),len(t)

dp = [[0]*(l2+1) for _ in range(l1+1)]
memo = [['']*(l2+1) for _ in range(l1+1)]

for i in range(1,l1+1):
  for j in range(1,l2+1):
    if s[i-1]==t[j-1]:
      dp[i][j] = dp[i-1][j-1] + 1
      memo[i][j] = s[i-1]
    else:
      if dp[i-1][j] >= dp[i][j-1]:
        dp[i][j] = dp[i-1][j]
        memo[i][j] = (i-1,j)
      else:
        dp[i][j] = dp[i][j-1]
        memo[i][j] = (i,j-1)
      
i,j = l1,l2
ans = []
while i > 0 and j > 0:
  if len(memo[i][j]) == 2:
    i, j = memo[i][j]
  else:
    ans.append(memo[i][j])
    i, j = i-1, j-1
    
print(''.join(ans[::-1]))

Measured memory_bytes: 617592
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

unsigned nCk_factorial_formula( unsigned n, unsigned k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main(){
    int n, p;cin>>n>>p;
    vector<int> sequence(n);for(int i=0;i<n;i++){cin>>sequence[i];}

    vector<int> even;
    vector<int> odd;
    for (auto i : sequence){
        if (i % 2 == 0){
            even.push_back(i);
        } else {
            odd.push_back(i);
        }
    }
    long long even_side = pow(2, even.size());
    long long odd_side = 0;
    if (p == 0){
        for (int i=0;i<=odd.size();i++){
            if (i % 2 == 0){
                odd_side += nCk_factorial_formula(odd.size(), i);
            }
        }
    } else {
        for (int i=0;i<=odd.size();i++){
            if (i % 2 == 1){
                odd_side += nCk_factorial_formula(odd.size(), i);
            }
        }
    }

    cout << even_side * odd_side <<endl;
    return 0;


}

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

#define M 1000001//task
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }//task
int h2(int key){ return 1+key%(M-1); }//task

int find(char str[]){//task
  int i=0,j;
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[j][0]!=NULL){
      if(strcmp(H[j],str)==0){
	return 1;
	break;
      }
      else i++;
    }
    else{
      return 0;
      break;
    }
  }
}

int insert(char str[]){//task
  int i=0,j;
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[j][0]==NULL){
      strcpy(H[j],str);
      break;
    }
    else i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <iostream>

int main(int argc, char const *argv[])
{
  int A[100];
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &A[i]);
  }

  double sum = 0.0;
  for (size_t i = 0; i < n; i++)
  {
    sum += 1.0 / A[i];
  }

  printf("%lf", 1.0 / sum);

  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <climits>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  int nA = getInt();
  int nB = getInt();
  int W  = getInt();

  vector<pair<int, int> > cmA(nA);
  vector<pair<int, int> > cmB(nB);

  vector<int> cs; cs.reserve(nA + nB);

  REP(i,nA){
    cmA[i].second = getInt();
    cmA[i].first  = getInt();
  }
  REP(i,nB){
    cmB[i].second = getInt();
    cmB[i].first  = getInt();
  }
  sort(cmA.begin(), cmA.end());
  sort(cmB.begin(), cmB.end());

  REP(i,nA) cs.push_back(cmA[i].first);
  REP(i,nB) cs.push_back(cmB[i].first);

  sort(cs.begin(), cs.end());
  cs.erase(unique(cs.begin(), cs.end()), cs.end());

  int ans = INT_MAX;

  for(int i = 0; i < cs.size(); i++){
    set<int> candA; candA.insert(0);
    set<int> candB; candB.insert(0);
    vector<int> candAA; candAA.reserve(W + 1); candAA.push_back(0);
    vector<int> candBB; candBB.reserve(W + 1); candBB.push_back(0);
    vector<bool> flagA(W + 1);
    vector<bool> flagB(W + 1);

    int ptrA = 0;
    int ptrB = 0;

    for(int j = i; j < cs.size(); j++){
      int c1 = cs[i];
      int c2 = cs[j];

      if(c2 - c1 >= ans) break;

      {
        int cai = candAA.size();
        while(ptrA != nA && cmA[ptrA].first < c2) ptrA++;
        while(ptrA != nA && cmA[ptrA].first == c2){
          int cnt = 0;
          for(int i = 0; i < cai; ++i){
            int ww = cmA[ptrA].second + candAA[i];
            if(ww <= W && !flagA[ww]){
              flagA[ww] = true;
              candAA.push_back(ww);
              candA.insert(ww);
              cnt++;
            }
          }
          ptrA++;
          cai += cnt;
        }
      }

      {
        int cbi = candBB.size();
        while(ptrB != nB && cmB[ptrB].first < c2) ptrB++;
        while(ptrB != nB && cmB[ptrB].first == c2){
          int cnt = 0;
          for(int i = 0; i < cbi; i++){
            int ww = cmB[ptrB].second + candBB[i];
            if(ww <= W && !flagB[ww]){
              flagB[ww] = true;
              candBB.push_back(ww);
              candB.insert(ww);
              cnt++;
            }
          }
          ptrB++;
          cbi += cnt;
        }
      }

      int diff = INT_MAX;

      if(candAA.size() != 1 && candBB.size() != 1){
        FOR(itA, candA) if(*itA != 0){
          set<int>::iterator itB = lower_bound(candB.begin(), candB.end(), *itA);
          if(itB != candB.end() && *itB != 0)
            diff = min(diff, abs(*itA - *itB));
          if(itB != candB.begin()) --itB;
          if(*itB != 0) diff = min(diff, abs(*itA - *itB));
        }
      }

      // if(c2 - c1 <= 1 && diff != INT_MAX) printf("%d %d\n", c2 - c1, diff);
      ans = min(ans, max(diff, c2 - c1));
    }
  }

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

  return 0;
}

Measured memory_bytes: 1160
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll> A(n);
    cin>>A;
    for(int i=1;i<n;i++){A[i]+=A[i-1];}
    ll ans=1;
    for(auto &I:A){if(I<=x){ans++;}}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,j,n) for(int i=j ; i < (int) (n) ; ++i )
#define rep(i,n) for(int i=0 ; i < (int) (n) ; ++i )

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

    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    if (n==1)
    {
        cout << 1 << endl;
    }
    else
    {
        int updown = 0;
        int cnt = 1;
        rep(i,n-1)
        {
            if (updown==0)
            {
                updown = ary[i+1]-ary[i];
                if (updown==0) continue;
                updown /= abs(updown);
            }
            else if ((ary[i+1]-ary[i])/updown<0)
            {
                // cout << i << " " << updown << endl;
                cnt++;
                updown = 0;
            }
            else
            {
                // pass
            }
            
        }
        cout << cnt << endl;
    }
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define benfero freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mm ' '
#define nl '\n'
#define MOD 1000007
typedef unsigned long long int ull;
typedef long long int ll;
int main()
{
    //benfero
    int n;
    cin>>n;
    int i, e;
    int ar[n][3];
    for(i=0;i<n;i++){
        for(e=0;e<3;e++){
            cin>>ar[i][e];
        }
    }

    int dp[n][3]={0};   
    for(i=0;i<3;i++){
        dp[0][i]=ar[0][i];
    }

    for(i=1;i<n;i++){
        dp[i][0]=ar[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=ar[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=ar[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;

    
    return 0;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;
	cin>>n;
	vector<tuple<int,int>> a(n);
	rep(i,n){
		int& num=get<0>(a.at(i));
		cin>>num;
		get<1>(a.at(i))=i+1;
	}
	sort(all(a));
	rep(i,n){
		int ans=get<1>(a.at(i));
		cout<<ans<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int a,b,i,j;
  cin >> a >> b;
  a--;
  b--;
  cout << "42 100" << endl;
  for(j=0;j<100;j++)
    cout << ".";
  cout << endl;
  for(i=0;i<10;i++){
    for(j=0;j<50;j++){
      cout << ".";
      if(b>0){
        cout << "#";
        b--;
      }else{
        cout << ".";
      }
    }
    cout << endl;
    for(j=0;j<100;j++)
      cout << ".";
    cout << endl;
  }
  for(j=0;j<100;j++)
    cout << "#";
  cout << endl;
  for(i=0;i<10;i++){
    for(j=0;j<50;j++){
      cout << "#";
      if(a>0){
        cout << ".";
        a--;
      }else{
        cout << "#";
      }
    }
    cout << endl;
    for(j=0;j<100;j++)
      cout << "#";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,k;
int a[200005],b[200005][45],c[45],ans[200005][45];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	int now=n-1;
	for (int i=1;i<=n;i++)
	{
		if (now%2==1)  k=k^a[i];
	}
	int pos=41;
	while (k!=0)
	{
		pos--;
		c[pos]=k%2;
		k/=2;
	}
	for (int i=1;i<=n;i++)
	{
		int pos=41;
		while (a[i]!=0)
		{
			pos--;
			b[i][pos]=a[i]%2;
			a[i]/=2;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=40;j++)
		{
			if (c[j]==1)  ans[i][j]=(b[i][j]+1)%2;
			else ans[i][j]=b[i][j];
		}
	}
	for (int i=1;i<=n;i++)
	{
		int tot=0,now=1;
		for (int j=40;j>=1;j--)
		{
			tot+=ans[i][j]*now;
			now*=2;
		}
		cout<<tot<<' ';
	}
	cout<<endl; 
	
	return 0;
}

Measured memory_bytes: 145816
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,aa[100000],b=1,cnt=0;
signed main(){
	cin>>a;
	rep(i,a){
		cin>>aa[i];
	}
	while(1){
		b=aa[b-1];
		cnt++;
		if(b==2){
			cout<<cnt;
			return 0;
		}
		if(cnt>=a){
			cout<<-1;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	cin >> n;
	string s;
	cin >> s;

	map<pair<string, string>, int> mp;
	rep(i, 1<<n) {
		string r, b;
		rep(j,n) {
			if (i >> j & 1)r += s[n + j];
			else b += s[n + j];
		}
		reverse(all(r));
		reverse(all(b));
		++mp[make_pair(move(r), move(b))];
	}
	long long ans = 0;
	rep(i, 1 << n) {
		string r, b;
		rep(j, n) {
			if (i >> j & 1)r += s[j];
			else b += s[j];
		}
		auto it = mp.find(make_pair(move(r), move(b)));
		if (it != mp.end())ans += it->second;
	}



	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 46080
S = input()
n = len(S)+1
A = [-1] * n
if (S[0] == '<'): A[0] = 0
if (S[-1] == '>'): A[-1] = 0
for i in range(n-2):
    if S[i] + S[i+1] == '><':
        A[i+1] = 0
for i in range(n-1):
    if (A[i] == -1): continue
    if S[i] == '<':
        A[i+1] = A[i] +1
for i in range(n-1, 0, -1):
    if S[i-1] == '>':
        A[i-1] = max(A[i-1],A[i] + 1)
print(sum(A))


Measured memory_bytes: 47084
N = int(input())
hen = []

hen = list(int(x) for x in input().split())
hen.sort()
#print(hen)
#hen_u = set(hen)
#print(hen_u)
tri = 0

for a in hen:
    for b in hen:
        if(a == b)or (a > b):
            continue
        for c in hen:
            if(a == c)or(b == c) or (a > c) or (b > c):
                continue
            if(a+b >c)and(b+c >a)and(c+a >b):
                tri += 1

print(tri)

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

int main(){
  int n, cmd, d, p, x;
  deque<int> dq;
  cin >> n;
  while (n--){
    cin >> cmd;
    if (0 == cmd) {
        cin >> d >> x;
        if (d) {
            dq.push_back(x);
        } else {
            dq.push_front(x);
        }
    }
    else if (1 == cmd) {
        cin >> p;
        cout << dq[p] << endl;
    }
    else if (2 == cmd) {
        cin >> d;
        if (d) {
            dq.pop_back();
        } else {
            dq.pop_front();
        }
    }
  }
}



Measured memory_bytes: 4528
n,m=map(int,input().split())

#Union-Find木
#par[i]:iの親　deep[i]:iの深さ　size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n

#親を見つける
def find(x):
  if par[x]==x:
    return x
  else:
    return find(par[x])

#二つのグループを統合する
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return
  if deep[x]<deep[y]:
    par[x]=y
    size[y]+=size[x]
  else:
    par[y]=x
    size[x]+=size[y]
    if deep[x]==deep[y]:
      deep[x]+=1

#xとyが同じグループに属するかどうか
def same(x,y):
  return find(x)==find(y)

#xが属するグループの要素数を返す
def group_count(x):
  return size[find(x)]
  
for i in range(m):
  a,b=map(int,input().split())
  unite(a-1,b-1)
  
from collections import Counter
x=[]
for i in par:
  x.append(find(i))
x=Counter(x)
print(len(x)-1)

  

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

using P = Point<long double>;
long double segDist(P& s, P& e, P& p) {
	if (s==e) return (p-s).dist();
	auto d = (e-s).dist2(), t = min(d,max(.0l,(p-s).dot(e-s)));
	return ((p-s)*d-(e-s)*t).dist()/d;
}
template<class P>
bool segmentIntersectionQ(P s1, P e1, P s2, P e2) {
	if (e1 == s1) {
		if (e2 == s2) return e1 == e2;
		swap(s1,s2); swap(e1,e2);
	}
	P v1 = e1-s1, v2 = e2-s2, d = s2-s1;
	auto a = v1.cross(v2), a1 = d.cross(v1), a2 = d.cross(v2);
	if (a == 0) { // parallel
		auto b1 = s1.dot(v1), c1 = e1.dot(v1),
		     b2 = s2.dot(v1), c2 = e2.dot(v1);
		return !a1 && max(b1,min(b2,c2)) <= min(c1,max(b2,c2));
	}
	if (a < 0) { a = -a; a1 = -a1; a2 = -a2; }
	return (0 <= a1 && a1 <= a && 0 <= a2 && a2 <= a);
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		P p0, p1;
		cin >> p0.x >> p0.y >> p1.x >> p1.y;
		P p2, p3;
		cin >> p2.x >> p2.y >> p3.x >> p3.y;
		if(segmentIntersectionQ(p0,p1,p2,p3)){
			cout << 0.0 << '\n';
		} else {
			long double ans0 = min(segDist(p0, p1, p2), segDist(p0, p1, p3));
			long double ans1 = min(segDist(p2, p3, p0), segDist(p2, p3, p1));
			cout << min(ans0, ans1) << '\n';
		}
	}
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    ll n,k;cin>>n>>k;
    ll ans=0;
    ans+=(n/k)*(n/k)*(n/k);
    if(k%2==0){
        int tmp=(n/k)*k;
        if(tmp+k/2<=n)ans+=(n/k+1)*(n/k+1)*(n/k+1);
        else ans+=(n/k)*(n/k)*(n/k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))
H,W = inpl()
MAP = [inpl() for i in range(H)]
flag = False #コインを持っているか
ans = []
for y in range(H):
    if y%2 == 0:
        xx = range(W)
    else:
        xx = reversed(range(W))
    for x in xx:
        if flag:
            ans.append([by,bx,y,x])
        if MAP[y][x]%2 == 1:
            flag = not flag
        bx,by = x,y
print(len(ans))
for a,zu,nya,n in ans:
    print(a+1,zu+1,nya+1,n+1)

Measured memory_bytes: 26232
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
long long a[55];long long ans;long long up[55],down[55],ups,downs;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	long long n;cin>>n;
	for(long long i=0;i<n;i++) cin>>a[i];sort(a,a+n);reverse(a,a+n);int dim=500;
	while(dim--)
	{
	for(int i=0;i<n;i++)
	{
		if(a[i]>=n) 
		{
			ans+=a[i]/n;for(int j=0;j<n;j++) if(i!=j) a[j]+=a[i]/n;
			a[i]=a[i]-a[i]/n*n;
	}
	}
}
	while(1)
	{
		downs=ups=0;
		for(long long i=0;i<n;i++)
		{
			if(a[i]>=n) up[ups++]=i;
			else down[downs++]=i;
		}if(ups==0) break;
		long long mi=1e16+2000;
		for(long long i=0;i<ups;i++)
		{
			long long j=up[i];
			mi=min(mi,a[j]);
		}
		int knife=n-ups+1;
		mi=mi/knife;ans+=mi*ups;//cout<<ans;
		for(long long i=0;i<ups;i++)
		{
			long long j=up[i];
			a[j]-=mi*knife;
		}
		for(long long i=0;i<downs;i++)
		{
			long long j=down[i];
			a[j]+=mi*ups;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

struct edge{
	int to;
	long long cost;
};

int N;
vector<vector<edge>> graph(100010);
vector<int> color(100010,-1);
queue<int> que;

void BFS(){
	while(que.empty()==0){
		int f=que.front();
		que.pop();
		for(auto e:graph[f]){
			if(color[e.to]==-1){
				color[e.to]=(color[f]+e.cost)%2;
				que.push(e.to);
			}
		}
	}
}

int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int u,v,w;
		cin >> u >> v >> w;
		u--;
		v--;
		edge e;
		e.to=v;
		e.cost=w;
		graph[u].push_back(e);
		e.to=u;
		graph[v].push_back(e);
	}
	
	color[0]=0;
	que.push(0);
	BFS();
	for(int i=0;i<N;i++)cout << color[i] << endl;
	
	return 0;
}

Measured memory_bytes: 8320