akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag) {
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;
}

void ansYES(bool flag) {
    if (flag) cout << "YES" << endl; else cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

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

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

struct datas {
    Int max;
    Int size;
};

class ContainChecker {
protected:
    Int minx, miny, maxx, maxy;
public:
    ContainChecker(Int minx, Int miny, Int maxx, Int maxy) : minx(minx), miny(miny), maxx(maxx), maxy(maxy) {};

    bool in(Int x, Int y) {
        return (minx <= x && miny <= y && x <= maxx && y <= maxy);
    }
};

int main(void) {
    string s;
    cin >> s;
    string p;
    for (auto z: s) {
        if (z == 'B') {
            if ( !p.empty()) p.pop_back();
        }else{
            p.push_back(z);
        }
    }
    cout << p << endl;

}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,N;
	while(scanf("%d",&N)!=EOF)
	{
		a=N%10;
		b=(N-N%100)/100;
		if(N>=100&&N<=999)
		{
			if(a<b||a>b)
			{
				printf("No\n");
			}
			else
				printf("Yes\n");
		}
	}
}

Measured memory_bytes: 128
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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [(usize1, usize1); n - 1]
    }
    let mut t = vec![vec![]; n];
    for &(a, b) in &v {
        t[a].push(b);
        t[b].push(a);
    }
    println!("{}", if dfs(0, 0, &t) == 0 {"Bob"} else {"Alice"});
}

fn dfs(v: usize, p: usize, t: &Vec<Vec<usize>>) -> usize {
    let mut g = 0;
    for &c in &t[v] {
        if c == p {
            continue;
        }
        g ^= dfs(c, v, t) + 1;
    }
    g
}


Measured memory_bytes: 18684
#include<cstdio>
#include<algorithm>
#define int long long int
using namespace std;

int a[200000], b[200000];
 main(void) {
    int n,h;
    scanf("%lld%lld",&n,&h);
    for(int i=0; i<n; i++)
        scanf("%lld%lld",&a[i],&b[i]);
    int m = 0;
    for(int i=0; i<n; i++)
        if(m < a[i]) m = a[i];
    sort(b, b+n);

    int res = (h+m-1)/m;
    int t = 0;
    for(int i=0; i<n; i++) {
        t += b[n-1-i];
        int k = (h>t ? (h-t+m-1)/m : 0)+ (i+1);
        if(0<k && k < res) res = k;
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB pop_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
#define vi vector<long long>

using namespace std;
typedef long long ll;
const ll mod=1e9;
const ll inf = 1e18+7;
const int maxn = 2e5+7;
//int k;
ll n,m,k,t,q,u,w,y,r;
int ret=0;
int a[100],b[100],c[100],d[100],v[100];

void dfs(int i,int x){
    v[i]=x;
    if(i==n){
        int ans=0;
        for(int j=0;j<q;j++)
            if(v[b[j]]-v[a[j]]==c[j]) ans+=d[j];
        ret=max(ret,ans);
        return;
    }
    for(int j=x;j<=m;j++)
        dfs(i+1,j);
}
int main(){
    FIO
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
    for(int i=1;i<=m;i++)
        dfs(1,i);
    cout<<ret<<endl;
    return 0;
}
/**
5
6
7
1 2 2 4
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
**/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ans=1;
  for(int i=1;;i++)
  {
    if(ans*2>=n)
    {
      if(ans*2==n)cout<<ans*2<<endl;
      else cout<<ans<<endl;
      break;
    }
    ans*=2;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi p(n); rep(i,n) cin >> p[i];
	int ans = 0;
	rep(i,n-1){
		if(p[i]==i+1){
			int tmp = p[i];
			p[i] = p[i+1];
			p[i+1] = tmp;
			ans++;
		}
	}
	if(p[n-1]==n) ans++;
	cout << ans << endl;
}


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

int main(){
  int m,z,p,k;
  cin >> p >> z >> m >> k;
  int ans=0;
  ans=min(p,k);
  ans-=max(0,k-p-z);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3532
N,M,X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

arr = [ 0 for i in range(N) ]
for p in A:
    arr[p] = 1

x2r = sum(arr[X:N])
x2l = sum(arr[0:X])

print(min([x2r, x2l]))


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

int main(void)
{
  int n, i, j, fa, fb, carry, ans[100];
  char a[101], b[101];

  scanf("%d", &n);

  while(n--){
    scanf("%s", a);
    scanf("%s", b);
    if(strlen(a) > 80 || strlen(b) > 80){
      printf("overflow\n");
      continue;
    }
    fa = strlen(a);
    fb = strlen(b);
    j = carry = 0;

    while(fa || fb){
      ans[j] = carry;
      if(fa) ans[j] += a[--fa] - '0';
      if(fb) ans[j] += b[--fb] - '0';
      carry = ans[j] / 10;
      ans[j] %= 10;
      j++;
    }
  if(carry) ans[j] = 1;
  else j--;
    if(j >= 80){
      printf("overflow\n");
      continue;
    }

    for(; j >= 0; j--)
      printf("%d", ans[j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 612
n = gets.to_i
takahashi = 1
aoki = 1

n.times do
  t, a = gets.split.map(&:to_i)
  i = [takahashi.to_r / t, aoki.to_r / a].max.ceil
  takahashi = t * i
  aoki = a * i
end

puts takahashi + aoki

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q,tmp;
ll gcd(ll x,ll y)
{
  if(y==0) return x;
  else return gcd(y,x%y);
}
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      ll p[1000001]={0};
      for(int i=2;i<=1e6;i++){
        if(p[i]!=0)continue;
        p[i]=i;
        for(int j=i+i;j<=1e6;j+=i){
          p[j]=i;
        }
      }
      cin>>n;
      ll a[n],ans=0;
      map<ll,ll>ma;
      for(int i=0;i<n;i++){
        cin>>a[i];
        ans=gcd(ans,a[i]);
        tmp=a[i];
        while(tmp!=1){
          ma[p[tmp]]++;
          tmp/=p[tmp];
        }
      }
      ll f=0;
      for(int i=0;i<n;i++){
        map<ll,ll>ma2;
        vector<ll>v;
        tmp=a[i];
        while(tmp!=1){
          ma2[p[tmp]]++;
          tmp/=p[tmp];
        }
        for(auto j:ma2){
          if(j.second!=ma[j.first]){
            f=1;
            break;
          }
        }
        if(f==1)break;
      }
      if(f==0) cout<<"pairwise coprime";
      else if(ans==1) cout<<"setwise coprime";
      else cout<<"not coprime";
}

Measured memory_bytes: 24008
#include <stdio.h>
#include <math.h>

int main(void){
	int i,j,n,x,ans;
	double xa,ya,ra,xb,yb,rb,dist;

	scanf("%d",&n);
	for(1;n>0;n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		dist=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if(dist<fabs(ra-rb))printf("%d\n",ra-rb>0 ? 2 : -2);
		else if(dist<=ra+rb)printf("1\n");
		else printf("0\n");

	}

	return 0;
}

Measured memory_bytes: 648
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
	int K, X;

	cin >> K >> X;

	for (int i = max(-1000000, X - K + 1); i <= min(1000000, X + K - 1); i++) cout << i << " ";
	cout << endl;

	return 0;
}


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

#define _GLIBCXX_DEBUG

int main() {
  int n, ai, t = 0;
  int count = 0;
  vector<int> a(100000);
  
  cin >> n;
  
  for(int i = 0; i < n; i++) {
    cin >> ai;
    ai--;
    a[i] = ai;
  }

  while(1) {
    if(t == 1) {
      cout << count << endl;
      break;
    }
    if(count >= n) {
      cout << -1 << endl;
      break;
    }
    count++;
    t = a[t];
  }  
  
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll a[200005],b[200005];
ll t;
ll ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i+1]=b[i]+a[i];
    }
    sort(b,b+n+1);
    for(int i=1;i<=n;i++){
        if(b[i]!=b[i-1]){
            ans+=(i-t)*(i-t-1)/2;
            t=i;
        }
    }
    ans+=(n+1-t)*(n-t)/2;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <unordered_map>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

int main(void) {
	// cout << calc2x(pow(10, 18)) << endl;


	ll n, k;
	cin >> n >> k;
	vector<ll> values(n,0);
	for (int i = 0; i < n; ++i) {
		cin >> values[i];
		values[i] -= 1;
	}

	vector<vector<ll>> nexts(61);
	nexts[0].resize(n);
	for (int i = 0; i < n; ++i) {
		nexts[0][i]=values[i];
	}
	for (int i = 1; i < nexts.size(); ++i) {
		nexts[i].resize(n);
		for (int j = 0; j < n; ++j) {
			nexts[i][j] = nexts[i-1][nexts[i-1][j]];
		}
	}

	ll x = 0;
	ll pos = 0;
	for (ll i = nexts.size()-1; i >=0 ; --i) {
		if (k &(1LL << i)) {
			pos = nexts[i][pos];
		}
	}

	auto output = pos +1;
	cout << output;

	return 0;
}


Measured memory_bytes: 100144
import java.util.Scanner;

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

        while(true){
            int numa = sc.nextInt();
            int numb = sc.nextInt();
            if(numa == 0 && numb == 0){
                break;
            }

            if(numa > numb){
                System.out.println(numb + " " + numa);
            }
            else{
                System.out.println(numa + " " + numb);
            }
        }
    }
}


Measured memory_bytes: 35852
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  l.sort()
  a=l[0]
  l2=[]
  c=1
  for x in l[1:]:
    if a==x:
      c+=1
    else:
      l2.append([a,c])
      c=1
      a=x
  l2.append([a,c])

  l2=sorted(l2,key=lambda x:x[1])

  ans=0
  for i in range(len(l2)-m):
    ans+=l2[i][1]

  return ans

print(main())


Measured memory_bytes: 37892
class DisjointSets:
    def __init__(self, n):
        self.nodes = [-1] * n #根にサイズを負の値で格納する。
    def find(self, i):
        if self.nodes[i] < 0: #値が負の場合は根
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) #縮約
            return self.nodes[i]
    def unite(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: #サイズ比較してiの方がサイズが大きいようにする
            i, j = j, i
        self.nodes[i] += self.nodes[j] #大きい方に小さい方を統合しサイズを登録する。
        self.nodes[j] = i # jの親はi
    
    def size(self, i): # 所属する集合の大きさを返す
        i = self.find(i)
        return -self.nodes[i]

n, m = map(int, input().split())
ds = DisjointSets(n)
for _ in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    ds.unite(a, b)

print(len(set(ds.find(i) for i in range(n))) - 1)

Measured memory_bytes: 81136
#include<bits/stdc++.h>
using namespace std;
int x,y;
string ans,s1,s2;

int main()
{
    cin>>s1>>s2;
    x = s1.size();
    y = s2.size();
    int i,j;
    int table[x+1][y+1];
    for( i = 0; i <= x; i++){
       for( j = 0;j <= y; j++)
            table[i][j] = 0;
    }


    for( i =1; i<=x; i++)
    {
        for( j = 1; j<=y; j++)
        {

            if(s1[i-1] == s2[j-1])
            {
                table[i][j] = 1 + table[i-1][j-1];
            }
            else
            {
                table[i][j] = max(table[i][j-1],table[i-1][j]);
            }
        }
    }
    i = x;
    j = y;
    //cout<<i<<j<<endl;

    while(i>0 && j>0){
            if(table[i][j] == table[i-1][j])i--;
            else if(table[i][j] == table[i][j-1]) j--;
            else {
                i--;j--;
                ans+=s1[i];
                //cout<<ans<<endl;
            }
    }


   // cout<<ans<<endl;
        reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

    // reverse(str.begin(), str.end());
//    print(0,0);
    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      a=a/2;
      b+=a;
    }
    else{
      b=b/2;
      a+=b;
    }
  }
  cout << a << " " << b;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

typedef string::const_iterator State;
int number(State&);
int factor(State&);
int term(State&);
int expression(State&);

// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}

// ??¬??§?????°???????????????????????????????????????????????????
int factor(State &begin) {
    if (*begin == '(') {
        begin++; // '('????£???°??????
        int ret = expression(begin);
        begin++; // ')'????£???°??????
        return ret;
    } else {
        return number(begin);
    }
    return -1;
}

// ?????????????????????????????????????????????????????????????????????
int term(State &begin) {
    int ret = factor(begin);

    for (;;) {
        if (*begin == '*') {
            begin++;
            ret *= factor(begin);
        } else if (*begin == '/') {
            begin++;
            ret /= factor(begin);
        } else {
            break;
        }
    }

    return ret;
}

// ?????????????????????????????????????????????????????????????????????
int expression(State &begin) {
    int ret = term(begin);

    for (;;) {
        if (*begin == '+') {
            begin++;
            ret += term(begin);
        } else if (*begin == '-') {
            begin++;
            ret -= term(begin);
        } else {
            break;
        }
    }

    return ret;
}

//begin???expected?????????????????????begin?????????????????????
void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl;
        cerr << "Rest string is '";
        while (*begin) {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        //throw ParseError();
    }
}


int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        State tmp = s.begin();
        int ans = expression(tmp);
        consume(tmp, '=');
        cout << ans << endl;
    }
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef  long long ll;

ll p = pow(10, 9) + 7;





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    set<string> st;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19184
#include<stdio.h>

int main(){
  int stg;
  char ans=' ';
  char s=' ';
  int cnt=0,n=0;
  int i;

  while(1){
    stg=getchar();
    if(stg==s||stg=='\n'){
      if(cnt>n){
	ans=s;
	n=cnt;
      }
      cnt=0;
    }
    if(stg==' '||stg=='\n') break;
    if(stg=='e'){
      getchar();
      getchar();
    }
    if(stg=='c'){
      for(i=0;i<6;i++)
	getchar();
    }
    s=stg;
    cnt++;
  }
  puts(ans=='e'?"egg":"chicken");
 
  return 0;
}

Measured memory_bytes: 524
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

const int N = 10000010;
int fa[N];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  for(int i = 1; i < N; i++){
    for(int j = i; j < N; j += i){
      fa[j]++;
    }
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ans += (ll)i*fa[i];
  }
  print(ans);
}


Measured memory_bytes: 42692
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
	
	int  a,b;

	cin >> a >> b;

	if ((a*b) % 2 == 0) {
		cout << "Even\n";
	}
	else {
		cout << "Odd\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int total = 0;
	int n = 0;
	int d1[101] = { 0 };
	int d2[101] = { 1 };


	cin >> n;


	for (int i = 0; i < n; i++) {

		cin >> d1[i] >> d2[i];
		

		if (d1[i] == d2[i] && total == 0) {

			if (d1[i - 1] == d2[i - 1] && total == 0) {

				if (d1[i - 2] == d2[i - 2] && total == 0) {

					cout << "Yes";

					total++;

				}

			}

		}

	}


	if (total == 0) {

		cout << "No";

	}

	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

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

bool solve()
{
	int N, M;
	cin >> N >> M;
	if (N == 0 && M == 0)return false;

	unordered_map<int, int> mp;
	vec h(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> h[i];
		int total = 0;
		for (int j = i; j >= 0; --j)
		{
			total += h[j];
			if (mp.count(total))
			{
				mp[total]++;
			}
			else
			{
				mp[total] = 1;
			}
		}
	}

	int ans = 0;
	vec w(M);

	for (int i = 0; i < M; ++i)
	{
		cin >> w[i];
		int total = 0;
		for (int j = i; j >= 0; --j)
		{
			total += w[j];
			if (mp.count(total))
			{
				ans += mp[total];
			}
		}
	}

	cout << ans << endl;

	return true;
}

int main()
{
	while (solve());

	return 0;
}


Measured memory_bytes: 16864
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <string>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

//Reading and Printing Arrays

//short int
#define rhd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%hd", &arr[aab]);}
#define phd(arr, n) for(int aab = 0; aab < n; aab++){printf("%hd ", arr[aab]);}
//int
#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
//unsigned int
#define ru(arr, n) for(int aab = 0; aab < n; aab++){scanf("%u", &arr[aab]);}
#define pu(arr, n) for(int aab = 0; aab < n; aab++){printf("%u ", arr[aab]);}
//long int
#define rld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%ld", &arr[aab]);}
#define pld(arr, n) for(int aab = 0; aab < n; aab++){printf("%ld ", arr[aab]);}
//unsigned long int
#define rlu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lu", &arr[aab]);}
#define plu(arr, n) for(int aab = 0; aab < n; aab++){printf("%lu ", arr[aab]);}
//long long int
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
//unsigned long long int
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
//float
#define rf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%f", &arr[aab]);}
#define pf(arr, n) for(int aab = 0; aab < n; aab++){printf("%f ", arr[aab]);}
//double
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
//char
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
//string
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

//swap
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
//freopen
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

/*       ▄▀▄     ▄▀▄
        ▄█░░▀▀▀▀▀░░█▄
    ▄▄  █░░░░░░░░░░░█  ▄▄
   █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█       */

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){
	int a;

	scanf("%d", &a);
	double cevap;

	cevap = (a / 3.0) * (a / 3.0) * (a / 3.0);

	printf("%.12lf", cevap);
}

Measured memory_bytes: 128
#include <stdio.h>

int	main(void)
{
  char	S[3];
  int	num;
  
  num = scanf("%s", S);
  if (num != 1)
    return (0);
  
  if (S[0] == S[1] && S[1] == S[2])
  {
        printf("No");
        return (0);
  }
  else
  {
      printf("Yes");
      return (0);
  }
  return (0);
}

Measured memory_bytes: 128
from itertools import permutations as perms

n = int(input().strip())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
lis = [(i + 1) for i in range(n)]
a = -1
b = -1
cnt = 0
for elem in perms(lis, n):
    cnt += 1
    if elem == p:
        a = cnt
    if elem == q:
        b = cnt
    if a != -1 and b != -1:
        break
print(abs(a - b))


Measured memory_bytes: 38896
from collections import deque
import sys;input=sys.stdin.readline

h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=deque()
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=deque()
    while stack:
        my,mx=stack.pop()
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if not tmp:
        print(i)
        break


Measured memory_bytes: 164488
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		var r = new List<int>();
		var n = int.Parse(Console.ReadLine());
		var s = Console.ReadLine();
		var qc = int.Parse(Console.ReadLine());

		var st = new ST_Bit(n);
		for (int i = 0; i < n; i++)
			st.Set(i, 1 << (s[i] - 'a'));

		for (int k = 0; k < qc; k++)
		{
			var q = Console.ReadLine().Split();
			if (q[0] == "1")
				st.Set(int.Parse(q[1]) - 1, 1 << (q[2][0] - 'a'));
			else
			{
				var f = st.Subor(int.Parse(q[1]) - 1, int.Parse(q[2]));
				r.Add(Enumerable.Range(0, 26).Count(i => (f & (1 << i)) != 0));
			}
		}

		Console.WriteLine(string.Join("\n", r));
	}
}

class ST
{
	public struct Node
	{
		public int k, i;
		public Node(int _k, int _i) { k = _k; i = _i; }

		public Node Parent => new Node(k - 1, i >> 1);
		public Node Child0 => new Node(k + 1, i << 1);
		public Node Child1 => new Node(k + 1, (i << 1) + 1);
	}

	protected int kMax;
	List<long[]> vs = new List<long[]> { new long[1] };

	public ST(int n)
	{
		for (int c = 1; c < n; vs.Add(new long[c <<= 1])) ;
		kMax = vs.Count - 1;
	}

	public virtual long this[int i] => vs[kMax][i];
	public long this[Node n]
	{
		get { return vs[n.k][n.i]; }
		set { vs[n.k][n.i] = value; }
	}

	public void InitAllLevels(long v)
	{
		foreach (var a in vs) for (int i = 0; i < a.Length; ++i) a[i] = v;
	}

	public void ForLevels(int i, Action<Node> action)
	{
		for (int k = kMax; k >= 0; --k, i >>= 1) action(new Node(k, i));
	}

	public void ForRange(int minIn, int maxEx, Action<Node> action)
	{
		for (int k = kMax, f = 1; k >= 0 && minIn < maxEx; --k, f <<= 1)
		{
			if ((minIn & f) != 0) action(new Node(k, (minIn += f) / f - 1));
			if ((maxEx & f) != 0) action(new Node(k, (maxEx -= f) / f));
		}
	}
}

class ST_Bit : ST
{
	public ST_Bit(int n) : base(n) { }

	public void Set(int i, long v) => ForLevels(i, n => this[n] = n.k == kMax ? v : this[n.Child0] | this[n.Child1]);

	public long Subor(int minIn, int maxEx)
	{
		var r = 0L;
		ForRange(minIn, maxEx, n => r |= this[n]);
		return r;
	}
}


Measured memory_bytes: 56156
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int R[300000];
int L[300000];
void solve() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> inputs;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		b--;
		inputs.push_back(make_pair(a, b));
	}
	sort(ALL(inputs));
	REP(i, n) {
		R[i] = i;
		L[i] = i;
	}
	//reverse(ALL(inputs));
	REP(i, m) {
		R[inputs[i].second] = R[inputs[i].second + 1];
		L[inputs[i].second + 1] = L[inputs[i].second];
	}
	REP(i, n) {
		if (i != 0) cout << " ";
		cout << R[i] - L[i] + 1;
	}
	cout << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 7568
fun main(args: Array<String>) {
    val M = readLine()!!.split(" ")[1].toInt()
    val ab = (0 until M).map { readLine()!!.split(" ").map { it.toInt() } }.sortedBy { it[1] }
    val list = mutableListOf<Int>()
    ab.forEach {
        if (list.isEmpty() || list.last() <= it[0]) list.add(it[1])
    }
    println(list.size)
}

Measured memory_bytes: 84036
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n,k,r,s,p,score=0,i;
    string str,player;
    cin>>n>>k>>r>>s>>p;
    cin>>str;
    for(i=0;i<str.length();i++){
        if(str[i]=='r')
            player +='p';
        else if(str[i]=='s')
           player +='r';
        else if(str[i]=='p')
            player +='s';
    }
    for(i=0;i<player.length();i++){
        if(i>=k){
            if(player[i]==player[i-k])
                player[i] ='0';
        }
    }
    for(i=0;i<player.length();i++)
    {
        if(player[i]=='r')
            score += r;
       else if(player[i]=='s')
            score += s;
          else if(player[i]=='p')
            score += p;

            //cout<<player[i];
    }
   // cout<<endl;
    cout<<score<<endl;
}


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

int main()
{
    string s;
    cin >> s;
    
    string text = "";
    
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'B')
        {
            if(text != "")
            {
                text.pop_back();
            }
        }
        else
        {
            text.push_back(s[i]);
        }
    }
    cout << text << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys

n, y = map(int,input().split())

a, b, c = 0, 0, 0

am = y // 10000
bm = y // 5000
cm = y // 1000

for i in range(am+1):
    for j in range(bm+1):
        if (9000*i + 4000*j + 1000*n == y) and (n-i-j >= 0):
            print(i, j ,n-i-j)
            sys.exit()
        if (y - 1000*n - 4000*j < 0):
            break
        if (n-i-j < 0):
            break

print(-1,-1,-1)


Measured memory_bytes: 3064
N=int(input())
S=input()
alf="abcdefghijklmnopqrstuvwxyz"
ans=0

for i in range(N-1):
    S1=list(S[0:i+1])
    S2=list(S[i+1:N])

    temp=0
    li1=[0]*26
    li2=[0]*26

    for j in range(len(S1)):
        li1[alf.find(S1[j])]+=1
    for k in range(len(S2)):
        li2[alf.find(S2[k])]+=1
    
    for l in range(26):
        if min(li1[l],li2[l])!=0:
            temp+=1
    if temp>ans:
        ans=temp
print(ans)


Measured memory_bytes: 9096
import copy
h,w,k2=map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0

for i in range(2**h):
    for j in range(2**w):
        d = copy.deepcopy(c)
        for k in range(h):
            if i%(2**(k+1))//(2**k)==1:
                for j2 in range(w):
                    d[k][j2]='r'
        for l in range(w):
            if j%(2**(l+1))//(2**l)==1:
                for i2 in range(h):
                    d[i2][l]='r'
        black = 0
        for i3 in range(h):
            for j3 in range(w):
                if d[i3][j3]=='#':
                    black +=1
        if black == k2:
            ans+=1
print(ans)


Measured memory_bytes: 72652
n,k = map(int,input().split())
mod = 10**9+7
l = [i for i in range(n+1)]
rl = [i for i in range(n,-1,-1)]
suml = [0]*(n+1)
suml[0] = l[0]
for i in range(n):
    suml[i+1] = suml[i] + l[i+1]
sumrl = [0]*(n+1)
sumrl[0] = rl[0]
for i in range(n):
    sumrl[i+1] = sumrl[i] + rl[i+1]
cnt = 0
for m in range(k,n+2):
    max_m = sumrl[m-1]
    min_m = suml[m-1]
    cnt += max_m-min_m+1
print(cnt%mod)


Measured memory_bytes: 45944
import copy

N = int(input())
A = list(map(str, input().split()))
bub = []
sel = []
bub = copy.copy(A)
sel = copy.copy(A)

# Bubble Sort
for i in range(N - 1, 0, -1):
    for j in range(N - 1, N - i - 1, -1):
        if bub[j][1] < bub[j - 1][1]:
            v = bub[j]
            bub[j] = bub[j - 1]
            bub[j - 1] = v

s_bub = [str(a) for a in bub]
s_bub = " ".join(s_bub)
print(s_bub)
print("Stable")

# Selection Sort
for i in range(N):  # i に、それ以降の最小値を持ってくる
    min_a = sel[i]  # 先頭を最小値として設定
    num = i
    for j in range(i + 1, N):  # 以下for内で、(i, N)における最小値をmin_aに取得
        if min_a[1] > sel[j][1]:
            min_a = sel[j]
            num = j
    if min_a[1] < sel[i][1]:
        sel[num] = sel[i]
        sel[i] = min_a

s_sel = [str(a) for a in sel]
s_sel = " ".join(s_sel)
print(s_sel)

if sel == bub:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int h, w;
  cin >> h >> w;
  int a[80][80], b[80][80], c[80][80];
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  rep(i, h) rep(j, w) c[i][j] = abs(a[i][j] - b[i][j]);
  bool dp[81][81][81 * 160] = {};
  dp[0][0][c[0][0]] = true;

  rep(i, h) rep(j, w)
  {
    for (int k = 0; k <= 80 * 160; k++)
    {
      if (!dp[i][j][k])
        continue;
      if (i + 1 < h)
      {
        dp[i + 1][j][abs(k + c[i + 1][j])] = true;
        dp[i + 1][j][abs(k - c[i + 1][j])] = true;
      }
      if (j + 1 < w)
      {
        dp[i][j + 1][abs(k + c[i][j + 1])] = true;
        dp[i][j + 1][abs(k - c[i][j + 1])] = true;
      }
    }
  }
  for (int k = 0; k <= 80 * 160; k++)
  {
    if (dp[h - 1][w - 1][k])
    {
      cout << k << endl;
      return 0;
    }
  }
  return 0;
}

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

int w,h;
int dp[2000][2000][2],s[2000][2000];
int sum[2000][2000];
int dx[]{1,0},dy[]{0,1};

int rec(int x,int y,int a){
	if(dp[x][y][a]!=-1)return dp[x][y][a];
	if(y==w)return 0;
	int res=(a==0?INT_MIN:INT_MAX);
	rep(i,2){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>h)continue;
		int b=rec(nx,ny,!a)+(i==1?sum[x][y]:0);
		if(a==0)res=max(res,b);
		else res=min(res,b);
	}
	return dp[x][y][a]=res;
}
int main(){
	scanf("%d%d",&w,&h);
	rep(i,h)rep(j,w)scanf("%d",&s[i][j]);
	int a=0;
	rep(i,w)rep(j,h){
		sum[j+1][i]=sum[j][i]+s[j][i];
		a+=s[j][i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<abs(a-rec(0,0,0)*2)<<endl;
}

Measured memory_bytes: 50184
#include <iostream>
using namespace std;
long long int dp[50][10000];
int x[50];
long long int dp2(int p, int q){
  if(dp[p][q] != -1){
  	return dp[p][q];
  }
  if(p == 0){
  	if((x[0] + 5000) == q && q == 5000){
  		return dp[p][q] = 2;
  	}else if((x[0] + 5000) == q || q == 5000){
      return dp[p][q] = 1;
    }else{
      return dp[p][q] = 0;
    }
  }
  long long int count = dp2(p - 1, q);
  count += dp2(p - 1, q - x[p]);
  return dp[p][q] = count;
}
int main(){
  int n, a;
  cin >> n >> a;
  for(int i = 0;i < 50;i++){
    for(int j = 0;j < 10000;j++){
      dp[i][j] = -1;
    }
  }
  for(int i = 0;i < n;i++){
    cin >> x[i];
    x[i] -= a;
  }
  cout << dp2(n - 1, 5000) - 1 << endl;
}

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

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

using namespace std;

const int MOD = 100000;
int dp[2][(1<<20)][2],H,W;
char G[20][20];
/*
dp[(x,y) & 1][column][Is the left is J?] := the number % 10^5
 */

inline void compute(int other){

  dp[0][0][0] = 1;

  rep(y,H)rep(x,W) {
    int phase = ( x + y * W ) & 1;
    rep(i,(1<<W))rep(k,2) dp[!phase][i][k] = 0;
    rep(bitmask,(1<<W)){     

      bool out = false;
      REP(i,1,W) if( ((bitmask>>x)&1) && ((bitmask>>(x-1))&1) ) {
        out = true;
        break;
      }
      if( out ) continue;

      int nbitmask = bitmask & (~(1<<x));

      if( G[y][x] == 'O' ) goto O;
      if( G[y][x] == 'I' ) goto I;

      // put J
      if( x != W-1 ) ( dp[!phase][nbitmask][1] += ( dp[phase][bitmask][0] + dp[phase][bitmask][1] ) ) %= MOD;
      else           ( dp[!phase][nbitmask][0] += ( dp[phase][bitmask][0] + dp[phase][bitmask][1] ) ) %= MOD;
      if( G[y][x] == 'J' ) goto Skip;

    O:;
      // put O
      // となりがJでない
      ( dp[!phase][nbitmask][0] += dp[phase][bitmask][0] ) %= MOD;

      // となりがJ
      if( x-1 >= 0 ) {
        nbitmask |= (1<<(x-1));
        ( dp[!phase][nbitmask][0] += dp[phase][bitmask][1] ) %= MOD;
        nbitmask &= (~(1<<(x-1)));
      }
      if( G[y][x] == 'O' ) goto Skip;

    I:;
      // put I
      if( !( ( bitmask>>x ) & 1 ) ) {
        nbitmask = nbitmask & (~(1<<x));
        ( dp[!phase][nbitmask][0] += ( dp[phase][bitmask][0] + dp[phase][bitmask][1] ) ) %= MOD;
      }
      
    Skip:;
      
    }
  }

  int sum = 0;
  rep(i,(1<<W)) rep(j,2) ( sum += dp[(H*W)&1][i][j] ) %= MOD;

  int total = 1;
  rep(i,other) ( total *= 3 ) %= MOD;
  cout << ( total - sum + MOD ) % MOD << endl;
}

int main(){
  cin >> H >> W;
  int other = 0;
  rep(i,H)rep(j,W){
    cin >> G[i][j];
    other += (G[i][j]=='?');
  }
  compute(other);
  return 0;
}

Measured memory_bytes: 17544
<?php
    fscanf(STDIN,"%s %s",$a,$b);
    if(strcmp($a,$b)>0){
        for($i=0;$i<$a;$i++){
            echo $b;
        }
    }else{
        for($i=0;$i<$b;$i++){
            echo $a;
        }
    }


    
?>
    

Measured memory_bytes: 4604
#include <iostream>

using namespace std;

long long n;
long long ans;
long long num[5];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M') num[0]++;
        else if(s[0] == 'A') num[1]++;
        else if(s[0] == 'R') num[2]++;
        else if(s[0] == 'C') num[3]++;
        else if(s[0] == 'H') num[4]++;
    }

    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += num[i]*num[j]*num[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

template<typename T>
T mypow(T a, T b){
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % mod) * a) % mod;
    else
        return (tmp * tmp) % mod;
}

ll gcd(ll a, ll b){
  	if(b == 0){
    	return a;
  	}
  	return gcd(b, a % b);
}

ll lcm (ll a, ll b) {
    ll tmp = a * b;
    tmp %= mod;
    tmp *= mypow(static_cast<long long>(gcd(a, b)), static_cast<long long>(mod - 2));
    tmp %= mod;
    return tmp;
}


map<ll, ll> factoring (ll n) {
  	map<ll, ll> mp;

  	for(ll i = 2; i * i <= n; i++){
    	while(n % i == 0){
      	    n /= i;
      	    mp[i]++;
    	}
  	}
  	if(n != 1) mp[n]++;
    return mp;
}


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

    ll n;
    cin >> n;
    vll a(n);
    vector<map<ll, ll>> mp(n);
    REP(i, n) {
        cin >> a[i];
        mp[i] = factoring(a[i]);
    }

    map<ll, ll> total = mp[0];
    REP(i, n - 1) {
        for (auto x : mp[i + 1]) {
            total[x.first] = max(total[x.first], x.second);
        }
    }

    ll l = 1;
    for (auto x : total) {
        l *= mypow(static_cast<long long>(x.first), static_cast<long long>(x.second));
        l %= mod;
    }

    // cout << l << endl;

    /*
    ll g = a[0], l = a[0]; // l : 最大公約数, AB の目標値
    REP(i, n - 1) {
        l = lcm(l, a[i + 1]);
    }
    ll pp = 1; // AB の目標値
    REP(i, n) {
        pp *= (a[i] / g);
        pp %= mod;
    }
    */
    // cout << l << endl;
    ll res = 0;
    REP(i, n) {
        res += mypow(static_cast<long long>(a[i]), static_cast<long long>(mod - 2)); // 1 / a[i]
        res %= mod;
    }
    res = (res * l) % mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3968
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //Maybe use while loops if TLE
		Scanner input = new Scanner(System.in); 
		String S = input.next();
		int N = S.length();
		long ans = 0;
		boolean[] vis = new boolean[N];
		for (int i = 0; i < N-1; i++) {
			if (S.charAt(i)=='<'&&S.charAt(i+1)=='>') {
				long prev = 0;
				long next = 0;
				for (int back = i; back>=0; back--) {
					if (S.charAt(back)!='<') break;
					else {
						prev++;
						vis[back]=true;
					} 
				}
				for (int up = i+1; up<N; up++) {
					if (S.charAt(up)!='>') {
						break;
					} 
					else {
						next++;
						vis[up]=true;
					} 
				}
				long max = Math.max(prev, next); //0<1<2<6>5>4>3>2>1>0; max = 6 --> increases ans by 21 
				long min = Math.min(prev, next);
				min--;
				ans+=max*(max+1)/2;
				ans+=min*(min+1)/2;
			}
		}
		//ERRORS BELOW for trivial cases like >>><<<
		long L = 0;
		char start = S.charAt(0);
		char end = S.charAt(N-1);
		for (int i = 0; i < N; i++) {
			if (vis[i]||S.charAt(i)!=start) break;
			else {
				L++;
				vis[i]=true;
			} 
		}
		long R = 0;
		for (int i = N-1; i >= 0; i--) {
			if (vis[i]||S.charAt(i)!=end) break;
			else R++;
		}
		ans+=L*(L+1)/2;
		ans+=R*(R+1)/2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 28896