akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >>s;

    int cnt=0, answer=0;
    string ss=s;

    for(int i=0; i<s.size(); i++){
        if((i+1)%2==0 && s[i]=='1'){
            s[i]='0';
            cnt++;
        }
        if((i+1)%2==1&&s[i]=='0'){
          s[i]='1';
            cnt++;
        }
    }
    answer=cnt;
    cnt=0;

    s=ss;

    for(int i=0; i<s.size(); i++){
          if((i+1)%2==0&&s[i]=='0'){
              s[i]='1';
              cnt++;
          }
          if((i+1)%2==1&&s[i]=='1'){
              s[i]='0';
              cnt++;
          }
    }
    cout <<min(answer,cnt) <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int H,W,K;
    cin>>H>>W>>K;
    string T[H];
    int n=H+W;
    for(int i=0;i<H;i++){
        cin>>T[i];
    }
    int count=0;
    int answer=0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                S.push_back(i);
            }
        }
        int P[S.size()];
        for (int i = 0; i < (int)S.size(); ++i) {
            P[i]=S[i];
        }
        bool flag=true;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                for(int k=0;k<(int)S.size();k++){
                    if(i==P[k]){
                        flag=false;
                    }
                    else if(P[k]>H-1 &j==P[k]-H){
                        flag=false;
                    }
                }
                if(flag){
                    if(T[i][j]=='#'){
                        count++;
                    }
                }
                flag=true;
            }
        }
        if(count==K){
            answer++;
        }
        count=0;
    }
    cout<<answer<<endl;
}


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

const int mxN = 52, MOD = 1e9 + 7;
long long n, k;
vector<vector<long long>> M(50, vector<long long>(50));

vector<vector<long long>> multiply(vector<vector<long long>> mat1, vector<vector<long long>> mat2)
{
    int N = mat1.size();
    vector<vector<long long>> res(N, vector<long long>(N));
    int i, j, k;
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            res[i][j] = 0;
            for (k = 0; k < N; k++)
            {
                res[i][j] += mat1[i][k] * mat2[k][j];
                res[i][j] %= MOD;
            }
        }
    }
    return res;
}

vector<vector<long long>> mexp(long long k)
{
    if (k == 1)
    {
        return M;
    }
    vector<vector<long long>> ret;
    vector<vector<long long>> rec = mexp(k / 2);
    if (k % 2 == 0)
    {
        ret = multiply(rec, rec);
    }
    else
    {
        ret = multiply(rec, rec);
        ret = multiply(ret, M);
    }
    return ret;
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> M[i][j];

    vector<vector<long long>> ret = mexp(k);
    long long ans = 0;
    for (auto &a : ret)
    {
        for (auto &n : a)
        {
            ans += n;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib> 
using namespace std;
static const int N = 1000;

int lcs(string X,string Y){
	int **c=(int **)malloc(sizeof(int *)*1001);
	for(int i=0;i<1001;i++){
		c[i]=(int *)malloc(sizeof(int)*1001);
	}
	int m=X.size();
	int n=Y.size();
	int maxl=0;
	X=' '+X;
	Y=' '+Y;
	c[0][0]=0;
	for(int i=1;i<=m;i++) c[i][0]=0;
	for(int j=1;j<=n;j++) c[0][j]=0;
	
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(X[i]==Y[j]){
				c[i][j]=c[i-1][j-1]+1;
			}else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			maxl=max(maxl,c[i][j]);
		}
	}
	for(int i=0;i<1001;i++){
		free(c[i]);
	}
	free(c);
	return maxl;
}

int main(){
	string s1,s2;
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cin >> s1 >> s2;
		cout << lcs(s1,s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 7124
n = gets(chomp:true).to_i
t = []

def h1(value, n)
  value % n
end

def h2(value, n)
  1 + (value % (n-1))
end

def h(value, i, n)
  ( h1(value, n) + i * h2(value, n) ) % n
end

def hash_insert(value, n ,t)
  i = 0
  while true
    j = h(value, i, n)
    if t[j].nil?
      t[j] = value
      break
    else
      i += 1
    end
  end
end

def hash_find(value, n ,t)
  i = 0
  while true
    j = h(value, i, n)
    if t[j] == value
      break "yes"
    elsif t[j].nil? || i >= n
      break "no"
    end
    i += 1
  end
end

(0...n).each do |i|
  order, value = gets.split.map{|a|
    if a[0] == "f"
      a = false
    elsif a[0] == "i"
      a = true
    else
      a.tr("ACGT","1234").to_i
    end
    }
  if order
    hash_insert(value, n, t)
  else
    puts hash_find(value, n, t)
  end
end


Measured memory_bytes: 14996
#include<stdio.h>
#define MAXN 1000+5
#define INF -1
struct node
{
	int r,l,p;
}T[MAXN];
void began(int u)
{
	if(u==INF)return;
	printf(" %d",u);
	began(T[u].l);
	began(T[u].r);
}
void middle(int u)
{
	if(u==INF)return;
	middle(T[u].l);
	printf(" %d",u);
	middle(T[u].r);
}
void endl(int u)
{
	if(u==INF)return;
	endl(T[u].l);
	endl(T[u].r);
	printf(" %d",u);
}
int main()
{
	int N,root;
	scanf("%d",&N);
	int i,v,R,L;
	for(i=0;i<N;i++)
	{
		T[i].l=INF;
		T[i].p=INF;
		T[i].r=INF;	
	} 
	for(i=0;i<N;i++)
	{
		scanf("%d%d%d",&v,&L,&R);
		T[v].l=L;
		T[v].r=R;
		if(L!=INF)T[L].p=v;
		if(R!=INF)T[R].p=v; 
	}
	for(i=0;i<N;i++)if(T[i].p==INF)root=i;
	printf("Preorder\n");
	began(root);
	printf("\n");
	printf("Inorder\n");
	middle(root);
	printf("\n");
	printf("Postorder\n");
	endl(root);
	printf("\n");
	return 0;
	return 0;
} 


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,d;
    cin >> n >> d;
    cout << (n+2*d)/(2*d+1) << endl;
}

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

int main() {
    int N;

    cin >> N;
    vector<int> d(N);
    rep(i, 0, N) {
        cin >> d.at(i);
    }

    int sum = 0;
    rep(i, 0, N - 1) {
        rep(j, i + 1, N) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

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

using namespace std;

// input

int n;


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

    cin >> n;

    bool flag = false;

    for(int i = 0;i < 26;i++){
        for(int j = 0;j < 16;j++){

            if(i * 4 + j * 7 == n){
                flag = true;
            }
            
        }
    }

    string ans = (flag)?"Yes":"No";
    cout << ans << "\n";
    
}

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 15 + 5, inf = 1e9 + 7 ;
using namespace std ;
int n, m, g[N][N], f[N][(1 << 15) + 5], G[(1 << 15) + 5][N] ; 
inline void upd(int &x, int y) { if (y < x) x = y ; }
int main() {
	scanf("%d%d", &n, &m) ;
	int x, y, z ;
	rep(i, 1, m) {
		scanf("%d%d%d", &x, &y, &z) ;
		g[x][y] = g[y][x] = z ;
	}
	m = (1 << n) - 1 ;
	rep(i, 1, m) rep(j, 1, n) if ((i >> (j - 1)) & 1) rep(k, 1, n) G[i][k] += g[j][k] ;
	rep(i, 1, n) rep(j, 1, m) f[i][j] = inf ; 
	f[1][1] = 0 ;
	rep(j, 1, m) {
	 	rep(i, 1, n) if ((j >> (i - 1)) & 1) rep(x, 1, n) if (!((j >> (x - 1)) & 1) && g[x][i]) 
			upd(f[x][j | (1 << (x - 1))], f[i][j] + G[j][x] - g[x][i]) ;
		int st = m ^ j ;
		for (int x = st ; x; x = (x - 1) & st) {
			int cost = 0 ;
			rep(i, 1, n) if ((x >> (i - 1)) & 1) cost += G[j][i] ;
			rep(i, 1, n) upd(f[i][j ^ x], f[i][j] + cost - G[x][i]) ;
		}
	}
	printf("%d\n", f[n][m]) ;
	return 0 ; 
}

Measured memory_bytes: 4864
N = int(input())
H = list(map(int,input().split()))
flag = 'Yes'

for i in range(N - 1):
	if H[N - i - 2] - H[N - i - 1] > 1:
		flag = 'No'
		break
	elif H[N - i - 2] - H[N - i - 1] == 1:
		H[N - i - 2] = H[N - i - 2] - 1
	else:
		pass

print(flag)

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;

    if (k > a)
    {
        k = k - a;
        a = 0;
        if (k > b)
        {
            b = 0;
        }
        else
        {
            b = b - k;
        }
    }
    else
    {
        a = a - k;
    }

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = 100100;
int A[MAXN];

int main() {
	int N, x;
	cin >> N >> x;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	ll ans = 0;
	for (int i = 0; i < N-1; i++) {
		int sum = A[i] + A[i+1];
		if (sum > x) {
			ans += sum-x;
			A[i+1] = max(0, A[i+1]-(sum-x));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    ll X, Y, Z, K;
    vector<ll> A, B, C;
    cin >> X >> Y >> Z >> K;
    ll temp;
    for (ll x = 0; x < X; x++) {
        cin >> temp;
        A.push_back(temp);
    }
    for (ll y = 0; y < Y; y++) {
        cin >> temp;
        B.push_back(temp);
    }
    for (ll z = 0; z < Z; z++) {
        cin >> temp;
        C.push_back(temp);
    }

    vector<ll> AB;
    for (ll x = 0; x < X; x++) {
        for (ll y = 0; y < Y; y++) {
            AB.push_back(A[x] + B[y]);
        }
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    vector<ll> ABC;
    ll XY = min(X * Y, K);
    for (ll xy = 0; xy < XY; xy++) {
        for (ll z = 0; z < Z; z++) {
            ABC.push_back(AB[xy] + C[z]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<ll>());

    for (ll xyz = 0; xyz < K; xyz++) {
        cout << ABC[xyz] << endl;
    }
    return 0;
}


Measured memory_bytes: 43256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B;
  int r = 0;
  
  REP(i, A+B)
    for(int j = i+1;j < A+B; j++)
      if (j < A || i >= A)
        r++;


  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




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

template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

int n;
vector<int> a;

map<vector<int>,int> bfs(vector<int> s){
	map<vector<int>,int> dist;
	dist[s] = 0;
	queue<vector<int>> que;
	que.push(s);
	while(!que.empty()){
		vector<int> v = que.front(); que.pop();
		if(dist[v] >= 4) break;
		for(int i = 1;i <= 2 * n - 3;i++){
			vector<int> to = v;
			for(int j = !(i % 2) + 1;;j += 2){
				if(i - j < 0 || i + j >= 2 * n - 1) break;
				int x = (i - j) / 2,y = (i + j) / 2;
				swap(to[x],to[y]);
				if(!dist.count(to)){
					dist[to] = dist[v] + 1;
					que.push(to);
				}
			}
		}
	}
	return dist;
}

signed main(){
	cin >> n;
	a.resize(n);
	for(int i = 0;i < n;i++){
		cin >> a[i]; a[i]--;
	}
	vector<int> vec(n);
	iota(vec.begin(),vec.end(),0);
	auto dist1 = bfs(vec),dist2 = bfs(a);
	int ans = n - 1;
	do{
		if(dist1.count(vec) && dist2.count(vec)){
			ans = min(ans,dist1[vec] + dist2[vec]);
		}
	}while(next_permutation(vec.begin(),vec.end()));
	cout << ans << endl;
}


Measured memory_bytes: 83092
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	cin >> s;
	deque<char> a, b;
	for(int i = 0; i < s.size(); i++) a.pb(s[i]);
	b=a;
	reverse(all(b));
	int q;
	cin>>q;
	for(int i = 0, x, y; i < q; i++) {
		cin >> x;
		if(x==1) swap(a, b);
		else {
			char z;
			cin >> y >> z;
			if(y==1) {
				a.push_front(z);
				b.pb(z);
			}
			else {
				a.pb(z);
				b.push_front(z);
			}
		}
	}
	for(char x: a) cout << x;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N; cin >> N;
    int P[N], Q[N];
    rep(i, N)cin >> P[i];
    rep(i, N)cin >> Q[i];
    int R[N];rep(i, N)R[i] = i + 1;
    int count = 0, ansP, ansQ;
    do {
        ++count;
        bool flg = true;
        rep(i, N)if(R[i] != P[i])flg = false;
        if(flg)ansP = count;
    }while(next_permutation(R, R + N));
    count = 0;
    do {
        ++count;
        bool flg = true;
        rep(i, N)if(R[i] != Q[i])flg = false;
        if(flg){
            ansQ = count;
            break;
        }
    }while(next_permutation(R, R + N));

    cout << abs(ansQ - ansP) << endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        ans += 1
print(ans)

Measured memory_bytes: 9128
def main():
    result = 'Yes'
    S = str(input())
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == 'L':
                result = 'No'
                break
        else:
            if S[i] == 'R':
                result = 'No'
                break
    print(result)

if __name__ == "__main__":
    main()

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


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

int main()
{
  int n;
  cin >> n;
  for(int i = 0; true; i++) {
    if(i*100+i*10+i < n && n <= i*100+i*10+i+ 111) {
      cout << i*100+i*10+i+111 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (a,b,c,d) = readLine()!!.split(" ").map { it.toInt() }
    if(Math.abs(a-c) <= d || (Math.abs(a-b) <= d && Math.abs(b-c) <= d)) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 40072
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll r;
cin>>r;
if(r<1200){
    cout<<"ABC"<<endl;
}else if(r<2800){
    cout<<"ARC"<<endl;
}else{
    cout<<"AGC"<<endl;
}
}









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

using namespace std;

typedef long long int int64;

int main() {
	int64 n, m;
	cin >> n >> m;
	if(n == 1 || m == 1) {
		cout << "1\n";
		return 0;
	}
	swap(n, m);
	int64 full = n/2 + n%2;
	int64 cutt = n/2;
	cout << ((full * (m/2 + m%2)) + (cutt * (m/2))) << "\n";
	return 0;
}

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

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int d = in.readInt();
		int x = in.readInt(); 
		int sum = 0;
		for(int i= 0; i<n; i++) {
			int a = in.readInt();
			int k =0; 
			while(d >= k*a + 1) {
				sum++; 
				k++; 
			}
		}
		System.out.println(x+sum); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 22740
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A, &B, &C);
  if(A==B && B==C){
    printf("No");
    return 0;
  }
  else if(A!=B && B!=C){
    if(A!=C){
      printf("No");
      return 0;
    }
    else{
      printf("Yes");
    return 0;
    }
  }
  else{
    printf("Yes");
    return 0;
  }
  }

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		Arrays.sort(c);
		char target = c[0];
		for (int i = 1; i < c.length; i++) {
			if (target == c[i]) {
				System.out.println("no");
				break;
			}else if(i == c.length-1) {
				System.out.println("yes");
				break;
			}else {
				target =c[i];
			}
		}

	}
}




Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll x=max(a,b);
	if(x==a)
	{
		a--;
	}
	else
		b--;
	x+=max(a,b);
	cout<<x;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

ll a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	for(int i = 0; i < n - 1; i++)
	{
		if(a[i] > 0 && a[i + 1] > 0)
		{
			if(a[i]%2==1 && a[i+1]%2==1)
			{
				a[i]--; a[i+1]--; ans++;
			}
			else if(a[i]%2==1)
			{
				a[i]--; a[i+1]--; ans++;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		ans += a[i]/2;
	}
	cout << ans;
}


Measured memory_bytes: 1152
a,b = map(int,input().split())
if a >= b:
    i = 1
    while i > 0:
        if (a*i) % b == 0:
            print(a*i)
            break
        i += 1
else:
    i = 1
    while i > 0:
        if (a*i) % b == 0:
            print(a*i)
            break
        i += 1

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    map<int, int> ma;
    rep(i, N) {
        ma[A[i]]++;
        if (ma[A[i]] == 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES";
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A,P;
    cin >> A;
    cin >> P;

    int ans;
    ans = (A * 3 + P) / 2;
    cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000];
int main()
{
int n,h,zbroj=0;
cin>>h;
cin>>n;
for(int i=0;i<n;i++)
{
  cin>> a[i];
  zbroj=zbroj+a[i];
}
if (h<=zbroj)
	cout << "Yes";
else
	cout << "No";
return 0;
}

Measured memory_bytes: 640
#include <stdlib.h>
#include <stack>
#include <iostream>
using namespace std;


#define REP(i,n) for(long i=0; i<(long)(n); ++i)
#define FOR(i,k,n) for(long i=(k);i<(long)(n);++i)

int main(){
	long n;

	cin >> n;
	stack<long> x;
	long long int ans = 1;
	const long long int mod = 1000000007;
	REP(i, n){
		long y;
		cin >> y;
		x.push(y);
		if(y < 2*x.size()-1){
			ans = ans * x.size() % mod;
			x.pop();
		}
	}
	REP(i, x.size()){
		ans = ans * (i+1) % mod;
	}
	cout << ans<< endl;
	return 0;
}


Measured memory_bytes: 1152
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (n, m) = i.read2::<usize, usize>();
    let mut p = i.read_vec::<usize>(n);
    let mut xys = Vec::new();
    for _ in 0..m {
        let xy = i.read2::<usize, usize>();
        xys.push((xy.0 - 1, xy.1 - 1));
    }
    for p in p.iter_mut() {
        *p -= 1;
    }

    writeln!(o, "{}", solve(&p, &xys)).unwrap();
}
fn solve(p: &[usize], xy: &[(usize, usize)]) -> usize {
    let mut visit = vec![false; p.len()];
    let mut edges = vec![Vec::new(); p.len()];
    let mut s = vec![false; p.len()];
    let mut result = 0;

    for &xy in xy {
        edges[xy.0].push(xy.1);
        edges[xy.1].push(xy.0);
    }
    let mut q = Vec::new();
    let mut idxs = Vec::new();

    for i in 0..p.len() {
        if visit[i] {
            continue;
        }
        visit[i] = true;
        let e = &edges[i];
        if e.is_empty() {
            if p[i] == i {
                result += 1;
            }
        } else {
            q.push(i);
            while let Some(i0) = q.pop() {
                idxs.push(i0);
                for &i1 in &edges[i0] {
                    if visit[i1] {
                        continue;
                    }
                    visit[i1] = true;
                    q.push(i1);
                }
            }
            for &idx in &idxs {
                s[p[idx]] = true;
            }
            for &idx in &idxs {
                if s[idx] {
                    result += 1;
                }
            }
            for &idx in &idxs {
                s[p[idx]] = false;
            }
            idxs.clear();
        }
    }

    result
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


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

int main(){
	char str1[11], str2[11], str3[11];
	
	cin >> str1 >> str2 >> str3;
	
	str1[0] -= 32;
	str2[0] -= 32;
	str3[0] -= 32;

	cout << str1[0] << str2[0] << str3[0] << "\n";	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 105
int a[MAX],dp[105][100005];
int gamedp(int n,int k)
{
	if(dp[n][k]!=-1)
	return dp[n][k];
	dp[n][k]=1;
	for(int i=1;i<=n;i++)
	{
	if(k>=a[i])
	{
	if(gamedp(n,k-a[i])==1)
	dp[n][k]=0;
}
}
return dp[n][k];

}
signed main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	memset(dp,-1,sizeof(dp));
	if(gamedp(n,k)==1)
	cout<<"Second"<<"\n";
	else
	cout<<"First"<<"\n";
}

Measured memory_bytes: 86912
N, K = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(str(Base_10_to_n(N, K))))

Measured memory_bytes: 38384
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    if (l.back() < accumulate(l.begin(), l.end() - 1, 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
//#include "test.h"
using namespace std;

int main() {
	int n, minv, v;
	cin >> n >> minv;
	int maxp = INT32_MIN;

	for (int i = 1; i < n; ++i) {
		cin >> v;
		maxp = max(maxp, v - minv);
		minv = min(minv, v);
	}
	cout << maxp << endl;
	return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int N;
ll a[3000];

ll dp[3000][3000][2];

ll dfs(int left, int right, bool turn)
{
    if (dp[left][right][turn] != -1) {
        return dp[left][right][turn];
    }
    else if (left == right) {
        ll X = 0, Y = 0;
        if (turn) X += a[left];
        else Y += a[left];
        dp[left][right][turn] = X - Y;
        return X - Y;
    }
    else {
        if (turn) {
            ll sl = a[left] + dfs(left + 1, right, !turn);
            ll sr = a[right] + dfs(left, right - 1, !turn);
            ll s = max(sl, sr);
            dp[left][right][turn] = s;
            return s;
        }
        else {
            ll sl = dfs(left + 1, right, !turn) - a[left];
            ll sr = dfs(left, right - 1, !turn) - a[right];
            ll s = min(sl, sr);
            dp[left][right][turn] = s;
            return s;
        }
    }
}

int main(int argc, char **argv)
{
    cin >> N;
    REP(i, N) cin >> a[i];

    REP(i, 3000) REP(j, 3000) REP(k, 2) dp[i][j][k] = -1;

    cout << dfs(0, N - 1, true) << endl;

    return 0;
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<int> edges(n);
    rep(i, n) cin >> edges[i];
    sort(edges.begin(), edges.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            auto it = lower_bound(edges.begin(), edges.end(), edges[i] + edges[j]);
            it--;
            int now = distance(edges.begin() + j, it);
            ans += now;
        }
    }
    cout << ans << endl;
}


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

int main(){
  
  int N;
  int x = 0;
  cin >> N;
  
  for (int i = 0; i < N; i ++){
    int l,r;
    cin >> l >> r;
    x += r - l + 1;
  }
  
  cout << x << endl;
  
}
  

Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let l = read_line();
    let n = to_i(&l);
    //println!("{}",n);
    let ret = (n-2)*180;
    print!("{}", ret);
    
    
}   

Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    B=[int(_) for _ in input().split()]
    ans=B[0]+B[-1]
    for i in range(n-2):
        ans+=min(B[i],B[i+1])
    print(ans)
if __name__=='__main__':
    main()

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

bool is_sorted(int a[]);

int n;
int arr[55];

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            swap(arr[i], arr[j]);

            if (is_sorted(arr)) {
                cout << "YES" << endl;
                return 0;
            }

            swap(arr[i], arr[j]);
        }
    }

    cout << "NO" << endl;

    return 0;
}

bool is_sorted(int a[])
{
    for (int i = 1; i < n; i++) {
        if (a[i - 1] >= a[i]) {
            return false;
        }
    }

    return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	map<string, int> m;
	m.insert(make_pair("SUN", 7));
	m.insert(make_pair("MON", 6));
	m.insert(make_pair("TUE", 5));
	m.insert(make_pair("WED", 4));
	m.insert(make_pair("THU", 3));
	m.insert(make_pair("FRI", 2));
	m.insert(make_pair("SAT", 1));
	string s; cin >> s;
	int ans = m.at(s);
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]
for i in range(1, n):
    dp += [min([dp[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])]
print(dp[-1])

Measured memory_bytes: 58336
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int MXN = 3e3;
int n, m, k;
ll mp[MXN][MXN], dp[MXN][MXN][5];
ll pa, pb, pc, pd;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	cin >> n >> m >> k;
	memset(mp, 0, sizeof(mp));
	for (int i=0; i<k; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		--x; --y;
		mp[x][y] = z;
	}
	memset(dp, 0, sizeof(dp));
	for (int i=0; i<n; i++) {
		pa = pb = pc = pd = 0;
		for (int j=0; j<m; j++) {
			dp[i][j][0] = max(pa, (i ? dp[i-1][j][4] : 0));
			dp[i][j][1] = max(dp[i][j][0] + mp[i][j], pb); // verified
			dp[i][j][2] = max(pb + mp[i][j], pc);
			dp[i][j][3] = max(pc + mp[i][j], pd);
			pa = max(pa, dp[i][j][0]);
			pb = max(pb, dp[i][j][1]);
			pc = max(pc, dp[i][j][2]);
			pd = max(pd, dp[i][j][3]);
			for (int l=0; l<4; l++) {
				dp[i][j][4] = max(dp[i][j][4], dp[i][j][l]);
			}
		}
	}
	cout << dp[n-1][m-1][4] << '\n';
}

Measured memory_bytes: 425456
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int a[n+1];
    int b[n];
    int pro,pro2;
    long long count = 0;
    
    for(int i = 0;i < n+1;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0;i < n;i++){
        scanf("%d",&b[i]);
    }
    
    for(int i = 0;i < n;i++){
      pro = b[i]-a[i];
        if(pro >= 0){
            count = count + a[i];
            pro2 = pro-a[i+1];
            if(pro2 >= 0){
                count = count + a[i+1];
                a[i+1]=0;
            }else{
                a[i+1] = a[i+1] - pro;
                count = count + pro;
            }
        }else{
             count = count + b[i];
        }
    }
    printf("%ld\n",count);
    return (0);
    
}

Measured memory_bytes: 896
fn memo(
    pos: usize,
    less: bool,
    cnt: usize,
    n: &[char],
    k: usize,
    dp: &mut Vec<Vec<Vec<Option<usize>>>>,
) -> usize {
    if cnt > k {
        return 0;
    }
    if pos >= n.len() {
        if cnt == k {
            return 1;
        }
        return 0;
    }
    if let Some(tmp) = dp[pos][less as usize][cnt] {
        return tmp;
    }
    let value = n[pos].to_digit(10).unwrap();
    //0
    let mut result = 0;
    if 0 < value {
        result += memo(pos + 1, true, cnt, n, k, dp);
    } else {
        result += memo(pos + 1, less, cnt, n, k, dp);
    }
    //1
    for x in 1..10 {
        if less {
            result += memo(pos + 1, less, cnt + 1, n, k, dp);
        } else {
            if x < value {
                result += memo(pos + 1, true, cnt + 1, n, k, dp);
            } else if x == value {
                result += memo(pos + 1, less, cnt + 1, n, k, dp);
            }
        }
    }
    dp[pos][less as usize][cnt] = Some(result);
    result
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.chars();
    let k: usize = sc.read();
    let mut dp = vec![vec![vec![None; 4]; 2]; 110];
    let result = memo(0, false, 0, &n, k, &mut dp);
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll w = in(), h = in(), n = in();
	ll right = 0, left = w, up = 0, bottom = h;
	REP(i, n) {
		ll x = in(), y = in(), a = in();
		if (a == 1)right = max(right, x);
		else if (a == 2)left = min(left, x);
		else if (a == 3)up = max(up, y);
		else bottom = min(bottom, y);
	}
	cout << max(left - right, 0LL) * max(bottom - up, 0LL) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;

int main(){
  int n;  cin >> n;
  long long vartic = 0, horizon = 0, maxN = 0;
  map<long long, long long> mp;
  rep(i, 0, n){
    long long tmp;
    cin >> tmp;
    mp[tmp]++;
  }

  for(auto it = mp.begin(); it != mp.end(); it++){
    if(it->second >= 4){
      vartic = horizon = it->first;
    }
    else if(it->second >= 2){
      vartic = horizon;
      horizon = it->first;
    }
  }
  cout << vartic * horizon << endl;
  return 0;
}


Measured memory_bytes: 6528
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int n;
	int t[SIZE],a[SIZE];
	cin >> n;
	rep(i,n) cin >> t[i] >> a[i];

 	ll A = 1, B=1;
	ll n_max1,n_max2,n_max;
	rep(i,n){
		if(A%t[i] == 0) n_max1 = A/t[i];
		else n_max1 = A/t[i] + 1;

		if(B%a[i] == 0) n_max2 = B/a[i];
		else n_max2 = B/a[i] + 1;

		n_max = max(n_max1,n_max2);
		A = n_max*t[i];
		B = n_max*a[i];
	}

	ll ans = A + B;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256