akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
void setIO(string name) {
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
vector<int> adj[200005];
int visited[200005]={0};
int ender=-1;
int n;
long long k;
vector<int> c;
void dfs(int node){
  visited[node]=1;
   c.pb(node);
  for(auto next:adj[node]){
    if(!visited[next]){
      dfs(next);
    }else{
      ender=next;
      break;
    }
  }
 
}

int main() {
   fast();
   cin>>n;
   cin>>k;
   for(int i=0;i<n;i++){
    int l;
    cin>>l;
    --l;
    adj[i].pb(l);
   }
   dfs(0);
  
  
     int x;
      for(int i=0;i<c.size();i++){
        if(c[i]==ender){
           x=i;
           break;
        }
      }
     if(k<=x){
       cout<<c[k]+1<<"\n";
       return 0;
     }else{
      long long y=c.size()-x;
      k-=x;
      k%=y;
      cout<<c[k+x]+1<<"\n";
      return 0;
     }
      
   

   

   

   
   



   
}
 


Measured memory_bytes: 24932
#include<stdio.h>
int main(){
	unsigned short row;            	/* 行数格納用変数 */
	unsigned short col;            	/* 列数格納用変数 */
	int sheet[101][101];	/* 表格納用配列 */
	int i,j;            	/* ループ変数 */
	
	/* 配列の初期化 */
	for(i = 0;i < 101;i++){
		for(j = 0;j < 101;j++){
			sheet[i][j] = 0;
		}
	}
	
	/* 行数、列数の入力 */
	scanf("%d %d", &row, &col);
	
	/* 表の要素の入力 */
	for(i =0;i < row;i++){
		for(j = 0;j < col;j++){
			/* i行j列の要素の入力 */
			scanf("%d", &sheet[i][j]);
		}
	}
	
	/* 各行の要素の合計の計算 */
	for(i =0;i < row;i++){
		for(j = 0;j < col;j++){
			/* i行j列の要素をi行末端に加算 */
			sheet[i][col] += sheet[i][j];
		}
	}
	
	/* 各列の要素の合計の計算 */
	for(i =0;i < row;i++){
		for(j = 0;j < col;j++){
			/* i行j列の要素をj列末端に加算 */
			sheet[row][j] += sheet[i][j];
		}
	}
	
	/* 全要素の合計の計算 */
	for(i = 0;i < row;i++){
		/* 各行の合計を表の末端に加算 */
		sheet[row][col] += sheet[i][col];
	}
	
	/* 表を出力 */
	for(i =0;i <= row;i++){
		for(j = 0;j < col;j++){
			/* i行j列の要素の出力 */
			printf("%d ", sheet[i][j]);
		}
		/* 末列の出力 */
		printf("%d\n", sheet[i][col]);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 100+7;
const int W = 1e5+7;

ll mem[N][W];
ll w[N],v[N];
int n,maxw;

ll dp(int i,int sumw)
{
    ll &ret = mem[i][sumw];
  	if (ret != -1) return ret;
  	if (i == n) return ret = 0;
  	ret = dp(i+1,sumw);
  	if (sumw+w[i] <= maxw) ret = max(ret,dp(i+1,sumw+w[i])+v[i]);
  	return ret;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

	memset(mem,-1,sizeof mem);
  	cin >> n >> maxw;
  	REP(i,0,n-1) cin >> w[i] >> v[i];
	cout << dp(0,0) << endl;
    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double 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

#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, w) for(int i = n; i >= 0; i--)
#define dforn(i, a, b) for(int i = a; i < b; i++)
#define dforw(i, b, a) for(int i = b; i >= a; i--)
#define read(v) for(auto &i:v) cin >> i;
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int, int> pii;

int n, k;
vi arr, dp;

int main(){
	ios_base::sync_with_stdio(0);
	cout.tie(0);cin.tie(0);
	
	cin >> n;
	k=2;
	arr.assign(n, 0);
	dp.assign(n, 999999999);
	dp[0] = 0;
	read(arr);

	forn(i, n)
		for(int j = i+1; j < n && j < i+k+1; j++)
			dp[j] = min(dp[j], dp[i]+abs(arr[j]-arr[i]));

	cout << dp[n-1] << endl;	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	static int maxCost = 4001;
	static int maxWeight = 400;
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ma = sc.nextInt();
		int mb = sc.nextInt();
		int[] arrA = new int[n + 1];
		int[] arrB = new int[n + 1];
		int[] arrC = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			arrA[i] = sc.nextInt();
			arrB[i] = sc.nextInt();
			arrC[i] = sc.nextInt();
		}
		int[][][] dp = new int[n + 1][maxWeight + 1][maxWeight + 1];
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= maxWeight; j++) {
				for (int k = 0; k <= maxWeight; k++) {
					dp[i][j][k] = maxCost;
				}
			}
		}
		dp[0][0][0] = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= maxWeight; j++) {
				for (int k = 0; k <= maxWeight; k++) {
					dp[i][j][k] = Math.min(dp[i][j][k], dp[i - 1][j][k]);
					if (j + arrA[i] <= maxWeight && k + arrB[i] <= maxWeight) {
						dp[i][j + arrA[i]][k + arrB[i]] = Math.min(dp[i - 1][j][k] + arrC[i], dp[i][j + arrA[i]][k + arrB[i]]);
					}
				}
			}
		}
		int min = maxCost;
		for (int i = 1; ma * i <= maxWeight && mb * i <= maxWeight; i++) {
			min = Math.min(dp[n][ma * i][mb * i], min);
		}
		if (min >= maxCost) {
			min = -1;
		}
		System.out.println(min);
	}
}


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

Measured memory_bytes: 600
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

const ll MAX = 510000;
const ll MOD = 998244353;

ll modpow(ll a, ll n){
  ll res = 1;
  while(n>0){
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
ll fac[MAX], finv[MAX], inv[MAX];

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

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


int main(){
  COMinit();
  ll n,m,k;
  cin >> n >> m >> k;
  ll ans = 0;
  for(ll i=0;i<=k;i++){
    ans += ((((m%MOD)*(modpow(m-1,n-1-i)%MOD))%MOD * (COM(n-1,i)%MOD))%MOD);
    ans = ans % MOD;
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    string s;cin>>s;
    ll res=0;
    bool f=false;
    for(int i=(int)s.length()-1;i>0;i--){
        if(s[i]=='9') res+=9;
        else{
            res+=9;
            f=true;
        }
    }
    res+=(s[0]-'0');
    if(f) res-=1;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};



int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int n;
	string s;
	in(n,s);
	vector<int> wq;
	priority_queue<int> rs;
	rep(i,n){
		if(s[i]=='W')wq.pb(i);
		else rs.push(i);
	}
	int ans=0;
	rep(i,wq.size()){
		if(rs.empty())break;//これより右側に赤色がない
		int ind=rs.top();
		if(wq[i]>rs.top())break;
		rs.pop();
		rs.push(wq[i]);
		swap(s[wq[i]],s[ind]);
		ans++;

	}
	out(ans);
	return 0;
}


Measured memory_bytes: 4756
import java.util.Scanner;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int n;
		int r = 0;
		while(scan.hasNext()){
			n = scan.nextInt();
			if(n == 0){
				break;
			}
			int x[] = new int[n];
			int y[] = new int[n];
			int h[] = new int[n];
			int w[] = new int[n];
			int size[] = new int[n];
			for(int i = 0; i < n ; i++){
				x[i] = scan.nextInt();
				y[i] = scan.nextInt();
				h[i] = scan.nextInt();
				w[i] = scan.nextInt();
				size[i] = x[i] + y[i] + h[i];
				if(size[i] <= 60){
					if(w[i] <= 2){
						r = r + 600;
					}else if(w[i] <= 5){
						r = r + 800;
					}else if(w[i] <= 10){
						r = r + 1000;
					}else if(w[i] <= 15){
						r = r + 1200;
					}else if(w[i] <= 20){
						r = r + 1400;
					}else if(w[i] <= 25){
						r = r + 1600;
					}
				}else if(size[i] <= 80){
					if(w[i] <= 5){
						r = r + 800;
					}else if(w[i] <= 10){
						r = r + 1000;
					}else if(w[i] <= 15){
						r = r + 1200;
					}else if(w[i] <= 20){
						r = r + 1400;
					}else if(w[i] <= 25){
						r = r + 1600;
					}
				}else if(size[i] <= 100){
					if(w[i] <= 10){
						r = r + 1000;
					}else if(w[i] <= 15){
						r = r + 1200;
					}else if(w[i] <= 20){
						r = r + 1400;
					}else if(w[i] <= 25){
						r = r + 1600;
					}
				}else if(size[i] <= 120){
					if(w[i] <= 15){
						r = r + 1200;
					}else if(w[i] <= 20){
						r = r + 1400;
					}else if(w[i] <= 25){
						r = r + 1600;
					}
				}else if(size[i] <= 140){
					if(w[i] <= 20){
						r = r + 1400;
					}else if(w[i] <= 25){
						r = r + 1600;
					}
				}else if(size[i] <= 160){
					if(w[i] <= 25){
						r = r + 1600;
					}
				}
			}
			System.out.println(r);
			r = 0;
		}
	}
}

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


#define mod 998244353

long long power(long long base,long long pow) {
  long long res = 1;
  for(int i = 0; i < pow; i++) res = (res* base) % mod;
  return res;
}

long long arr[(int)1e5+5];
int main() {
  int n;cin >> n;
  for(int i = 0; i < n;i++) {
    long long x; cin >> x;arr[x]++;
    if(i == 0 && x != 0)  {cout << 0 <<endl; return 0;}
  }
  for(int i = n; i < (int)1e5+5;i++) {
    if(arr[i] != 0) {cout << 0 <<endl; return 0;}
  }
  if(arr[0] != 1) {cout << 0 <<endl; return 0;}
  long long res = 1;
  for(int i = 2; i <= n;i++) {
    res = res * (power(arr[i-1],arr[i]))%mod;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    long long int a[n];
    long long int ans[2] = {0};
    for (int i=0; i<n; ++i) cin >> a[i];
    for (int i=0; i<2; ++i) {
        int sign;
        long long int suma = 0;
        if (i==0) sign = 1;
        else sign = -1;
        for (int j=0; j<n; ++j) {
            suma += a[j];
            if (suma * sign <= 0) {
                ans[i] += abs(suma - sign);
                suma = sign;
            }
            sign *= -1;
        }
    }

    cout << min(ans[0], ans[1]) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a, cc = b; i <= cc; ++i)
#define PER(i, a, b) for (int i = a, cc = b; i >= cc; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
 
inline int read(){
    int x = 0, ch = getchar(), f = 1;
    while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int Ma = sc.nextInt();
		final int Mb = sc.nextInt();
		int[][][] dp = new int[N + 1][N * 10 + 1][N * 10 + 1];

		for (int i = 0; i <= N; i++) {
			for (int j = 0; j < dp[i].length; j++) {
				for (int k = 0; k < dp[i][j].length; k++) {
					dp[i][j][k] = Integer.MAX_VALUE;
				}
			}
		}
		dp[0][0][0] = 0;

		for (int i = 1; i <= N; i++) {
			int ai = sc.nextInt();
			int bi = sc.nextInt();
			int ci = sc.nextInt();
			for (int j = 0; j < dp[i].length; j++) {
				for (int k = 0; k < dp[i][j].length; k++) {
					if(dp[i-1][j][k] == Integer.MAX_VALUE) {
						continue;
					}
					dp[i][j][k] = Math.min(dp[i - 1][j][k], dp[i][j][k]);
					dp[i][j + ai][k + bi] = Math.min(dp[i - 1][j][k] + ci, dp[i][j + ai][k + bi]);
				}
			}
		}
		int minCost = Integer.MAX_VALUE;
		for (int j = 1; j < dp[N].length; j++) {
			for (int k = 1; k < dp[N][j].length; k++) {
				if ( j * Mb == k * Ma) {
					minCost = Math.min(minCost,dp[N][j][k]);
				}
			}
		}

		if (minCost == Integer.MAX_VALUE) {
			minCost = -1;
		}
		
		System.out.println(minCost);
		sc.close();
	}
}

Measured memory_bytes: 55396
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 200005;
const ll mm = 1e+18;
int a,b;
int f(int x){
    int res= a*x/b;
    res-=a*(x/b);
    return res;
}
int  ternary_search(int l, int r) {
    while (r - l >0) {
        int m1 = l + (r - l) / 3;
        int m2 = r - (r - l) / 3;
        int f1 = f(m1);      //evaluates the function at m1
        int f2 = f(m2);      //evaluates the function at m2
        if (f1 < f2)
            l = m1+1;
        else
            r = m2-1;
    }
    return f(l);                    //return the maximum of f(x) in [l, r]
}
void solve()
{
    int n;
    cin>>a>>b>>n;
    cout<<f(min(n,b-1));
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

void Main() {
  int n = read<int>();
  int x = read<int>();
  vector<int> A(n);
  rep(i, n) A[i] = read<int>();

  ll ans = 0;
  ll pre = 0;
  rep(i, n) {
    if (A[i] + pre > x) {
      int eat = A[i] + pre - x;
      A[i] -= eat;
      ans += eat;
    }
    pre = A[i];
  }
  cout << ans << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n, o = 0;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    if (x & 1)
      o ^= 1;
  }
  if (o) cout << "NO";
  else cout << "YES";
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long L, long long R, long long d);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    long long d;
    scanf("%lld",&d);
    solve(L, R, d);
}

void solve(long long L, long long R, long long d){
    ll cnt = 0;
    FOR(i, R+1, L){
        if(i%d == 0){
            cnt++;
        }
    }
    cout << cnt << el;
}



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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = (int)2e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9;
const ll INF = (ll)1e18;

int n, p[N], add[4 * N], pa[N]; 
pii a[2][4 * N];         
set <int> s;
vector <int> g[N];

void build(int v, int tl, int tr){
	if(tl == tr){
		a[tl % 2][v].f = p[tl];
		a[tl % 2][v].s = tl;
		a[1 - tl % 2][v].f = n + 1;
		return;
	}
	int tm = (tl + tr) >> 1;
	build(v + v, tl, tm);
	build(v + v + 1, tm + 1, tr);
	a[0][v] = min(a[0][v + v], a[0][v + v + 1]);
	a[1][v] = min(a[1][v + v], a[1][v + v + 1]);
}

void push(int v){
	add[v] %= 2;
	if(add[v] == 0)
		return;
	swap(a[0][v + v], a[1][v + v]);
	swap(a[0][v + v + 1], a[1][v + v + 1]);
	add[v + v]++;
	add[v + v + 1]++;
	add[v] = 0;
}

pii get(int v, int tl, int tr, int l, int r, int c){
	if(r < tl || tr < l)
		return mp(n + 1, 0);
	if(l <= tl && tr <= r)
		return a[c][v];
	int tm = (tl + tr) >> 1;
	push(v);
	pii res = min(get(v + v, tl, tm, l, r, c), get(v + v + 1, tm + 1, tr, l, r, c));
	a[0][v] = min(a[0][v + v], a[0][v + v + 1]);
	a[1][v] = min(a[1][v + v], a[1][v + v + 1]);
	return res;
}

void updpos(int v, int tl, int tr, int pos){
	if(tl == tr){
		a[0][v].f = a[1][v].f = n + 1;
		return;
	}
	int tm = (tl + tr) >> 1;
	if(pos <= tm)
		updpos(v + v, tl, tm, pos);
	else updpos(v + v + 1, tm + 1, tr, pos);
	a[0][v] = min(a[0][v + v], a[0][v + v + 1]);
	a[1][v] = min(a[1][v + v], a[1][v + v + 1]);
}

void upd(int v, int tl, int tr, int l, int r){
	if(r < tl || tr < l)
		return;
	if(l <= tl && tr <= r){
		add[v]++;
		swap(a[0][v], a[1][v]);
		return;
	}
	int tm = (tl + tr) >> 1;
	push(v);
	upd(v + v, tl, tm, l, r);
	upd(v + v + 1, tm + 1, tr, l, r);
	a[0][v] = min(a[0][v + v], a[0][v + v + 1]);
	a[1][v] = min(a[1][v + v], a[1][v + v + 1]);
}

int solve(int l, int r){
	if(l > r)
		return 0;
	int L = get(1, 1, n, l, r, l % 2).s;
	int R = get(1, 1, n, L + 1, r, 1 - l % 2).s;
	pa[p[L]] = p[R];
	g[p[L]].pb(solve(l, L - 1));
	g[p[L]].pb(solve(L + 1, R - 1));
	g[p[L]].pb(solve(R + 1, r));
	return p[L];

}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(NULL);

	cin >> n;
	
	for(int i = 1; i <= n; ++i)
		cin >> p[i];

	build(1, 1, n);

	s.insert(solve(1, n));

	while(!s.empty()){
		int x = *s.begin();
		s.erase(x);
		cout << x << " " << pa[x] << " ";
		for(int j : g[x])
			if(j)
				s.insert(j);
	}

	return 0;
}

Measured memory_bytes: 33664
n = int(input())
w = list(map(int, input().split()))
t = sum(w)
s_1, s_2 = 0, 0
for i in range(n):
    s_1 += w[i]
    if s_1 >= t // 2:
        s_2 = s_1 - w[i]
        print(min(abs(t-s_1*2), abs(t-s_2*2)))
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
		vector<int> mon(1000,0);
	mon[0]=300000;
	mon[1]=200000;
	mon[2]=100000;

	int x,y;cin>>x>>y;x-=1;y-=1;
	int ans;
	if(x==y && (x==0))ans=400000;
	else ans=0;
	cout<<mon[x]+mon[y]+ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a;
int ans[100000];

signed main() {
	int i;
	cin >> n;
	rep(i, n) {
		cin >> a; a--;
		ans[a] = i + 1;
	}
	rep(i, n) {
		cout << ans[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main()
{
    int64_t X,Y;
    cin >> X>>Y;

    int cnt=0;
    int64_t v=X;
    while (v <= Y) {
        cnt++;
        v = v * 2;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int n;
	int t[100005],x[100005],y[100005];
	scanf ("%d",&n);
	int flag=0;
	for (int i = 0 ; i < n ; i++)
	 {
	 	scanf ("%d%d%d",&t[i],&x[i],&y[i]);
	 	  if (t[i] == x[i] + y[i])
	 	   flag ++;
	 	  else if (t[i] > x[i] + y[i])
	 	   {
	 	   	int temp;
	 	   	temp = t[i] - x[i] - y[i];
	 	   	if (temp%2 == 0)
	 	   	 flag++;
			}
	 }
	 if (flag == n)
	  printf ("Yes\n");
	else
	 printf ("No\n");
return 0;
}

Measured memory_bytes: 1280
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	char S[4] = {0};
	scanf("%s", S);

	if (S[1] == 'B') {
		printf("ARC\n");
	} else {
		printf("ABC\n");
	}
	return 0;
}


Measured memory_bytes: 1648
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc146
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc146A();
        }

        public static void solve_abc146B()
        {

        }

        public static void solve_abc146A()
        {
            string s = Console.ReadLine();
            Dictionary<string, int> week = new Dictionary<string, int>();

            week.Add("MON", 1);
            week.Add("TUE", 2);
            week.Add("WED", 3);
            week.Add("THU", 4);
            week.Add("FRI", 5);
            week.Add("SAT", 6);
            week.Add("SUN", 7);

            Console.WriteLine(s == "SUN" ? 7 : 7 - week[s]);
        }
    }
}


Measured memory_bytes: 11104
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
bool check(ll ar[],ll n,ll x,ll k)
{
	ll ctr=0;
	for(ll i=0;i<n;i++)
	{
		ctr+=ceil((ar[i]*1.0)/(x*1.0))-1;
	}
//	cout<<x<<" "<<ctr<<' '<<k<<endl;
	if(ctr<=k)
	return true;
	else
	return false;
}
int main()
{
	ll i,j,k,m,n,t;
	cin>>n>>k;
	ll ar[n];
	for(i=0;i<n;i++)
	cin>>ar[i];
	ll ans=0;
	for(i=0;i<n;i++)
	ans=max(ans,ar[i]);
	ll l=1,r=ans;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(check(ar,n,mid,k))
		{
			ans=min(ans,mid);
			r=mid-1;
		}
		else
		l=mid+1;
	}
	cout<<ans;
}

Measured memory_bytes: 5076
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		Pattern p = Pattern.compile("^[0-9]{" + A +"}"+"[-]"+"[0-9]{" + B + "}$");
		Matcher m = p.matcher(S);
		System.out.println(m.find() ? "Yes":"No");
	}
}


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

int main() {
  int N;
  cin >> N;
  int x = 0;
  
  for( int i = 0; i < N; i++) {
    int a, b,c;
    cin >> a >> b;
    c = b-a+1;
    x += c;
  }
  
  cout << x << endl;
    
}


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

public class Main {
    public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>ans  = new ArrayList<>();
        
        int cou = 0, max = 0;
        for(int i=0; i<S.length(); i++) {
        if(ss[i]=='A' || ss[i]=='C' || ss[i]=='G' || ss[i]=='T') {
        	cou++;
        }else {
        	if(max < cou) {
        		max = cou;
        	}
        	cou = 0;
        }
        }
        if(max < cou) max = cou;
        Collections.sort(ans);
        System.out.println(max);
    }
}


Measured memory_bytes: 35604
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"

int main(int argc, char const *argv[]) {

  int A, B;
  std::cin >> A >> B;

  if (A%2 == 1 && B%2 == 1) {
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<unordered_map>

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;

const int N=1010;
const int INF=0x3f3f3f3f;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dist[N][N];
char w[N][N];
int ans=INF;
int n,m;
int cx,cy;
int ex,ey;

void bfs(){
    memset(dist,0x3f,sizeof(dist));
    PII E={ex,ey};
    PII q[2*N*N];
    int tt=N*N,hh=N*N;
    q[tt]={cx,cy};
    dist[cx][cy]=0;
    while(tt>=hh){
        PII t=q[hh++];
        if(E==t) break;
        int x=t.first;
        int y=t.second;
        for(int i=0;i<4;++i){
            int tx=x+dx[i];
            int ty=y+dy[i];
            if(tx<1||tx>n) continue;
            if(ty<1||ty>m) continue;
            if(w[tx][ty]=='#') continue;
            if(dist[tx][ty]>dist[x][y]){
                q[--hh]={tx,ty};
                dist[tx][ty]=dist[x][y];
            }
        }
        for(int i=-2;i<=2;++i)
            for(int j=-2;j<=2;++j){
                int tx=x+i;
                int ty=y+j;
                if(tx<1||tx>n) continue;
                if(ty<1||ty>m) continue;
                if(w[tx][ty]=='#') continue;
                if(dist[tx][ty]>dist[x][y]+1){
                    dist[tx][ty]=dist[x][y]+1;
                    q[++tt]={tx,ty};
                }
            }
    }
}

int main(){
    cin>>n>>m;
    cin>>cx>>cy;
    cin>>ex>>ey;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j){
            cin>>w[i][j];
        }

    bfs();
    if(dist[ex][ey]==0x3f3f3f3f) dist[ex][ey]=-1;
    cout<<dist[ex][ey]<<endl;
    return 0;
}

Measured memory_bytes: 24556
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main(){
    string str;
    stack<int> stack;
    while (cin >> str){
        if (str[0] == '+') {
            int a = stack.top();
            stack.pop();
            int b = stack.top();
            stack.pop();
            stack.push(a + b);
        }else if (str[0] == '*'){
            int a = stack.top();
            stack.pop();
            int b = stack.top();
            stack.pop();
            stack.push(a * b);

        }else if (str[0] == '-') {
            int a = stack.top();
            stack.pop();
            int b = stack.top();
            stack.pop();
            stack.push(b - a);

        } else {
            stack.push(stoi(str));
        }
    }

    cout << stack.top() << endl;
    return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,z,ans=0,sum=0,flag=1;
struct node{
	int x,y,step;
};
char c[55][55];
bool vis[55][55];
int s1[5]={0,1,-1,0,0};
int s2[5]={0,0,0,1,-1};
queue<node> q;




void bfs()
{
	int i,j;
	node s;
	s.x=s.y=1;
	
	
	
	s.step=0;
	
	
	
	
	q.push(s);
	vis[1][1]=1;
	while(!q.empty())
	{
		
		node u=q.front();
		
		
		
		
		if(u.x==n&&u.y==m)
		{
			flag=0;
			ans=u.step;
			break;
		}
		
		
		
		
		q.pop();
		for(i=1;i<=4;i++)
		{
			int xx,yy;
			xx=u.x+s1[i];
			yy=u.y+s2[i];
			if(xx<1||xx>n||yy<1||yy>m) continue;
			if(vis[xx][yy]||c[xx][yy]=='#') continue;
			node v;
			v.x=xx;
			v.y=yy;
			v.step=u.step+1;
			q.push(v);
			vis[xx][yy]=1;
		}
	}
}
int main()
{
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)
	{
		cin>>c[i][j];
		if(c[i][j]=='.') sum++;
	}
	
	
	bfs();
	
	
	if(flag) cout<<-1;
	else cout<<sum-(ans+1);
	return 0;
}	

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

//座標pに集まることにした時の体力消費を計算する関数
ll calc(vector<ll> &x, int p)
{
    ll ret = 0;
    for (auto y : x)
    {
        ret += (y - p) * (y - p);
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    //大きい数で初期化しておく
    ll ans = INF;
    //1<=x<=100なので、1～100までの座標をすべて試す
    rep(i, 100)
    {
        //答えを小さいほうに更新
        ans = min(ans, calc(x, i));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  uint64_t n;
  std::cin >> n;
  auto m = n;
  uint64_t s = 0;

  for (int i = 0; i < 10; i++) {
    s += n % 10;
    n /= 10;
  }

  if (m % s == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n, q,cnt=0;

struct node {
	int t,d,x;
}c[1000000+5];

bool cmp(node a, node b)
{
	if (a.t == b.t)
		return a.d < b.d;
	return a.t < b.t;
}

multiset<int>que;

int main()
{
	file(1);
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++)
	{
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		s -= x, t -= x;
		cnt++;
		c[cnt].t = s, c[cnt].x = x, c[cnt].d = 1;
		cnt++;
		c[cnt].t = t, c[cnt].x = x, c[cnt].d = -1;
	}
	sort(c + 1, c + 1 + cnt, cmp);
	int cc = 1;
	while (q--)
	{
		int d;
		scanf("%d", &d);
		while (c[cc].t <= d && cc <= cnt)
		{
			if (c[cc].d == 1)
				que.insert(c[cc].x);
			else
				que.erase(c[cc].x);
			cc++;
		}
		if (que.size())
			printf("%d\n", *que.begin());
		else
			printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 16768
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main()
{
    ll n,k,x,y;
    cin >> n >> k >> x >> y;
    if(k>=n){
        cout << n*x << endl;
    }
    else{
        cout << k*x+(n-k)*y << 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;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int x,y,z,w;
  for(int i=0;i<10;i++){
    if(i*1000<=n && (i+1)*1000>=n){
      x=i;
      n=n-x*1000;
    }
  }
  for(int i=0;i<10;i++){
    if(i*100<=n && (i+1)*100>=n){
      y=i;
      n=n-y*100;
    }
  }
  for(int i=0;i<10;i++){
    if(i*10<=n && (i+1)*10>=n){
      z=i;
      w=n-z*10;
    }
  }
    
  int a=0;
  int b=0;
  if(x==y){
    if(y==z) a++;
  }
  else if(y==z && w==z) a++;
  if(a!=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	/*
	 * 余りの最大値を求める。
	 */
	public static void main(String[] args) {

		/*
		 * Scannerで値取得。
		 */
		Scanner s = new Scanner(System.in);
		long number = s.nextInt();
		s.close();

		/*
		 * 少し試行すると最大値が変わらないため、
		 * 割る数を1つずつ値をずらして求めてみる。
		 * i ％ (i + 1)
		 * →結局1からnumber-1までの和になるから計算する。
		 */

		long max = 0;
		//max:答え,intを越える可能性があるため。
		if (number != 1) {
			max = number * (number - 1) / 2;
		}

		System.out.println(max);

	}

}


Measured memory_bytes: 22740
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for(int i = 0;i < n; i++) cin >> R[i];

    int maxv = -2000000000; // R[i]が取りうる最大値-最小値で初期化
    int minv = R[0];        // 入力の最初の値で初期化

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	int ans = (B  - 2 + (A - 1) ) / (A - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
A=sorted(LI())
B=sorted(LI())
C=sorted(LI())
ans=0
for i in range(n):
    ans+=bisect_left(A,B[i])*(n-bisect_right(C,B[i]))
    #print(bisect_left(A,B[i]))
    #print(n-bisect_right(C,B[i]))
print(ans)

Measured memory_bytes: 94180
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
signed main(){
	ll a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    SORT(x)     sort(x.begin(),x.end())

using namespace std;

int main(){
    ll a,b;
    cin >> a >> b;
    if(a<b) swap(a,b);
    for(ll i=1;i<=b;i++)
        if((a*i)%b==0) { cout << a*i << endl; return 0; }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265359
int main(void)
{
	double a,b,c,S,L,h;
	scanf("%lf %lf %lf",&a,&b,&c);
    
	S=a*b*sin(c/180*PI)/2;
	L=a+b+sqrt((a*a)+(b*b)-(2*a*b*cos(c/180*PI)));
	h=b*sin(c/180*PI);
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}


Measured memory_bytes: 2052
x1=0
x2=0
x3=0
x4=0

y1='AC x '
y2='WA x '
y3='TLE x '
y4='RE x '

n=int(input())

for i in range(n):
  a=input()  
  if a=='AC':
    x1=x1+1
  if a=='WA':
    x2=x2+1
  if a=='TLE':
    x3=x3+1
  if a=='RE':
    x4=x4+1
    
x1=str(x1)
x2=str(x2)
x3=str(x3)
x4=str(x4)

y1=y1+x1
y2=y2+x2
y3=y3+x3
y4=y4+x4

print(y1)
print(y2)
print(y3)
print(y4)

Measured memory_bytes: 9168
"use strict"
function main(arg) {

	let b  = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	let a = arg.split(',');
	console.log(b[a[0] - 1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21828
/**
 *  author: mahfuzz
 *  created: 22.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    ll n, a, b;
    cin >> n >> a >> b;
    
    cout << a * (n / (a+b)) + (n % ( a + b ) > a ? a : n % ( a + b )) << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();

            long[] Arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            int ans = 0;

            long max;
            long sum;

            for (int i = 0; i < Arr.Length; i++) 
            {
                for (int j = i; j < Arr.Length; j++)
                {
                    for (int k = i+1; k < Arr.Length; k++)
                    {
                        if (Arr[i] != Arr[j] && Arr[i] != Arr[k] && Arr[j] != Arr[k])
                        {
                            max = Math.Max(Arr[i], Math.Max(Arr[j],Arr[k]));
                            sum = Arr[i] + Arr[j] + Arr[k];
                            if (sum - max > max) 
                            {
                                ans++;
                            }
                        }

                    }

                }

            }
            ans = ans / 2;

            Console.WriteLine(ans);

        }

    }
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int n,k,sum=1;
	string s;
	cin>>n>>k>>s;
	char c,lst;
	lst=c=s[0];
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]) sum++;
	}
	sum=sum-2*k;
	if(sum<1) sum=1;
	cout<<n-sum<<endl;
	return 0;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,t;cin>>n>>t;
  int a[n];
  rep(i, n){ cin>>a[i]; }

  int m[n];
  m[0]=a[0];
  int b[n];
  b[0] = 0;
  int v = 1;
  rep(i, 1, n){
    m[i] = min(a[i], m[i-1]);
    b[i] = a[i]-m[i-1];
    chmax(v, b[i]);
  }
  dump_1d(a, n);
  dump_1d(m, n);
  dump_1d(b, n);
  dump(v);

  int cnt=0;
  rep(i, n){
    if(b[i]==v) cnt++;
  }
  cout << cnt << endl;


  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2560