akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 998244353;

vector<int> data_bit;
struct BIT{
    void init(int n){
        data_bit.assign(n+1, 0);// 1-indexed [1,n]
    }

    void add(int i, int x){
        while(i < data_bit.size()){
            data_bit[i] += x;
            i += (i & -i);
        }
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += data_bit[i];
            i -= (i & -i);
        }
        return s;
    }
};

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

    vector<pair<int, int>> x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    // compression
    vector<int> yc(n);
    int id = 0;
    for(int i=0; i<n; i++){
        yc[y[i].second] = id;
        id += 1;
    }

    BIT bitl;
    bitl.init(n);

    vector<int> UL(n), DL(n), UR(n), DR(n);
    for(int i=0; i<n; i++){
        int node = x[i].second;
        DL[i] = bitl.sum(yc[node]+1);
        UL[i] = i - DL[i];
        bitl.add(yc[node]+1,1);
    }

    BIT bitr;
    bitr.init(n);

    for(int i=n-1; i>=0; i--){
        int node = x[i].second;
        DR[i] = bitr.sum(yc[node]+1);
        UR[i] = (n-1-i) - DR[i];
        bitr.add(yc[node]+1,1);
    }
    //for(int i=0; i<n; i++) cout << DL[i] << " " << UL[i] << " " << DR[i] << " " << UR[i] << endl;

    vector<long long int> pow2(n+1,1);// pow2[i] = 2^i
    for(int i=0; i<n; i++){
        pow2[i+1] = pow2[i] * 2;
        pow2[i+1] %= MOD;
    }

    vector<vector<int>> vec = {DL, UL, DR, UR};
    long long int ans = 0;
    for(int i=0; i<n; i++){
        for(int bit=0; bit<(1<<4); bit++){
            long long int count = 1;
            vector<int> flag(4);
            for(int j=0; j<4; j++){
                if(bit >> j & 1){
                    count *= ((pow2[vec[j][i]] - 1) % MOD + MOD) % MOD;
                    count %= MOD;

                    if(vec[j][i] > 0) flag[j] = 1;
                }
            }
                 if(flag[0] == 1 && flag[3] == 1) count *= 2;
            else if(flag[1] == 1 && flag[2] == 1) count *= 2;
            ans += count;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18744
#include <iostream>
#include <stdio.h>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	vector<int> vc; // <T>でT型のvector
	int n;
	cin >> n;
	int m = n;
	while (m--) {
		int x;
		cin >> x;
		vc.push_back(x);
	}
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += vc[i];
	}
	
	int sum1 = sum;
	int sum2 = 0;
	int min = 10000;
	for (int i = 0; i < n; i++) {
		sum1 -= vc[i];
		sum2 += vc[i];
		if (abs(sum2 - sum1) < min) {
			min = abs(sum2 - sum1);
		}
	}
	printf("%d", min);
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = int(input())
p = list(map(int,input().split(" ")))

m = p[0]
res = 0
for i in p:
    #最小値更新
    if i <= m:
        m = i
    if i == m:
        res += 1
        
print(res)
        
    
    

Measured memory_bytes: 24744
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    if(n%2==0){
        cout << n/2 <<endl;
    } else 
        cout << n/2+1 << endl;
    return 0;
}

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

using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;


int main() {
int n; cin >> n;
int r[n],g[n],b[n];
string s;cin >> s;
if(s[0]=='R'){r[0]=1;g[0] = 0;b[0] = 0;}
if(s[0]=='G'){g[0]=1;r[0] = 0;b[0] = 0;}
if(s[0]=='B'){b[0]=1;g[0] = 0;r[0] = 0;}
for (int i = 1; i < n; ++i)
{
   if(s[i]=='R'){r[i]=r[i-1]+1;g[i] = g[i-1];b[i] = b[i-1];}
   if(s[i]=='G'){g[i]=g[i-1]+1;r[i] = r[i-1];b[i] = b[i-1];}
   if(s[i]=='B'){b[i]=b[i-1]+1;g[i] = g[i-1];r[i] = r[i-1];}
}
ll cnt=0;
for (int i = 0; i < n-2; ++i)
{
   for (int j = i+1; j <n-1 ; ++j)
   {
       if (s[i]=='R')
       {
           if(s[j]=='G'){
            cnt += b[n-1]-b[j];
            if(s[2*j-i]=='B')cnt--;
           }
           if(s[j]=='B'){
            cnt += g[n-1]-g[j];
            if(s[2*j-i]=='G')cnt--;
           }
       }
       if (s[i]=='G')
       {
           if(s[j]=='R'){
            cnt += b[n-1]-b[j];
            if(s[2*j-i]=='B')cnt--;
           }
           if(s[j]=='B'){
            cnt += r[n-1]-r[j];
            if(s[2*j-i]=='R')cnt--;
           }
       }
       if (s[i]=='B')
       {
           if(s[j]=='G'){
            cnt += r[n-1]-r[j];
            if(s[2*j-i]=='R')cnt--;
           }
           if(s[j]=='R'){
            cnt += g[n-1]-g[j];
            if(s[2*j-i]=='G')cnt--;
           }
       }       
   }
}
/*for (int i = 0; i < n; ++i)
{
    cout << r[i] << g[i] << b[i] << "\n";
}*/
cout << cnt << endl;
return 0;
}




Measured memory_bytes: 3684
W, H, N = map(int, input().split())
zahyo = [list(map(int, input().split())) for i in range(N)]
x_min = y_min = 0
x_max = W
y_max = H
for i in range(N):
    if zahyo[i][2] == 1:
        if x_min < zahyo[i][0]:
            x_min = zahyo[i][0]
    
    elif zahyo[i][2] == 2:
        if zahyo[i][0] < x_max:
            x_max = zahyo[i][0]
            
    elif zahyo[i][2] == 3:
        if y_min < zahyo[i][1]:
            y_min = zahyo[i][1]
            
    elif zahyo[i][2] == 4:
        if zahyo[i][1] < y_max:
            y_max = zahyo[i][1]
    
if (x_max - x_min) > 0 and  (y_max - y_min) > 0:
    print((x_max - x_min) * (y_max - y_min))
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
// #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
bool desc_sort(const int & lhs,const int & rhs)
{
    return lhs>rhs;
}
bool desc_pii_sort(const pii & lhs , const pii & rhs)
{
    return lhs>rhs;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.F = lhs.S;
    a.S = lhs.F;
    b.F = rhs.S;
    b.S = rhs.F;
    return a<b;
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif


// #define int long long
#define modd 1e0



inline ll fast_expo(ll base,ll power,ll modulo=modd){
    base%=modulo;
    if (base<0LL) base+=modulo;
    ll x=base,cnt=power,ans=1LL;
    while(cnt){
        if (cnt&1LL) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1LL;
    }
    // int tmp=ans;
    return ans;
}
inline ll inv(ll base,ll modulo=modd){
    return fast_expo(base,modulo-2LL,modulo);
}

int c[4];

signed main()
{
    #ifdef _SUBLIME
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    fio;
    int t;
    cin>>t;
    while(t--)
    {
    	string s;
    	cin>>s;
    	if(s=="AC")
    		c[0]++;
    	else if(s=="WA")
    		c[1]++;
    	else if(s=="TLE")
    		c[2]++;
    	else
    		c[3]++;
    }
    cout<<"AC x "<<c[0]<<endl;
    cout<<"WA x "<<c[1]<<endl;
    cout<<"TLE x "<<c[2]<<endl;
    cout<<"RE x "<<c[3]<<endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] v = new long[N+1];

        long max = Long.MIN_VALUE;
        for(int i = 1; i<=N; i++) {
            v[i] = sc.nextLong();
        }
        for(int i = 0; i<=N; i++) {
            for(int j = 0; j<=N; j++) {
                if(i+j > N) continue;
                if(K-i-j < 0) continue;
                long tmp = 0;
                PriorityQueue<Long> queue = new PriorityQueue<Long>();
                for(int l = 1; l<=N; l++) {
                    if(l<=i || (N-j+1)<=l) {
                        tmp += v[l];
                        queue.add(v[l]);
                    }
                }
                for(int l = 0; l<(K-i-j); l++) {
                    long tmp2 = tmp;
                    if(queue.size()!=0) tmp2 -= queue.poll();
                    tmp = Math.max(tmp,tmp2);
                }
                //System.out.println(i+" " + j+" " +(K-i-j)+" "+ tmp);
                max = Math.max(max, tmp);
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define min(a,b) (((a)>(b))?(b):(a))
#define max(a,b) (((a)>(b))?(a):(b))
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	int n;cin>>n;
	string S;cin>>S;
	int sum[n+10];
	sum[0]=0;
	for(int i=0;i<n;i++){
		sum[i+1]=sum[i]+(S[i]=='W'?1:0);
	}
	int ans=n;
	for(int i=0;i<=n;i++){
		int left=sum[i]-sum[0];
		int right=n-i-(sum[n]-sum[i]);
		ans=min(left+right,ans);
	}
	cout<<ans;
}


Measured memory_bytes: 1796
#include <stdio.h>
#include <stdlib.h>

#define LL long long int

int cmpLL(const void *n1, const void *n2) {

    if (*(LL *)n1 > *(LL *)n2) {
        return 1;
    } else if (*(LL *)n1 < *(LL *)n2) {
        return -1;
    }

    return 0;
}


int main(void) {

    int n;
    scanf("%d", &n);
    LL *a = (LL *)malloc(n * sizeof(LL));
    LL *b = (LL *)malloc(n * sizeof(LL));
    for (int i = 0; i < n; i ++) {
        scanf("%lld %lld", &a[i], &b[i]);
    }

    qsort(a, n, sizeof(LL), cmpLL);
    qsort(b, n, sizeof(LL), cmpLL);

    int ret;
    if (n % 2 == 1) {
        ret = b[(n - 1) / 2] - a[(n - 1) / 2] + 1;
    } else {
        ret = (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1;
    }

    printf("%d", ret);

    return 0;
}

Measured memory_bytes: 6396
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 998244353;
int m, p1, p2, a, b; string s;
int main() {
	while (cin >> m >> p1 >> p2, m || p1 || p2) {
		vector<vector<pair<int, int> > > G(p1 + p2);
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> s; a--, b--;
			G[a].push_back(make_pair(b, s == "yes" ? 0 : 1));
			G[b].push_back(make_pair(a, s == "yes" ? 0 : 1));
		}
		vector<int> col(p1 + p2), comp(p1 + p2);
		vector<bool> vis(p1 + p2);
		vector<vector<int> > comps;
		for (int i = 0; i < p1 + p2; i++) {
			if (vis[i]) continue;
			queue<int> que; que.push(i);
			vector<int> w = { i }; vis[i] = true;
			while (!que.empty()) {
				int u = que.front(); que.pop();
				for (pair<int, int> j : G[u]) {
					if (!vis[j.first]) {
						vis[j.first] = true;
						col[j.first] = col[u] ^ j.second;
						w.push_back(j.first);
						que.push(j.first);
					}
				}
			}
			comps.push_back(w);
		}
		vector<int> e1(comps.size()), e2(comps.size());
		for (int i = 0; i < comps.size(); i++) {
			for (int j : comps[i]) {
				if (col[j] == 0) e1[i]++;
				else e2[i]++;
			}
		}
		vector<vector<int> > dp(comps.size() + 1, vector<int>(p1 + 1, false)); dp[0][0] = true;
		vector<vector<vector<int> > > dp2(comps.size() + 1, vector<vector<int> >(p1 + 1));
		for (int i = 0; i < comps.size(); i++) {
			for (int j = 0; j <= p1; j++) {
				if (j >= e1[i] && dp[i][j - e1[i]]) {
					dp[i + 1][j] += dp[i][j - e1[i]];
					dp2[i + 1][j] = dp2[i][j - e1[i]];
					dp2[i + 1][j].push_back(i);
				}
				if (j >= e2[i] && dp[i][j - e2[i]]) {
					dp[i + 1][j] += dp[i][j - e2[i]];
					dp2[i + 1][j] = dp2[i][j - e2[i]];
				}
				dp[i + 1][j] %= mod;
			}
		}
		if (dp[comps.size()][p1] != 1) cout << "no" << endl;
		else {
			vector<int> res = dp2[comps.size()][p1];
			vector<bool> ret(p1 + p2, true);
			for (int i = 0; i < comps.size(); i++) {
				for (int j : comps[i]) {
					if (col[j] ^ (binary_search(res.begin(), res.end(), i) ? 0 : 1)) ret[j] = false;
				}
			}
			for (int i = 0; i < p1 + p2; i++) {
				if (ret[i]) cout << i + 1 << endl;
			}
			cout << "end" << endl;
		}
	}
	return 0;
}

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


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a;
    vector<int> b;
    rep(i, n) {
        int x;
        cin >> x;
        if (x>=0) a.push_back(x);
        else b.push_back(-x);
    }
    sort(whole(a));
    sort(whole(b));
    int ans = INF;
    rep(i, k+1) {
        int l = i;
        int r = k-i;
        if (l>a.size() || r>b.size()) continue;
        int ia = 0, ib = 0;
        if (l>0) ia = a[l-1];
        if (r>0) ib = b[r-1];
        chmin(ans, ia*2+ib);
        chmin(ans, ib*2+ia);
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    for (int& i : a)
        cin >> i;
    bool ok = true;
    for (int i : a)
        if (!(i % 2))
            ok &= (!(i % 3) || !(i % 5));
    if (ok)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    GAME_OVER;
}

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

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'R') {
      cnt = 1;
    }
  }
  for (int i = 1; i < 3; i++) {
    if (s.at(i-1) == 'R' && s.at(i) == 'R') {
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int a[3][3];
  int d[3][3];
  int n;
  rep(i,3)rep(j,3)cin >> a[i][j];
  cin >> n;
  rep(k,n){
    int b;
    cin >> b;
    rep(i,3)rep(j,3)if(a[i][j]==b)d[i][j]=1;
  }
  bool ans = false;
  rep(i,3){
    int count = 0;
    rep(j,3)count += d[i][j];
    if(count==3)ans = true;
  }
  rep(i,3){
    int count = 0;
    rep(j,3)count += d[j][i];
    if(count==3)ans = true;
  }
  {
    int count = 0;
    rep(j,3)count += d[j][j];
    if(count==3)ans = true;
  }
  {
    int count = 0;
    rep(j,3)count += d[j][2-j];
    if(count==3)ans = true;
  }
  cout << (ans?"Yes":"No");
}


Measured memory_bytes: 256
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
#define bit(x, i) (x & (1 << i))
#define IN(i, l, r) (l < i && i < r)
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getS(x) scanf("%s", x)
#define clr(a, x) memset(a, x, sizeof(a))
#define char2Int(c) (c - '0')
#define SZ(x) ((int)((x).size()))
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// for debug
inline void pisz(int n) { printf("%d\n", n); }
#define DBG(vari) cerr << #vari << " = " << (vari) << endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ')
#define printV(a) printA(a, 0, a.size() - 1)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

// struct

// data

int main() {
  int n;
  int a[200010];
  getI(n);
  REP(i, 0, n) getI(a[i]);
  ll ans = 0;
  REP(i, 1, n) {
    if (a[i] >= a[i - 1]) continue;
    ans += a[i - 1] - a[i];
    a[i] = a[i - 1];
  }
  printf("%lld\n", ans);
  return 0;
}


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

void solve(long long N, long long M_a, long long M_b, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
    // min cost for i'th chem with j grams of A and k grams of B
    vector<vector<vector<int>>> dp(41, vector<vector<int>>(401, vector<int>(401, 50000)));
    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
      for (int costA = 0; costA <= 400; costA++) {
        for (int costB = 0; costB <= 400; costB++) {
	    if (dp[i][costA][costB] == 50000) continue;
	    dp[i+1][costA][costB] = min(dp[i+1][costA][costB], dp[i][costA][costB]);
	    dp[i+1][costA + a[i]][costB+b[i]] = min(dp[i+1][costA + a[i]][costB + b[i]], dp[i][costA][costB] + (int)c[i]);
        }
      }
    }
    int res = 50000;
    for (int ca = 1; ca < 401; ca++) {
      for (int cb = 1; cb < 401; cb++) {
	  if (ca * M_b == cb * M_a) res = min(res, dp[N][ca][cb]);
      }
    }
    if (res == 50000) cout << -1 << endl;
    else cout << res << endl;
}

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

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


Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
#define int long long
signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int r;
	cin>>r;
	cout<<3*r*r<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int row,col,k;
	cin>>row>>col>>k;
	char c;
	int arr[row+1][col+1];
	int cnt=0,total=0;
	for(int i=0;i<row;i++)
	{
	    for(int j=0;j<col;j++)
	    {
	        cin>>c;
	        if(c=='#')
	        {
	            arr[i][j]=1;
	            
	        }
	        else
	        {
	            arr[i][j]=0;
	        }
	        
	    }
	}
	
	
	
	
	
	for(int row1=0;row1<(1<<row);row1++)
	{
	    for(int col1=0;col1<(1<<col);col1++)
	    {
	        total=0;
	        for(int i=0;i<row;i++)
	        {
	            for(int j=0;j<col;j++)
	            {
	               
	               if (((row1>>i)&(1))==0 and ((col1>>j)&(1))==0 and arr[i][j]==1)total = total + 1;

	               
	               
	                
	            }
	        }
	        if(total==k)
	        {
	            cnt++;
	        }
	    }
	}
	
	
	cout<<cnt<<endl;
	
	
	
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

  int n; cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (d[i-1] != d[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b, x = na()
s = x/a
import math

if s <= a*b/2:
    aa = s*2/b
    print("{:.14f}\n".format(math.atan2(b, aa)/math.pi*180))
else:
    bb = (s-a*b/2)*2/a
    print("{:.14f}\n".format(math.atan2(b-bb, a)/math.pi*180))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
  cin >>N;
  int A[N];
  int count=0;
  for(int i=0;i<N;i++){
  cin>> A[i];
  }
  for(int i=0;i<N;i++){
    int minj=i;
  	for(int j=i;j<N;j++){
    	if(A[j]<A[minj]){
          minj=j;}  	
    }
    if(A[i]!=A[minj]){swap(A[i],A[minj]);count++;}       
  }
   for(int i=0;i<N-1;i++){
  cout << A[i]<<' ';
  }
  cout <<A[N-1]<<endl;
 cout <<count<<endl; 
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n) {
        if (s[i] == 'R') a[i] = 0;
        if (s[i] == 'G') a[i] = 1;
        if (s[i] == 'B') a[i] = 2;
    }
    vector<ll> cnt(3);
    rep(i, n) cnt[a[i]]++;
    ll ans = 1;
    rep(i, 3) ans *= cnt[i];
    rep(j, n)rep(i, j) {
        int k = j + (j-i);
        if (k < n) {
            if (a[i] == a[j]) continue;
            if (a[i] == a[k]) continue;
            if (a[k] == a[j]) continue;
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#input phase
N = int(input())
V = list(map(int,input().split()))
#make dictionary
D1 = {}
D2 = {}
#append element to dictionary
for i in range(N):
    if i % 2 == 0 :
        if V[i] in D1 :
            D1[V[i]] += 1
        else:
            D1[V[i]] = 1
    else:
        if V[i] in D2 :
            D2[V[i]] += 1
        else:
            D2[V[i]] = 1
#define max-value of each dictionary
maxD1 = max(D1.values())
maxD2 = max(D2.values())
# I haven't appreciated dictionary method well...
if max(D1, key=D1.get) != max(D2, key=D2.get):
    print(N-maxD1-maxD2)
else:
    D1[max(D1, key=D1.get)] = 0
    D2[max(D2, key=D2.get)] = 0
    maxD12 = max(D1.values())
    maxD22 = max(D2.values())
    if maxD12 >= maxD22 :
        if len(D1) > 1 :
            print(N-maxD12-maxD2)
        else :
            print(N-maxD2)
    else :
        if len(D2) > 1 :
            print(N-maxD1-maxD22)
        else :
            print(N-maxD2)


Measured memory_bytes: 17632
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

void solve(){
  string s; cin >> s;
  int rc = 0, n = s.size();
  vector<int> ans(n, 0);
  for(int i = 0; i < n; i++){
    if(s[i] == 'L'){
      int x = i, mc, sum, a, b, lc = 1;
      while(i + 1 < n && s[i + 1] == 'L'){
        lc++;
        i++;
      }
      sum = lc + rc;
      if(sum % 2 == 0){
        ans[x - 1] = ans[x] = sum / 2;
      }
      else{
        if(rc > lc){
          if(rc % 2 == 1){
            ans[x - 1] = sum / 2 + 1;
            ans[x] = sum / 2;
          }
          else{
            ans[x - 1] = sum / 2;
            ans[x] = sum / 2 + 1;
          }
        }
        else{
          if(lc % 2 == 1){
            ans[x] = sum / 2 + 1;
            ans[x - 1] = sum / 2;
          }
          else{
            ans[x] = sum / 2;
            ans[x - 1] = sum / 2 + 1;
          }
        }
      }
      rc = 0;
    }
    else rc++;
  }
  for(int i = 0; i < n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int map[10][10];
int deep = 0;

void small(int inc, int x, int y);
void medium(int inc, int x, int y);
void large(int inc, int x, int y);
int count_and_max(void);
int max(int a, int b);

int main(void)
{
	int x, y;
	int inc;
	int count;

	while (scanf("%d,%d,%d", &x, &y, &inc) != EOF){
		map[y][x]++;
		small(inc, x, y);
		medium(inc, x, y);
		large(inc, x, y);
	}
	
	count = count_and_max();
	printf("%d\n%d\n", count, deep);

	return (0);
}

void small(int inc, int x, int y)
{
	int i;
	int ex[4] = {1, -1, 0, 0};
	int ey[4] = {0, 0, 1, -1};

		if (inc >= 1){
			for (i = 0; i < 4; i++){
				if (0 <= y + ey[i] && y + ey[i] <= 9 && 0 <= x + ex[i] && x + ex[i] <= 9){
					map[y + ey[i]][x + ex[i]]++;
				}
			}
		}
}

void medium(int inc, int x, int y)
{
	int i;
	int ex[4] = {1, 1, -1, -1};
	int ey[4] = {1, -1, 1, -1};

	if (inc >= 2){
		for (i = 0; i < 4; i++){
			if (0 <= y + ey[i] && y + ey[i] <= 9 && 0 <= x + ex[i] && x + ex[i] <= 9){
				map[y + ey[i]][x + ex[i]]++;
			}
		}
	}
}

void large(int inc, int x, int y)
{
	int i;
	int ex[4] = {2, -2, 0, 0};
	int ey[4] = {0, 0, 2, -2};

	if (inc >= 3){
		for (i = 0; i < 4; i++){
			if (0 <= y + ey[i] && y + ey[i] <= 9 && 0 <= x + ex[i] && x + ex[i] <= 9){
				map[y + ey[i]][x + ex[i]]++;
			}
		}
	}
}

int count_and_max(void)
{
	int ans = 0;
	int i, j;

	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			if (map[i][j] == 0){
				ans++;
			}
			deep = max(deep, map[i][j]);
		}
	}
	
	return (ans);
}

int max(int a, int b)
{
	if (a >= b){
		return (a);
	}
	else {
		return (b);
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e6+5 ;

ll check(ll a, ll b, ll c)
{
    if(a && b&& c)
    {
        return 6;
    }
    int cnt[2] = {0};
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;
    if(cnt[1]==2)
    {
        return 2;
    }
    return 0;
}

void SOLVE(int cas)
{
    vector<ll>v(7);
    for(ll &i:v)
    {
        scanf("%lld",&i);
    }
    ll ans =0;
    ans+= v[1]*2;
    ll tmp= (v[0]/2)*4 + (v[3]/2)*4 + (v[4]/2)*4;
    if(v[0] && v[3] && v[4])
        tmp+= check(v[0]%2 , v[3]%2 , v[4]%2);
    ll mini = min(v[0], min(v[3],v[4]));
    ll tmp2 = mini*6 + ((v[0]-mini)/2)*4 + ((v[3]-mini)/2)*4 + ((v[4]-mini)/2)*4 ;

    ans+= max(tmp, tmp2);
    //debug(ans);
    printf("%lld\n",ans/2);



}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n; cin >> n;
  vector<ll> p(n);
  rep(i, n)
    cin >> p[i];
  
  ll cnt = 0;
  for(ll i=1; i<n-1; i++){
    if(p[i-1]<p[i] && p[i+1]>p[i])
      cnt++;
    if(p[i-1]>p[i] && p[i+1]<p[i])
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(ll,h,w,n);
    int m=max(h,w);
    p((n+m-1)/m);
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n/(a+b)*a + min(a,n%(a+b))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll d[2][n+1];
  d[0][0]=d[1][0]=0;
  rep(i,2) {
    rep(j,n) R d[i][j+1];
    rep(j,n) d[i][j+1]+=d[i][j];
  }
  ll ans=0;
  rep(i,n) {
    ans=max(ans,d[0][i+1]+d[1][n]-d[1][i]);
  }
  pr(ans);
}

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


Measured memory_bytes: 256
long long N,a,b,c,t;
main(){
	scanf("%lld",&N);
	for(a=1;a<=3500;++a){
		for(b=1;b<=a;++b){
			t=4*a*b-N*b-N*a;
			if(t>0){
				c=N*a*b/t;
				if(4*a*b*c==N*(a*b+b*c+c*a)){
					return!printf("%lld %lld %lld",a,b,c);
				}
			}
		}
	}
}


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	string s,t;
	cin>>s>>t;
	long long ans=inf;

	for(long long i=0;i+t.size()-1<s.size();i++){
		string hoge=s.substr(i,t.size());
		long long pre=0;
		for(long long j=0;j<t.size();j++){
			if(hoge.at(j)!=t.at(j)) pre++;
		}

		chmin(ans,pre);
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 string s; cin >> s;
	int n = s.size();
	int minn = 999;
	for (int i = 0; i <= n - 3;i++) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		minn = min(minn, abs(num - 753));
	}
	cout<<minn<< endl;

 

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while(true){
    int n,m; double p; cin >> n >> m >> p;
        if(n+m+p == 0)break;
    vi v(2000,0); int sum = 0;
    rep(i,n){
        int temp;cin >> temp;
        v[i+1]=temp;sum+=temp*100;
    }
    double money = (double)(sum-sum*(p/100));
    if(v[m]) cout << (int)money/v[m] << endl;
    else
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<queue>

using namespace std;

int h, w, Left = 0, nowX = 0, nowY = 0;
char box;
bool pass[9][9];

int main(){
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> box;
			if (box == '#' && (i != 0 || j != 0)){
				Left++;
				pass[i][j] = true;
			}
		}
	}

	for (int i = 0; i < h + w - 2; i++){
		if (pass[nowY][nowX + 1]){
			nowX = nowX + 1;
			Left--;
		}
		else if (pass[nowY + 1][nowX]){
			nowY = nowY + 1;
			Left--;
		}
	}

	if (Left == 0 && nowX == w - 1 && nowY == h - 1){
		cout << "Possible\n";
	}else{
		cout << "Impossible\n";
	}

	return 0;
}

Measured memory_bytes: 384
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;
	cin >> x >> y;
	int a[] = {300000,200000,100000};
	int sum = 0;
	if(x <= 3) sum += a[x-1];
	if(y <= 3) sum += a[y-1];
	if(x == 1 && y == 1) sum += 400000;
	cout << sum << '\n';

	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    var xor = 0L
    var bitCount = 0L
    repeat(readLine()!!.trim().toInt()){
        val n = readLine()!!.trim().toLong()
        xor = xor xor n
        bitCount += n % 2
    }
    println(if (xor > 1L || (xor == 0L && bitCount > 0)) "Alice" else "Bob")
}


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

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

int n;
int x[110];

int main() {
    
    cin >> n;
    rep(i, n) cin >> x[i];

    
    int l = 1, r = 100;
    rep (i, n) {
        l = min(l, x[i]);
        r = max(r, x[i]);
    }

    int ans = 1e9;
    for (int i = l; i < r; i++) {
        int cost = 0;
        rep(j, n) cost += (i - x[j]) * (i - x[j]);
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i, N - 1) {
        int sum1 = a[i] + a[i + 1];
        if (sum1 <= x) continue;

        int diff = sum1 - x;
        ans += diff;

        a[i+1] = max(0LL, a[i+1] - diff);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

int main(){
    string S;

    cin >> S;

    int n = S.size();
    for (int i : irange(0, n)){
        if (i % 2 == 0){
            if (S[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
        if (i % 2 == 1) {
            if (S[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define T 1001
#define M 1000000007
#define E e[x][i]
#define S e[x].size()
using namespace std;
typedef long long ll;
int N,s,t,j;
string n[T];
vector<int> e[T];
 
ll func(int x){
  ll r=0,i;
  if(!S){
    if(n[x]=="E") return 1;
    return 2;
  }
  if(n[x][0]=='E'){
    r++;
    for(i=0;i<S;i++) r*=func(E);
    if(n[x]=="E?") r++;
  }
  else if(n[x][0]=='A'){
    for(i=0;i<S;i++) r+=func(E);
    if(n[x]=="A?") r++;
  }else{
    r++;
    for(i=0;i<S;i++) r*=(1+func(E));
    if(n[x]=="R") r--;
  }
  return r%M;
}

main(){
  cin>>N;
  for(j=0;j<N;j++) cin>>n[j];
  while(--N) cin>>s>>t,e[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
}

Measured memory_bytes: 1356
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const int dh[4] = {0, 1, 0, -1};
const int dw[4] = {1, 0, -1, 0};


int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    
    auto bfs = [&] (int sh, int sw) {
        if (S[sh][sw] == '#') return -1;
        vector<vector<bool>> seen(H, vector<bool>(W, false));
        vector<vector<int>> dist(H, vector<int>(W, INF));
        dist[sh][sw] = 0;
        queue<pair<int, int>> que;
        que.emplace(sh, sw);
        int ret = 0;
        while (!que.empty()) {
            int h, w; tie(h, w) = que.front(); que.pop();
            if (seen[h][w]) continue;
            seen[h][w] = true;
            for (int i = 0; i < 4; i++) {
                int nh = h + dh[i], nw = w + dw[i];
                if (nh < 0 || H <= nh || nw < 0 || W <= nw) continue;
                if (seen[nh][nw]) continue;
                if (S[nh][nw] == '#') continue;
                dist[nh][nw] = dist[h][w] +1;
                chmax(ret, dist[nh][nw]);
                que.emplace(nh, nw);
            }
        }
        return ret;
    };
    
    int ans = -1;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        if (S[i][j] == '#')continue;
        int res = bfs(i, j);
        chmax(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <queue>
#include <ctype.h>

using namespace std;

struct Node {
  int s;
  int x;
  int y;
  int cost;
  Node() {;}
  Node(int s, int x, int y, int c) : s(s), x(x), y(y), cost(c) {;}
  bool operator<(const Node &rhs) const { return cost > rhs.cost; }
};

char field[100][100];
bool visit[2][100][100];
static const int dx[9] = { 1, 1, 1, 1, 1, 2, 2, 2, 3 };
static const int dy[9] = { -2, -1, 0, 1, 2, -1, 0, 1, 0 };

int main() {
  int w, h;
  while (scanf("%d %d", &w, &h), w|h) {
    priority_queue<Node> que;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        char c;
        scanf(" %c ", &c);
        field[y][x] = c;
        if (c == 'S') {
          que.push(Node(0, x, y, 0));
          que.push(Node(1, x, y, 0));
        }
      }
    }
    memset(visit, false, sizeof(visit));
    while (!que.empty()) {
      Node node = que.top();
      que.pop();
      if (visit[node.s][node.y][node.x]) { continue; }
      visit[node.s][node.y][node.x] = true;
      if (field[node.y][node.x] == 'T') {
        printf("%d\n", node.cost);
        goto next;
      }
      for (int i = 0; i < 9; i++) {
        int ns = 1 - node.s;
        int nx = node.x + (node.s == 0 ? dx[i] : -dx[i]);
        int ny = node.y + dy[i];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h || visit[ns][ny][nx] || field[ny][nx] == 'X') { continue; }
        int ncost = node.cost;
        if (isdigit(field[ny][nx])) {
          ncost += field[ny][nx] - '0';
        }
        que.push(Node(ns, nx, ny, ncost));
      }
    }
    puts("-1");
next:;
  }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	int n; cin>>n;
	int a[120]={0};
	for(int i=0;i<n;i++) cin>>a[i];

	int cnt=0;
	for(int i=0;i<n-1;i++){
		if(a[i] == a[i+1]){
			a[i+1] = INF;
			cnt++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def inpl():
    return list(map(int, input().split()))


N, A, B, C, D = inpl()
S = "#" + input() + "#"
section = [-1 for i in range(N + 2)]
ischange = defaultdict(lambda: False)
interval = defaultdict(lambda: [-1, -1])
sec_num = 0

flag = True
for i, s in enumerate(zip(S, S[1:])):
    if s == ("#", "#"):
        sec_num += 1
        section[i] = -1
        section[i + 1] = -1
        flag = True
    else:
        section[i] = sec_num
        section[i + 1] = sec_num
        if flag is True:
            interval[sec_num][0] = sec_num
            flag = False
        else:
            interval[sec_num][1] = sec_num + 1
    if B - 1 <= i < D and i < N and S[i] + S[i + 1] + S[i + 2] == "...":
        ischange[sec_num] = True

if section[A] != section[C] or section[B] != section[D]:
    print("No")
elif section[A] != section[B]:
    print("Yes")
elif C < D:
    print("Yes")
elif ischange[section[A]] is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5356
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  const int B = 26;
  ll n;
  string ans;
  cin >> n;

  while (n != 0) {
    n--;
    char tmp = n % B + 'a';
    ans.push_back(tmp);
    n /= B;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3628