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

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

struct Lamp {int top = -1; int bottom = -1; int right = -1; int left = -1;};
struct Node {int u;int v;ll w;};

int main() {
    int H, W; cin >> H >> W;
    char grid[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) cin >> grid[i][j];
    }

    Lamp memo[H][W];

    for (int i = 0; i < H; ++i) {
        int lstone = -1;
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '#') {
                lstone = j; continue;
            }
            memo[i][j].left = j - lstone - 1;
        }
    }
    for (int i = 0; i < H; ++i) {
        int rstone = W;
        for (int j = W-1; j >= 0; --j) {
            if (grid[i][j] == '#') {
                rstone = j; continue;
            }
            memo[i][j].right = rstone - j - 1;
        }
    }
    for (int j = 0; j < W; ++j) {
        int tstone = -1;
        for (int i = 0; i < H; ++i) {
            if (grid[i][j] == '#') {
                tstone = i; continue;
            }
            memo[i][j].top = i - tstone - 1;
        }
    }
    for (int j = 0; j < W; ++j) {
        int bstone = H;
        for (int i = H-1; i >= 0; --i) {
            if (grid[i][j] == '#') {
                bstone = i; continue;
            }
            memo[i][j].bottom = bstone - i - 1;
        }
    }

    int res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            Lamp x = memo[i][j];
            res = max(res, 1 + x.top + x.bottom + x.left + x.right);
        }
    }
    cout << res << endl;

}


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

int main(void){
    int N,ac=0,wa=0,tle=0,re=0;
    cin >> N;
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        if(S=="AC") ac++;
        if(S=="WA") wa++;
        if(S=="TLE") tle++;
        if(S=="RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int n, m;
	int doro[50] = { 0 };
	int i;
	
	scanf("%d %d", &n, &m);
	
	for(i=0; i<m; i++){
		int a, b;
		
		scanf("%d %d", &a, &b);
		doro[a-1]++;
		doro[b-1]++;
	}
	
	for(i=0; i<n; i++)
		printf("%d\n", doro[i]);
	
	return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
dif=[]
for i in range(n-1):
  mx=0
  for j in range(i+1,n):
    md=abs(a[j]-a[i])
    if mx<md:
      mx=md
  dif.append(mx)
print(max(dif))

Measured memory_bytes: 39024
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
#include <string.h>

using namespace std;

int main(){
  int A[26], B[26];
  int n;
  string s;

  for(int i = 0; i < 26; i++){
    A[i] = B[i] = 0;
  }

  cin >> n;

  // cout << (s[0] - 'a') << endl;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(i==0){
      for(int j = 0; j < s.size(); j++){
        A[s[j] - 'a']++;
      }
    }
    else{
      for(int j = 0; j < s.size(); j++){
        B[s[j] - 'a']++;
      }
      for(int k = 0; k < 26; k++){
        if(A[k] > B[k]){
          A[k] = B[k];
        }
        B[k] = 0;
      }
    }
  }

  for(int i = 0; i < 26; i++){
    //   cout << A[i];
    for(int j = 0; j < A[i]; j++){
      cout << char('a' + i);
    }
  }
  cout << endl;


  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			int b=sc.nextInt();
			a[b-1]=i+1;
		}
		for(int i=0;i<n;i++) {
			System.out.print(a[i]+" ");
		}
	}

}


Measured memory_bytes: 62668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int ,int>> ab(n);
  rep(i,n)cin>>ab[i].first>>ab[i].second;
  SORT(ab);
  int buy=0,res=0;
  rep(i,n){
    buy+=ab[i].second;
    if(buy>=m){
      res+=((m-(buy-ab[i].second))*ab[i].first);
      out(res);
      return 0;
    }
    else res+=ab[i].second*ab[i].first;
  }
  

  return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

int cnt;
void merge(vector<int> &v, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    int L[n1 + 1];
    int R[n2 + 1];
    for (int i = 0; i < n1; ++i)
        L[i] = v[left + i];
    for (int i = 0; i < n2; ++i)
    {
        R[i] = v[mid + i];
    }
    L[n1] = (1LL << 31) - 1;
    R[n2] = (1LL << 31) - 1;

    int i = 0, j = 0;
    for (int k = left; k < right; ++k)
    {
        cnt++;
        if (L[i] <= R[j])
        {
            v[k] = L[i];
            i++;
        }
        else
        {
            v[k] = R[j];
            j++;
        }
    }
}

void mergesort(vector<int> &v, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergesort(v, left, mid);
        mergesort(v, mid, right);
        merge(v, left, mid, right);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    mergesort(v, 0, n);

    for (int i = 0; i < n; ++i)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
typedef long long i64;
const int N = 5e3+5; int P;
int n, f[N], ans; void fix(int &x) { x<P?0:x-=P; }
int main()
{
    scanf("%d%d", &n, &P), f[0] = 1;
    for(int i = 2; i <= n; ++i)
    {
        int v = (i <= n/2+1?i-2:n-i+1)+1;
        for(int j = v; j < n; ++j) fix(f[j] += f[j-v]);
    }
    for(int i = 0; i < n; ++i) fix(ans += i64(n-i)*f[i]%P);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3832
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>
 
using namespace std;

int main(){
    const auto spots = []() -> vector<int>
    {
        size_t n;
        vector<int> sp;
        cin >> n;
        sp.reserve(n);
        for(size_t i = 0; i < n; ++i){
            int a;
            cin >> a;
            sp.push_back(a);
        }
        return sp;
    }();
    
    const auto get_pos = [&](int i){ return (i < 0 || i >= (int)spots.size())? 0 : spots[i]; };
    const auto get_cost = [&](int i, int j){ return abs(get_pos(i) - get_pos(j)); };
    
    const int n = (int)spots.size();
    
    const int total_cost = [&]() -> int
    {
        int cost = 0;
        for(int i = 0; i <= n; ++i)
        {
            cost += get_cost(i, i-1);
        }
        return cost;
    }();
    
    for(int non_visit = 0; non_visit < n; ++non_visit)
    {
        const int cost = total_cost
            - get_cost(non_visit-1, non_visit  )
            - get_cost(non_visit,   non_visit+1)
            + get_cost(non_visit-1, non_visit+1);
        
        cout << cost << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,u,v;
	cin>>n>>m;
	vector<vector<int>> adj(n+1,vector<int>());
	for(int i=0; i<m; i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector<int> par(n+1,-1);
	par[0] = 0;
	par[1] = 0;
	queue<int> q;
	q.push(1);
	while(!q.empty())
	{
		u = q.front();
		q.pop();
		for(auto& v: adj[u])
		{
			if(par[v]==-1)
			{
				par[v] = u;
				q.push(v);
			}
		}
	}
	if(*min_element(par.begin(), par.end())==-1)
		cout<<"No\n";
	else{
		cout<<"Yes\n";
		for(int i=2; i<=n; i++)
			cout<<par[i]<<"\n";
	}
}

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

int a[100010],b[100010],c[100010],ans,n;

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    n=read();
    ++n;
    
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
        
    b[1]=1,c[n]=a[n];
    
    for(int i=2;i<=n;i++)
        b[i]=(b[i-1]-a[i-1])*2;
        
    for(int i=n-1;i>=1;i--)
        c[i]=c[i+1]+a[i];
        
    for(int i=1;i<=n;i++)
        ans+=min(b[i],c[i]);
        
    for(int i=1;i<=n;i++){
        if(a[i]>b[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
            
    writeln(ans);
    return 0;
}

Measured memory_bytes: 5980
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

Graph g;
// d[i] := 頂点 i に移動するとき, それ以降に移動する回数の期待値
vector<double> d;
void dfs(int u, int p) {
    double sum = 0;
    int cnt = 0;
    for (int v: g[u]) if (v != p) {
        dfs(v, u);
        sum += d[v] + 1;
        cnt++;
    }
    d[u] = (cnt ? sum / cnt : 0);
}
vector<double> res;
void dfs2(int u, int p, double d_par = 0) {
    double total = 0;
    for (int v: g[u]) total += (v == p ? d_par : d[v]) + 1;
    res[u] = total / g[u].size();
    for (int v: g[u]) if (v != p) {
        double nd_par = (total - (d[v] + 1)) / (g[u].size() - 1);
        dfs2(v, u, nd_par);
    }
}

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int n; cin >> n;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v; u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    if (n == 1) return !(cout << 0 << endl);
    if (n == 2) return !(cout << "1\n1" << endl);
    int r = -1;
    for (int i = 0; i < n; i++) if (g[i].size() >= 2) r = i;
    d.resize(n);
    dfs(r, -1);
    res.resize(n);
    dfs2(r, -1);
    for (auto e: res) cout << e << endl;
    return 0;
}

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


int main() {
  int n;
  int64_t cnt = 0;
  cin >> n;
 
  map<int,int>mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }
  for (auto m : mp) {
    if (m.second % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}




Measured memory_bytes: 4864
#include <stdio.h>

int main(void)
{
	char s[3][4];
	scanf("%s%s%s",s[0],s[1],s[2]);
	fprintf(stderr,"%s\n%s\n%s\n",s[0],s[1],s[2]);
	printf("%c%c%c",s[0][0],s[1][1],s[2][2]);

	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,d,x,vis[101];
int main() {
	scanf("%d%d",&n,&d);
	for (int i = 1;i <= d;i++) {
		int x,y; scanf("%d",&x);
		for (;x--;) {
			scanf("%d",&y);
			if (vis[y] == 0) n--,vis[y] = 1;
		}
	}
	printf("%d",n);
    return 0;
}

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

using namespace std;

int main(){
    long long suma=0, n;
    int x, y, a, b, c, aux;

    deque<int> numA, numB, numC;

    cin>>x>>y>>a>>b>>c;

    for(int i=0;i<a;i++){
        scanf("%d", &aux);
        numA.push_back(aux);
    }
    
    for(int i=0;i<b;i++){
        scanf("%d", &aux);
        numB.push_back(aux);
    }

    for(int i=0;i<c;i++){
        scanf("%d", &aux);
        numC.push_back(aux);
    }

    sort(numA.begin(),numA.end());
    sort(numB.begin(),numB.end());

    n=numA.size()-1;
    for(int i=0;i<x;i++,n--){
        numC.push_back(numA[n]);
    }

    n=numB.size()-1;
    for(int i=0;i<y;i++,n--){
        numC.push_back(numB[n]);
    }

    sort(numC.begin(),numC.end());
    
    n=x+y;
    int cant=numC.size()-1;
    while(n--){
        suma+=numC[cant];
        cant--;
    }

    cout<<suma<<endl;

	return 0;
}

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

const int maxn = 2e5+5;
int n, a[maxn];
ll pre[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = a[i] + pre[i-1];
    }
    ll ans = 1e18;
    for (int i = 1; i < n; i++) {
        ll sum = pre[i];
        ans = min(ans,abs(sum-(pre[n]-sum)));
    }
    cout << ans << '\n';
}



Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

template<class T>
T pow(T x, ll n, T r = 1) {
    while (n) {
        if (n & 1) r *= x;
        x *= x;
        n >>= 1;
    }
    return r;
}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};
using Mint = ModInt<TEN(9)+7>;
const int MN = 1000000;
int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n;
    cin >> n;
    using P = pair<int, int>;
    vector<P> v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(P(x, 0));
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back(P(x, 1));
    }

    Mint ans = 1;
    sort(v.begin(), v.end());
    int co = 0;
    for (auto p: v) {
        if (p.second == 0) {
            if (co < 0) {
                ans *= -co;
            }
            co++;
        } else {
            if (0 < co) {
                ans *= co;
            }
            co--;
        }
    }
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

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

    list<int> b;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;

        if (i % 2 == 0) {
            b.push_front(a);
        } else {
            b.push_back(a);
        }
    }

    if (n % 2 == 0) {
        reverse(b.begin(), b.end());
    }

    for (int i : b) {
        cout << i << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N, sum = 0;
    cin >> N;
    vint a(N);
    rep(i, N)
    {
        cin >> a[i];
        sum += a[i];
    }
    double ave = (double)sum / (double)N;
    double dif = INT_MAX, ans = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if (dif >= abs(a[i] - ave))
        {
            ans = i;
            dif = abs(a[i] - ave);
        }
    }
    cout << ans;
    return 0;
}

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

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

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

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

signed main(void)
{
	string a, b, c;
	cin >> a >> b >> c;
	int aa = stoi(a+b+c);

	if(aa%4) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf= 1000000000;

int main()
{
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i = 0; i < n;i++)
        {
                cin >> arr[i];
        }
        int ans= inf;
        for(int i = 1; i<= 100;i++)
        {
                int cost = 0;
                for(int j = 0; j < n;j++)
                {       

                        cost += (arr[j] -i)*(arr[j] - i);
                }

                        ans = min(ans,cost);
                
        }
        cout  << ans << endl;
}


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

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;

const int summax = 50 * 50;

int main()
{

    //ifstream cin("input.txt");
    //freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, a;
    cin >> n >> a;

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

    vector<vector<ll> > dp(summax + 1, vector<ll>(n + 1));
    dp[0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int k = n; k >= 0; --k) {
            for (int sum = 0; sum <= summax; ++sum) {
                if (!dp[sum][k]) {
                    continue;
                }
                dp[sum + x[i]][k + 1] += dp[sum][k];
            }
        }
    }

    ll ans = 0;
    for (int z = a; z <= summax && z / a <= n; z += a) {
        ans += dp[z][z / a];
    }
    cout << ans << "\n";

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;
 
signed main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; i++) cin >> B[i];
    vector<int> ans(N, 1000000);
    for (int i = 0; i < N - 1; i++) {
        ans[i] = min(ans[i], B[i]);
        ans[i + 1] = min(ans[i + 1], B[i]);
    }
    cout << accumulate(ans.begin(), ans.end(), 0L) << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    print(len(set(list(map(int,input().split())))))

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s,t;
    cin>>s>>t;

    vector<string> candidate;

    //全部?のパターンもあり得る
    int n=s.size();
    REP(i,n){
        int pos = 0;
        while(pos < t.size()){
            if(i-pos < 0){
                pos++;
                continue;
            }

            bool flg=true;
            string decrypt = s;
            REP(j,t.size()){
                //DEBUG2(s[i-pos+j],t[j]);
                if((i-pos+j)>=n || (s[i-pos+j]!='?' && s[i-pos+j]!=t[j])){
                    flg=false;
                    break;
                }

                decrypt[i-pos+j] = t[j];
            }

            if(flg){
                replace(ALL(decrypt),'?','a');
                candidate.emplace_back(decrypt);
            }
            pos++;
        }
    }

    if(candidate.empty()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ALL(candidate));
    //DEBUG_VEC(candidate);
    cout << candidate[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const ll llinf=LLONG_MAX;
const long inf=LONG_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int i,n;
ll a[3*nmax],l[3*nmax],r[3*nmax],ans=-llinf;
multiset<ll>s;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=3*n;i++)cin>>a[i];
	for(i=1;i<=3*n;i++)
	{
		s.in(a[i]);
		l[i]=l[i-1]+a[i];
		if(s.size()>n)
		{
			l[i]-=(*s.begin());
			s.erase(s.begin());
		}
	}
	s.clear();
	for(i=3*n;i>=1;i--)
	{
		s.in(-a[i]);
		r[i]=r[i+1]+a[i];
		if(s.size()>n)
		{
			r[i]+=(*s.begin());
			s.er(s.begin());
		}
	}
	for(i=n;i<=2*n;i++)ans=max(ans,l[i]-r[i+1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12032
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int sx,sy,tx,ty;
		Scanner sc = new Scanner(System.in);
		sx = sc.nextInt();
		sy = sc.nextInt();
		tx = sc.nextInt();
		ty = sc.nextInt();

		a(sx, tx, "R");
		a(sy, ty, "U");
		a(sx, tx, "L");
		a(sy, ty, "D");
		System.out.print("D");
		a(sx, tx+1, "R");
		a(sy, ty+1, "U");
		System.out.print("L");
		System.out.print("U");
		a(sx, tx+1, "L");
		a(sy, ty+1, "D");
		System.out.print("R");

		sc.close();
	}


	public static void a(int sa, int ta, String s) {
		int d = Math.abs( ta - sa );
		for(int i = 0; i < d; i++) {
			System.out.print(s);
		}
	}
}


Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  int x, y, z;
  cin >> x >> y >> z;

  swap(x, y);
  swap(x, z);

  cout << x << " " << y << " " << z << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <utility>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;
#define LL long long

void solve(long long N, std::vector<long long> a){
    auto me = max_element(a.begin(), a.end(), [](auto a, auto b){
        return abs(a)<abs(b);
    });
    vector<pair<LL, LL>> procs;
    LL ime = me-a.begin();
    if((*me) >= 0){
        for(LL i=0; i<N; i++){
            if(i==ime)continue;
            if(a[i]<0){
                a[i]+=(*me);
                procs.emplace_back(make_pair(ime, i));
            }
        }
        for(LL i=1; i<N; i++){
            if(a[i] < a[i-1]){
                a[i]+=a[i-1];
                procs.emplace_back(make_pair(i-1, i));
            }
        }
    }else{
        for(LL i=0; i<N; i++){
            if(i==ime)continue;
            if(a[i]>0){
                a[i]+=(*me);
                procs.emplace_back(make_pair(ime, i));
            }
        }
        for(LL i=N-2; i>=0; i--){
            if(a[i] > a[i+1]){
                a[i] += a[i+1];
                procs.emplace_back(make_pair(i+1, i));
            }
        }
    }
    cout << procs.size() << endl;
    for(auto p: procs){
        cout << p.first+1 << " " << p.second+1 << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> stack = new ArrayDeque<>();
		String[] str = br.readLine().split(" ");
		int a,b;
		/*for(int i = 0; i < str.length ; i++){
			System.out.println(str[i]);
		}*/
		for(int i = 0; i < str.length ; i++)
		{
			switch(str[i])
			{
			case "+":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b+a);
				//System.out.println("a+b"+a+" "+b+""+(a+b));
				
				break;
			case "-":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(b-a);
				//System.out.println("b-a"+b+" "+a+" "+(b-a));
				
				break;
			case "*":
				a = stack.pollLast();
				b = stack.pollLast();
				stack.offer(a*b);
				//System.out.println("a*b"+a+" "+b+""+(a*b));
				
				break;
					
			default :
				stack.offer(Integer.parseInt(str[i]));
				break;
			}
		}
		
		System.out.println(stack.poll());
		
	}
}

Measured memory_bytes: 24524
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,s;
	cin>>a>>s;
	if(a==1&&s==2)cout<<3<<endl;
	else if(a==2&&s==1)cout<<3<<endl;
	else if(a==1&&s==3)cout<<2<<endl;
	else if(a==3&&s==1)cout<<2<<endl;
	else cout<<1<<endl;
}

Measured memory_bytes: 256
/* created by <xrssa> */
#pragma GCC optimize("O3","unroll-loops","omit-frame-pointer","inline","fast-math","no-stack-protector") //Optimization flags
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
// #include <x86intrin.h> //AVX/SSE Extensions

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

#define f(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define fa(elem, arr) for(auto &elem:arr)
#define gcd(x,y)         __gcd(x,y)
#define lcm(x,y)        (x/gcd(x,y))*y
#define mod             1000000007
#define all(a)           a.begin(),a.end()
#define INF 1e9 // # define INF 0x3f3f3f3f 
#define EPS 1e-6

void solve(){
    int n,k;cin>>n;cin>>k;int arr[n];f(i,n) cin>>arr[i];
    vector<int> dp(n,INF);
    dp[0]=0;
    f(i,n){
        fab(j,i+1,i+k+1){
            if (j<n){
                dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
            }
        }
    }
    cout << dp[n-1] << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    // for multiple test case use
    // int t;cin>>t;while(t--) solve();
    return 0;
}


Measured memory_bytes: 1024
n = int(input())

def gcd1(a,b):
  while b:
    a,b = b,a%b
  return a

def lcm1(a,b):
  return a*b//gcd1(a,b)
num = 1
for i in range(n):
    num = lcm1(num,int(input()))
print(num)
    

Measured memory_bytes: 2940
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x:x[0], reverse=True)
last_removed = 1000000
ans = 0
for i in range(m):
	if ab[i][1] <= last_removed:
		last_removed = ab[i][0]
		ans += 1
print(ans)

Measured memory_bytes: 29064
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld eps = 1e-8, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using Point = complex<ld>;
class Line {
public:
	Point a, b;
};
ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;	// a,b,c??????????¨???¨???
	if (cross(b, c) < -eps) return -1;	// a,b,c???????¨???????
	if (dot(b, c) < 0) return 2;		// c,a,b????????§??´???
	if (norm(b) < norm(c)) return -2;	// a,b,c???????????´???
	return 0;							// a,c,b???????????´???
}

bool isis_ll(Line l, Line m) {
	return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(Line l, Point p) {
	return abs(cross(l.b - p, l.a - p)) < eps;
}

bool isis_sp(Line s, Point p) {
	return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

int main()
{
	cout << fixed << setprecision(3);
	int n;
	ld x1, x2, x3, y1, y2, y3;
	cin >> n;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Point p1(x1, y1), p2(x2, y2), p3(x3, y3);
		Point c = is_ll((Line){ (p1 + p2) / (ld)2, (p1 + p2) / (ld)2 + (p2 - p1) * Point(0, 1) }, (Line){ (p2 + p3) / (ld)2, (p2 + p3) / (ld)2 + (p3 - p2) * Point(0, 1) });
		cout << c.real() << ' ' << c.imag() << ' ' << abs(p1 - c) << endl;
	}
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    char x , y ;
    cin >> x >> y ;
    if ( x < y) cout << '<' ;
    else if (x > y) cout << '>' ;
    else cout << '=' ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

#define PI acos(-1)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int INF = 100500;
const int MAXN = 1e5 + 9;

ll n, a, b;
ll xx[MAXN];

void input() {                  
	cin >> n >> a >> b;
	for(int i = 0; i < n; i++) cin >> xx[i];
}

void solve() {          
	ll ans = 0;
	for(int i = 1; i < n; i++) ans += min(b, (xx[i] - xx[i - 1]) * a);
	cout << ans << endl;
}

int main() {     
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}


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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
string s;
int dp[3005][3005];

int add(int a, int b)
{
  a = (a + mod) % mod;
  b = (b + mod) % mod;
  return (a + b) % mod;
}

int solve(int smaller, int bigger)
{
  if(smaller < 0 || bigger < 0)
    return 0;
  if(!smaller && !bigger)
    return 1;
  int &ans = dp[smaller][bigger];
  if(~ans)
    return ans;
  int idx = s.size() - smaller - bigger;
  if(s[idx] == '>')
    return ans = add(solve(smaller - 1, bigger), solve(smaller - 1, bigger + 1));
  else
    return ans = add(solve(smaller, bigger - 1), solve(smaller + 1, bigger - 1));
}

int main()
{
  int n;
  cin >> n >> s;
  int ans = 0;
  memset(dp, -1, sizeof dp);
  for(int i = 1; i <= n; i++)
  {
    ans = add(ans, solve(i - 1, n - i));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 246400
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){

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

}


Measured memory_bytes: 3084
#include<iostream>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	float a,b,c,d,e,f,x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
	y=(c*d-a*f)/(b*d-e*a);
	x=(c-y*b)/a;
	cout<<fixed;
	cout<<setprecision(3)<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,k,z,cun=0;
  ll d[10000],a[10000],b[100000]={};
  cin>>n>>k;
  for(ll i=0;i<k;i++){
    cin>>d[i];
    for(ll j=0;j<d[i];j++){
      cin>>a[i];
      b[a[i]]++;
    }
  }
  for(ll i=0;i<n;i++){
    if(b[i+1]==0){
      cun++;
    }
  }
  cout<<cun<<"\n";
  return 0;
}


Measured memory_bytes: 4424
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  loop
  @tailrec
  def loop: Unit = {
    val Array(h, r) = readLine.trim.split(' ').map(_.toInt)
    if (h == 0) return
    val suspects = Array.tabulate(h){_ ⇒
      val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
      Point(x, y)
    }
    val Array(u, m, s, du, dm, ds) = readLine.trim.split(' ').map(_.toInt)
    val ume = Array.tabulate(u){_ ⇒
      val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
      Point(x, y)
    }
    val momo = Array.tabulate(m){_ ⇒
      val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
      Point(x, y)
    }
    val sakura = Array.tabulate(s){_ ⇒
      val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
      Point(x, y)
    }
    val umeAngle = Angle.byMeasure(du / 2.0)
    val momoAngle = Angle.byMeasure(dm / 2.0)
    val sakuraAngle = Angle.byMeasure(ds / 2.0)
    val trees = Array(ume → umeAngle, momo → momoAngle, sakura → sakuraAngle)
    val count = Array.tabulate(h){_ ⇒ 0}
    for (_ ← 0 until r){
      val Array(w, a) = readLine.trim.split(' ').map(_.toInt)
      val wind = Angle.byMeasure(w)
      var s = suspects.indices.filter(i ⇒ isReach(Point(0, 0), suspects(i), wind, umeAngle, a))
      s = s.filterNot(i ⇒ trees.exists{case (tree, angle) ⇒ tree.exists(t ⇒ isReach(t, suspects(i), wind, angle, a))})
      s.foreach(i ⇒ count(i) += 1)
    }
    println(
      if (count.forall(_ == 0)) "NA" else count.max match {case c ⇒ count.indices.filter(i ⇒ count(i) == c).map(_ + 1).mkString(" ")}
    )
    loop
  }

  def isReach(tree: Point, house: Point, wind: Angle, range: Angle, length: Int): Boolean = {
    (tree.distance(house) <= length) && (wind + range - Angle(tree.vectorTo(house))).sin >= 0 && (wind - range - Angle(tree.vectorTo(house))).sin <= 0
  }

  case class Point(x: Int, y: Int) {
    def distance(that: Point): Double = this - that match {case p ⇒ math.sqrt(p.x * p.x + p.y * p.y)}
    def -(that: Point): Point = Point(x - that.x, y - that.y)
    def vectorTo(that: Point): Vector = that - this match {case Point(dx, dy) ⇒ Vector(dx, dy)}
  }

  case class Vector(x: Int, y: Int) {
    def dot(that: Vector): Int = x * that.x + y * that.y
    def cross(that: Vector): Int = x * that.y - y * that.x
  }
  object Angle{
    def byMeasure(measure: Double): Angle = {
      val rad = measure / 180 * math.Pi
      new Angle(math.sin(rad), math.cos(rad))
    }
    def apply(vector: Vector): Angle = math.sqrt(vector.x * vector.x + vector.y * vector.y) match {case n ⇒ new Angle(vector.y / n, vector.x / n)}
  }
  class Angle private (val sin: Double, val cos: Double) {
    def +(that: Angle): Angle = new Angle(sin * that.cos + cos * that.sin, cos * that.cos - sin * that.sin)
    def -(that: Angle): Angle = new Angle(sin * that.cos - cos * that.sin, cos * that.cos + sin * that.sin)
  }
}


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

const int MOD = 2011;
int inv[2022];
char AA[100][100];
bool visited[100][100];

class Result
{
public:
	int x,y,v;
	Result()
	{}

	Result(int x, int y, int v)
		:x(x),y(y),v(v)
	{}
};

int findexpr(int x, int y, int d)
{
	while(1) {
		if(y < 0 || AA[y][x] == '!') break;
		if(visited[y][x]) break;
		if(AA[y][x] !='.') return y;

		y += d;
	}

	return -1;
}

Result expr(int x, int y);
Result term(int x, int y);
Result factor(int x, int y);
Result powexpr(int x, int y);
Result primary(int x, int y);
Result fraction(int x, int y);
Result digit(int x, int y);

Result expr(int x, int y)
{
	visited[y][x] = true;
	Result a = term(x,y);
	x = a.x; y = a.y;

	while(AA[y][x+1] == '+' || AA[y][x+1] == '-') {
		visited[y][x+1] = true;
		char op = AA[y][x+1];

		Result b = term(x + 3, y);
		x = b.x; y = b.y;
		
		if(op == '+') a.v = (a.v + b.v) % MOD;
		if(op == '-') a.v = (a.v - b.v + MOD) % MOD;
	}

	return Result(x,y,a.v);
}

Result term(int x, int y)
{
	visited[y][x] = true;

	Result a = factor(x, y);
	x = a.x; y = a.y;

	while(AA[y][x+1] == '*') {
		visited[y][x+1] = true;

		Result b = factor(x + 3, y);
		x = b.x; y = b.y;
		a.v *= b.v;
		a.v %= MOD;
	}

	return Result(x,y,a.v);
}

Result factor(int x, int y)
{
	visited[y][x] = true;

	Result a;
	if(AA[y][x] == '-') {
		if(AA[y][x+1] == '-') {
			a = fraction(x, y);
		}
		else {
			a = factor(x + 2, y);
			a.v = (-a.v + MOD) % MOD;
		}
	}
	else {
		a = powexpr(x, y);
	}

	return a;
}

Result powexpr(int x, int y)
{
	visited[y][x] = true;

	Result a = primary(x,y);
	x = a.x; y = a.y;

	if(y!=0 && isdigit(AA[y-1][x])) {
		int pw = AA[y-1][x] - '0';
		int p = a.v;
		int res = 1;
		for(int i=0; i<pw; i++) {
			res *= p;
			res %= MOD;
		}

		a.v = res % MOD;
		a.x += 1;
	}

	return a;
}

Result primary(int x, int y)
{
	visited[y][x] = true;

	Result a;
	if(isdigit(AA[y][x])) {
		a.v = AA[y][x] - '0';
		a.x = x + 1;
		a.y = y;
	}
	else {
		a = expr(x + 2,y);
		a.x += 2;
	}

	return a;
}

Result fraction(int x, int y)
{
	bool findTop=false, findBtm=false;
	Result t, b;

	int tx = x;
	while(AA[y][x] == '-') {
		visited[y][x] = true;
		x++;
	}

	x = tx;
	while(AA[y][x] == '-') {
		if(!findTop) {
			int ty = findexpr(x,y-1,-1);
			if(ty != -1) {
				t = expr(x,ty);
				findTop = true;
			}
		}
		if(!findBtm) {
			int by = findexpr(x,y+1,1);
			if(by != -1) {
				b = expr(x,by);
				findBtm = true;
			}
		}

		x++;
	}

	Result res;
	res.x = x;
	res.y = y;
	res.v = t.v * inv[b.v] % MOD;

	return res;
}

int main()
{
	for(int i=1; i<MOD; i++)
	for(int j=1; j<MOD; j++) 
		if(j * i % MOD == 1) inv[i] = j;

	int N;
	while(cin >> N, N) {
		memset(visited, 0, sizeof(visited));
		for(int i=0; i<100; i++)
		for(int j=0; j<100; j++)
			AA[j][i] = '!';

		for(int i=0; i<N; i++)
			cin >> AA[i];

		cout << expr(0, findexpr(0,0,1)).v << endl;
	}
}

Measured memory_bytes: 0
void main() {
  auto A = ri, B = ri, C = ri, D = ri, E = ri;
  auto arr = [A, B, C, D, E];
  int res = int.max;
  do {
    int tmp;
    foreach(i, v; arr) {
      if(i == 4) tmp += v;
      else tmp = (tmp + v + 9) / 10 * 10;
    }
    
    res = min(res, tmp);
  } while(nextPermutation(arr));
  res.writeln;
}
// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;

typedef long long ll;

const int INF = 1001001001;

int a[12][12];

void solve(){
    
}

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i, n){
      if(s>>i&1){
        cost += c[i];
        rep(j, m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost); 
   
  }
  if(ans == INF) cout << -1 << "\n";
  else cout << ans << "\n";


  return 0;
}




Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC112B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var T = ReadInt;

            michi[] a = new michi[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = new michi() { cost = ReadInt, time = ReadInt };
            }

            if (a.Where(x => x.time <= T).Count() == 0)
            {
                Console.WriteLine("TLE");
                return;
            }
            int ans = a.Where(x => x.time <= T).Select(x => x.cost).Min();

            Console.WriteLine(ans);
        }
        struct michi
        {
            public int cost;
            public int time;
        }

    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
def lscan; gets.split.map(&:to_i); end

mm, dd = lscan

ans = 0

1.upto(mm) do |m|
  1.upto(dd) do |d|
    d1 = d%10
    d10 = d/10
    ans += 1 if d1 >= 2 && d10 >= 2 && d1*d10 == m
  end
end

p ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
 int n,a,b,c;
string s;
 cin >> a>>s;
b=3200;
 cout <<((b<=a)?s:"red" )<<endl;
 return 0;
  }

Measured memory_bytes: 256