akhauriyash/Code-Regression huggingface dataset:
queue = []
head = 0
tail = 0
cnt = 0
MAX = 1000000
def enqueue(x):
    global tail
    global MAX
    queue[tail] = x
    tail += 1
    if tail == MAX:
        tail = 0


def dequeue():
    global head
    global MAX
    x = queue[head]
    head += 1
    if head == MAX:
        head = 0
    return x


queue.extend(range(0,MAX+1,1))
n, q = list(map(int,input().split()))
for i in range(0,n,1):
    idata, value = input().split()
    value = int(value)
    enqueue((idata,value))

while head!=tail:
    #print(queue)
    idata, value = dequeue()
    value -= q
    cnt += min(q,value+q)
    if value<=0:
        print(idata+" "+str(cnt)) 
        continue   
    enqueue((idata,value))





Measured memory_bytes: 57540
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int main(){
  int d; cin>>d;
  if(d==25)
  cout<<"Christmas"<<endl;
  else if(d==24)
  cout<<"Christmas Eve"<<endl;
  else if(d==23)
  cout<<"Christmas Eve Eve"<<endl;
  else
  cout<<"Christmas Eve Eve Eve"<<endl;


  return 0;
}


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

int main() {
  int K,N; cin >> K >> N;
  vector<int> A(N); vector<int> interval(N);
  for (int i =0; i<N; i++) {
    cin >> A.at(i);
    if (i >= 1) interval.at(i) = A.at(i) - A.at(i-1);
  }
  interval.at(0) = K + A.at(0) - A.at(N-1);
  
  int maxInterval =0;
  for (int i =0; i<N; i++) {
    maxInterval = max(interval.at(i), maxInterval);
  }
  
  cout << K - maxInterval << endl;
}
  

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  rep(i,n+1){
    rep(j,m+1){
      if(i*(m-j)+j*(n-i)==k){
        print("Yes");
        return 0;
      }
    }
  }
  print("No");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
    ll A, B;
    cin >> A >> B;
    for (ll C = 1; C < 4; C++){
        if((A*B*C)%2 == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = input[0], K = input[1];

        var bigArray = new SortedDictionary<long, long>();

        for(var i = 0; i < N; ++i)
        {
            var num_times = Console.ReadLine().Split();
            long num = long.Parse(num_times[0]), times = long.Parse(num_times[1]);
            if (!bigArray.ContainsKey(num))
                bigArray.Add(num, 0);
            bigArray[num] += times;
        }

        foreach(KeyValuePair<long, long> num_times in bigArray)
        {
            K -= num_times.Value;
            if (K > 0) continue;
            Console.WriteLine(num_times.Key);
            return;
        }
    }
}

Measured memory_bytes: 20292
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M; cin >> N >> M;
    vector<int> Hs(N); for (auto &hi : Hs) cin >> hi;
    vector<int> goodFlags(N, true);
    for (int i = 0; i < M; ++i)
    {
        int Ai, Bi; cin >> Ai >> Bi; --Ai; --Bi;
        if (Hs[Ai] > Hs[Bi])
        {
            goodFlags[Bi] = false;
        }
        else if (Hs[Ai] < Hs[Bi])
        {
            goodFlags[Ai] = false;
        }
        else
        {
            goodFlags[Ai] = goodFlags[Bi] = false;
        }
    }
    cout << count(goodFlags.begin(), goodFlags.end(), true) << endl;
}


Measured memory_bytes: 4048
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();

		int[][] numOfTrains = new int[n][n];

		for (int i=0;i<m;i++) {
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;

			numOfTrains[l][r]++;
		}

		int[][] numOfTrainsSum = new int [n][n];

		for (int i=0;i<n;i++) {
			for (int j=i;j>=0;j--) {
				if (j==i) {
					numOfTrainsSum[j][i]=numOfTrains[j][i];
				} else {
					numOfTrainsSum[j][i]=numOfTrainsSum[j+1][i]+numOfTrains[j][i];
				}
			}
		}

		int[][] ans = new int[n][n];

		for (int i=0;i<n;i++) {
			for (int j=i;j<n;j++) {
				if(j==i) {
					ans[i][j]=numOfTrainsSum[i][j];
				} else {
					ans[i][j]=ans[i][j-1]+numOfTrainsSum[i][j];
				}
			}
		}

		for (int i=0;i<q;i++) {
			int pp = sc.nextInt()-1;
			int qq = sc.nextInt()-1;
			System.out.println(ans[pp][qq]);
		}

	}




}




Measured memory_bytes: 164528
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	ll xr=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		xr=xr^a[i];
	}
	for(int i=0;i<n;i++)
	{
		a[i]=a[i]^xr;
		cout<<a[i]<<" ";
	}
	return 0;
}


Measured memory_bytes: 5072
using System;
using System.Linq;

namespace aoj
{
    class Program
    {
        static void Main(string[] args)
        {
            var sNum = int.Parse(Console.ReadLine());
            int[] S = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var qNum = int.Parse(Console.ReadLine());
            int[] Q = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var count = 0;
            for (var i = 0; i < Q.Length; ++i)
            {
                if (HasValue(S, Q[i])) { ++count; }
            }
            Console.WriteLine(count);
        }
        
        static bool HasValue(int[] _array, int _value)
        {
            for (var i = 0; i < _array.Length; ++i)
            {
                if (_array[i] == _value) { return true; }
            }

            return false;
        }

    }
}



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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	ll a,b;	cin >>a>>b;
	
	if(a<=8&&b<=8) cout <<"Yay!"<<endl;
	else cout <<":("<<endl;
	
	
    return 0;
}

Measured memory_bytes: 256
loop do
    n, m, a = gets.chomp.split.map(&:to_i)

    break if n == 0 && m == 0 && a == 0

    hl = []

    m.times do
        h, p, q = gets.split.map(&:to_i)
        hl.push [h, p, q]
    end

    hl = hl.sort_by(&:first).reverse

    ans = a

    for i in 0..m-1
        if ans == hl[i][1]
            ans = hl[i][2]
        elsif ans == hl[i][2]
            ans = hl[i][1]
        end
    end
    puts ans

end


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

using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  cin.ignore();

  y = y - 2 * x;
  if(y < 0){
    cout << "No" << endl;
    return 0;
  }

  int y_d = y / 2;
  int y_m = y % 2;
  if(y_m == 1){
    cout << "No" << endl;
    return 0;
  }

  if(y_d > x){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iW = int.Parse(sS[0]);
            int iH = int.Parse(sS[1]);
            int iN = int.Parse(sS[2]);
            List<ClsSmp> lstInp = new List<ClsSmp>();
            for (int i = 0; i < iN; i++)
            {
                sS = Console.ReadLine().Trim().Split(' ');
                ClsSmp oneUsr = new ClsSmp();
                oneUsr.iX = int.Parse(sS[0]);
                oneUsr.iY = int.Parse(sS[1]);
                oneUsr.iA = int.Parse(sS[2]);
                lstInp.Add(oneUsr);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<ClsSmp> lstZan = new List<ClsSmp>();
            lstZan.Add(new ClsSmp() { iX = 00, iY = 00, iA = 0 });
            lstZan.Add(new ClsSmp() { iX = iW, iY = iH, iA = 0 });
            for (int i = 0; i < lstInp.Count; i++)
            {
                switch (lstInp[i].iA)
                {
                    case 1:
                        if (lstZan[0].iX < lstInp[i].iX) { lstZan[0].iX = lstInp[i].iX; }
                        break;
                    case 2:
                        if (lstZan[1].iX > lstInp[i].iX) { lstZan[1].iX = lstInp[i].iX; }
                        break;
                    case 3:
                        if (lstZan[0].iY < lstInp[i].iY) { lstZan[0].iY = lstInp[i].iY; }
                        break;
                    case 4:
                        if (lstZan[1].iY > lstInp[i].iY) { lstZan[1].iY = lstInp[i].iY; }
                        break;
                }
            }
            int iOut = 0;
            if (lstZan[0].iX >= lstZan[1].iX || lstZan[0].iY >= lstZan[1].iY) { iOut = 0; }
            else
            {
                iOut = (lstZan[1].iX - lstZan[0].iX) * (lstZan[1].iY - lstZan[0].iY);
            }

            // 出力
            Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
        private class ClsSmp
        {
            public int iX { get; set; } = 0;
            public int iY { get; set; } = 0;
            public int iA { get; set; } = 0;
        }
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans;
    for (int i = min(a,c); i < max(c,d); i++){
        if (a <= i && i < b){
            if (c <= i && i < d){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,X; cin>>N>>X;
    vint m(N);
    REP(i,N) cin>>m[i];

    int sum=accumulate(ALL(m),0LL);
    int Min=*min_element(ALL(m));
    cout<<N+(X-sum)/Min<<endl;
}


Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		String N = sc.next();

		if(N.charAt(0) == N.charAt(1) && N.charAt(1) == N.charAt(2) || N.charAt(2) == N.charAt(3) && N.charAt(1) == N.charAt(2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

vector< vector<int> > v;
queue< pair<int,int> > q;

signed main(){

  int n,m; cin >> n >> m;
  v.resize(n+1);
  for(int i = 0; i < m; i++){
    int p,y; cin >> p >> y;
    q.push({p,y});
    v[p].push_back(y);
  }

  for(int i = 1; i <= n; i++){
    sort(v[i].begin(),v[i].end());
  }

  for(int i = 0; i < m; i++){
    pair<int,int> p = q.front();
    q.pop();
    auto it = lower_bound(v[p.first].begin(),v[p.first].end(),p.second) - v[p.first].begin();
    printf("%06d%06d\n",p.first,it+1);
  }

  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int bubble(int n,vector<int> v){
    int times=0;

    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(v[j-1]>v[j]) {
                swap(v[j-1],v[j]);
                times++;
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << v[i] << (i < n-1?' ':'\n');
    }
    return times;
}

int main(){
    int n,tmp;
    vector<int> v;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    cout << bubble(n,v) << endl;

    return 0;
}

Measured memory_bytes: 3156
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(aA) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    std::cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long int X;
    cin >> X;
    bool flag[X + 1];

    for (int i = 1; i < X + 1; i++){
        flag[i] = false;
    }

    flag[1] = true;
    for (int i = 2; i <= X; i++){
        int v = i * i;
        while(v <= X){
            flag[v] = true;
            v *= i; 
        }
    }
    for (int i = X; i >= 1; i--){
        if (flag[i]){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        int[] A = cin.ArrayInt(N);

        var dic = new Dictionary<long, long>();
        dic.Add(0, 1);
        long A_sum = 0;
        for (int i = 0; i < N; i++)
        {
            A_sum += A[i];
            if (dic.ContainsKey(A_sum)) dic[A_sum]++;
            else dic.Add(A_sum, 1);
        }
        long ans = 0;
        foreach (var x in dic.Values)
        {
            if (x >= 2) ans += x * (x - 1) / 2;
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] cArr = new char[h][w];

		for(int i=0; i<h; i++){
			String str = sc.next();
			for(int j=0; j<str.length(); j++){
				cArr[i][j] = str.charAt(j);
			}
		}
	
		boolean flag = true;

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(cArr[i][j] =='#'){
					if((i-1)>=0 && cArr[i-1][j]=='#'){
						continue;
					}else if((i+1)<h && cArr[i+1][j]=='#'){
						continue;
					}else if((j-1)>=0 && cArr[i][j-1]=='#'){
						continue;
					}else if((j+1)<w && cArr[i][j+1]=='#'){
						continue;
					}else{
						flag = false;
						break;
					}
				}
			}
			if(!flag) break;
		}
		
		if(!flag){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 21844
N, K = map(int, input().split())
A = list(map(int, input().split()))

A = [-1] + A

loop_pos = None
loop_start_time = None
loop_end_time = None
visited = [-1]*(N+1)
pos = 1
i = 0
while visited[pos] == -1:
    visited[pos] = i
    pos = A[pos]
    i += 1  
    if visited[pos] != -1:
        loop_pos = pos
        loop_start_time = visited[pos]
        loop_end_time = i

# print(loop_start_time, loop_end_time)
w = loop_end_time - loop_start_time
K = min(K, loop_start_time) + max(0, K-loop_start_time)%w
# print(f"K: {K}")

pos = 1
for i in range(K):
    # print(pos)
    pos = A[pos]
print(pos)

Measured memory_bytes: 100052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)
        if(s[i]==s[i+1] && s[i+1]==s[i+2])
        {
            cout<<"Yes";
            exit(0);
        }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<vector<ll>>G(N);

    rep(i,M){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    rep(i,G[0].size()){
        rep(j,G[G[0][i]].size()){
            if(G[G[0][i]][j]==N-1){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;


    return 0;
    

}

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


#define en "\n"
#define sqrt(n) sqrt((long double) n)
#define all(c) (c).begin() , (c).end()
#define MOD 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define flash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_input(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))


using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef set<int> seti;
typedef pair<double, double> pdd;
typedef long double ld;



const double EPS=0.000000001;
const double INFD32=1000000000;
const ll INF64=1000000000000000000;
const int INF32=1000000000;

#define maxN 30000000

signed main(void){
    int t=1;
    //cin>>t;
    while(t--){
      ll k;
      ll x;
      cin>>k>>x;
      ll start=(x+k)-1;
      ll end=(x-k)+1;
      for(ll i=min(start,end);i<=max(start,end);i++){
        cout<<i<<" ";
      }
    }
    return 0;
  }


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N;
  cin>>N;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  map<ll,ll> m;
  rep(i,N) m[v[i]]++;
  ll cnt = 0;
  for(auto x:m) cnt++;
  if(cnt>=4||cnt==0) cout<<"No"<<endl;
  if(cnt==2){
    ll p = 0;
    vector<ll> q(2);
    bool ok = true;
    for(auto x:m){
      if(p==0){
        if(x.first != 0) ok = false;
        q[0] = x.second;
      }
      if(p==1){
        q[1] = x.second;
      }
      p++;
    }
    if(ok&&q[1]==(q[0]*2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  if(cnt==1) {
    ll t = 0;
    for(auto x:m) t = x.first;
    if(t==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  if(cnt==3){
    ll t = 0;
    vector<ll> q(3);
    ll p = 0;
    for(auto x:m) {
      t ^= x.first;
      q[p] = x.second;
      p++;
    }
    if(t==0&&q[0]==q[1]&&q[1]==q[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
	int n;
	int last = 0;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		if(a >= last){
			ans++;
			last = a;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  ll x = a + b;
  ll cnt = (n / x) * a;
  cnt += min(a, n % x);
  cout << cnt << endl;
  return 0;
}

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

int32_t main(){
	int n, m; cin>>n>>m;
	int ans = 0;
	vector<int> dishes(m + 1, 0);
	for(int person = 0; person < n; person++){
		int k; cin>>k;
		for(int i = 0; i < k; i++){
			int x; cin>>x;
			dishes[x]++;
		}
	}
	for(int i = 1; i <= m; i++){
		if(dishes[i] == n){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = (LL(n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT fixed << setprecision(16)
const double PI = 3.1415926535897932;

template <class T, class U>
istream& operator >> (istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Suffix_Array.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator >> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int n, m, s, t;
vector<int> G[100000];
vector<LL> A[100000];
vector<LL> B[100000];
LL DA[100000];
LL DB[100000];
LL ans[100000];

void Dij(int st, vector<LL>* C, LL* dist) {
	PriorityQ<PP> Q;
	Q.push(PP(0, st));
	fill(dist, dist + n, INFLL);

	while (!Q.empty()) {
		PP p = Q.top(); Q.pop();
		LL d = p.first;
		int from = p.second;
		if (dist[from] != INFLL) continue;

		dist[from] = d;
		REP(k, 0, G[from].size()) {
			int to = G[from][k];
			LL cost = C[from][k];

			Q.push(PP(d + cost, to));
		}
	}
}


int main() {
	cin >> n >> m >> s >> t;
	--s; --t;

	REP(i, 0, m) {
		LL u, v, a, b;
		cin >> u >> v >> a >> b;
		--u; --v;
		G[u].push_back(v);
		G[v].push_back(u);
		A[u].push_back(a);
		A[v].push_back(a);
		B[u].push_back(b);
		B[v].push_back(b);
	}

	Dij(s, A, DA);
	Dij(t, B, DB);
	
	REP(i, 0, n) {
		ans[i] = DA[n - i - 1] + DB[n - i - 1];
	}
	REP(i, 1, n) {
		ans[i] = min(ans[i], ans[i - 1]);
	}
	reverse(ans, ans + n);
	REP(i, 0, n) {
		cout << 1000000000000000 - ans[i] << endl;
	}

	return 0;
}


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

int asumikana(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N;
int a[114514];

int main(void) {
	int i;
	int sumipe;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	qsort(a, N, sizeof(*a), asumikana);
	sumipe = 1;
	for (i = 1; i < N; i++) {
		if (a[i - 1] != a[i]) sumipe++;
	}
	printf("%d\n", sumipe);
	return 0;
}



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

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];

	for (int x = 0; x < n; x++) cin >> a[x];

	for (int y = 0; y < n; y++) {
		cout << a[y];
		if (y != n - 1) cout << " ";
	}
	cout << "\n";

	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j]>v) {
			a[j + 1] = a[j];
			j--;
			a[j + 1] = v;
		}
		for (int y = 0; y < n; y++) {
			cout << a[y];
			if (y != n - 1) cout << " ";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int cur;
    cin >> cur;
    int cnt=1;
    int ans=0;
    for(int n=1; n<N; n++) {
        int a;
        cin >> a;
        if(a==cur) {
            cnt++;
        } else {
            ans += cnt/2;
            cnt=1;
        }
        cur = a;
    }
    ans += cnt/2;
    cout << ans << endl;


    return 0;
    
}

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 



int main(){
	LL Q,H,S,D,N;
	cin>>Q>>H>>S>>D>>N;
	vector<pLL> A;
	A.push_back(ii(Q*8,0));
	A.push_back(ii(H*4,1));
	A.push_back(ii(S*2,2));
	A.push_back(ii(D,3));
	sort(A.begin(),A.end());
	if(A[0].second==3){
		cout<<(A[0].first*(N/2) + A[1].first/2*(N%2))<<endl;
	}
	else{
		cout<<(A[0].first/2)*N<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j, k;
	ll ret = 0;
	ll h, w;
	
    cin >> h >>w;

    if ( ( h == 1) || (w == 1) ) {
        cout << 1 << endl;
    }
    else {
        cout << (((h * w % 2) == 1) ? (h * w / 2 + 1) : h * w / 2) <<endl;
    }
	return 0;
}


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

int mod = 1000000007;

int main()
{
    int N, x, y, z;
    cin >> N;
    vector<vector<int>> list(N, vector<int>(N, -1));
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        for (int j = 0; j < x; j++)
        {
            cin >> y >> z;
            list[i][y - 1] = z;
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        int count = 0;
        bitset<15> x(i);
        bool np = true;
        for (int j = 0; j < N; j++)
        {
            if(x.test(j))//正直者
            {
                count++;
                for (int k = 0; k < N; k++)//j人目に対する証言
                {
                    if (list[j][k] == -1)
                        continue;
                    if (x.test(k) != list[j][k])
                        np = false;
                }
            } 
        }
        if(np)
            ans = max(ans, count);
    }
    cout << ans;
}

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

const ll MOD = 1000000007;

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

const ll MAX = 1000005;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  COMinit();
  int N;
  cin >> N;
  ll ans;
  if ( N==1 ) ans = 0;
  else if ( N==2 ) ans = 2;
  else {
    ans = modpow(10, N, MOD);
    ans = ans - (modpow(9, N, MOD));
    if (ans < 0) ans += MOD;
    ans = ans - (modpow(9, N, MOD));
    if (ans < 0) ans += MOD;
    ans = (ans + modpow(8, N, MOD)) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 27068
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;
typedef pair<int,int> P;
string s;
int k;
int INF=1000000000;
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int main(){
    int n,m;cin>>n>>m;
    vector<int> v[n];
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int num[n];
    rep(i,0,n) num[i]=i;
    int count=0;
    do{
        bool flag=true;
        for(int now=0;now<n-1;now++){
            bool flag2=false;
            for(int i=0;i<v[num[now]].size();i++){
                if(num[now+1]==v[num[now]][i]){
                    flag2=true;
                    break;
                }
            }
            if(!flag2){
                flag=false;
                break;
            }
        }
        if(flag) count++;
    }while(next_permutation(num+1,num+n));
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 300010
using namespace std;
struct tt{int l, r, sum;}t[6000010];
struct aa{int x, y;}a[N];
int n, m, l, root[N], ans, now, l1, x;
inline char gc(){
	return getchar();
	static char now[1<<16], *S, *T;
	if(S==T){T=(S=now)+fread(now, 1, 1<<16, stdin); if(S==T)return EOF;}
	return *S++;
}
inline int read(){
	int x=0, f=1; char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=gc();}
	return x*f;
}
inline bool cmp(aa a, aa b){return a.x<b.x;}
inline void ins(int i, int x, int L, int R){
	t[l]=t[i]; t[l].sum++;
	if(L<R){
		int mid=(L+R)>>1, l1=l;
		if(x<=mid){l++; t[l1].l=l; ins(t[i].l, x, L, mid);}
		else{l++; t[l1].r=l; ins(t[i].r, x, mid+1, R);}
	}
}
inline int csum(int x1, int x2, int a, int b, int L, int R){
	if(a<=L&&R<=b)return t[x1].sum-t[x2].sum;
	int mid=(L+R)>>1, s=0;
	if(a<=mid)s+=csum(t[x1].l, t[x2].l, a, b, L, mid);
	if(mid<b)s+=csum(t[x1].r, t[x2].r, a, b, mid+1, R);
	return s;
}
int main(){
	n=read(); m=read();
	for(int i=1; i<=n; i++){a[i].x=read(); a[i].y=read();}
	sort(a+1, a+1+n, cmp);
	l=root[0]=now=0;
	for(int i=1; i<=m; i++){
		root[i]=root[i-1];
		while(now<n&&a[now+1].x==i){
			now++;
			l++; l1=l; ins(root[i], a[now].y, 1, m); root[i]=l1;
		}
	}
	printf("%d\n", n);
	for(int i=2; i<=m; i++){
		ans=n;
		for(x=i; x<=m; x+=i)ans-=csum(root[x-1], root[x-i], x-i+1, x-1, 1, m);
		x-=i; if(x<m)ans-=csum(root[m], root[x], x+1, m, 1, m);
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> a(H); 
 
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  
  for (int i=0 ; i < W+2 ; i++){
    cout << "#" ;
  }
  cout << endl;
    
  for (int i = 0; i < H; i++) {
    cout << "#" << a.at(i) <<"#" << endl;
  }
   for (int i=0 ; i < W+2 ; i++){
    cout << "#" ;
  }
  cout << endl;
  
}


Measured memory_bytes: 3600
while True:
    n, s = map(int, input().split())
    if n == 0 and s == 0:
        break

    ans = 0
    for b in range(2 ** 10):
        comb = set()
        for i in range(10):
            if b >> i & 1:
                comb.add(i)
        if len(comb) == n:
            if sum(comb) == s:
                ans += 1
    print(ans)



Measured memory_bytes: 5592
#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;

int main(){
  vector<char> b(4);
  vector<int> a(4);
  rep(i,4){
    cin>>b[i];
    a[i] = b[i] - '0';
  }
  
  vector<char> op(3);
  
  
  rep(bit,8){
    int sum = 0;
    rep(j,3){
      if(bit>>j & 1){
        op[2-j] = '+';
        sum += a[3-j];
      }else{
        op[2-j] = '-';
        sum -= a[3-j];
      }
    }
    if(a[0]+sum == 7){
      rep(i,3) cout<<a[i]<<op[i];
      cout<<a[3]<<"=7"<<endl;
      return 0;
    }
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int n;
ll dp[404][404];
int a[404];
ll pre[404];
ll sum(int l,int r){return pre[r]-pre[l-1];}
int main(){
	memset(dp,inf,sizeof(dp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]+a[i];
	for(int i=1;i<=n;i++)dp[i][i]=0;
	for(int len=1;len<=n;len++){
		for(int l=1;l+len-1<=n;l++){
			int r=l+len-1;
			for(int i=l;i<r;i++){
				dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+sum(l,r));
			}
		}
	}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int pn = 0;
int p[1000000];
int s[1000000];

int main() {
    s[1] = 0;
    int i = 2;
    do {
        bool flg = true;
        for(int j = 0; j < pn; j++) {
            if(p[j] * p[j] > i) break;
            if(i % p[j] == 0) {
                flg = false;
                break;
            }
        }
        if(flg) p[pn++] = i;
        s[i] = pn;
    } while((++i) <= 999999);


    int n;
    while(cin >> n) {
        cout << s[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 7172
#include<iostream>
#include<map>
#include<stack>
#include<vector>
using namespace std;

int main() {
    int N;
    cin>>N;
    int a[N-1], b[N-1];
    for(int i=0;i<N-1;++i){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }

    vector<vector<int> >tree;
    vector<vector<int> >tree1;
    for(int i=0;i<N;++i){
        vector<int> tmp;
        tree.push_back(tmp);
        tree1.push_back(tmp);
    }
    for(int i=0;i<N-1;++i){
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
        tree1[a[i]].push_back(b[i]);
    }
    /**
    int tree[N][N];
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            tree[i][j] = 0;
        }
    }
    for(int i=0;i<N-1;++i){
        tree[a[i]][b[i]] = 1;
        tree[b[i]][a[i]] = 1;
    }
    **/

    int K=0;
    for(int i=0;i<N;++i){
        if(K<tree[i].size()) K = tree[i].size();
    }

    cout<<K<<endl;

    int tmparr[N];
    for(int i=0;i<N;++i){
        tmparr[i] = 1;
    }

    int tmp;
    stack<int> s;
    s.push(0);

    map<vector<int>, int>kmap;
    
    int i;
    while(!s.empty()){
        i = s.top();
        s.pop();
        tmp = tmparr[i];
        for(int j=0;j<tree1[i].size();++j){
            s.push(tree1[i][j]);
            vector<int> c;
            c.push_back(i);
            c.push_back(tree1[i][j]);
            kmap[c] = tmp;
            tmp = (tmp + 1) % (K+1);
            if(tmp == 0) tmp = 1;
            tmparr[tree1[i][j]] = tmp;
        }
    }

    for(int i=0;i<N-1;++i){
        vector<int>c;
        c.push_back(a[i]);
        c.push_back(b[i]);
        cout<<kmap[c]<<endl;
    }
}


Measured memory_bytes: 22308
import sys
n, m = map(int, input().split())

cnt = {}
for i in range(m):
    s, c = map(int, input().split())
    if cnt.get(s) is not None and cnt[s] != c:
        print(-1)
        sys.exit()
    cnt[s] = c

for i in range(10**n):
    si = str(i)
    if len(si) != n: continue

    flg = 0
    for j in range(n):
        if cnt.get(j + 1) is None:
            continue
        if si[j] == str(cnt[j + 1]):
            flg += 1
    if flg == len(cnt):
        print(i)
        sys.exit()
print(-1)


Measured memory_bytes: 9208
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(
            think(2, 10, 20),
            [30, 50, 90, 170, 330, 650, 1290, 2570, 5130, 10250]
        )

    def test_2(self):
        self.assertEqual(
            think(4, 40, 60),
            [200, 760, 3000, 11960, 47800, 191160, 764600, 3058360, 12233400, 48933560]
        )


def solve():
    r, d, x = read()
    result = think(r, d, x)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(r, d, x):
    length = 10
    result = [x]
    for i in range(length):
        result.append(result[-1] * r - d)
    return result[1:]


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5584
// B - Sum of Three Integers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int k,s; cin>>k>>s;
	int ans = 0;

	// for (int x=0; x<=s && x<=k; x++){
	for (int x=0; x<=min(s,k); x++){
		int yz = s - x;
		//0<=y+z<=k -> y+z+1 通り, k<y+z<=2k -> 2k-(y+z)+1 通り
		if (yz<=2*k) ans += (yz<=k)? yz + 1: 2*k - yz + 1;
	}

	cout<< ans <<endl;
}

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

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

    long n;
    cin >> n;
    int a[n + 1];
    a[0] = -1;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] != -2 && a[i] == a[i - 1]) {
            sum++;
            a[i] = -2;
        }
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,m;
int main(){FAST;
cin>>n>>m;
if(n == m){
  cout<<"Yes\n";
}
else{
  cout<<"No\n";
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	string t[3] = { "Sunny", "Cloudy", "Rainy" };

	string S;
	cin >> S;

	rep(i, 3)
	{
		if (S == t[i])
		{
			cout << t[(i + 1) % 3] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    ll n,a,b;scanf("%lld %lld %lld",&n,&a,&b);

    if(n==1&&a!=b||a>b){
        printf("0\n");
        return 0;
    }else if(n==2||n==1&&a==b){
        printf("1\n");
        return 0;
    }

    ll x=a*(n-2);
    ll y=b*(n-2);
    printf("%lld\n",y-x+1);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    d = d * d;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d) ans++;
    }
    cout << ans;

   return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    for (ll i = 0; i < N; i++) {
        cin >> H[i];
    }

    ll ans = 0;
    vector<ll> temp;
    while (any_of(cbegin(H), cend(H), [](auto x) { return x != 0; })) {
        for (ll i = 0; i < N; i++) {
            if (H[i] != 0) {
                temp.push_back(i); // index
            } else {
                if (temp.size() > 0) {
                    ll minnum = INT64_MAX;
                    for (ll i = 0; i < temp.size(); i++) {
                        minnum = min(minnum, H[temp[i]]);
                    }
                    ans += minnum;
                    for_each(cbegin(temp), cend(temp),
                             [&H, minnum](auto index) { H[index] -= minnum; });

                    vector<ll> temp2;
                    swap(temp, temp2);
                }
            }
        }
        if (temp.size() > 0) {
            ll minnum = INT64_MAX;
            for (ll i = 0; i < temp.size(); i++) {
                minnum = min(minnum, H[temp[i]]);
            }
            ans += minnum;
            for_each(cbegin(temp), cend(temp),
                     [&H, minnum](auto index) { H[index] -= minnum; });

            vector<ll> temp2;
            swap(temp, temp2);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  bool flag=false;
  string s;
  cin >> s;
  if(s[0] == 'A') flag=true;

  int count=0,c=0;
  for(int i=2;i<s.size()-1;i++) {
    if(s[i]=='C') count++;
  }
  for(int i=1;i<s.size();i++) {
    if('a'<=s[i] && s[i]<='z') c++;
  }
  if(flag&&count==1&&c==s.size()-2) cout << "AC" << endl;
  else cout << "WA" << endl;
}

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

int main(void)
{
  char s[101];
  scanf("%s", s);
  
  int l = strlen(s);
  for (int i = 0; i < l; i++){
    if (i % 2 == 0){
      //奇数番目
      if (s[i] == 'L'){
        printf("No");
        return 0;
      }
    }else{
      //偶数番目
      if (s[i] == 'R'){
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}


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

int n, len, i, j;
ll t [3001];
ll dp [3001][3001];

int main ()
    {
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        scanf ("%lld",&dp[i][i]);
    for (len=1; len<n; len++)
        for (i=1; i+len<=n; i++)
            {
            j=i+len;
            dp[i][j]=max(dp[i][i]-dp[i+1][j],dp[j][j]-dp[i][j-1]);
            }
    printf ("%lld\n",dp[1][n]);
    return 0;
    }


Measured memory_bytes: 70016
#include <iostream>

using namespace std;

int main(void){
    int a,b,i;
    cin >> a >> b;
    for(i=1;i<=1250;i++)
        if((int)(i*0.08)==a&&(int)(i*0.1)==b){
            cout << i;
            return 0;
        }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256