akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr int ddx[] = {1,1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr int ddy[] = {1,-1,1,-1,0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
constexpr int INF = 1<<28;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,C_h,C_w,D_h,D_w;
  cin>>H>>W>>C_h>>C_w>>D_h>>D_w;
  C_h--,C_w--,D_h--,D_w--;
  vector S(H,vector<char>(W));
  rep(i,H)rep(j,W)cin>>S[i][j];

  vector dist(H,vector(W,INF));
  dist[C_h][C_w] = 0;
  deque<int> deq;
  deq.emplace_front(C_h*W+C_w);
  while(!deq.empty()){
    int cur = deq.front();
    deq.pop_front();
    int y = cur/W;
    int x = cur%W;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]){
        dist[ny][nx] = dist[y][x];
        deq.emplace_front(ny*W+nx);
      }
    }
    rep(j,20){
      int ny = y+ddy[j];
      int nx = x+ddx[j];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]+1){
        dist[ny][nx] = dist[y][x]+1;
        deq.emplace_back(ny*W+nx);
      }
    }
  }
  int ans = dist[D_h][D_w];
  cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 8464
#include <iostream>
using namespace std;
int main(void){
    int m, f, b, debt;
    cin >> m >> f >> b;
     
    if(m >= b){
        cout << 0 << endl;
    }
     
    else{
        debt = b - m;
        if(f >= debt){
            cout << debt << endl;
        }
        else cout << "NA" << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int x,a,b;
  cin >> x >> a >> b;

  cout << (x-a)%b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;

    int price = 700;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'o') {
            price += 100;
        }
    }

    std::cout << price << std::endl;
}

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

int main() {
  int A, B, C, X; cin >> A >> B >> C >> X;
  int c = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++)
        c += (500 * i + 100 * j + 50 * k == X);
    }
  }
  cout << c << endl;
}


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

int main()
{
    int h1,m1,h2,m2,k;
    scanf("%i %i %i %i %i",&h1,&m1,&h2,&m2,&k);
    int tm = 60 - m1 + m2;
    if(h1==h2) tm =  m2-m1;
    else {
        for(int i = h1+1; i < h2; i++){
            if(i == 24) i = 0;
            tm += 60;
        }
    }
    int s = tm - k;
    if(s < 0) cout << "0";
    else cout << s;

    return 0;
}


Measured memory_bytes: 3764
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

ll f(ll x) {
	ll d = 1, cnt = 0;
	for (ll y = 9; x > 0; y *= 10)  {
		ll z = min(x, y);
		x -= z;
		cnt += d * z;
		d++;
	}
	return cnt;
}

int main() {
	for (;;) {
		ll N, K; cin >> N >> K;
		if (N == 0 && K == 0) break;
		N--;
		ll lb = 0, ub = N + 1;
		while (ub - lb > 1) {
			ll mid = (lb + ub) / 2;
			if (f(mid) <= N) lb = mid;
			else ub = mid;
		}
		N -= f(lb);
		stringstream ss;
		for (int i = 1; i <= 100; i++)
			ss << (lb + i);
		cout << ss.str().substr(N, K) << endl;
	}
}

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

int main() {
    string s;
    cin>>s;
    int c1=0,c2=0;
    for(auto it:s) c1+=(it=='A'), c2+=(it=='B');
    if(c1==3 || c1==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll L, R;
  while (cin >> L >> R) {
    int M = 2019;
    int res = M;
    for (int mi = 0; mi < M; mi++) {
      for (int mj = 0; mj < M; mj++) {
        if (L + mi < R - mj) {
          res = min(res, (int)((L + mi) * (R - mj) % M));
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 10.08.2020 13:05:55
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n,k;
    cin >> n >> k;
    vector<bool> have(n,true);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            --a;
            have[a]=false;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(have[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=205;
int n,ql,qr,ans;
int dist[maxn],que[maxn];
char e[maxn][maxn];

int solve(int s){
	rep(i,n)dist[i]=INF;
	dist[s]=0;
	ql=qr=0;
	que[qr++]=s;
	while(ql<qr){
		int x=que[ql++];
		rep(i,n)if(e[x][i]=='1'){
			if(dist[i]==INF){
				dist[i]=dist[x]+1;
				que[qr++]=i;
			}
			else{
				int cur=abs(dist[i]-dist[x]);
				if(cur!=1)return -1;
			}
		}
	}
	int mx=0;
	rep(i,n)mx=max(mx,dist[i]+1);
	return mx;
}

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%s",e[i]);
	ans=-1;
	rep(i,n)ans=max(ans,solve(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = ReadInt();
            WriteLine(3 * (r * r));
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}
long comb(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
using namespace std;

int main(){
   int n;
   std::cin >> n;
   std::vector<string> a(n);
   rep(i,n)std::cin >> a[i];
   sort(a.begin(),a.end());
   //rep(i,n)std::cout << a[i] << std::endl;
   int count=0;
   int max=0;
   string w="";
   for(int i=1;i<n;i++){
       if(a[i-1]==a[i]){
           count++;
           if(count==max)w=w+" "+a[i];
           if(count>max){
               w=a[i];
               max=count;
           }
       }
       else count=0;
       
   }
   if(max==0){
       rep(i,n)std::cout << a[i] << std::endl;
   }
   std::cout << w << std::endl;
}





Measured memory_bytes: 14336
#include <stdio.h>

int main(){    
    int N; 
    int M ;
    int C ;
    scanf("%d%d%d",&N,&M,&C);
    int arr[N][M];
    int arr2[M];
    for(int j =0 ; j<M ;j++){
        scanf("%d",&arr2[j]);
    }
    int sum , count =0;
    int i, j ;
    for(i=0 ; i<N ; i++){
       sum = 0 ;
      for(j =0 ; j<M ;j++){
        scanf("%d",&arr[i][j]);
        sum+=arr[i][j]*arr2[j];
      }
       if(sum+C > 0){
        count++;
      }

    }
    
    printf("%d",count);
    
} 

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll x;cin >> x;
	
	if(x % 11 == 0)
	{
		cout << (x / 11LL) * 2LL << endl;
	}
	else
	{
		ll ans = (x / 11LL)*2LL;
		x %= 11;
		if(x <= 6)cout << ans + 1 << endl;
		else cout << ans + 2 << endl;
	}
	
	return 0;
}

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 ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()

template <typename T>
using pr = array <T, 2>;

template <typename T>
using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 303;
int n, m, dp[N][N], cost[N][N];
char a[N][N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	ll res = 0;
	for (int j = 1; j < m; j++) {
		memset(& cost, 0, sizeof(cost));
		memset(& dp, 0x3f, sizeof(dp));
		for (int i = n - 1; i >= 0; i--) {
			for (int k = n - 1; k >= 0; k--) {
				cost[i][k] = cost[i + 1][k + 1] + (a[n - i][j] == a[n - k][j + 1]);
			}
		}
		dp[0][0] = 0;
		for (int i = 0; i <= n; i++) {
			for (int k = 0; k <= n; k++) {
				if (i > 0) {
					dp[i][k] = min(dp[i][k], dp[i - 1][k] + cost[i - 1][k]);
				}
				if (k > 0) {
					dp[i][k] = min(dp[i][k], dp[i][k - 1] + cost[i][k - 1]);
				}
			}
		}
		res += dp[n][n];
	}
	cout << res;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		long K = Long.parseLong(s[1]);
		long sum=0,ans=0;
		long a[]=new long[N];
		
		s=br.readLine().split(" ");
		for(int i=0;i<N;i++)
			a[i]=Long.parseLong(s[i]);
		
		Arrays.sort(a);
		
		if(K>=N)
			ans=0;	
				
		else 
		{
			for(int i=0;i<N-K;i++)
				sum+=a[i];
			ans=sum;
		}
		
		
		out.println(ans);
	
	}
}




Measured memory_bytes: 78088
#include<iostream>
#include<vector>
using namespace std;
struct E
{
	int u,v,w;
};
const int maxn = 2600;
vector<E> es;
vector<int> inv_g[maxn];
int dis[maxn]; 
bool vis[maxn];
const int inf = 1e9;
bool bellman_ford(int s,int n)
{
	for(int i=1;i<=n;++i)dis[i] = inf;
	dis[s] = 0;
	for(int t=1;t<n;++t) 
		for(E e:es)
			if(dis[e.u] != inf && dis[e.u] + e.w < dis[e.v])
				dis[e.v] = dis[e.u] + e.w;
	for(E e:es)
		if(vis[e.v] && dis[e.u] != inf && dis[e.u] + e.w < dis[e.v])
			return false;
	return true;
}
void dfs(int x)
{
	if(vis[x])return;
	vis[x] = 1;
	for(int y:inv_g[x])
		dfs(y);
}
int main()
{
	int n,m,p;
	cin>>n>>m>>p;
	for(int i=1;i<=m;++i)
	{
		int x,y,w;
		cin>>x>>y>>w;
		es.push_back({x,y,p-w});
		inv_g[y].push_back(x);
	}
	dfs(n);
	if(!bellman_ford(1,n))
		cout<<-1<<endl;
	else
		cout<<max(-dis[n],0)<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	
	int mini,maxi;
	mini= min(a,b);
	maxi= max(a,b);
	
	for(int i=1;i<=maxi;i++)
	{
		cout<<mini;
	}
	
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if n <= k:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 67832
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b,k;
	cin>>a>>b>>k;
	int cnt=0,ans;
	rep(i,105){
		int j=105-i;
		if(a%j==0 && b%j==0){
			cnt++;
			//cout<<cnt<<":"<<j<<endl;
		}
		if(cnt==k){
			ans=j;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1e9+7;

int main(){
    int n;
    cin>>n;
    int a[100010];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n,greater<int>());
    
    ll ans=1,cnt=0;
    rep(i,0,n-1){
        if(a[i]==a[i+1]){
            ans*=a[i];
            cnt++;
            i++;
        }
        if(cnt==2)break;
    }
    if(cnt==2)cout<<ans<<endl;
    else cout<<'0'<<endl;
    return 0;
}

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

inline int index(int n_half, int diff) {
    return n_half + (diff + 1) / 2;
}

int main() {
    int n, n_half;
    cin >> n;
    n_half = n >> 1;
    double p[n], dp[n_half + 1][n + 1];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i <= n_half; i++) {
        fill(dp[i], dp[i] + n + 1, 0);
    }
    dp[0][index(n_half, 1)] = p[0];
    dp[0][index(n_half, -1)] = 1 - p[0];
    for (int i = 1; i <= n_half; i++) {
        int k = i << 1;
        int max_diff = k + 1;
        dp[i][index(n_half, -max_diff)] = dp[i - 1][index(n_half, -max_diff + 2)] * (1 - p[k]) * (1 - p[k - 1]);
        for (int diff = -max_diff + 2; diff < max_diff; diff += 2) {
            dp[i][index(n_half, diff)] =
                dp[i - 1][index(n_half, diff - 2)] * p[k] * p[k - 1] +
                dp[i - 1][index(n_half, diff)] * (p[k] * (1 - p[k - 1]) + (1 - p[k]) * p[k - 1]) +
                dp[i - 1][index(n_half, diff + 2)] * (1 - p[k - 1]) * (1 - p[k]);
        }
        dp[i][index(n_half, max_diff)] = dp[i - 1][index(n_half, max_diff - 2)] * p[k] * p[k - 1];
    }
    double res = 0;
    for (int i = n_half + 1; i <= n; i++) {
        res += dp[n_half][i];
    }
    cout << setprecision(10) << res << endl;
    return 0;
}


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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

int main() {
	string s;
	cin >> s;

	while (s.size() > 1) {
		s = s.substr(0, s.size() - 2);
		if (s.substr(0, s.size()/2) == s.substr(s.size()/2, s.size())) break;
	}
	cout << s.size() << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(void)
{
	int b, r, g, c, s ,t;
	
	while (scanf("%d %d %d %d %d %d", &b, &r, &g, &c, &s, &t), t != 0){		
		int coin = 100;
		
		for (int i = 0; i < (b * 5) + (r * 3); i++){
			coin += 13;
		}
		coin += b * 15;
		coin += r * 15;
		
		for (int i = 0; i < g; i++){
			coin += 7;
		}
		
		for (int i = 0; i < c; i++){
			coin += 2;
		}
		
		for (int i = 0; i < s; i++){
			coin += 3;
		}
		
		coin -= (t - (b*5 + r*3))*3;
		
		printf("%d\n", coin);
	}
}

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


int main(){
	int n,m,i,sum = 0,count = 0;
	cin >> n;
	cin >> m;
	int a[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
		sum = sum + a[i];
	}
	sort(a, a+n, greater<int>());
	i = 0;
	while(1){
		if(a[i] >= ((double)sum)/(4*m)){
			count++;
			if(count >= m){
				break;
			}
		}
		else{
			break;
		}
		i++;
	}
	if(count >= m){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}


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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

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

int main() {
  int n,e=0,o=0;
  bool flag;//first->true second->false
  cin>>n;
  VI a(n);
  REP(i,n){
    cin>>a[i];
    if(a[i]%2==0)e++;
    else o++;
  }
  if(o==0)flag=false;
  else flag=true;
  if(flag)puts("first");
  else puts("second");
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n, m;
    while(cin >>n >>m && (n || m)){
        vector<P> p;
        for(int i = m; i >= 0; i--) p.push_back( P(0, i) );

        REP(i, n){
            REP(j, m){
                int tmp; cin >>tmp;
                p[j].first += tmp;
            }
        }

        sort(p.rbegin(), p.rend());

        REP(i, m - 1) cout <<1 + m - p[i].second <<" ";
        cout <<1 + m - p[m - 1].second <<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W=MI()
    if(1 in (H,W)):
        print(1)
        return
    print(ceil(H*W,2))
if __name__ == '__main__':
    main()

Measured memory_bytes: 6156
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int main(){
	
	int m;
	cin >> m;
	for(int i = 0; i < m; i++){
		set<string> s;
		string str;
		cin >> str;
		for(int j = 1; j < str.size(); j++){
			string prv = str.substr(0,j);
			string nxt = str.substr(j);

			string bprv = prv;
			string bnxt = nxt;
			reverse(bprv.begin(),bprv.end());
			reverse(bnxt.begin(),bnxt.end());

			s.insert(prv+nxt);
			s.insert(bprv+nxt);
			s.insert(prv+bnxt);
			s.insert(bprv+bnxt);

			s.insert(nxt+prv);
			s.insert(nxt+bprv);
			s.insert(bnxt+prv);
			s.insert(bnxt+bprv);
		}
		cout << s.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 996
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define MX 500009 
#define INF 100000000009
using namespace std;
 
int main(){
    string s;
    int n;
    cin>>s;
    if(s=="SUN")cout<<7;
    else if(s=="MON")cout<<6;
    else if(s=="TUE")cout<<5;
    else if(s=="WED")cout<<4;
    else if(s=="THU")cout<<3;
    else if(s=="FRI")cout<<2;
    else cout<<1;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

ll rec(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return 0;
	else return a / b * b * 3 + rec(a%b, b);
}


int main() {
	ll n, x; cin >> n >> x;
	cout << rec(n - x, x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int n,q;cin>>n>>q;
  string s;cin>>s;
  int idx=s.find("AC");
  vector<int> found;
  while(idx!=string::npos){
    found.push_back(idx);
    idx=s.find("AC",idx+2);
  }
  rep(i,q){
    int l,r;cin>>l>>r;
    auto begin=lower_bound(all(found),l-1);
    auto end=lower_bound(all(found),r-1);
    int count=end-begin;
    cout<<count<<endl;
  }
  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<queue>
#include<vector>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



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

	ll r = 0;
	ll g = 0;
	ll b = 0;

	for (int i = 0;i < n;i++){
		if (s[i] == 'R'){
			++r;
		}else if (s[i] == 'G'){
			++g;
		}else{
			++b;
		}
	}

	const ll total = r * g * b;
	ll total_wrong = 0;
	for (int i = 0;i < n - 2;i++){
		for (int j = 1;i+2*j < n;j++){
			bool is_false = s[i] == s[i+j] || s[i] == s[i+2*j] || s[i+j] == s[i+2*j];
			if (!is_false){
				total_wrong++;
			}
		}
	}
	const ll ans = total - total_wrong;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
import queue
k = int(input())
queue = queue.Queue()
for i in range(1, 10):
    queue.put(i)

for i in range(0, k - 1):
    x = queue.get()
    if x % 10 != 0:
        queue.put(10 * x + x % 10 - 1)
    queue.put(10 * x + x % 10)
    if x % 10 != 9:
        queue.put(10 * x + x % 10 + 1)
print(queue.get())

Measured memory_bytes: 12452
N,X = map(int, input().split())
l = sorted(map(int, input().split()+[X]))
r = [l[n+1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Measured memory_bytes: 14864
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}


int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>s1;
    if(n<3200)cout<<"red\n";
    else cout<<s1<<"\n";


    





    	






    

}



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

int main(){
	int N,K;
	int num=1;
	cin >> N >> K;
	for(int i=0;i<N;i++){
		if(num<=K){
			num*=2;
		}
		else num+=K;
	}
	cout << num << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = [None] * n

x[0] = 0
for i in range(n):
    aa = a[i] if i % 2 == 0 else -a[i]
    x[0] += aa
for i in range(1,n):
    x[i] = 2*a[i-1] - x[i-1]
print(' '.join(map(str, x)))


Measured memory_bytes: 19096
from collections import deque
import sys

N_MAX = 200000 + 5

H, W, K = map(int, input().split())
sth, stw, glh, glw = map(int, input().split())

INF = 10**6 * K

dp = [[INF for _ in range(W + 2)] for _ in range(H + 2)]

dp[0] = [-1] * (W + 2)
dp[H + 1] = [-1] * (W + 2)
for h in range(1, H + 1):
    s = sys.stdin.readline()
    dp[h][0] = -1
    dp[h][W + 1] = -1
    for w in range(1, W + 1):
        if s[w - 1] == "@":
            dp[h][w] = -1

dp[sth][stw] = 0


# Seen = [[INF]*W for _ in range(H)]
XY = {(1, 0), (-1, 0), (0, 1), (0, -1)}


def bfs(sth, stw, glh, glw):
    next_q = deque()
    next_q.append((sth, stw))

    while len(next_q) != 0:
        # キュー取り出し(先頭)
        h, w = next_q.popleft()
        for dh, dw in XY:
            for sk in range(1, K + 1):
                hs, ws = h + dh * sk, w + dw * sk
                if dp[hs][ws] == -1:
                    break
                if dp[hs][ws] == INF:
                    next_q.append((hs, ws))
                    dp[hs][ws] = dp[h][w] + 1
                elif dp[hs][ws] <= dp[h][w]:
                    # もし、dp[hs][ws] が 今の値以下なら
                    # その先はdp[hs][ws]をもとに 書き込まれている or 今後書き込まれる ので止める
                    break
                # if hs == glh and ws == glw:
                #    return dp[h][w] + 1
    # return -1


def main():
    bfs(sth, stw, glh, glw)

    if dp[glh][glw] == INF:
        print(-1)
    else:
        print(dp[glh][glw])


if __name__ == '__main__':
    main()


Measured memory_bytes: 53372
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i){
        if(s[i] == t[i]){ans+=1;}
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), i = 0, t = 0;
		int[] a = new int[N];
		boolean ok = true;
		while (N-->0) {
			a[i++] = sc.nextInt();
			ok&=((a[i-1]&1)==0);
		}
		if (ok) {
			while (true) {
				for (i=0; i<a.length; i++) {
					ok&=((a[i]&1)==0);
					if (ok) a[i] = a[i]/2;
				}
				if (!ok) break;
				t++;
			}
		}
		System.out.println(t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 36104
N = gets.to_i
NAMES = N.times.map{ gets[0] }.select{|s| %w(M A R C H).include?(s[0])}
h = Hash.new{|h, k| h[k] = 0 } 
NAMES.each{|s| h[s] += 1}

ans = 0
%w(M A R C H).combination(3).each do |(a, b, c)|
  ans += h[a] * h[b] * h[c]
end
p ans


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

int main(void){
	int K;
	cin >> K;
	vector<int> v;
	ll x = 7;
	ll ans = 1;
	ll L = log(K*K);
	while (1) {
		if (x%K == 0) break;
		if (ans>K) {
			cout << -1 << endl;
			return 0;
		} 
		int d = x%K;
		x = (10*d+7);
		ans++;
	}
	cout << ans << endl;

return 0;
}


Measured memory_bytes: 3592
// Knock, Knock. Tera baap aaya
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int n;
    cin >> n;
    set<string> a;
    string s;
    while(n--){
    	cin >> s;
    	a.insert(s);
    }
    cout << sz(a);
}


Measured memory_bytes: 19172
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, a, f = 0;
	scanf("%d", &n);
	rep(i, n){
	  scanf("%d", &a);
	  if(a != i + 1)++f;
	}
	printYN(f < 3);

	Please AC;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut a = vec![vec![0 as usize; m]; n];
    for i in 0..n {
        for j in 0..m {
            a[i][j] = sc.read();
            a[i][j] -= 1;
        }
    }
    let ans = solve(&a, vec![true; m], m - 1);
    println!("{}", ans);
}

fn solve(a: &Vec<Vec<usize>>, mut now: Vec<bool>, rep: usize) -> i32 {
    let (n, m) = (a.len(), a[0].len());
    let mut count: Vec<i32> = vec![0; m];
    for i in 0..n {
        for j in 0..m {
            if now[a[i][j]] {
                count[a[i][j]] += 1;
                break;
            }
        }
    }
    let mut cand = -1;
    let mut index = 0;
    for i in 0..m {
        if count[i] > cand {
            cand = count[i];
            index = i;
        }
    }
    if rep == 0 {
        cand
    } else {
        now[index] = false;
        std::cmp::min(cand, solve(a, now, rep - 1))
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .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: 4352
#include<iostream>
using namespace std;
 
int main(){
 
  int k,s;
  cin >> k >> s;
  int ans = 0;
   
  for(int x = 0;x<=k;x++){
    for(int y=0;y <= k; y++){
      
      int z = s - x - y;
      if(0 <= z && z <= k) ans++;
  
    }
  }
  
  cout << ans << endl;
  
}

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

using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

const ll oo = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-9;

#define DBG 0
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define TRM(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = " << (X[i][j]) << "\n";}
#define TRP(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = (" << (X[i][j]).xx << ", " << (X[i][j]).yy << ")\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

const ll mod = 1e9+7;

template <class T>
void myMin(T& a, T b){
	a = min(a,b);
}

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

	ll N;
	cin >> N;

	vvpl dp(N+1, vpl(N+1, {0,0}));

	FOR(i,0,N)
		cin >> dp[0][i].yy;

	FOR(len,1,N) {
		FOR(off,0,N) {
			if(len + off >= N)
				continue;
			dp[len][off].xx = oo;
			FOR(k,0,len) {
				hline;
				TR(len);
				TR(off);
				TR(k);
				TR(len-k-1);
				TR(off+k+1);
				TRP(dp,k,off);
				TRP(dp,len-k-1,off+k+1);
				myMin(dp[len][off],
						{ dp[k][off].xx + dp[len-k-1][off+k+1].xx + dp[k][off].yy + dp[len-k-1][off+k+1].yy
						, dp[k][off].yy + dp[len-k-1][off+k+1].yy
						});
			}

			TRP(dp,len,off);
		}
	}

	cout << dp[N-1][0].xx << endl;
}


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

const int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  string p;
  for(int i=0;i<n;){
    if(s1[i]!=s1[i+1]){
      p+='a';
      i++;
    }else{
      p+='b';
      i+=2;
    }
  } 
  int m=p.size();
  ll ans;
  if(p[0]=='a') ans=3;
  else ans=6;
  rep(i,m-1){
    if(p[i]=='a') ans=ans*2%mod;
    else{
      if(p[i+1]=='a') continue;
      else ans=ans*3%mod;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let cl: String = read();

	if cl == "Sunny" {
		println!("Cloudy"); 
	} else if cl == "Cloudy" {
		println!("Rainy");
	} else {
		println!("Sunny");
	}
}

Measured memory_bytes: 4352
s = gets.chomp.chars

gc = 0
ans = 0
s.each do |ss|
  if gc > 0
    gc -= 1
    if ss == 'g' 
      ans += 1
    end
  else
    gc += 1
    if ss == 'p' 
      ans -= 1
    end
  end
end
puts ans

Measured memory_bytes: 9596
x,y = map(int,input().split())
res = 10**12

#0,0
if x<=y:
    res = min(res, y-x)

#0,1
if x <= -y:
    res = min(res, -y-x+1)

#1,0
if -x<=y:
    res = min(res, y+x+1)

#1,1
if -x <= -y:
    res = min(res, -y+x+2)

print(res)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, D, X[12][12];

int main() {

	scanf("%d%d", &N, &D);
	rep(i, N) rep(j, D) {
		scanf("%d", &X[i][j]);
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int sum = 0;
			rep(d, D) {
				sum += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
			}
			if ((int)sqrt(sum) * (int)sqrt(sum) == sum) ans++;
		}
	}



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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n,k;
  int num=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
      if(num<k){
          num=num*2;
      }else{
          num=num+k;
      }
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> W(N);
    ll lsum = 0;
    ll rsum = 0;
    ll minv = 100000;
    for (ll i = 0; i < N; i++)
    {
        cin >> W.at(i);
        rsum += W.at(i);
    }

    minv = abs(rsum - lsum);

    for (ll i = 0; i < N; i++)
    {
        rsum -= W.at(i);
        lsum += W.at(i);
        minv = min(minv, abs(rsum - lsum));
    }

    cout << minv << endl;

    return;
}

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


Measured memory_bytes: 256
N,L = map(int, input().split() )
t = []
for i in range(N):
    t.append(L)
    L = L + 1
if 0 in t:
    print(sum(t))
elif t[0] > 0:
    print(sum(t[1:]))
else: 
    print(sum(t[:N-1]))

Measured memory_bytes: 3060
H, W, N = map(int, input().split())
sh, sw = map(int, input().split())
S = input()
T = input()

left = 0
right = W + 1
up = 0
down = H + 1

for s, t in zip(S[::-1], T[::-1]):
    if left + 1 >= right or up + 1 >= down:
        break

    if t == 'L':
        right = min(W + 1, right + 1)
    if t == 'R':
        left = max(0, left - 1)
    if t == 'U':
        down = min(H + 1, down + 1)
    if t == 'D':
        up = max(0, up - 1)

    if s == 'R':
        right -= 1
    if s == 'L':
        left += 1
    if s == 'D':
        down -= 1
    if s == 'U':
        up += 1

print('YES' if left < sw < right and up < sh < down else 'NO')


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

int main(){
    string C_1, C_2;
    cin >> C_1 >> C_2;
    if (C_1.at(0) == C_2.at(2) && C_1.at(1) == C_2.at(1) && C_1.at(2) == C_2.at(0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

int main(int arg, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<pair<int, int>>> A(V);
        for (int i = 0; i < E; i++) {
                int s, t, w;
                cin >> s >> t >> w;
                A[s].push_back({w, t});
                A[t].push_back({w, s});
        }
        vector<bool> U(V);
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
        q.push({0, 0});
        int sum = 0;
        while (!q.empty()) {
                auto c = q.top();
                q.pop();
                if (U[c.second])
                        continue;
                U[c.second] = true;
                sum += c.first;
                for (auto &a: A[c.second])
                        q.push(a);
        }
        cout << sum << endl;
        return 0;
}

Measured memory_bytes: 7816
l = sorted(list(map(int,input().split())))
x = abs(l[2]-l[0])
y = abs(l[2]-l[1])

if (x%2 == 0 and y%2 == 0): # 差が ぐぐ
    ans = x//2 + y//2
elif (x%2 == 1 and y%2 == 1): #差が きき
    ans = x//2 + y//2 + 1
else: # 差が ぐき or きぐ
    ans = x//2 + y//2 + 2

print (ans)


Measured memory_bytes: 9120