akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'

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

#ifndef __LOCAL
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout); FAST;
#else
#define FILES(namein, nameout) FAST;
#endif //__LOCAL

using namespace std;
using namespace __gnu_pbds;
using python = void;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned short uss;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type> ordered_set;

const ll M = 1e9+7;
const ll N = 3011;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
ld a[N];
ld dp[N][N];
python solve(){
	FAST;
	ll n;
	cin >> n;
	for(ll i =0;i<n;i++) cin >> a[i];
	dp[0][1] = a[0], dp[0][0] = 1-a[0];
	for(ll i =1;i<n;i++){
		dp[i][0] = dp[i-1][0]*(1-a[i]);
		for(ll j = 1;j<=i+1;j++){
			dp[i][j] = dp[i-1][j-1]*a[i] + dp[i-1][j]*(1-a[i]);
		}
	}
	ld res = 0;
	for(ll i = n/2+n%2;i<=n;i++) res+=dp[n-1][i];
		cout << fixed << setprecision(11) << res << '\n';
}

signed main(){
	FAST;
	ll q = 1;
	//cin >> q;
	while(q--){
		solve();
	}
}

Measured memory_bytes: 139776
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;

double a,b,x;

int main()
{
	cin>>a>>b>>x;
	double S=x/a;
	double c=(2.0*S-a*b)/a;
	double ans;
	if (c<=0.0) ans=atan(b/(2.0*S/b));
	else ans=atan((b-c)/a);
	printf("%.10lf",ans*180.0/3.1415926535897932384626);
	return 0;
}


Measured memory_bytes: 256
//    Unmesh Kumar
//    CSE'22 IIT Roorkee

#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

bool comp(ll a,ll b)
{
  return a>b;
}

ll arr[1000005];
ll a[1000005];
ll b[1000005];

int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  ll count=0;
  rep(o,3)
  {
    if(s[o]=='A')
    {
      count++;
      break;
    }
  }
  rep(o,3)
  {
    if(s[o]=='B')
    {
      count++;
      break;
    }
  }
  if(count==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i, j, n, m, flag=0;
  char s[11], t[12];
  scanf("%s", s);
  scanf("%s", t);
  n = strlen(s);
  m = strlen(t);
  for(i=0; i<n; i++){
    if(s[i]!=t[i]){
      flag = 1;
    }
  }
  if(m-n!=1){
    flag = 1;
  }
  if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
char a[100001],b,s[10000001];
int i=0;
int main()
{
	cin>>a;
	for(int j=0;j<strlen(a);j++)
	{
		s[i]=a[j];
		i+=2;
	}
	i=1;
	a[0]='\0';
	cin>>a;
	for(int j=0;j<strlen(a);j++)
	{
		s[i]=a[j];
		i+=2;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	if (n[0] == n[1] && n[0] == n[2]) || (n[1] == n[2] && n[1] == n[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
using namespace std;
 
int main() {
	int X, Y,N,A,B,sum,ans;
    cin >> A >> B;
    if(B%A == 0){
        cout << A+B << endl;
    }else cout << B-A << endl; 
	return 0;
}

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



int main()
{
int n,m;scanf("%d %d",&n,&m);
vector<int> c(m);for(int i=0;i<m;i++)scanf("%d ",&c[i]);
vector<int> dp(n+1,INF);dp[0]=0;
for(int i=1;i<n+1;i++)
{
for(int j=0;j<m;j++)
{
if(i-c[j]<0)continue;
dp[i]=min(dp[i-c[j]]+1,dp[i]);
}
}
printf("%d\n",dp[n]);
}


Measured memory_bytes: 3276
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;
 
int ans;
 
int count(vector<vector<int> > vvi,vector<int> flag){
    int cnt=0;
    for(int i=0; i<vvi.size(); ++i){
        if(flag[i]==1){
            for(int j=0; j<vvi[i].size(); ++j){
                if(vvi[i][j]==1) vvi[i][j]=0;
                else if(vvi[i][j]==0) vvi[i][j]=1;
            }
        }
    }
    for(int i=0; i<vvi[0].size(); ++i){
        int b=0;
        for(int j=0; j<vvi.size(); ++j){
            if(vvi[j][i]==1) ++b;
        }
        if(b>vvi.size()-b) cnt+=b;
        else cnt+=vvi.size()-b;
    }
    return cnt;
}
 
void solve(vector<vector<int> > vvi,vector<int> flag,int k){
    if(k==flag.size()){
        ans=max(ans,count(vvi,flag));
        return;
    }
    flag[k]=0;
    solve(vvi,flag,k+1);
    flag[k]=1;
    solve(vvi,flag,k+1);
}
 
int main(){
    int C,R;
    while(cin >> R >> C&&C!=0&&R!=0){
        vector<vector<int> > osenbei(R,vector<int>(C));
        vector<int> flag(R);
        ans=0;
        for(int i=0; i<R; ++i){
            for(int j=0; j<C; ++j){
                cin >> osenbei[i][j];
            }
        }
        solve(osenbei,flag,0);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
char a[205],s[101],t[101];
int main(){
  	int n;
  	cin>>n>>s>>t;
  	for(int i=0;i<n;i++){
    	a[2*i]=s[i];
    	a[2*i+1]=t[i];
  	}
  	cout<<a;
  	return 0;
}

Measured memory_bytes: 256
class Matrix:
    def __init__(self, rows, cols, values=None):
        self.rows = rows
        self.cols = cols
        if values is not None:
            self.values = values
        else:
            row = [0 for i in range(cols)]
            self.values = [row[:] for j in range(rows)]

    def row(self, i):
        return self.values[i-1]

    def col(self, j):
        return [row[j-1] for row in self.values]

    def __mul__(self, other):
        assert self.cols == other.rows

        m = self.__class__(self.rows, other.cols)
        for i in range(self.rows):
            for j in range(other.cols):
                m[i, j] = sum(a * b for (a, b) in zip(self.row(i),
                                                      other.col(j)))
        return m

    def __getitem__(self, idx):
        row, col = idx
        return self.values[row-1][col-1]

    def __setitem__(self, idx, val):
        row, col = idx
        self.values[row-1][col-1] = val

    def __str__(self):
        s = []
        for row in self.values:
            s.append(" ".join([str(i) for i in row]))
        return "\n".join(s)


def run():
    n, m, l = [int(v) for v in input().split()]

    m1 = []
    for i in range(n):
        m1.append([int(v) for v in input().split()])

    m2 = []
    for i in range(m):
        m2.append([int(v) for v in input().split()])

    print(Matrix(n, m, m1) * Matrix(m, l, m2))


run()


Measured memory_bytes: 6980
S = input()
T = input()
list_s = list(S)
list_t = list(T)
A = []
for i in range(len(list_s)-len(list_t)+1):
    t = i
    count = 0
    for j in range(len(list_t)):
        if list_t[j] == list_s[t]:
            t +=1
            count +=1
        else:
            t +=1
    A.append(count)
print(len(list_t) - max(A)) 

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

using namespace std;

int main(void){
	int i, j, n, dp[31];
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(dp,dp + 31,0);
		dp[0] = 1;
		for(i = 0;i < n;i++){
			for(j = 1;j <= 3;j++){
				if(i + j <= n){
					dp[i + j] += dp[i];
				}
			}
		}
		cout << dp[n] / 3650 + 1 << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> vec(N);
  string W;
  
  for(int i; i<N; i++){
    cin >> W;
    vec.at(i) = W;
  }
  
  string word, wordmae;
  bool shiri = true;
  
  for(int i = 0; i<N; i++){
    word = vec.at(i);
    
    if(i != 0){
      wordmae = vec.at(i-1);
      for(int j=0; j < i; j++){//初出の単語かどうか
        if(word == vec.at(j)){
          shiri = false;
        }
      }
      if(shiri == false){break;}
      
      if(word.at(0) != wordmae.at(wordmae.size()-1)){//しりとりできてるかどうか
        shiri = false;
        break;
      }
      
    }
    if(i == N-1){
      shiri = true;
    }
    
  }
  if(shiri == true){
    cout << "Yes"<< endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i32 = itr.next().unwrap().parse().unwrap();
    let a: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let s = a.iter().sum::<i32>();
    // s / n - iが最も小さい
    let mut ans = Vec::new();
    for i in 0..n {
        ans.push(((s - a[i as usize] * n).abs(), i));
    }
    ans.sort();
    println!("{}", ans[0].1);
}


Measured memory_bytes: 2076
<?php
fscanf(STDIN, "%d", $n);
$x = 0;
for ($i = 1; $i <= $n; $i += 2) {
	$y = 0;
	for ($j = 1; $j <= $i; $j++) {
		if ($i % $j == 0) $y++;
	}
	if ($y == 8) $x++;
}
echo $x;

Measured memory_bytes: 4604
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

struct Node
{
    int turn;
    int idx;
    Node(){}
    Node(int _t, int _i) {
        turn = _t;
        idx = _i;
    }
    bool operator < (const Node &a) const {
        if (turn == a.turn) {
            return idx > a.idx;
        }
        return turn > a.turn;
    }
};

int N,M;
string S;
int ans[100010];

int main ()
{
    cin >> N >> M >> S;
    priority_queue<Node> que;
    que.push(Node(0, 0));

    fill (ans, ans + 100010, -1);
    ans[0] = 0;

    for (int i = 1; i <= N; i++) {
        //cerr << i << endl;
        if (que.empty()) {
            break;
        }
        if (S[i] == '1') {
            continue;
        }
        int turn = que.top().turn;
        int idx = que.top().idx;
        if (abs(idx - i) > M) {
            i--;
            que.pop();
            continue;
        }
        ans[i] = idx;
        que.push(Node(turn + 1, i));
    }

    if (ans[N] == -1) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> ret;
    int ver = N;
    while (ver != 0) {
        int nver = ans[ver];
        ret.push_back(abs(nver - ver));
        ver = nver;
    }

    reverse(ret.begin(), ret.end());
    REP(i,ret.size()) {
        cout << ret[i] << ((i < (int)ret.size() - 1) ? " " : "\n");
    }

    return 0;
}


Measured memory_bytes: 1528
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N, M;

//bool check(vector<int> v)
bool check(int* v)
{
	int no[1000];
	for (int i = 1; i <= N; i++)
	{
		no[i] = i;
	}
	bool flg[1000][1000] = {};
	bool ng = false;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			int a = no[v[j * 2]];
			int b = no[v[j * 2 + 1]];
			if (flg[a][b])
			{
				ng = true;
			}
			flg[a][b] = true;
			flg[b][a] = true;
		}
		for (int j = 1; j <= N; j++)
		{
			no[j]--;
			if (no[j] < 1) no[j] = N;
		}
	}
	return ng;
}


int arena[1000010];

signed main()
{
	cin >> N >> M;

	int first = ceil(M / 2.0);
	for (int i = 0; i < first; i++)
	{
		int index = i;
		int sub = (first * 2 - 1) - (index * 2);
		arena[i * 2] = i;
		arena[i * 2 + 1] = i + sub;
	}

	int offset = (first * 2);
	int range = (M * 2 - offset);
	for (int i = first; i < M * 2; i++)
	{
		int index = i - first;
		int sub = range - (index * 2);
		arena[i * 2] = index + offset;
		arena[i * 2 + 1] = index + offset + sub;
	}

	for (int j = 0; j < M; j++)
	{
		arena[j * 2]++;
		arena[j * 2 + 1]++;
		int a = arena[j * 2];
		int b = arena[j * 2 + 1];
		cout << a << " " << b << endl;
	}

	//cout << (check(arena) ? "ng" : "ok") << endl;
}





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

template<typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n,0);
  rep(i,n) cin >> p[i];

  int max = 0;
  rep(i,k) max += p[i];
  int tmp = max;
  int ii = k;
  FOR(i,k,n) {
    tmp = tmp - p[i-k] + p[i];
    if(max < tmp) {
      max = tmp;
      ii = i;
    }
  }

  ll sum = 0;
  if (ii == k) {
    rep(i,k) {
      sum += p[i] + 1;
    }
  } else {
    FOR(i,ii-k+1,ii+1) {
      sum += (p[i] + 1);
    }
  }
  double ans = sum / 2.0;

  cout << fixed;
  cout << setprecision(14) << ans << endl;
  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n){
    int a;
    cin >> a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  int ans = 0;
  for(auto it = mp.begin(); it != mp.end(); it++){
    ans = max(ans, it->second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
#include<stdio.h>
int main()
{
    long long int n,i,a[10001],sum=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    long long int min=a[0];
    for(i=0;i<n;i++){
       if(min>a[i]){
            min=a[i];
       }
    }
    long long int max=a[0];
    for(i=0;i<n;i++){
        if(max<a[i]){
            max=a[i];
        }
    }
    for(i=0;i<n;i++){
        sum=sum+a[i];
    }
    printf("%lld %lld %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    ll A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    map<int, int> M;
    rep(i, N) {
        cin >> X[i];
        M[X[i]] = i;
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
    rep(i, N + 1) dp[i][0] = B * i;
    rep(i, 1, N + 1) {
        ll mi = dp[i - 1][1];
        rep(j, 1, N + 1) {
            if(j - 1 < M[i]) dp[i][j] = mi + B;
            else if(j - 1 > M[i]) dp[i][j] = mi + A;
            else dp[i][j] = mi;
            if(j != N) mi = min(mi, dp[i - 1][j + 1]);
        }
    }
    ll ans = dp[N][0];
    rep(i, N + 1) {
        ans = min(ans, dp[N][i]);
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 198144
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static int N;
    static int M;
    static int A;
    static long B;
    static long C;
//    static int[][] map;
    static int min = 9999999;

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

        N = scanner.nextInt();
        
        if(N < 1200){
            System.out.println("ABC");
        }else if(N < 2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }

    }




}



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

int main() {
  
  int N; cin >> N; vector<int> vec(N); int sum = 0;
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      sum += vec.at(i) * vec.at(j);
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>


using namespace std;

int main(){
    int N, count = 0;
    cin >> N;
    for(int i = 1; i < 10; i++){
        for(int j = i; j < 10; j++){
            if(N == i * j){
                count++;
            }
        }
    }
    if(count == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> Pii;

set<int> mp[200001];

int main() {
    int h,w,n,x,y;
    cin >> h >> w >> n;
    
    for(int i=0;i<n;++i) {
        cin >> x >> y;
        mp[y].insert(x);
    }

    for(int i=1;i<=w;++i) mp[i].insert(h+1);

    vector<Pii> v;
    int j_lower_lim = 1;
    for(int i=1;i<=w;++i) {
        while(mp[i].find(j_lower_lim) != mp[i].end()) ++j_lower_lim;
        set<int>::iterator j_itr = mp[i].upper_bound(j_lower_lim);
        if(j_itr != mp[i].end()) {
            v.emplace_back(*j_itr, i);
        }
        ++j_lower_lim;
    }
    sort(v.begin(), v.end());

    cout << v[0].first-1 << "\n";
}

Measured memory_bytes: 30584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    string s;
    cin>>s;
    long long int result=1;
    FOR(i,1,n){
        if(s[i]!=s[i-1]){
            result++;
        }
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    int count = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) {
        if (x == 1) {
            count = i;
            break;
        }
        x = a[x];
    }
    if (count!=0) {
        cout << count << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

int counter(string s){
  int n = int(s.size());
  int count = 0;
  for (int i = 1; i < n; i++) {
    if(s[i] == 'B' && s[i-1] == 'A') {
      count++;
    }
  }
  return count;
}

bool last_a(string s){
  int n = int(s.size());
  if(s[n-1] == 'A') return true;
  else return false;
}

int first_b(string s){
  if(s[0] == 'B') return true;
  else return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> v(n+2, "X");
  vector<int> count(n+2);
  vector<bool> count_a(n+2, false);
  vector<bool> count_b(n+2, false);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    count[i] = counter(v[i]);
    count_a[i] = last_a(v[i]);
    count_b[i] = first_b(v[i]);
  }
  ll res = 0;

  int tmp1 = 0;
  int tmp2 = 0;
  int tmp3 = 0;
  bool flag = false;
  for (int i = 1; i <= n; i++) {
    if(count_b[i] && count_a[i]){
      if(flag){
        res++;
      }
      tmp3++;
      flag = true;
      continue;
    }
    if(count_a[i]) tmp1++;
    else if(count_b[i]) tmp2++;
  }
  // cout << res << endl;

  if(flag && tmp1 > 0){
    res++;
    tmp1--;
  }
  if(tmp2 > 0 && flag){
    res++;
    tmp2--;
  }
  // cout << res << endl;


  res += min(tmp1, tmp2);
  // cout << res << endl;

  for (int i = 1; i <= n+1; i++) {
    res += count[i];
  }

  cout << res << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
		
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
vector<ll> factorial;
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%mod;
        a = a * a%mod;
        b >>= 1;
    }
    return res;
}

ll CC(ll n, ll k) {
    return factorial[n] * inv(factorial[k]) % mod * inv(factorial[n - k]) % mod;
}


void fill_factorial(ll n) {
    factorial.resize(n+1);
    factorial[0] = 1;
    for(ll i=1; i<=n; i++) factorial[i] = (factorial[i-1]*i)%mod;
}

int main() {
	ll tttt; 
	//cin>>tttt;
	tttt = 1;
    while(tttt--) { 	
		ll n; cin>>n;
		if(n==1) cout<<0;
		else {
			fill_factorial(n+10);
			ll ans = binpow(10,n);
			ans = (ans - binpow(8,n)+ mod)%mod;
			for(int i=1; i<=n; i++) {
				ans = (ans - 2*CC(n,i)*binpow(8,n-i) + mod)%mod;
			}
			cout<<ans;
		}
		
    } 
    return 0; 
}

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

const int maxN = 2005, mod = 1e9 + 7;

int n, k;
int f[maxN + 1][maxN + 1];
int fac[maxN * maxN + 1], inv[maxN * maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline int C(int n, int m)
{
	if(n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
	scanf("%d %d", &n, &k);
	if(k == 1) { puts("1"); return 0; }
	
	fac[0] = 1;
	for(int i = 1; i <= n * k; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n * k] = mpow(fac[n * k], mod - 2);
	for(int i = n * k - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++)
		{
			if(j) f[i][j] = f[i][j - 1];
			f[i][j] = ADD(f[i][j], 1ll * f[i - 1][j] * C(i * (k - 1) + j - 1, k - 2) % mod);
		}

	int ans = 1ll * f[n][n] * fac[n] % mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 47360
def sumList(index,array):
    if index ==n:
        sumArray.append(array)
    else:
        sumList(index+1,array)
        nextArray =[0]*(m+1)
        for i in range(m+1):
            nextArray[i] +=array[i]+ list[index][i]
        sumList(index+1,nextArray)



if __name__ == '__main__':
    n,m,x = map(int, input().split())

    list = []
    for i in range(n):
        a = [int(i) for i in input().split()]
        list.append(a)
    firstArray = [0] * (m + 1)
    sumArray = []
    sumList(0,firstArray)

    min = 100000000
    for i in sumArray:
        amount =0
        count =0
        for j in range(len(i)):
            if j == 0:
                amount =i[j]
            else:
                if i[j] >=x:
                    count+=1
        if count == m and min >= amount:
            min = amount

    if min == 100000000:
        print(-1)
    else:
        print(min)


Measured memory_bytes: 10972
#include<bits/stdc++.h>
using namespace std;
char a[10000000];
int main()
{
	cin>>a;
	int t,s;
	int len=strlen(a);
	for(int i=1;i<=len;i++)
		if(a[i]=='p')
			t++;
	s=len/2-t;
	cout<<s;
	return 0;
}

Measured memory_bytes: 384
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC115A
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  if(n==22) printf("Christmas Eve Eve Eve");
  else if(n==23) printf("Christmas Eve Eve");
  else if(n==24) printf("Christmas Eve");
  else printf("Christmas");
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define LL inline ll
#define I inline int
#define V inline void
#define B inline bool
#define ll long long int
#define isnum(ch) ('0'<=ch&&ch<='9')
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define gc (_op==_ed&&(_ed=(_op=_buf)+fread(_buf,1,100000,stdin),_op==_ed)?EOF:*_op++)
char _buf[100000],*_op(_buf),*_ed(_buf);
I getint(){
	rnt _s=0;re char _ch=gc;
	while(!isnum(_ch))_ch=gc;
	while(isnum(_ch))_s=_s*10+_ch-48,_ch=gc;
	return _s;
}
const int N=1e5+1;
int n,k;
ll S,up=1,dw=1;
struct node{
	ll x,y;
	V input(){x=getint(),y=getint();}
	B operator<(const node&u)const{
		return x>u.x;
	}
}a[N];
LL gcd(ll x,ll y){return !y?x:gcd(y,x%y);}
int main(){
	n=getint();
	FOR(i,1,n)a[i].input(),S+=a[i].x,a[i].x=max(a[i].x,a[i].y);
	sort(a+1,a+1+n);ll now=0,dis;
	while(now<S)now+=a[++k].x;
	FOR(i,1,n){
		dis=S-now+a[min(i,k)].x;
		if(dis<=a[i].y&&dis*dw<a[i].y*up)
			up=dis,dw=a[i].y;
	}
	up=(dw-up)+dw*(n-k),dw*=n,now=gcd(up,dw);
	cout<<up/now<<' '<<dw/now;
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

void push(int elem[], int value, int* pNum)
{
    elem[*pNum] = value;
    ++(*pNum);
    return;
}

int pop(int elem[], int* pNum)
{
    int ret = 0;

    if (*pNum > 0) {
        --(*pNum);
        ret = elem[*pNum];
    }

    return ret;
}

int main(void)
{
    int  elem[1000];
    int  num = 0;
    char input[100];
    int  x, y;

    while (scanf("%s", input) != EOF) {
        switch (input[0]) {
        case '+' :
            x = pop(elem, &num);
            y = pop(elem, &num);
            push(elem, y+x, &num);
            break;
        case '-' :
            x = pop(elem, &num);
            y = pop(elem, &num);
            push(elem, y-x, &num);
            break;
        case '*' :
            x = pop(elem, &num);
            y = pop(elem, &num);
            push(elem, y*x, &num);
            break;
        case '/' :
            x = pop(elem, &num);
            y = pop(elem, &num);
            push(elem, y/x, &num);
            break;
        default :
            x = atoi(input);
            push(elem, x, &num);
            break;
        }
    }

    printf("%d\n", pop(elem, &num));

    return 0;
}

Measured memory_bytes: 1148
#include<iostream>

int main(){
	int a;
	std::cin >> a;
	int b;
	std::cin >> b;
	int c;
	std::cin >> c;
	int d;
	std::cin >> d;
	int e;
	std::cin >> e;
	int k;
	std::cin >> k;

	if (e - a <= k){
			std::cout << "Yay!" << std::endl;
	}else{
			std::cout << ":(" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;

    cout << N / 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<char> S(N), T(N);
    rep(i, 0, N) cin >> S.at(i);
    rep(i, 0, N) cin >> T.at(i);
    rep(i, 0, N) cout << S.at(i) << T.at(i);
    cout << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		long k=s.nextLong();
		
		int[] arr=new int[n+1];
		
		for(int i=1;i<n+1;i++)
		{
			arr[i]=s.nextInt();
		}
		
		int[] visited=new int[n+1];
		
		ArrayList<Integer> translate=new ArrayList<>();
		ArrayList<Integer> cycle=new ArrayList<>();
		
		visited[1]=1;
		
		int curr=1;
		
		while(visited[arr[curr]]==0)
		{
			visited[arr[curr]]=1;
			curr=arr[curr];
		}
		
		int goal=arr[curr];
		curr=arr[goal];
		
		cycle.add(goal);
		
		while(curr!=goal)
		{
			cycle.add(curr);
			curr=arr[curr];
		}
		
		int start=1;
		
		while(start!=goal)
		{
			translate.add(start);
			start=arr[start];
		}
		
		translate.add(goal);
		
		if(k<translate.size())
		{
			System.out.println(translate.get((int)k));
		}
		else
		{
			k=k-translate.size()+1;
			
			long rem=k%cycle.size();
			
			System.out.println(cycle.get((int)rem));
		}
	}
	
}

Measured memory_bytes: 60532
//2019.5.19 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int x;
    bool fl0,fl1;
    inline void MAIN(){
        x=read();
        if(x%100<=12&&x%100>=1)fl0=1;
        x/=100;
        if(x<=12&&x>=1)fl1=1;
        if(fl0&&fl1)puts("AMBIGUOUS");
        else if(fl0)puts("YYMM");
        else if(fl1)puts("MMYY");
        else puts("NA");
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
// ACM-ICPCà\I2010 B. À}Æ½¸

#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

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

int main(){
	int w, h;
	string s[59];
	int step[30][30];
	while(cin >> w >> h, w){
		getline(cin, s[0]);
		for(int i=0;i<2*h-1;i++) getline(cin, s[i]);
		for(int i=0;i<2*h-1;i++) s[i] += " ";
		memset(step, -1, sizeof(step));
		queue< pair<int, int> > qu; qu.push(make_pair(0,0));
		step[0][0] = 1;
		while(!qu.empty()){
			pair<int, int> p = qu.front(); qu.pop();
			int x = p.first, y = p.second;
			for(int i=0;i<4;i++){
				int nx = x+dx[i], ny = y+dy[i];
				if(nx<0||h<=nx||ny<0||w<=ny) continue;
				if(s[2*x+dx[i]][2*y+dy[i]]=='1') continue;
				if(step[nx][ny]!=-1) continue;
				step[nx][ny] = step[x][y] + 1;
				qu.push(make_pair(nx, ny));
			}
		}
		cout << (step[h-1][w-1] == -1 ? 0 : step[h-1][w-1]) << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int alice =0;
        int Bob =0;
        for(int x=1;x<=n;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        for(int x=1;x<=n;x++) {
            if(x%2==1) {
                alice+=list.get(x-1);
            }else{
                Bob+=list.get(x-1);
            }
        }
        System.out.println(alice-Bob);
    }
}


Measured memory_bytes: 23892
def resolve():
  N = int(input())
  A = [int(x) for x in input().split(" ")]
  if N == 0 and A[0] != 1:
    print(-1)
    return True
  min_maxs = [0] * len(A)
  min_maxs[len(A)-1] = [A[-1], A[-1]]

  for index in reversed(range(len(A)-1)):
    min_maxs[index] = [min_maxs[index+1][0] // 2 + A[index], min_maxs[index+1][1] + A[index]]

  result = 1
  recent = 1
  for index in range(1, len(A)):
    num_of_node = (recent - A[index-1]) * 2
    if num_of_node < min_maxs[index][0]:
      print(-1)
      return True
    
    result += min(num_of_node, min_maxs[index][1])
    recent = min(num_of_node, min_maxs[index][1])

  print(result)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 85600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
template<class T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) : n(n), d(n + 1) {}
	void add(int i, T x) { // a[i]+=x
		for (i++; i <= n; i += i & -i) {
			d[i] += x;
		}
	}
	T sum(int i) { // return a[1]+a[2]+...a[i]
		T x = 0;
		for (i++; i; i -= i & -i) {
			x += d[i];
		}
		return x;
	}
	T range_sum(int i, int j) {
		return sum(j) - sum(i - 1);
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	V a(n + 1);
	rep1(i, n) {
		cin >> a[i];
	}
	VE<VE<P<int>>> Q(n + 1);
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		Q[r].push_back(make_pair(l, i));
	}
	V Prev(n + 1, -1);
	V ans(q);
	BIT<int> BIT(n + 1);
	rep1(i, n) {
		if (Prev[a[i]] == -1) {
			BIT.add(i, 1);
		}
		else {
			BIT.add(Prev[a[i]], -1);
			BIT.add(i, 1);
		}
		Prev[a[i]] = i;
		rep(x, Q[i].size()) {
			int l = Q[i][x].first, num = Q[i][x].second;
			ans[num] = BIT.range_sum(l, i);
		}
	}
	rep(i, q) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 33252
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll k, s;
        in >> k >> s;
        ll ans = 0;
        for (int x = 0; x <= k; x++) {
            if (s < x) {
                break;
            }
            for (int y = 0; y <= k; y++) {
                if (s < x + y) {
                    break;
                }
                int z = s - x - y;
                ans += 0 <= z && z <= k;
            }
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

int main(void){
    char s[10], t[10];

    scanf("%s %s", s, t);

    int i = 0, cnt = 0;
    while(s[i] != '\0'){
        if(s[i] == t[i]) cnt++;
        i++;
    }

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

    return 0;
}

Measured memory_bytes: 128
S=input()
from0=0
from1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=='1':
      from0+=1
    else:
      from1+=1
  else:
    if S[i]=='1':
      from1+=1
    else:
      from0+=1
print(min(from0,from1))

Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}


int main(){
    int h=in(),w=in();
    vector<vec> a(h,vec(w));
    rep(i,h){
        string s=stin();
        rep(j,w){
            a[i][j]=s[j]=='.'?0:1;
        }
    }
    vector<vector<bool>> done(h,vector<bool>(w));
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> que;
    if(a[0][0]==0)que.push(mp(0,mp(0,0)));
    else que.push(mp(1,mp(0,0)));
    done[0][0]=true;
    while(!que.empty()){
        int cost = que.top().first,x=que.top().second.first,y=que.top().second.second;
        que.pop();
        if(x==h-1 && y==w-1){
            if(a[h-1][w-1]==1)cost++;
            cout<<cost/2<<endl;
            return 0;
        }
        if(x<h-1 && !done[x+1][y]){
            int new_cost=a[x][y]==a[x+1][y]?cost:cost+1;
            que.push(mp(new_cost,mp(x+1,y)));
            done[x+1][y]=true;
        }
        if(y<w-1 && !done[x][y+1]){
            int new_cost=a[x][y]==a[x][y+1]?cost:cost+1;
            que.push(mp(new_cost,mp(x,y+1)));
            done[x][y+1]=true;
        }
    }
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
	val arr = readLine()!!.split(" ")
    val a: Int = Integer.parseInt(arr[0])
    val b: Int = Integer.parseInt(arr[1])
    val c: Int = Integer.parseInt(arr[2])
    val ab: Int = a - b
	var ans: Int = c - ab

  if(ans < 0){
     ans = 0
  }
  // 出力
  println(Integer.toString(ans));
}

Measured memory_bytes: 37948
N, L = [int(nl) for nl in input().split()]
T = []
for n in range(N):
  T.append(L + n)
T_abs = [abs(t) for t in T]
mn_T_abs = min(T_abs)
idx_mn_T_abs = T_abs.index(mn_T_abs)
T.pop(idx_mn_T_abs)
ans = sum(T)
print(ans)

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

int main()
{
    long long l,r;
    cin>>l>>r;
    long long mn=2019;
//    cout<<l<<"  "<<r<<endl;
    if(l/2019!=r/2019)mn=0;
    else if(l%2019==0||r%2019==0)mn=0;
    else
    {
        l%=2019;
        r%=2019;
//        cout<<l<<"  "<<r<<endl;
        for(long long i=l;i<=r;i++)
        {
            for(long long j=i+1;j<=r;j++)
            {
//                cout<<i<<"  "<<j<<endl;
                long long temp=(i*j)%2019;
                if(mn>temp)
                {
                    mn=temp;
//                    cout<<i<<" "<<j<<"  "<<mn<<endl;
                }
            }
        }

    }
        cout<<mn<<endl;
}


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

void solve()
{
  string s,t;
  cin >> s >> t;
  if (s==t.substr(0,s.size()))
    cout << "Yes" << endl;
  else cout << "No" << endl;

}

int main ()
{
      
     int t;
     t=1;//cin >> t;
     for (int tt=1;tt<=t;tt++)
     {
         solve();

     }

    return 0;
     
     
     
     
 }


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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 H,W; 
char C[55][55];
int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

bool sa(int h,int w){
    rep(k,4){
        int a=h+dx[k],b=w+dy[k];
        if(a<H && a>=0 && b<W && b>=0){
            if(C[a][b]=='#') return true;
        }
    }
    return false;    
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> C[i][j];
    bool can=true;
    rep(i,H){
        rep(j,W){
            if(C[i][j]=='#'){
                if(!sa(i,j)) can=false;
            }
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
int n,x,y,a[N];
long long Ans;
int get ()
{
	bool f=0; int x; char ch;
	while (!isdigit (ch=getchar ())) if (ch=='-') f=1; x=ch-48;
	while (isdigit (ch=getchar ())) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
bool cmp (const int a,const int b){return a>b;}
int main ()
{
	n=get ();
	for (int i=1;i<=n;++i) a[i]=get ();
	sort (a+1,a+n+1,cmp);
	for (int i=1;i<=n;++i)
	{
		if (a[i]==a[i+1])
		{
			if (!x) x=a[i],i++;
			else {y=a[i];break;}
		}
	}
	Ans=(long long)x*y;
	cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 640
I,a,i=input,24,int;n=i(I());d=[0]+sorted(list(map(i,I().split())))+[24]
for j in range(1,n+1,2):d[j]=24-d[j]
d.sort()
for j in range(n+1):a=min(a,abs(d[j+1]-d[j]))
print(a)

Measured memory_bytes: 9156