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

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define vecin(a, n) rep(i, n)scanf("%d", &a[i])
#define debug(d) fprintf(stderr, "%d\n", d)

using ll = long long;

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

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

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

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

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

int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	if (k > (n - 1)* (n - 2) / 2) {
		printf("-1\n");
		return 0;
	}
	printf("%d\n", n - 1 + (n - 1) * (n - 2) / 2 - k);
	rep(i, n - 1) {
		printf("1 %d\n", i + 2);
	}
	int index = 2, path = 3;
	rep(i, (n - 1)* (n - 2) / 2 - k) {
		printf("%d %d\n", index, path);
		if (path != n)++path;
		else {
			++index;
			path = index + 1;
		}
	}

	Please AC;
}


Measured memory_bytes: 504
def fibo(n):
	S=[1,1]
	s=1
	if n>1:
		for i in range(2,n+1):
			S.append(S[i-1]+S[i-2])
			s=S[i]
	return s

def main():
	if __name__=="__main__":
		n=int(input())
		print(fibo(n))

main()

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll x, y;
    cin >> x >> y;
    ll mx = y / 2;
    int ans = 1;
    while (x <= mx) {
        x *= 2;
        ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

void __print(ll x) {cerr << x;}
void __print(ld x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
	// #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    ll tc = 0;
    while(tc++ < t){
    	ll n;cin>>n;
    	if(n >= 30)	cout<<"Yes";
    	else cout<<"No";
    }
}

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

int main(){
  long n,m;
  cin >> n >> m;
  if(n==1&&m==1){
    cout << 1 << endl;
  }
  else if(n==1){
    cout << m-2 << endl;
  }
  else if(m==1){
    cout << n-2 << endl;
  }
  else{
    cout << (m-2)*(n-2) << endl;   
  }
}


Measured memory_bytes: 384
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<sstream>  
#include<set>  
#include<vector>  
#include<stack>  
#include<map>  
#include<queue>  
#include<deque>  
#include<cstdlib>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<ctime>  
#include<functional> 
#define INT_MAX 2147483647
#define INT_MIN -2147483648
typedef long long LL;
using namespace std;

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;
	cout << (b - a)*(b - a + 1)/2 - b;
}


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;
    cin>>n>>a>>b;
    if(n==1){
        if(a==b){
            cout <<1<<endl;
        }
        else{
            cout <<0<<endl;
        }
    }
    else{
        if(a>b){
            cout <<0<<endl;
        }
        else if(a==b){
            cout << 1<<endl;
        }
        else{
            cout <<(b-a)*(n-2)+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	x := iScan()
	m := iSScan(n)
	fmt.Println((x-sum(m))/min(m) + n)
}


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

int main(){
	stack<int> State;  //State.top() -->  Last '\' index
	stack<pair<int, int> > Lake;  //Lake.top().second --> area 
    string str;     cin >> str;
	int sum = 0, s;
	for (int i = 0; i < str.size() ; i ++){
		if (str[i] == '\\') State.push(i);
		else if (str[i] == '/' && !State.empty() > 0){
            s = i - State.top();
			sum += s;
			while((Lake.size() > 0) and (State.top() < Lake.top().first)){
			s += Lake.top().second;
			Lake.pop();
			}
			Lake.push(make_pair(State.top(), s));
			State.pop();
		}
	}
	stack<int> ans;
	while ( !Lake.empty() ){ans.push(Lake.top().second); Lake.pop();}
	cout << sum << endl;
	cout << ans.size();
	while ( !ans.empty() ){cout << " " << ans.top(); ans.pop();}
	cout << endl;
    return 0;
}



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

int main(){
	int n, b, f, r, v;
	int i, j, k;
	int count[4][3][10] = {0};
	
	cin >> n;
	
		for(i = 0; i < n; i++){
			cin >> b >> f >> r >> v;
			count[b -1][f - 1][r - 1] += v;
		}
		
		for(i = 0; i < 4; i++){
			for(j = 0; j < 3; j++){
				for(k = 0; k < 10; k++){
					cout << " " << count[i][j][k];
				}
				cout << endl;
			}
			if(i < 3){
				cout << "####################" << endl;
			}
		}

 	return 0;
}

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	string o,e;
	cin >> o;
	cin >> e;
	for(int i=0;i<o.length();i++){
		cout << o[i];
		if(e[i] == '\0') break;
		cout << e[i];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1010],b[1010];
char s[1010][1010];
int main()
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	memset(b,0,sizeof(b));
	memset(a,0,sizeof(a));
	for(i=1; i<=n; i++)
	{
		scanf("%s",s[i]+1);
		for(j=1; j<=m; j++)
			if(s[i][j]=='.')
			{
				a[i]++;
				b[j]++;
			}
	}
	for(i=1; i<=n; i++)
	{
		if(a[i]==m) continue;
		for(j=1; j<=m; j++)
			if(b[j]!=n) cout<<s[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
//    int x=sc.nextInt();
    int a=sc.nextInt();
//    int b=sc.nextInt();
//    int[] a={sc.nextInt(),sc.nextInt(),sc.nextInt()};
//    Arrays.sort(a);
    System.out.println(a<1200?"ABC":a<2800?"ARC":"AGC");
  }
}


Measured memory_bytes: 21844
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=186;
int sum[maxn][maxn],n,m,dp[2][maxn][maxn][maxn];
char s[maxn];
int que(int xl,int xr,int yl,int yr){
	int siz=(xr-xl+1)*(yr-yl+1),tot=sum[xr][yr]-sum[xl-1][yr]-sum[xr][yl-1]+sum[xl-1][yl-1];
	if(!tot||tot==siz)return 1;
	return 0;
}
void init(){
	rep(i,1,n)rep(j,i,n)for(int r=1,l=1;l<=m;l=r+1){
		r=l;
		if(!que(i,j,l,r)){
			dp[0][i][j][l]=l-1;continue;
		}
		while(r<m&&que(i,j,l,r+1))r++;
		rep(k,l,r)dp[0][i][j][k]=r;
	}
	/* for(int i=1;i<=n;++i)
        for(int j=i;j<=n;++j)
            for(int l=1,r;l<=m;l=r)
            {
                r=l;
                while(que(i,j,l,r)&&r<=m)r++;
                for(int p=l;p<r;++p)dp[0][i][j][p]=r-1;
                if(l==r)dp[0][i][j][l]=l-1,r++;
            }*/
}
/*int find(int c,int i,int j,int st){
	int l=i,r=j;
	int ans=0;
	while(l<r){
		int mid=(l+r)>>1;
	//	cout<<mid<<endl;
		ans=max(ans,min(dp[c][i][mid][st],dp[c][mid+1][r][st]));
		if(dp[c][i][mid][st]<dp[c][mid+1][r][st])r=mid;
		else l=mid+1;
	}
	return ans;
}*/
int find(int c,int u,int d,int L){
    int l=u,r=d-1,mid;
    int res=0;
    int v1,v2;
    while(l<=r)
    {
        mid=(l+r)/2;
        v1=dp[c][u][mid][L];
        v2=dp[c][mid+1][d][L];
        res=max(res,min(v1,v2));
        if(v1<v2)r=mid-1;
        else l=mid+1;
    }
    return res;
}
void go(int c){
	rep(i,1,n)rep(j,i,n)rep(l,1,m){
		//cout<<c<<' '<<i<<' '<<j<<' '<<l<<endl;
		int r=dp[c^1][i][j][l],tar;
		if(r!=m){
			tar=dp[c^1][i][j][r+1];tar=max(tar,find(c^1,i,j,l));
		}
		else tar=m;
		dp[c][i][j][l]=tar;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			sum[i][j]=(s[j]=='#');
		}
	}
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i][j-1];
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i-1][j];
	init();
	int ans=0;
	for(int i=1;dp[(i&1)^1][1][n][1]<m;i++)go(i&1),ans=i;
	printf("%d",ans);
	return 0; 
}

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

#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ll long long
#define sc second
#define fr first
const int nax = 2e5+5;
// const int mod = 1e4+7;
using namespace std;
typedef pair<double,double> pi;
typedef tuple<int,int,int> tu;

signed main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
    #endif
	int mod;
	cin >> mod;
	ll val = 7%mod;
	for(int i=1;i<1e7;i++)
	{
		if(val == 0)
		{
			cout << i << "\n";
			return 0;
		}
		val = (val*10+7)%mod;
	}
	cout << -1 << "\n";
	return 0;
}



Measured memory_bytes: 3644
c = [list(map(int,input().split())) for i in range(3)]
x = c[0][0]
for i in range(x+1):
    a1 = i
    b1 = x-i
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x := intSliceScanner(5)
	k := intScanner()
	if max(x)-min(x) <= k {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


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

int A[100005];

int main()
{
    int N, C, K;
    scanf("%d %d %d", &N, &C, &K);

    for(int i=1; i<=N; i++)
        scanf("%d", &A[i]);

    sort(A+1, A+1+N);

    int ans = 0, taken = 0, lim = 0;

    for(int i=1; i<=N; i++)
    {
        if(taken==0 || A[i]>lim)
        {
            ans++;
            taken = C-1;
            lim = A[i] + K;
        }
        else
            taken--;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }

int main()
{
    int n, k; cin >> n >> k;
    ll mod[k]={};
    FOR(i, 1, n+1) mod[i%k]++;

    ll ans = 0;
    FOR(a, 1, n+1){
        int m = (-a%k + k)%k;
        if(m==0 || 2*m == k){
            ans += mod[m]*mod[m];
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1],b[55],c[55];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n-1;i++) cin>>c[i];
	int tot=0;
	for(int i=0;i<n;i++){
		if(a[i+1]-a[i]==1&&a[i]<=n-1) tot+=b[i]+c[a[i]-1];
		else tot+=b[i];
	}
	cout<<tot<<endl;
	return 0;
}


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

int main(){
	int X;
	cin >> X;
	vector<vector<int>> data(2, vector<int>(X));
	int result = 0;
  
	for (int j = 0; j < 2; j++){
    	for( int i = 0; i < X; i++){
    		cin >> data.at(j).at(i);
    	}
    }
	
	for (int i = 0; i < X; i++){
      int row_num = 0;
      int get_num = 0;
      for ( int j = 0; j<X; j++){
		if ( i==j ) {
          get_num += data.at(row_num).at(j);
          row_num = 1;
        }
        get_num += data.at(row_num).at(j);
      }
      result = get_num > result? get_num:result;
    }
	cout << result << endl;
}

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

using namespace std;

struct Edge {
	int to, cap, cost, rev;
};

vector< vector<Edge> > G;

void addEdge(int from, int to, int cap, int cost) {
	if (from < 0 || to < 0) return;

	G[from].push_back({to, cap, cost, (int)G[to].size()});
	G[to].push_back({from, 0, -cost, (int)G[from].size()-1});
}

#define INF 1000000000

typedef pair<int, int> P;

int dist[21000], h[21000] = {0}, prevV[21000], prevE[21000];
int flow(int s, int t, int f) {
/*
	int res = 0;
	while (f > 0) {
		fill(&dist[0], &dist[0]+21000, INF); dist[s] = 0;
		while (1) {
			bool isUpdated = false;
			for (int i = 0; i < G.size(); ++i) {
				if (dist[i] == INF) continue;
				for (int j = 0; j < G[i].size(); ++j) {
					Edge& e = G[i][j];
					if (e.cap > 0 && dist[i]+e.cost < dist[e.to]) {
						dist[e.to] = dist[i]+e.cost;
						prevV[e.to] = i;
						prevE[e.to] = j;
						isUpdated = true;
					}
				}
			}
			if (!isUpdated) break;
		}

		if (dist[t] == INF) {
			cout << "ERROR" << endl;
			exit(1);
		}

		int d = f;
		for (int v = t; v != s; v = prevV[v]) {
			d = min(d, G[prevV[v]][prevE[v]].cap);
		}
		f -= d;
		res += d * dist[t];
		for (int v = t; v != s; v = prevV[v]) {
			Edge& e = G[prevV[v]][prevE[v]];
			e.cap -= d;
			G[e.to][e.rev].cap += d;
		}
	}
	return res;
*/
	int res = 0;
	while (f > 0) {
		fill(&dist[0], &dist[0]+21000, INF); dist[s] = 0;
		priority_queue<P, vector<P>, greater<P> > Q; Q.push({0, s});
		while ( !Q.empty() ) {
			P p = Q.top(); Q.pop();
			int v = p.second;
			if (p.first > dist[v]) continue;
			for (int i = 0; i < G[v].size(); ++i) {
				Edge& e = G[v][i];
				if (e.cap > 0 && dist[v]+e.cost+h[v]-h[e.to] < dist[e.to]) {
					dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
					prevV[e.to] = v;
					prevE[e.to] = i;
					Q.push({dist[e.to], e.to});
				}
			}
		}
		for (int i = 0; i < G.size(); ++i) h[i] += dist[i];

		if (dist[t] == INF) {
			cout << "ERROR" << endl;
			exit(1);
		}

		int d = f;
		for (int v = t; v != s; v = prevV[v]) {
			d = min(d, G[prevV[v]][prevE[v]].cap);
		}
		f -= d;
		res += d * h[t];
		for (int v = t; v != s; v = prevV[v]) {
			Edge& e = G[prevV[v]][prevE[v]];
			e.cap -= d;
			G[e.to][e.rev].cap += d;
		}
	}
	return res;
}

#define MAX_W 10000

int main() {
	int M, N, K; cin >> M >> N >> K;
	vector<int> w(N);
	for (int i = 0; i < N; ++i) {
		cin >> w[i];
	}
	vector<int> a(K);
	for (int i = 0; i < K; ++i) {
		cin >> a[i]; --a[i];
	}
	a.erase(unique(a.begin(), a.end()), a.end());
	K = a.size();

	int last = K;
	G.resize(2*K);
	vector<int> prev(N, -1);
	for (int i = 0; i < K; ++i) {
		addEdge(i-1, i, INF, MAX_W);
		if (prev[a[i]] > -1) {
			addEdge(prev[a[i]], last, 1, MAX_W*(i-prev[a[i]])-w[a[i]]);
			addEdge(prev[a[i]]+1, last, 1, MAX_W*(i-prev[a[i]]-1)-w[a[i]]);
			addEdge(last, i, 1, 0);
			++last;
		}
		prev[a[i]] = i;
	}
	G.resize(last);
//	for (int i = 0; i < N; ++i) {
//		addEdge(prev[a[i]], t, 1, -w[a[i]]);
//	}
//	addEdge(K-1, t, INF, 0);

	int sum = 0;
	for (int i = 0; i < K; ++i) {
		sum += w[a[i]];
	}
	cout << (sum - (MAX_W * (K-1) * (M-1) - flow(0, K-1, M-1))) << endl;
}

Measured memory_bytes: 4092
n, a, b = gets.split.map{|i| i.to_i}
ans = 0
for i in 1..n do
    temp, j = 0, i
    loop{
        if j==0 then
            break
        end
        temp+=j%10
        j/=10
    }
    if a<=temp && temp<=b then
        ans+=i
    end
end
puts ans

Measured memory_bytes: 1788
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 5e5+5;

const int mod = 1e9+7;

string s;
long long ans;
long long p2[N];
long long p3[N];

int main(){
    p2[0] = p3[0] = 1;
    for(int i = 1; i < N; i++){
        p2[i] = p2[i - 1] * 2;
        p3[i] = p3[i - 1] * 3;
        p2[i] %= mod;
        p3[i] %= mod;
    }
    int cnt1 = 0;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            ans += (p2[cnt1] * p3[s.size() - i - 1]) % mod;
            ans %= mod;
            cnt1++;
        }
    }
    ans += p2[cnt1];
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 8320
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, c);
  swap(b, c);
  printf("%d %d %d\n", a, b, c);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    char a,b;
    cin>>a>>b;
    if(a>b) cout<<'>'<<endl;
    else if(a<b) cout<<'<'<<endl;
    else cout<<'='<<endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
SC = [list(map(int, input().split())) for i in range(M)]


# 0も１桁に含める
start = 10**(N-1)
if N == 1:
    start = 0
stop = 10**N

flag = True

ans = ''
# 矛盾したらフラグをfalse
# 矛盾しなければフラグTrue
for i in range(start,stop):
    flag = True
    ans = str(i)
    for sc in SC:
        if ans[sc[0]-1] != str(sc[1]):
            flag = False
            break
    if flag:
        break

if flag:
    print(ans)
else:
    print(-1)



Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int c=0,f=0,j;
	char s[200];
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='C') 
		{
			j=i;
			c=1;
		}
	}
	for(int i=j;i<strlen(s);i++)
	{
		if(s[i]=='F') f=1;
	}
	if(c==1&&f==1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define N 11
using namespace std;
int n,np,id[N];
pair<int,int> pos[N];
double res=0;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) id[i]=i;
	for (int i=0;i<n;i++)
		cin>>pos[i].first>>pos[i].second;
	do{
		for (int i=0;i<n-1;i++){
			int x1=pos[id[i]].first,x2=pos[id[i+1]].first,y1=pos[id[i]].second,y2=pos[id[i+1]].second;
			res+=sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); 
			//cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<res<<endl;
		}
	}while(next_permutation(id,id+n));
	np=1;
	for (int i=1;i<=n;i++) np*=i;
	res/=np;
	//cout<<np<<endl;
	printf("%.7lf",res);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int N = sc.ni();
        int M = sc.ni();
        DisjointSetUnion dsu = new DisjointSetUnion(N);
        for (int i = 0; i < M; i++) {
        	dsu.connect(sc.ni()-1, sc.ni()-1);
        }
        int ans = 0;
        for (int i = 0; i < N; i++)
        	ans = Math.max(ans, dsu.weight[i]);
        pw.println(ans);
        
        pw.close();
    }
    
    //implementation of union find data structure
    static class DisjointSetUnion {
    	public int[] parent;
    	public int[] weight;
    	public int count;

    	public DisjointSetUnion(int N) {
    		count = N;
    		parent = new int[N];
    		for (int i = 0; i < N; i++)
    			parent[i] = i;
    		weight = new int[N];
    		Arrays.fill(weight,1);
    	}

    	//"find"
    	public int root(int p) {
    		while (p != parent[p]) {
    			p = parent[p];
    		}
    		return p;
    	}

    	//"union"
    	public void connect(int p, int q) {
    		p = root(p);
    		q = root(q);
    		if (p==q)
    			return;
    		if (weight[p] < weight[q]) {
    			parent[p] = q;
    			weight[q] += weight[p];
    		} else {
    			parent[q] = p;
    			weight[p] += weight[q];
    		}
    		count--;
    	}

    	public boolean connected(int p, int q) {
    		return root(p) == root(q);
    	}
    }
 
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 58024
#include<iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cctype>
#include<iterator>
#include <stdio.h>
#include <string.h>
//#include<conio.h>
#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using ld = long double;


int main()
{
	MEGA_MIND
			ll n, k,arr[200005],sum=0;
		cin >> n >> k;
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i];
		}
		sort(arr, arr + n);
		for (int i = n-1; i >= 0; i--)
		{
			if (k>0)
			{
				k--;
			}
			else
			{
				sum += arr[i];
			}
		}
		cout << sum << endl;
	
	return  0;
}



Measured memory_bytes: 1792
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------
int n, m;
vector<vector<int>> g;

int ok = false;

int visited[200100] = {0};

void bfs(int now, int counter){
    if(counter >= 2) return;
    for(int i = 0; i < g[now].size(); i++){
        if(visited[i] == 1) continue;
        if(g[now][i] == n - 1){
            ok = true;
            return;
        }
        bfs(g[now][i], counter + 1);
    }
}

int main(void){
    
    cin >> n >> m;
    g.resize(n);

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bfs(0, 0);

    if(ok){
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }


}

Measured memory_bytes: 12016
#include <cstdio>
#include <algorithm>
struct point
{
	int x, y;
}
p[200002];
int N, L = 1 << 30, R = -1 << 30;
long long diff()
{
	int WL = L, WR = R;
	for (int i = 1; i <= N; i++)
	{
		if (p[i].x > p[i].y)
			std::swap(p[i].x, p[i].y);
		WL = std::max(WL, p[i].x);
		WR = std::min(WR, p[i].y);
	}
	return (long long)(WL - L) * (R - WR);
}
int same()
{
	for (int i = 1; i <= N; i++)
		if (p[i].x > p[i].y)
			std::swap(p[i].x, p[i].y);
	std::sort(p + 1, p + N + 1, [] (const point &a, const point &b) { return a.x < b.x; });
	static int xmin[200002], xmax[200002], ymin[200002], ymax[200002];
	xmin[N + 1] = ymin[0] = 1 << 30;
	xmax[N + 1] = ymax[0] = -1 << 30;
	for (int i = N; i; i--)
	{
		xmin[i] = std::min(xmin[i + 1], p[i].x);
		xmax[i] = std::max(xmax[i + 1], p[i].x);
	}
	for (int i = 1; i <= N; i++)
	{
		ymin[i] = std::min(ymin[i - 1], p[i].y);
		ymax[i] = std::max(ymax[i - 1], p[i].y);
	}
	int O = 1 << 30;
	for (int i = 0; i <= N; i++)
		O = std::min(O, std::max(xmax[i + 1], ymax[i]) - std::min(xmin[i + 1], ymin[i]));
	return O;
}
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d%d", &p[i].x, &p[i].y);
		L = std::min(L, p[i].x);
		R = std::max(R, p[i].x);
		L = std::min(L, p[i].y);
		R = std::max(R, p[i].y);
	}
	printf("%lld\n", std::min(diff(), (long long)(R - L) * same()));
	return 0;
}


Measured memory_bytes: 4864
n = int(input())
S = [input() for _ in range(n)]
D = {}
for s in S:
    if s in D:
        D[s] += 1
    else:
        D[s] = 1
m = int(input())
T = [input() for _ in range(m)]
for t in T:
    if t in D:
        D[t] -= 1
D_sorted = sorted(D.items(), key=lambda x: x[1], reverse=True)
for k, v in D_sorted:
    print(max(0, v))
    exit()

Measured memory_bytes: 3064
package main

import (
    "fmt"
    "sort"
)

type As [][]int

func (a As) Len() int {
    return len(a)
}

func (a As) Swap(i, j int) {
    a[i], a[j] = a[j], a[i]
}

func (a As) Less(i, j int) bool {
    if a[i][1] == a[j][1] {
        return a[i][0] < a[j][0]
    }
    return a[i][1] < a[j][1]
}

func main() {
    var n, m int
    fmt.Scan(&n, &m)
    as := make(As, m)
    for i := 0; i < m; i++ {
        var a, b int
        fmt.Scan(&a, &b)
        b--
        as[i] = []int{a, b}
    }
    sort.Sort(as)
    var sum int
    var lb int
    for i := 0; i < m; i++ {
        a, b := as[i][0], as[i][1]
        if a > lb {
            lb = b
            sum++
        }
    }
    fmt.Println(sum)
}


Measured memory_bytes: 6784
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	c := make([]int, n)
	a := make([][]int, n)
	for i := range a {
		fmt.Scan(&c[i])
		a[i] = make([]int, m)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}

	ans := math.MaxInt32
	for bit := 0; bit < (1 << uint(n)); bit++ {
		sum := make([]int, m)
		price := 0
		ok := true
		for i := 0; i < n; i++ {
			if bit&(1<<uint(i)) == 0 {
				continue
			}
			for j := 0; j < m; j++ {
				sum[j] += a[i][j]
			}
			price += c[i]
		}
		for _, s := range sum {
			if s < x {
				ok = false
			}
		}
		if ok {
			if price < ans {
				ans = price
			}
		}
	}

	if ans == math.MaxInt32 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 2228
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 1000000007

ll H, W;
vector<vector<char>> A;
VVL dp;

void solve() {
    cin >> H >> W;
    A = vector<vector<char>>(H, vector<char>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
        }
    }
    dp = VVL(H, VL(W, 0));
    dp[0][0] = 1;
    FOR(i, 1, H) {
        dp[i][0] = A[i][0] == '.' ? dp[i - 1][0] : 0;
    }
    FOR(j, 1, W) {
        dp[0][j] = A[0][j] == '.' ? dp[0][j - 1] : 0;
    }
    FOR(i, 1, H) {
        FOR(j, 1, W) {
            dp[i][j] = A[i][j] == '.' ? (dp[i - 1][j] + dp[i][j - 1]) % MOD : 0;
        }
    }
    print(dp[H - 1][W - 1]);
}

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

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;	//Nは支払額、Aは1円の枚数
  int X ;	//Xは500で割ったあまり
  cin >> N >> A; 
  
  X = N % 500 ;
	if (X - A <= 0 ){
 		cout << "Yes" << endl ;
    }
	else {
		cout << "No" << endl ;      
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double x[110], y[110];
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> x[i];
	for(int i=1; i<=n; i++)
		cin >> y[i];
	double s1 = 0;
	for(int i=1; i<=n; i++) // p=1
		s1 += abs(x[i]-y[i]);
	cout << fixed << setprecision(6) << s1 << endl;
	double s2 = 0;
	for(int i=1; i<=n; i++) // p=2
		s2 += (x[i]-y[i])*(x[i]-y[i]);
	s2 = sqrt(s2);
	cout << fixed << setprecision(6) << s2 << endl;
	double s3 = 0;
	for(int i=1; i<=n; i++) // p=3
		s3 += abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
	s3 = pow(s3, 1.0/3);
	cout << fixed << setprecision(6) << s3 << endl;
	double s4 = 0;
	for(int i=1; i<=n; i++)
		s4 = max(s4, abs(x[i]-y[i]));
	cout << fixed << setprecision(6) << s4 << endl;
	return 0;
}


Measured memory_bytes: 3416
def solve():
    A,B,C,K = map(int,input().split())
    ans = 0
    if A > K:
        print(K)
    else:
        ans += A
        K -= A

        if B > K:
            print(ans)
        else:
            K -= B
            print(ans - K)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 61900
#include <bits/stdc++.h>
using namespace std;
//他の方のを参考にしました(>_<)
int main(){
  int K, S, ans=0;
  cin >> K >> S;
  
  for(int i=0 ; i<=K ; i++)
    for(int j=max(0, S-K-i) ; j<=K ; j++) //←ここは自分で考えました、結構いい感じだと思います
      if(S-K<=i+j && i+j<=S)              //←ここはパクリました
        ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x;
	int y;

	for (;;)
	{

		scanf("%d %d", &x, &y);

		if (x==0&&y==0)
		{
			break;
		}

		if (x > y)
		{
			printf("%d %d\n", y, x);
		}
		else 

			printf("%d %d\n", x, y);
	}
}

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int a, b, c;
	cin >> a >> b >> c;

	Int ans;
	if (c) {
		ans = 1;
		c--;
	}
	else {
		ans = 0;
	}
	if (b+a>=c) {
		ans += b + c;
		cout << ans << "\n";
	}
	else {
		ans += a + b + b;
		cout << ans << "\n";
	}

}


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

int main(){
  char x,y;
  for (int i=0; i<3; i++){
  for (int j=0; j<3; j++){
    if (i==j) cin >> x;
    else cin >> y;
  }
    cout << x;
 }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, M;
	cin >> N >> M;
	int dp[1 << N];
	int inf = 1000000000;
	for (int i = 0; i < (1 << N); i++) {
		dp[i] = inf;
	}
	dp[0] = 0;
	pair<int, int> k[M];
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		int c = 0;
		for (int j = 0; j < b; j++) {
			int cc;
			cin >> cc;
			c += (1 << (cc - 1));
		}
		k[i] = make_pair(a, c);
	}
	for (int i = 0; i < (1 << N); i++) {
		for (int j = 0; j < M; j++) {
			int to = i | k[j].second;
			dp[to] = min(dp[to], dp[i] + k[j].first);
		}
	}
	if (dp[(1 << N) - 1] == inf) cout << -1 << endl;
	else cout << dp[(1 << N) - 1] << endl; 	
}


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

int main() {
  int N,A,B,C,D; cin >> N >> A >> B >> C >> D;
  string S; cin >> S;
  string ans="";
  if(ans.empty()){
    for(int i=A-1;i<C;i++)
      if(S[i]=='#'&&S[i+1]=='#') ans = "No";
    for(int i=B-1;i<D;i++)
      if(S[i]=='#'&&S[i+1]=='#') ans = "No";
  }
  if(ans.empty()){
    int maxab = max(A,B); 
    int mincd = min(C,D); 
    for(int i=maxab-2;i<mincd-1;i++){
      if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.') ans = "Yes";
    }
  }
  if(ans.empty()){
    if(C<D) ans = "Yes";
    else ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
pre = ""
for i in range(N):
    if i >= K and T[i - K]==T[i]:
        if T[i] == "r" and pre[i - K] == "p":
            pre += "x"
            continue
        if T[i] == "s" and pre[i - K] == "r":
            pre += "x"
            continue
        if T[i] == "p" and pre[i - K] == "s":
            pre += "x"
            continue

    if T[i] == "r":
        ans += P
        pre += "p"
    if T[i] == "s":
        ans += R
        pre += "r"
    if T[i] == "p":
        ans += S
        pre += "s"
print(ans)

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

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,t=0,m=0,i;
	string s;
	cin>>n>>s;
	for (i=0;i<s.size();i++){
		if (s[i]=='D'){
			t--;
		}
		else {
			t++;
			m=max(m,t);
		}
	}
	cout<<m;
	return 0;
}

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

unsigned int cur = 0;
string S;

int digit() {
  return (int)(S[cur++] - '0');
}

long long lrrule() {
  long long a = digit();
  while (cur < S.size()) {
    char op = S[cur++];
    if (op == '+') {
      int b = digit();
      a += b;
    } else {
      assert(op == '*');
      int b = digit();
      a *= b;
    } 
  }
  return a;
}

/*
  先学期7月7日の資料を参考にすると、今回のBNFは
  expression = term { '+' term }
  term = digit { '*' digit }
  digit = '0' | \dots | '9' 
  となる。
 */

long long term() {
  long long a = digit();
  while (cur < S.size() && S[cur] == '*') {
    cur++;
    int b = digit();
    a *= b;
  }
  return a;
}

long long expression() {
  long long a = term();
  while (cur < S.size() && S[cur] == '+') {
    cur++;
    long long b = term();
    a += b;
  }
  return a;
}

long long mfrule() {
  return expression();
}

int main() {
  long long a;
  cin >> S >> a;
  cur = 0;
  long long x = lrrule();
  cur = 0;
  long long y = mfrule();
  // cerr << "x = " << x << ", y = " << y << endl;
  if (a == x && a == y) {
    cout << "U" << endl;
  } else if (a != x && a == y) {
    cout << "M" << endl;
  } else if (a == x && a != y) {
    cout << "L" << endl;
  } else {
    cout << "I" << endl;
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.8lf\n", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
    return 0;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	char a;
	cin >> a;
	char boin[] = { 'a','i','u','e','o' };
	bool ans = false;
	REP(i, 5)if (a == boin[i])ans = true;
	cout << (ans ? "vowel" : "consonant") << endl;
}



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

int main() {
	int n = 0, k = 0,some = 0;
	int ans = 0,cnt = 0;
	int a[200009] = {};
	int m[200009] = {};
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		std::cin >> some;
		a[i] = some;
		m[some-1]++;
	}
	std::sort(m, m + n);
	std::reverse(m, m + n);
	for (int i = 0; i < k; i++) {
		m[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		ans += m[i];
	}
	std::cout << ans << std::endl;
}
	

Measured memory_bytes: 1024
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 


vector<int> graph[NMAX];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,x,y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<int> sol(n);
	for(int i =0 ;i< n; ++i)
	{
		for(int j = i+ 1; j< n; ++j)
		{
			int mini = min(j - i,abs(x-i) + 1 + abs(y-j));
			sol[mini]++;
		}
	}

	for(int i = 1; i< n; ++i)
	{
		cout << sol[i] << '\n';
	}

	

    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define PI acos(-1)
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,k;
		cin >> n >> k;
		int ans = 0;
		int cur = n+1;
		rep(i,1,n+2){
			if(i>=k) ans += n*i-(i*(i-1))+1;
			// trace(ans, (i*(i-1))/2 , n*i-(i*(i-1))/2);
		}
		cout << ans % M;
	}
}


Measured memory_bytes: 3636