akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> AC(N, false);
  vector<int> WA(N, 0);
  rep(i,M) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC") {
      AC[p] = true;
    }
    if (s == "WA" && (!AC[p])) {
      WA[p]++;
    }
  }
  
  int ACs = 0, pena = 0;
  
  rep(i,N) {
    if (AC[i]) {
      ACs++;
      pena += WA[i];
    }
  }
  
  cout << ACs << " " << pena << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

//Tax Rate Changed(AOJ)
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp
//about 6 min
//全探索は経験があったのでやり方がわかった。が、while(1)で繰り返すやり方がうまいとは思えないので何か良い方法を知りたい。

int tax(int x,int y,int s){
    int max=0;
    rep2(i,1,s){
        rep2(j,1,s){
            if(i*(100+x)/100+j*(100+x)/100==s){
                if(i*(100+y)/100+j*(100+y)/100>max)max=i*(100+y)/100+j*(100+y)/100;
            }
        }
    }
    return max;
}

int main(){
    vin pay(10000);
    int i=0;
    while(1){
        int x,y,s;cin>>x>>y>>s;
        if(x==0&&y==0&&s==0)break;
        pay[i]=tax(x,y,s);
        i++;
    }
    int j=0;
    while(pay[j]){
        cout<<pay[j]<<endl;
        j++;
    }
}


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

ll lcm(ll a,ll b){
	if(a < b){
	 ll tmp;
	 tmp = a;
	 a = b;
	 b = tmp;
	}
	while(true){
		a %= b;
		if(a == 0)return b;
		else{
			b %= a;
			if(b == 0)return a;
		}
	}
}

int main(){
	ll a,b; cin >> a >> b;
	ll r = lcm(a,b);
	ll r_num = r;
	ll ans = 1;
	for(int i = 2;i<=sqrt(r);i++){
		if(r%i == 0){
			ans++;
			while(r%i==0)r/=i;
		}
		if(r == 1)break;
	}
  if(r != 1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int a, b, c, d, e, k;
  std::cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k) {
    std::cout << "Yay!\n";
  } else {
    std::cout << ":(\n";
  }
}

Measured memory_bytes: 256
import math
import itertools
import sys
sys.setrecursionlimit(20000)


def gcd(a, b):
    a, b = abs(a), abs(b)
    a, b = max(a, b), min(a, b)
    while b > 0:
        tmp = b
        b = a % b
        a = tmp
        a, b = max(a, b), min(a, b)
    return a


def dist(p, q):
    return math.sqrt((p[0] - q[0]) ** 2 +
                     (p[1] - q[1]) ** 2)


def is_liner(a, b, c):
    x = (b[0] - a[0], b[1] - a[1])
    y = (c[0] - a[0], c[1] - a[1])
    gcdx = gcd(x[0], x[1])
    x = (x[0] // gcdx, x[1] // gcdx)
    gcdy = gcd(y[0], y[1])
    y = (y[0] // gcdy, y[1] // gcdy)
    return x == y


def angle(a, b, c):
    p = (b[0] - a[0], b[1] - a[1])
    q = (c[0] - a[0], c[1] - a[1])
    ang = abs(math.atan2(p[1], p[0]) - math.atan2(q[1], q[0]))
    return min(ang, math.pi * 2 - ang)


def outer_soul(a, b, c):
    A = angle(a, b, c)
    B = angle(b, c, a)
    C = angle(c, a, b)
    s2A = math.sin(2*A)
    s2B = math.sin(2*B)
    s2C = math.sin(2*C)
    o = [0] * 2
    for i in range(2):
        o[i] = (s2A * a[i] + s2B * b[i] + s2C * c[i]) / (s2A + s2B + s2C)
    return o


def check(o, r, P):
    for p in P:
        if dist(o, p) > r + 1e-6:
            return False
    return True


def main():
    N = int(input())
    P = [None] * N
    for i in range(N):
        x, y = map(int, input().split())
        P[i] = (x, y)
    ans = float("inf")
    for a, b, c in itertools.combinations(P, r=3):
        if is_liner(a, b, c):
            continue
        o = outer_soul(a, b, c)
        r = dist(a, o)
        if check(o, r, P):
            ans = min(ans, r)
    for a, b in itertools.combinations(P, r=2):
        o = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2)
        r = dist(a, b) / 2
        if check(o, r, P):
            ans = min(ans, r)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

long long dfs(string S,string tmp,int now){
	if(now==S.size()){
		return 0;
	}
	tmp += S[now];
	now++;
	//cout << now<< endl;
	long long ll = stoll(tmp);
	if ((int)S.size() - now-1 >= 0)
	{
		ll *= pow(2, (int)S.size() - now-1);
		//cout << pow(2, (int)S.size() - now - 1) << endl;
	}
	return ll + dfs(S, "", now) + dfs(S, tmp, now);
}
int main()
{
	string S;
	cin >> S;
	cout << dfs(S, "", 0) << endl;
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int n,w;
int dp[102][10002];

signed main() {
cin>>n>>w;
vector<int>value(n);
vector<int>weight(n);
rep(i,n){
  cin>>value[i]>>weight[i];
}
rep(i,102){
  rep(j,10002){
    dp[i][j]=0;
  }
}
rep(i,n){
  rep(j,w+1){
    if(j>=weight[i])dp[i+1][j]=max(dp[i][j-weight[i]]+value[i],dp[i][j]);
    else dp[i+1][j]=dp[i][j];
  }
}
int ans=0;
rep(i,w+1){
  ans=max(ans,dp[n][i]);
}
cout<<ans<<endl;
}



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

LL arr[105];

int main()
{
    LL X , K , D;
    cin >>X >> D >> K;
    if(X<0) X=-X;
    LL num=X/K;
    if(num>=D)
    {
        cout << X-D*K ;
        return 0;
    }
    else
    {
        D-=num;
        X-=num*K;
        if(D&1)
        {
            cout << abs(X-K) ;
            return 0;
        }
        else
            cout << X;
    }

    return 0;

}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
ll n;
cin>>n;
vec(a,5);
a=getv<ll>(5);
vec(b,5);
rep(i,5){
  if(n%a[i])b[i]=n/a[i]+1;
  else b[i]=n/a[i];
}
ll ans=LLONG_MAX;
sort(all(b));
op(5+b[4]-1);
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string a,b,c;
int main() {
	// your code goes here
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
	cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
ABC = list(map(int, input().split()))
ABC.sort()
ans = 0

while ABC.count(min(ABC)) != 3:
    if ABC.count(min(ABC)) == 2:
        dif = ABC[2] - ABC[0]
        ABC[0] += dif
        ABC[1] += dif
        ans += dif
    else:
        ABC[0] += 2
        ans += 1
        ABC.sort()

print(ans)

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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    int a, b, h, ans;
    cin>>a>>b>>h;
    ans=(a+b)*h/2;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
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; }

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

  ll ans = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int l = 1; l <= k; ++l) {
        ans += gcd(i, gcd(j, l));
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  map<string, ll> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }

  ll sum = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    ll t = it->second;
    sum += t * (t - 1) / 2;
  }
  cout << sum << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs            v.size()
#define ss            s.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii            pair<int, int>
#define int           long long
#define ull           unsigned long long
#define pb            push_back
#define mpp           make_pair
#define Okay          0
#define pi            3.14159

const int inf = 1e6;
const int cont = 1e18;
using namespace std;

vector<int>Graph[20];
int ans = 0;
int n, m;

void dfs(set<int>st, int u){
    if(st.count(u))return;
    st.insert(u);
    if(st.size() == n){
        ans++;
        return;
    }
    for(int i=0; i<Graph[u].size(); i++){
        int v = Graph[u][i];
        dfs(st, v);
    }
}

void solve(){

    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a, b;
        cin>>a>>b;
        Graph[a].pb(b);
        Graph[b].pb(a);
    }
    set<int>st;
    dfs(st, 1);

    cout<<ans<<endl;
}

int32_t main() {
   Fast;
   int tst;

    solve();
    return Okay;
}



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)

int main()
{
    ll a,b;
    cin>>a>>b;

    a--;
    if(a==-1) a=0;
    if(a%4==0) a=a;
    else if(a%4==1) a=1;
    else if(a%4==2) a++;
    else a=0;
    if(b%4==0) b=b;
    else if(b%4==1) b=1;
    else if(b%4==2) b++;
    else b=0;
    ll ans=a^b;
    cout<<ans;
    return 0;
}


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

int main() {
  int *A, n, i, j, p=0, r, x, temp;

  scanf( "%d" , &n );
  A = malloc(n * sizeof(int));
  for ( j=0; j<n; j++ ) scanf( "%d" , &A[j] );

  r = n-1;
  x = A[r];
  i = p-1;
  for ( j=p; j<r; j++ )
    if ( A[j] <= x ) {
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  for ( j=0; j<(i+1); j++ ) printf( "%d " , A[j] );
  printf( "[%d] " , A[i+1] );
  for ( j=(i+2); j<(n-1); j++ ) printf( "%d " , A[j] );
  printf( "%d\n" , A[n-1] );

  return 0;
}



Measured memory_bytes: 2088
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        var A = Console.ReadLine().Split(' ').Select(x => float.Parse(x)).ToArray();

        float denominator = 0.0f;

        for (var i = 0; i < N; i++)
        {
            denominator = denominator + 1 / A[i];
        }

        var ans = 1 / denominator;

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N=1e5+5;
const int INF=0x3f3f3f;

int a[3][105];
int dp[3][105];

int main(void){
    int n;
    cin >> n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    dp[1][1]=a[1][1];
    dp[2][1]=dp[1][1]+a[2][1];
    for(int i=2;i<=n;i++)   dp[1][i]=dp[1][i-1]+a[1][i];
    for(int j=2;j<=n;j++)   dp[2][j]=a[2][j]+max(dp[1][j],dp[2][j-1]);
    /*for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++)
            printf("%d ",dp[i][j]);puts("");
    }*/
    cout << dp[2][n]<<endl;
}


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

int main(){
	int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i< n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	int mid = n/2;
	if(v[mid] == v[mid-1])
		cout<<0;
	else{
//		if(v[mid] == v[mid+1])
		cout<<v[mid]-v[mid-1];
	}
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strings"
)

var LowerAlphabets = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
	"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

var AlphabetNumberMap = map[string]int{
	"a": 10,
	"b": 11,
	"c": 12,
	"d": 13,
	"e": 14,
	"f": 15,
	"g": 16,
	"h": 17,
	"i": 18,
	"j": 19,
	"k": 20,
	"l": 21,
	"m": 22,
	"n": 23,
	"o": 24,
	"p": 25,
	"q": 26,
}

func main() {
	var n int
	fmt.Scan(&n)
	var names []string
	for n > 26 {
		names = append([]string{LowerAlphabets[((n - 1) % 26)]}, names...)
		n = (n-1) / 26
	}
	names = append([]string{LowerAlphabets[((n - 1) % 26)]}, names...)
	fmt.Println(strings.Join(names, ""))
}


Measured memory_bytes: 1856
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int n, p_sum;
long long int m;
long long int d[100001];
vector<pair <int, int> > p(10001);

int main()
{
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		p_sum = 0;
		for(int i = 0; i < n; i++){
			p[i].second = i;
			cin >> d[i] >> p[i].first;
			p_sum += (p[i].first) * d[i];
			p[i].first = -p[i].first;
		}
		sort(p.begin(), p.begin()+n);
		for(int i = 0; i < n; i++){
			if(m == 0) break;
			int min_m_d = min(d[p[i].second], m);
			p_sum += (p[i].first) * min_m_d;
			m -= min_m_d;
		}
		cout << p_sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1368
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	/*static double res=0;
	 static void help(int p,int r,int n){
		double tmp=p;
		for(int i=1;i<=n;i++){
			double x=1+(double)r/1200 ;
			tmp*=x;
		}
		res+=tmp;
		int k=100000,m=360;
		for(int i=m;i>0;i--){
			help(k,5,i);
		}
		System.out.println("paid amount "+k*m+" ");
		System.out.println((long)res);
	}*/
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
		int[] a=new int[n];
		int res=0;
		int[] c=new int[n];
		for(int i=0;i<n;i++){a[i]=s.nextInt();}
		for(int i=1;i<=n;i++){res+=s.nextInt();}
		for(int i=1;i<n;i++){c[i]=s.nextInt();}
		
		for(int i=1;i<n;i++){
			if(a[i]==a[i-1]+1){
				res+=c[a[i-1]];
			}
		}
		System.out.println(res);
	}
}			
	













Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
      int[] a = new int[10];
      for(int b =0;b<10;b++)
      a[b]=int.Parse(Console.ReadLine());
      Array.Sort(a);
      Console.WriteLine(a[9]);
      Console.WriteLine(a[8]);
      Console.WriteLine(a[7]);
      }
      }
      }

Measured memory_bytes: 9308
/**

n 人の学生を含むクラスでプログラミングの試験を行った。それぞれの得点をs1, s2 ... snとしたときの、標準偏差を求めるプログラムを作成せよ。

得点の平均値をｍとすれば、分散α2は以下の式で得られる：

α2 = (?ni=1(si - m)2)/n

分散の正の平方根が標準偏差αとなる。

 */

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成

		Scanner sc = new Scanner(System.in);
		//生徒の数に０がはいるまで処理を繰り返す
		while(true){

		//生徒の数を受け取る
		int intSeito = sc.nextInt();
		//生徒が０の場合処理を終了する
		if(intSeito == 0){
			break;
			}
		//点数と平均と結果を入れる変数を作る。
		int  [] Ten =new int [intSeito];
		double dbHeikin = 0;
		double dbKekka = 0;
		double dbGoukei = 0;
		//生徒の数だけ処理を繰り返す
		for(int i = 0; i < intSeito ; i ++){
			//受けとった数字をdb平均に足していく
			Ten [i] = sc.nextInt();
			dbGoukei += Ten[i];
		}
		//点の合計に生徒数を引いて平均点を出す。
		dbHeikin = dbGoukei/intSeito;
		//生徒の数だけ処理を繰り返す
		for(int j = 0; j < intSeito ; j++){
			//dbKekkaに点数-平均点の2乗を足していく
			dbKekka += Math.pow(Ten[j]-dbHeikin,2);
		}
		//dbKekkaから生徒の数を割り
		//平方根の中にいれる
        dbKekka= Math.sqrt(dbKekka/(double)intSeito);

        //結果表示
        System.out.println(dbKekka);


		}
	}
}

Measured memory_bytes: 23756
#include<stdio.h>

int main(void)
{
  int k,s,x=0,y=0,z=0,counter=0;
  scanf("%d %d",&k,&s);
  for(x=0;x<=k;x++)
    {
      for(y=0;y<=k;y++)
	{
	  if(s-(x+y) <= k && s-(x+y) >=0)
	    {
	      counter++;
	    }
	}
    }
    
  printf("%d\n",counter);
  return 0;
}


Measured memory_bytes: 128
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 998244353L

fun main() {
	abc000X()
}

fun abc000X() {
	val (l,r,d) = list()
	println((l..r).count {it%d==0})
}


Measured memory_bytes: 36508
/* ===================================*/
/* Author :   MD FAHAD                */
/* Email  :   fahad.mohad99@gmail.com */
/* Institute: HSTU                    */
/* ===================================*/

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using  namespace  std;



#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))

#define READ_IN freopen("Input.txt","r",stdin)
#define READ_OUT freopen("Output.txt","w",stdout)

typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{
    int N; cin >> N;

    set<int> a;

    for(int i=0;i<N;i++){

        int x; cin >> x;

        a.insert(x);
    }

    int k = a.size();


    if(k%2==0)
    cout << k-1 << "\n";
    else
        cout << k << "\n";


    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(){
int a,b,c;
  int ans=1;
  scanf("%d %d %d",&a,&b,&c);
  if(a!= b){
  ans++;
  }
  if(c!=a & c!=b){
  
  ans++;
  }
  printf("%d\n",ans);
  return(0);
}

Measured memory_bytes: 128
array_1 = []
for i in range(3):
    line = input().rstrip().split(' ')
    array_1.append(line)
    
# print(array_1)

bool_array = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(False)
    bool_array.append(tmp)

# print(bool_array)

num = int(input().rstrip())
for i in range(num):
    input_line = input().rstrip()
    for j in range(3):
        for k in range(3):
            if array_1[j][k] == input_line:
                bool_array[j][k] = True

ans = "No"
for i in range(3):
    if bool_array[i][0] and bool_array[i][1] and bool_array[i][2]:
        ans = 'Yes'

for i in range(3):
    if bool_array[0][i] and bool_array[1][i] and bool_array[2][i]:
        ans = 'Yes'

if bool_array[0][0] and bool_array[1][1] and bool_array[2][2]:
    ans = 'Yes'

if bool_array[0][2] and bool_array[1][1] and bool_array[2][0]:
    ans = 'Yes'
    
    
print(ans)

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

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

  string str2 = str;
  reverse(str.begin(), str.end());
  if (str == str2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 10000;
  rep(i, s.size()-t.size()+1){
    int cnt = 0;
    rep(j, t.size()){
      if (s[i+j] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514];
ll num[2];
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	if(n%2){
		for(int i=0;i<(n-1)/2;i++){
			num[1]+=2*a[n-1-i];
			num[2]-=2*a[i];
		}
		num[1]-=a[n-1-(n-1)/2]+a[n-2-(n-1)/2];
		num[2]+=a[(n-1)/2]+a[(n-1)/2+1];
		for(int i=(n-1)/2+2;i<n;i++){
			num[1]-=2*a[n-1-i];
			num[2]+=2*a[i];
		}
		ans=max(num[1],num[2]);
	}else{
		for(int i=0;i<n/2-1;i++)ans-=2*a[i];
		ans+=a[n/2]-a[n/2-1];
		for(int i=n/2+1;i<n;i++)ans+=2*a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
 
using namespace std;
 
#define MOD 100000
#define MAX_N 50
#define MAX_S 3001
typedef long long ll;
 
int main(){
    int N,M,S;
    while(cin >> N >> M >> S, N){
        ll dp[MAX_N][MAX_S] = {{}};
        dp[0][0] = 1;
        for(int i = 1 ; i <= M ; i++){
            for(int j = N*N ; j > 0 ; j--){
                for(int k = 0 ; k <= S-i ; k++){
                    dp[j][k+i] += dp[j-1][k];
                    dp[j][k+i] %= MOD;
                }
            }
        }
        cout << dp[N*N][S] << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 1000005;

int n;
string s;
int species[N];

bool good() {
    for (int i = 2; i < n; i++) {
        species[i] = species[i - 2] ^ (s[i - 1] ^ species[i - 1]);
    }
    int firstSpecies = species[n - 2] ^ (s[n - 1] ^ species[n - 1]);
    int lastSpecies = species[1] ^ (s[0] ^ species[0]);
    if (firstSpecies == species[0] && lastSpecies == species[n - 1]) {
    } else {
        return false;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    cin >> s;
//     n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') s[i] = 1;
        else s[i] = 0;
    }
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            species[0] = i;
            species[1] = j;
            if (good()) {
                for (int i = 0; i < n; i++) {
                    printf(species[i] == 1 ? "S" : "W");
                }
                printf("\n");
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 976
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  else return A * Pow(A * A % MOD, N / 2) % MOD;
}

ll nCr(ll N, ll R){
  ll ans = 1;
  for (ll i = 0; i < R; i++){
    ans *= N - i; ans %= MOD;
    ans *= Pow(i + 1, MOD - 2); ans %= MOD;
  }
  return ans;
}

int main(){
  ll X, Y; scanf("%lld%lld", &X, &Y);

  if (-1 * X + 2 * Y < 0 || (-1 * X + 2 * Y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }

  if (2 * X - Y < 0 || (2 * X - Y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }

  ll A = (-1 * X + 2 * Y) / 3, B = (2 * X - Y) / 3;
  printf("%lld\n", nCr(A + B, A));

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val result = Array(H, { IntArray(W, { 0 })})

    var i = 0
    var cur = 0
    while (i < H) {
        val indices = if (i % 2 == 0) (0..W-1) else (0..W-1).reversed()

        indices.forEach {j ->
            result[i][j] = cur + 1
            a[cur]--
            if (cur < N && a[cur] == 0) {
                cur++
            }
        }
        if (cur < N && a[cur] == 0) {
            cur++
        }
        i++
    }

    result.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 39696
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int power(int b,int p);
	
	int x,maxv=1;
	cin>>x;
	
	for(int i=2;i<=int(sqrt(x));i++){
		for(int j=2;j<=10;j++){
			if(power(i,j)<=x && power(i,j)>maxv)
			maxv=power(i,j);
		}
	}
	cout<<maxv;
	return 0;
}

int power(int i,int j){
	int ans=1;
	
	for(int k=1;k<=j;k++){
		ans*=i;
	}
	return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e8+5);
void max_self(ll &a, ll b) {
    a = max(a, b);
}
void min_self(ll &a, ll b) {
    a = min(a, b);
}
void mul(ll &a, ll b) {
    a = (a * b) % mod;
}
void add_self(ll &a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}

ll n,m;
pair<ll,ll> a[100005];

bool mycmp(pair<ll,ll> &x, pair<ll,ll> &y){
    return x.second<y.second;
}

ll f(ll n){
    if(n%4==0)
        return n;
    else if(n%4==1)
        return 1;
    else if(n%4==2)
        return n+1;
    else if(n%4==3)
        return 0;
}

ll run() {
    ll a,b;
    cin>>a>>b;
    if(a){
        ll ans =f(b)^f(a-1);;
        cout<<ans;
    }
    else{
        ll ans =f(b)^f(0);
        cout<<ans;
    }
}


















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

using namespace std;

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

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = max(0, i - 2); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define pn putchar('\n')
#define ps putchar(' ')
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N=1e5+5;


int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  for(int i=0;i<s.length();i++)
  {
  	 int j=i;
  	 ans++;
  	 while(j<s.length()&&s[i]==s[j])
  	 {
  	 	 j++;
	   }
	   i=j-1;
   } 
   cout<<ans;
}





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

using namespace std;

int main() {

    int X, N;
    cin >> X >> N;

    int p[N + 1];
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    p[N + 1] = 100000;

    for (int i = 0; i <= 50; i++) {
        int ans_up = X + i;
        int ans_down = X - i - 1;
        

        for (int j = 1; j <= N + 1; j++) {
            if (ans_up == p[j]) {
                break;
            }
            if (j == N + 1) {
                cout << ans_up << endl;;
                return 0;
            }
        }

        for (int j = 1; j <= N + 1; j++) {
            if (ans_down == p[j]) {
                break;
            }
            if (j == N + 1) {
                cout << ans_down << endl;;
                return 0;
            }              
        }
    }

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int left = 0;
    int right = 10001;
    int ans = 100000000;
    while (left < right){
        int mid = (left+right)/2;
        // cout << "mid:" << mid << endl;
        int eight = mid * 0.08;
        int ten = mid * 0.1;
        if (eight == a && ten == b){
            ans = min(mid, ans);
        }
        if (mid * 0.08 > a && mid * 0.1 > b) right = mid;
        else left = mid + 1;
    }
    if (ans > 10000) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

const int MAXN = 2005;
const int MIN = -100000;

int n, a[3 * MAXN], shift, mx, dp[MAXN][MAXN], r[MAXN], c[MAXN];

struct todo{
	int i, j, val;
	todo(int i, int j, int val): i(i), j(j), val(val){}
};

void upd(int i, int j, int val){
	dp[i][j] = max(dp[i][j], val - shift);
	r[i] = max(r[i], dp[i][j]);
	c[j] = max(c[j], dp[i][j]);
	mx = max(mx, dp[i][j] + shift);
}

vector <todo> v;
void add_todo(int i, int j, int val){
	v.push_back(todo(i, j, val));
}
void fix(){
	for(todo d : v)
		upd(d.i, d.j, d.val);
	v.clear();
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < 3 * n; i++){
		scanf("%d", &a[i]);
		a[i]--;
	}
	
	shift = 0, mx = 0;
	for(int i = 0; i < n; i++){
		r[i] = MIN;
		c[i] = MIN;
	}
	for(int i = 0; i < n; i++)
	for(int j = 0; j < n; j++){
		dp[i][j] = MIN;
	}
	
	upd(a[0], a[1], 0);
	upd(a[1], a[0], 0);
	
	/*
	cout << "--------------" << endl;
	cout << "Initial ::: " << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)
			cout << dp[i][j] + shift << ' ';
		cout << endl;
	}
	cout << "--------------" << endl;*/
	
	for(int k = 0; k < n - 1; k++){
		for(int i = 0; i < 3; i++)
		for(int j = i + 1; j < 3; j++){
			int x = a[2 + 3 * k + i], y = a[2 + 3 * k + j];
			int z = a[2 + 3 * k] ^ a[3 + 3 * k] ^ a[4 + 3 * k] ^ x ^ y;
			int rmx = max(mx, dp[z][z] + shift + 1);
			
			add_todo(x, y, rmx);
			add_todo(y, x, rmx);
		}
		for(int i = 0; i < 3; i++){
			int x = a[2 + 3 * k + i];
			int y = a[2 + 3 * k + (i + 1) % 3];
			int z = a[2 + 3 * k + (i + 2) % 3];
			
			for(int j = 0; j < n; j++){
				int cmx = max(c[j] + shift, (y == z ? dp[y][j] + shift + 1 : MIN));
				add_todo(x, j, cmx);
				
				int rmx = max(r[j] + shift, (y == z ? dp[j][y] + shift + 1 : MIN));
				add_todo(j, x, rmx);
			}
		}
		
		if(a[2 + 3 * k] == a[3 + 3 * k] && a[3 + 3 * k] == a[4 + 3 * k]){
			shift++;
			mx++;
		}
		fix();
		/*
		cout << "--------------" << endl;
		cout << 2 + 3 * k << " ::: " << endl;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++)
				cout << dp[i][j] + shift << ' ';
			cout << endl;
		}
		cout << "--------------" << endl;*/
	}
	
	mx = max(mx, dp[a[3 * n - 1]][a[3 * n - 1]] + shift + 1);
	printf("%d\n", mx);
		
	return 0;
}


Measured memory_bytes: 19604
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int N, M, Q, ans = -1;
vector<int> a, b, c, d;

// 条件を満たす数列 vec を深さ優先探索で全て列挙し、スコアの最大値を求める
void dfs(int cnt, vector<int> vec)
{
    if (cnt == N) // N 個の要素を構成した場合、スコアを算出
    {
        int score = 0;
        for (int i = 0; i < Q; ++i)
        {
            if (vec[b[i]] - vec[a[i]] == c[i])
            {
                score += d[i];
            }
        }
        ans = (std::max)(ans, score);
    }
    else
    {
        // 数列を構成　
        for (int i = vec[cnt]; i <= M; ++i)
        {
            vector<int> nextvec = vec;
            nextvec.push_back(i);
            dfs(cnt + 1, nextvec);
        }
    }
}

int main()
{
    cin >> N >> M >> Q;
    a.reserve(Q), b.reserve(Q), c.reserve(Q), d.reserve(Q);
    for (int i = 0; i < Q; ++i)
    {
        int at, bt, ct, dt;
        cin >> at >> bt >> ct >> dt;
        --at, --bt;
        a[i] = at, b[i] = bt, c[i] = ct, d[i] = dt;
    } 
    vector<int> v = {1}; // A0 = 1
    dfs(0, v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 105
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
const int M = 4;
ll dp[maxn][M][M][M];
int n;

bool ok(string s)
{
    int len = s.length();
    for(int i = 0; i < len; i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') continue;
        else return false;
    }
    return true;
}

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    string s;
    cin >> s;
    int len = s.length();
    int mx = 0;
    for(int i = 0; i < len; i++){
        for(int l = 1; l <= len - i; l++){
            string st = s.substr(i, l);
           // cerr << st << endl;
            if(ok(st)) mx = max(mx, (int)st.length());
        }
    }
    cout << mx << endl;
    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n,d; cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d,0));
    rep(i,n)rep(j,d)cin>>x[i][j];

    int ans=0;
    rep(i,n)rep(j,i){
        int sum=0;
        rep(k,d)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        int tmp=floor(sqrt(sum));
        if(tmp*tmp==sum)ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int n; cin >> n;
    vector<ll> a(n); 
    ll total = 0;   
    FOR(i, 0, n) {
        cin >> a[i];
        total ^= a[i];
    }
    vector<ll> ans;
    FOR(i, 0, n) ans.push_back(total ^ a[i]);
    FOR(i, 0, ans.size()) cout << (i ? " " : "") << ans[i];
    cout << endl;
}

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

Measured memory_bytes: 6876
#include <iostream>
#include <limits.h>

const long MAX_N = 100000;
const long MAX_M = 10000;
const long FEE = 100;

long next(bool *stations, long N, long current) {
  long i = current + 1;

  if (i >= N) {
    i = 0;
  }

  if (i < 0) {
    i = N - 1;
  }

  while(!stations[i]) {
    i++;

    if (i >= N) {
      i = 0;
    }
  }

  return i;
}

long previous(bool *stations, long N, long current) {
  long i = current - 1;

  if (i >= N) {
    i = 0;
  }  

  if (i < 0) {
    i = N - 1;
  }

  while(!stations[i]) {
    i--;

    if (i < 0) {
      i = N - 1;
    }
  }

  return i;
}

int main(void) {
  bool stations[MAX_N] = {false};

  long N = 0;
  long M = 0;
  long p = 0;

  std::cin >> N >> M >> p;

  stations[0] = true;

  for (long i = 0; i < M; i++) {
    long d = 0;
    
    std::cin >> d;

    long index = (d - p);

    if (index < 0) {
      index += N;
    }
    
    stations[index] = true;
  }

  long cost = LONG_MAX;

  long m = 0;
  long clockwiseCurrent = 0;
  long counterClockwiseCurrent = 0;
  
  while (m <= M) {
    long nextStation = next(stations, N, clockwiseCurrent);

    long c = LONG_MAX;

    if (nextStation == 0) {
      c = clockwiseCurrent;
    } else {
      c = 2 * clockwiseCurrent + (N - nextStation);
    }

    cost = std::min(c, cost);
    
    long previousStation = previous(stations, N, counterClockwiseCurrent);

    if (previousStation == 0) {
      c = N - counterClockwiseCurrent;
    } else {
      c = 2 * (N - counterClockwiseCurrent) + previousStation;
    }

    cost = std::min(c, cost);

    m++;
    
    clockwiseCurrent = nextStation;
    counterClockwiseCurrent = previousStation;
  }

  std::cout << (cost * FEE) << std::endl;

  return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;

struct node{
	int tp,i,j,k;
};
node ans[200005];
int top,P=100000;
ll a[200005];
void pushop(int tp,int i,int j,int k){
	ans[++top]=(node){tp,i,j,k};
	if (tp==0) a[k]=a[i]+a[j];
	else a[k]=(a[i]<a[j]?1:0);
}
void set0(int p){
	pushop(0,P,P,p);
}
void set1(int p){
	set0(p);
	pushop(0,p,4,p);
}
void Add(int i,int j,int k){
	pushop(0,i,j,k);
}
int main(){
	//a[0]=328446235; a[1]=584328952;
	pushop(1,P,0,4);
	pushop(1,P,1,5);
	pushop(0,4,5,4);
	pushop(1,P,4,4);
	set0(5);
	Add(4,4,5);
	int p0=3,p1=4,p2=5;
	int A=200,B=201,f1=202,f2=203,v=204;
	Rep(i,29,0){
		set1(v); set0(B);
		For(j,1,i) Add(v,v,v);
		Add(A,v,f1);
		pushop(1,0,f1,f1);
		pushop(1,f1,p1,f1);
		
		Rep(j,29,0){	
			set1(v);
			For(k,1,j) Add(v,v,v);
			Add(B,v,f2);
			pushop(1,1,f2,f2);
			pushop(1,f2,p1,f2);
			
			set0(v); 
			Add(f2,p0,v);
			For(k,1,j) Add(v,v,v);
			Add(B,v,B);
			
			Add(f1,f2,v);
			pushop(1,v,p2,v);
			pushop(1,v,p1,v);
			For(k,1,i+j) Add(v,v,v);
			Add(2,v,2);
		}
		
		set0(v); 
		Add(f1,p0,v);
		For(j,1,i) Add(v,v,v);
		Add(A,v,A);
		
		//cout<<a[A]<<' '<<a[0]<<' '<<i<<endl;
	}
	cout<<top<<endl;
	For(i,1,top)
		cout<<(ans[i].tp?'<':'+')<<' '<<ans[i].i<<' '<<ans[i].j<<' '<<ans[i].k<<endl;
}

Measured memory_bytes: 4552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int ans[310][310];
bool seen[310][310];
ll dist[310][310], L;

void dijk(int beg, vector<vector<int>> &g, vector<vector<ll>> &d){
    vector<int> cand{beg};
    seen[beg][beg]=1;
    for(int t=0; cand.size()>0; ++t){
        vector<int> nx;
        priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
        for(int i=0; i<cand.size(); ++i){
            for(int j=0; j<g[cand[i]].size(); ++j){
                if(!seen[beg][g[cand[i]][j]]){
                    pq.push(make_pair(d[cand[i]][j], g[cand[i]][j]));
                }
            }
        }
        while(pq.size()>0){
            if(!seen[beg][pq.top().second]){
                int nw=pq.top().second;
                nx.push_back(nw);
                ans[beg][nw]=t;
                seen[beg][nw]=1;
                dist[beg][nw]=pq.top().first;
                for(int i=0; i<g[nw].size(); ++i){
                    if(!seen[beg][g[nw][i]]){
                        if(dist[beg][nw]+d[nw][i]<=L){
                            pq.push(make_pair(dist[beg][nw]+d[nw][i], g[nw][i]));
                        }
                    }
                }
            }
            pq.pop();
        }
        for(int i=0; i<nx.size(); ++i) dist[beg][nx[i]]=0;
        nx.swap(cand);
    }
}


int main() {
	int N, M;
	cin >> N >> M >> L;
	vector<vector<int>> v(N+1);
	vector<vector<ll>> cost(N+1);
	for(int i=0; i<M; ++i){
	    int A, B;
	    ll C;
	    cin >> A >> B >> C;
	    if(C<=L){
	        v[A].push_back(B);
	        cost[A].push_back(C);
	        v[B].push_back(A);
	        cost[B].push_back(C);
	    }
	}
	for(int i=1; i<=N; ++i){
	    for(int j=1; j<=N; ++j) ans[i][j]=-1;
	    ans[i][i]=0;
	    dijk(i, v, cost);
	}
	int Q;
	cin >> Q;
	for(int i=0; i<Q; ++i){
	    int s, t;
	    cin >> s >> t;
	    cout << ans[s][t] << endl;
	}
	return 0;
}


Measured memory_bytes: 3456
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int f[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
int inv[N];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int C (int n, int k) {
	return (f[n] * (ll)inv[k] % mod) * (ll)inv[n-k]%mod;
}

int main () {
	SpeedForce;
	cin >> n >> k;
	f[0] = 1;
	inv[0] = inv[1] = 1;
	For (i, 2, n) inv[i] = (mod -mod/i) * (ll)inv[mod%i] % mod;
	For (i, 1, n) {
		inv[i] = (inv[i-1] * (ll)inv[i]) % mod;
		f[i] = f[i-1] * (ll)i % mod;
	}

	For (i, k, n+1) {
		auto f = [&](ll x) {
			return x * (x+1)/ 2ll;
		};
		ll cur = f(i-1);
		ll now = f(n) - f(n-i);
		now %= mod;
		cur %= mod;
	//	cout << now << ' ' << cur << '\n';
		ans = (ans + 1 + now - cur + mod) % mod;
		
	}
	
	cout << ans << '\n';


	return Accepted;
}

// B...a

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

int arr[10000];

int main(){
    int n,k;
    //vector<int> v(n);
	cin>>n>>k;	
	for(int i=0;i<n;i++){
		//int aa; cin>>aa;
		//v.push_back(aa);
		cin>>arr[i];
	}
	//sort(v.begin(),v.end());
	sort(arr,arr+n);
	int aa=0;
	for(int i=0;i<k;i++){
		aa+=arr[i];
	}
	cout<<aa<<"\n";
	return 0;
}

Measured memory_bytes: 3636
from heapq import heappush, heappop
v,e,r = map(int,input().split())
edges=[[] for i in range(v)]
d = [float('INF')]*v

for i in range(e):
  s,t,c = map(int,input().split())
  edges[s].append([t,c])

que = []
heappush(que,(0,r))
d[r] = 0

while que:
  c, u = heappop(que)
  for v, s in edges[u]:
    if d[v] > s + c:
      d[v] = s + c
      heappush(que,(d[v],v))
for i in d:
  if i == float('inf'):
    print('INF')
  else:
    print(i)


Measured memory_bytes: 96968
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;



int main() {
   
   long long a;
   int n;
   long long  max =-1000000;
   long long  min =1000000;
   long long  sum =0;

   cin >>n;
   
   for(int i=0;i<n;i++){
       cin >>a;
       if(a<min)min =a;
       if(a>max)max=a;
       sum +=a;
   }
   cout<<min<<" "<<max<< " "<<sum<<endl;
  
}


Measured memory_bytes: 3124
#include<stdio.h>
int main() {
	int x;
	int i = 1;
	while (1) {
		scanf("%d", &x);
		if (x != 0) {
			printf("Case %d: %d\n", i, x);
			i++;
		}
		else {
			break;
		}
	
	}
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    ll n; cin >> n;
    vector <char> c;
    while (n) {
        c.pb(n % 26 + 'a' - 1);
        n = (n - 1) / 26;
    }
    ROF(i, c.size()  - 1, 0)
        cout << ((c[i] == '`') ? 'z' : c[i]);
    cout << '\n';
}

Measured memory_bytes: 3640