akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		while(true){
			int n = s.nextInt();
			int x = s.nextInt();
			if(n == 0 && x == 0) break;
			int sum = 0;
			int count = 0;
			int a = 0;
			int num[] = new int [n];
			for(int i = 0; i < n; i++) num[i] = i + 1;
			for(int i = a; i < n; i++){
				for(int j = i+1; j < n; j++){
					for(int k = j+1; k < n; k++){
						sum = num[i] + num[j] + num[k];
						if(sum == x){
							count++;
						}
						a++;
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void main(String[] args) {
	
		new Main().run();
		
	}
}

Measured memory_bytes: 26880
#include<stdio.h>

int main()
{
	int input[10000];
	int i=0,count=0;
	
	while(1)
	{
		scanf("%d",&input[i]);
		if(input[i]==0) break;
		i++;
		count++;
	}
	
	for(i=0;i<count;i++)
		printf("Case %d: %d\n",i+1,input[i]);
	
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FavoriteSound | diff FavoriteSound.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FavoriteSound.cpp && ./a.out

/*
 
 3/14/2019
 
 10:12-
 
 */

int A,B,C;

void solve() {
  cout<<min(C,B/A)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>C;
  solve();
  
  return 0;
}


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

class Program {
  static void Main(string[] args) {
    Console.ReadLine();
    var v = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    var even = new Dictionary<int, int>();
    var odd = new Dictionary<int, int>();

    for (int i = 0; i < v.Length; i++) {
      var d = (i % 2 == 0 ? even : odd);

      if (!d.ContainsKey(v[i])) {
        d.Add(v[i], 0);
      }

      d[v[i]]++;
    }

    var e = even.Select(a => a).OrderBy(a => -a.Value).ToArray();
    var o = odd.Select(a => a).OrderBy(a => -a.Value).ToArray();

    int remain = 0;

    if (e[0].Key != o[0].Key) {
      remain = e[0].Value + o[0].Value;
    } else if (e.Length == 1 && o.Length == 1) {
      remain = Math.Max(e[0].Value, o[0].Value);
    } else if (e.Length == 1) {
      remain = e[0].Value + o[1].Value;
    } else if (o.Length == 1) {
      remain = e[1].Value + o[1].Value;
    } else {
      remain = Math.Max(
        e[0].Value + o[1].Value,
        e[1].Value + o[0].Value
      );
    }

    Console.WriteLine(v.Length - remain);
  }

}


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


int F[1000][1000];

//?????????????????????
void r(int yy,int xx,int z){
 if(F[yy][xx]!=z){
	return ;
 }

F[yy][xx]=10;

r(yy-1,xx,z);
r(yy,xx+1,z);
r(yy+1,xx,z);
r(yy,xx-1,z);

}




int main(){
 int w,h,xs,ys,xg,yg,n;
 int c,d,x,y;

while(1){
 cin>>w>>h;

//?????????????????????0???????????????
 if(w==0&&h==0)break;
//???????????????????????????????????\?????°????±??????£???????????????
 cin>>xs>>ys>>xg>>yg>>n;

//n?????°???????????????????????????
for(int i=0;i<n;i++){
	cin>>c>>d>>x>>y;//?????????????????¨????????±????????????
	if(d==0){
		F[x  ][y]=c;
		F[x+1][y]=c;
 		F[x+2][y]=c;
 		F[x+3][y]=c;
 		F[x  ][y+1]=c;
 		F[x+1][y+1]=c;
 		F[x+2][y+1]=c;
 		F[x+3][y+1]=c;
	}
	if(d==1){
		F[x][y  ]=c;
 		F[x][y+1]=c;
		F[x][y+2]=c;
		F[x][y+3]=c;
 		F[x+1][y  ]=c;
		F[x+1][y+1]=c;
		F[x+1][y+2]=c;
 		F[x+1][y+3]=c;
	}
}

//??\????????????????????????


//??????????????????
r(xs,ys,F[xs][ys]);
//??´???????????????
if(F[xg][yg]==10){
	cout<<"OK"<<endl;
}else{
	cout<<"NG"<<endl;
}
//???????????????????????????
for(int i=1;i<=w;i++){
	for(int g=1;g<=w;g++){
		F[i][g]=6;
	}
}
//?????????????????????
}
return 0;
}





	

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int n,k,a[N];

bool check(int x){
	int cnt=0;
	for(int i=1;i<=n;i++){
		cnt+=(a[i]-1)/x;
	}
	return cnt<=k;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
   	cin>>n>>k;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    int L=1,R=*max_element(a+1,a+1+n);
    while(L<R){
    	int mid=(L+R)/2;
    	if(check(mid))
    		R=mid;
    	else
    		L=mid+1;
    }
    cout<<L<<'\n';
    return 0;
}


Measured memory_bytes: 4400
def main():
  S = input()
  T = input()
  s_l = len(S)
  t_l = len(T)
  if s_l == 0 or s_l > 10:
    print("No")
    return

  if not s_l+1 == t_l:
    print ("No")
    return

  for i in range(s_l):
    if not S[i] == T[i]:
      print("No")
      return

  print("Yes")
  


if __name__ == "__main__":
  main()

Measured memory_bytes: 9052
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  string ans = "Three";
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'Y') {
      ans = "Four";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


struct UnionFind {
	vector<int> d; // d[i]:iの親の番号　(例) d[3] = 2 : 3の親が2 d[3] = -3 : 3は根で、その連結成分のサイズは3

	UnionFind(int N) : d(N, -1) {} // 負なら根である 非負なら子である

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (d[x] < 0) return x; //負なら根であるから根を返す
		return d[x] = root(d[x]);
	}

	bool unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return false; //xとyの根が同じ(=同じ木にある)時はそのまま
		if (d[rx] > d[ry])swap(rx, ry); //木のサイズが大きいほうにくっつける
		d[rx] += d[ry]; //サイズが上乗せされる
		d[ry] = rx; //yの根はxになる
		return true;
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
	int size(int x) {
		return -d[root(x)];
	}
};


signed main() {
	int N, M;
	cin >> N >> M;
	UnionFind tree(N);
	rep(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		tree.unite(x, y);
	}
	set<int>se;
	rep(i, N)se.insert(tree.root(i));
	int ans = se.size();
	cout << ans << endl;
}

Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string s;
  cin >> s;
  int ans = 0, l = s.size();
  REP(h, l) {
    REP(t, l) {
      if(h + t >= l) break;
      int len = l - h - t;
      string part = s.substr(h, len);
      REP(i, len) {
        char c = part[i];
        if(!(c == 'A' || c == 'C' || c == 'G' || c == 'T')) break;
        if(i == len - 1) {
          ans = max(ans, len);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[1010];
int main(){
	ll n,s;
	while(scanf("%*lld%lld%lld",&n,&s),n){
		rep(i,0,n){
			ll h,p,q;
			scanf("%lld%lld%lld",&h,&p,&q);
			a[i]=h*101*101+p*101+q;
		}
		sortdown(a,n);
		rep(i,0,n){
			ll p=a[i]/101%101;
			ll q=a[i]%101;
			if(p==s)s=q;
			else if(q==s)s=p;
		}
		printf("%lld\n",s);
	}
}




Measured memory_bytes: 2036
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;cin>>x;
  vector<int>a;
  a.push_back(1);
  repi(i,2,1001)
  {
    int ta=i*i;
    while(ta<1001)
    {
      a.push_back(ta);
      ta*=i;
    }
  }
  sort(all(a));
  cout<<*(upper_bound(all(a),x)-1)<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long result=1;
		for(int i=1;i<=N;i++) {
			result =result * i % 1000000007;
		}
		System.out.print(result);
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int n; cin>>n;
    string s; cin>>s;
    string t = s.substr(s.length()/2);
    cout<<(s==t+t?"Yes":"No")<<endl;
    return 0;
}



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

const int N = 100005;
int main() {
	int n, a[100005];
	cin >> n;
	for (int i = 0; i < N; i++)
		a[i] = 0;

	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		a[t]++;
	}
	
	int ans = 0;
	for (int i = 0; i < N - 2; i++)
		ans = max(ans,a[i] + a[i + 1] + a[i + 2]);
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
const int N = 5010;
const ll INF = 1e18;
int n;
ll a[N];
VI e[N];
void out(VVL &dp){
    REP(f,2){
        REP(i,dp[f].size()) cout << dp[f][i] << " ";
        cout << endl;
    }
    cout << endl;
}
void dfs(int now, int past, VVL &dp){
    dp.assign(2, VL(1, INF));
    if (a[now] > 0) dp[1][0] = a[now];
    else dp[0][0] = a[now];
    for (int next : e[now]){
        if (next == past) continue;
        VVL dp2(2);
        dfs(next, now, dp2);
        int n = dp[0].size(), m = dp2[0].size();
        VVL dp_next(2, VL(n + m, INF));
        REP(i,n) REP(f,2) REP(j,m) REP(g,2){
            if (dp[f][i] == INF || dp2[g][j] == INF) continue;
            dp_next[f & g][i + j] = min(dp_next[f & g][i + j], dp[f][i] + dp2[g][j]);
            if (g || dp2[g][j] < 0) dp_next[f][i + j + 1] = min(dp_next[f][i + j + 1], dp[f][i]);
        }
        // out(dp);
        // out(dp2);
        // out(dp_next);
        dp.swap(dp_next);
    }
}
int main() {
    cin >> n;
    REP(i,n) a[i] = in();
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    VVL dp(2);
    dfs(0, -1, dp);
    int ans = n;
    REP(i,n){
        if (dp[0][i] < 0 || dp[1][i] < INF) ans = min(ans, i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
def main(n,a,b,c):
  import bisect
  ans=0
  for i in range(n):
    na=bisect.bisect_left(a,b[i])
    nc=n-bisect.bisect_right(c,b[i])
    ans+=na*nc
  print(ans)
if __name__=='__main__':
  n=int(input())
  a=sorted(list(map(int,input().split())))
  b=sorted(list(map(int,input().split())))
  c=sorted(list(map(int,input().split())))
  main(n,a,b,c)


Measured memory_bytes: 23200
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/



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

    ll n, m;
    cin>>n>>m;
    m/=2;
    if (n>=m) cout<<m;
    else cout<<(n+m)/2;

}

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

int main() {
  int H, W; cin >> H >> W;
  vector<vector<int>> G(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) cin >> G.at(i).at(j);
  }
  vector<vector<int>> A(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) cin >> A.at(i).at(j);
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i)+G.at(i).at(k));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A.at(i).at(j) != -1) ans += G.at(A.at(i).at(j)).at(1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long a[n], amax=0;
	for(long long i=0;i<n;i++){
		cin>>a[i];
	}sort(a, a+n);
	long long m=a[n-1];
	long long b[m]={0};
	for(long long i=0;i<n;i++){
		if(a[i]==a[i-1]){
			b[a[i]-1]=1;
		}
	}for(long long i=0;i<n;i++){
		long long temp=a[i];
		for(long long j=temp*2;j<=m;j+=temp){
			b[j-1]=1;
		}
	}long long count=0;
	for(long long i=0;i<n;i++){
		if(b[a[i]-1]==0){
			count++;
		}
	}cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 12952
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){

  int N;
  int x;
  cin>>N>>x;
  vector<int>A(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<=N-1;i++){
  
    if(A[i]<=x){
    
      ans++;
      x-=A[i];
    }
    else{
    
      break;
    }
    if(i==N-1){
    
      if(x>0)ans--;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int res = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int k = S - i - j;
      if (k >= 0 && k <= K) {
        ++res;
      }
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3156
N,K=map(int,input().split())
ans=0
if K==0:
  print(N*N)
  exit(0)
for b in range(K+1,N+1):
  _=(N//b)*(b-K)+max(0,(N%b)-K+1)
  ans+=_
  #print(b,_)
print(ans)

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

int main(){
    long long int x, y, count = LLONG_MAX, pushed;
    cin >> x >> y;
    if (x < y){
        pushed = y - x;
        count = min(count, pushed);
    }
    if (-1*x <= y){
        pushed = (y - (-1*x)) + 1;
        count = min(count, pushed);
    }
    if (x <= -1*y){
        pushed = ((-1*y) - x) + 1;
        count = min(count, pushed);
    }
    if (-1*x <= -1*y){
        pushed = ((-1*y) - (-1*x)) + 2;
        count = min(count, pushed);
    }
    cout << count << endl;
    return 0;    
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INF 1e9

int Graf[MAX][MAX];
int d[MAX];
int p[MAX];

int min(int a,int b){
  if(a<b) return a;
  return b;
}

int prim(int n){
  int i,v,sum = 0;
  for(i = 0 ; i < n ; i++){
    d[i] = INF;
    p[i]= 0;
  }
   
  d[0] = 0;
  
  while(1){
    v = -1;
    for(i = 0 ; i < n ; i++){
      if(!p[i] && (v == -1 || d[i] < d[v])){
        v = i;
      }
    }
    if(v == -1)break; 
    p[v] = 1;
    sum += d[v];
    for(i = 0 ; i < n ; i++){
      if(Graf[v][i] == -1)continue;
      d[i] = min(d[i],Graf[v][i]);
    }
  }
  return sum;
}

int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&Graf[i][j]);
    }
  }
  printf("%d\n",prim(n));
  return 0;
}

Measured memory_bytes: 640
n=int(input())
prime=[]
for i in range(2,int(n**0.5)+1):
	cnt=0
	while n%i==0:
		n//=i
		cnt+=1
	prime.append(cnt)
	if n==1:
		break
if n>1:
	prime.append(1)
ans=0
for x in prime:
	for i in range(1,x+1):
		if x>=i:
			ans+=1
			x-=i
		else:
			break
print(ans)

Measured memory_bytes: 17208
sizeI, sizeJ, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(sizeI)]
ret = 0
for i in range(sizeI):
    s = c
    for j in range(sizeJ):
        s += a[i][j] * b[j]
    if s > 0:
        ret += 1
print(ret)

Measured memory_bytes: 3064
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (d, t, s) = readIntegerList()
    val ans = if (t * s >= d) "Yes" else "No"
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36464
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b = list(map(int, sys.stdin.buffer.readline().split()))
aa = str(a) * b
bb = str(b) * a
ans = min(aa, bb)
print(ans)


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

class Program
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        WriteLine(K == 1 ? 0 : N - K);
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll dp[100003][4];

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j == k) continue;
        ll add;
        if (k == 0)
          add = a[i];
        else if (k == 1)
          add = b[i];
        else
          add = c[i];
        dp[i][k] = max(dp[i][k], dp[i - 1][j] + add);
      }
    }
  }

  rep(i, 3) ans = max(ans, dp[n - 1][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define lul2            998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

set<int> bruh[26];

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}
void solve()
{
    int n; cin>>n;
    string s; cin>>s;
    rep(i,0,n)
    {
        bruh[s[i]-'a'].insert(i);
    }
    int q; cin>>q;
    rep(i,0,q)
    {
        int a; cin>>a;
        if(a == 1)
        {
            int index; cin>>index;
            char x; cin>>x;
            index--;
            bruh[s[index]-'a'].erase(index);
            bruh[x-'a'].insert(index);
            s[index]=x;            
        }
        else{
            int l,r; cin>>l>>r;
            l--,r--;
            int cnt = 0;
            rep(i,0,26)
            {
                auto it = bruh[i].lower_bound(l);
                if(it!=bruh[i].end() and *it<=r) cnt++; 
            }
            cout<<cnt<<endl;
        }
    }
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

//Coding below.
int main (){
    int N;
    cin >> N;
    int A[N];
    for(int i=1;i<=N;i++){
        cin >> A[i];
        //A[]入力
    }
    int ans[N];
    for(int i=0;i<=N;i++){
        ans[i] = 0;
        //初期化
    }
    for(int i=1;i<=N;i++){
        //i番の生徒はA[i]番目
        ans[A[i]] = i;
    }
    for(int i=1;i<=N;i++){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1536
N = int(input())
S = []

ans = 0
end_a = 0
start_b = 0
both = 0
for i in range(N):
    s = input()
    S.append(s)
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
    elif s[-1] == 'A':
        end_a += 1
    elif s[0] == 'B':
        start_b += 1

if both == 0:
    ans += min(start_b, end_a)
else:
    if start_b == end_a == 0:
        ans += both - 1
    else:
        ans += both + min(start_b, end_a)

print(ans)


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var x = r[0].ToInt();
            var y = r[1].ToInt();
            var z = r[2].ToInt();
            WriteRead(z + " " + x + " " + y);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main()
{
	int n, i, count=0;
	cin>>n;
	int arr[4];
	for(i=0; i<4; i++)
	{	
		{
		arr[i] =  n%10;
		n = n/10;
		}
	}
	for(i=0; i<4; i++)
	{
		if (arr[i] == 2)
		{
			count++;
		}
	}
	
	cout<<count<<endl;
	
	return 0;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

map<ll,ll> soinsubunkai(ll x){    // x = {first^second}*...
  map<ll,ll> ans;
  if(x==1){return ans;}
  ll p=x;
  for(ll i=2;i*i<=x;i++){
    while(p%i==0){
      p /= i;
      ans[i]++;
    }
  }
  if(p!=1)ans[p]++;
  return ans;
}


int main(){

  ll N;
  cin >> N;
  auto x = soinsubunkai(N);

  ll ans = 0;
  for(auto a:x){
    ll cnt = 1;
    while(a.second >= cnt){
      ans++;
      a.second -= cnt;
      cnt++;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<n;++i)
main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];

  rep(i,n){
    map<double,ll>cnt;
    rep(j,n){
      if(i==j)continue;
      double X=(x[i]-x[j]);
      double Y=(y[i]-y[j]);
      cnt[ atan2(X,Y) ]++;
    }
    //for(auto x:cnt){
    //  cout<<x.first<<","<<x.second<<endl;
    //}cout<<endl;
    for(const auto& x:cnt)if(x.second+1>=k){
      cout<<1<<endl;
      return 0;
    }
  }

  cout<<0<<endl;

}


Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>

using namespace std;

int main() {
	int i, j, k;
	int m;

	cin >> m;

	cout << (24 - m) + 24 << endl;











	getchar();
	getchar();
	return 0;
}

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

int main(){

	int n;
	vector<long long int> a, b, c;
    long long int ans=0;
  
  	cin>> n;

	a.resize(n);
	b.resize(n);
	c.resize(n);

    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;i++) cin>> c[i];

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

    for(int i=0;i<n;i++){
    	auto itra=lower_bound(a.begin(), a.end(), b[i]);
    	auto itrc=upper_bound(c.begin(), c.end(), b[i]);
    	ans+=(itra-a.begin())*(c.end()-itrc);
	//cout<< itra-a.begin() << " " << c.end()-itrc << " " << ans <<endl;
    }
  
  	cout<< ans <<endl;
  
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 = 1LL << 60;
ll dp[100010][3];

int main() {
  int n;
  cin >> n;
  ll a[100010][3];
  rep(i,n) {
    rep(j,3) cin >> a[i][j];
  }


  // 最小化問題なので INF で埋める
  // rep(i,100010) dp[i] = 0;
  // dp[0] = 0;

  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
        if (j == k) continue;
        chmax(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  ll res = 0;
  rep(i,3) {
    chmax(res, dp[n][i]);
  }
  
  cout << res << endl;
}


Measured memory_bytes: 4992
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void main() {
    const ip = readToArray!(long);
    const auto n = ip[0], l = ip[1];

    long sum = 0;
    for(long i = 0; i < n; i++) {
        sum += l + i;
    }

    if (l < 0 && l + n - 1 >= 0) {
        // nothing
    } else if (l + n - 1 < 0) {
        sum -= l + n - 1;
    } else {
        sum -= l;
    }
    writeln(sum);
}


Measured memory_bytes: 256
def check(i,adj):
    visited = [False]*N
    visited[i] = True
    q = [i]
    while q != []:
        v = q.pop(0)
        for w in adj[v]:
            if not visited[w]:
                visited[w] = True
                q.append(w)
    return all(visited)
N,M = map(int,input().split())
adj = [[] for i in range(N)]
edges = []
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edges.append((a,b))
    adj[a].append(b)
    adj[b].append(a)
ans = 0
for a,b in edges:
    tmp = [adj[i].copy() for i in range(N)]
    tmp[a].remove(b)
    tmp[b].remove(a)
    if not check(0,tmp):
        ans += 1
print(ans)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b0=[]
b1=[]
for i in range(n):
  if i%2==0:
    b0.append(a[i])
  else:
    b1.append(a[i])
if n%2!=0:
  b0=list(reversed(b0))
  b=b0+b1
  print(' '.join(map(str, b)))
else:
  b1=list(reversed(b1))
  b=b1+b0
  print(' '.join(map(str, b)))


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

void Main()
{
  int c[3][3];
  rep(i,3) {
    rep(j,3){
  	  cin >> c[i][j];
    }
  }
  rep(a1,101){
    int b1 = c[0][0] - a1;
    int b2 = c[0][1] - a1;
    int b3 = c[0][2] - a1;
    rep(a2,101){
      rep(a3,101){
        if (a2 + b1 == c[1][0] && a3 + b1 == c[2][0] &&
            a2 + b2 == c[1][1] && a3 + b2 == c[2][1] &&
            a2 + b3 == c[1][2] && a3 + b3 == c[2][2]){
          cout << "Yes" << endl;
          return;
        }
      }
    }
  }
  cout << "No" << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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



int main(){
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    int c=0;
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int a;
            cin>>a;
            auto itr=mp.find(a);
            if(itr==mp.end()){
                c++;
                mp[a]=1;
            }
        }
    }
    cout<<n-c<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}

#define Maxn 500009
stack <int> MyStack;
int n, x;
int a[Maxn];
int main() {
#ifdef Qrsikno
	freopen("g.in","r",stdin);
	freopen("g.out","w",stdout);
#endif
	n = read(), x = read();
	if(n == 1) {
		if(x == 1) 
			puts("Yes"),printf("1\n");
		else puts("No");
		return 0;
	}
	if(n == 2) {
		if(x != 2) puts("No");
		else puts("Yes"), printf("1\n2\n3\n");
		return 0;
	}
	if(x == 1 || x == 2 * n - 1) {
		puts("No");
		return 0;
	}
	puts("Yes");
	n = (n * 2 - 1);
	int mid = (n + 1) / 2;
	if(x != 2) {
		a[mid] = x, a[mid - 1] = x - 1, a[mid + 1] = x + 1, a[mid + 2] = x - 2;  
		rep(i, 1, n)
			if(!(x - 2 <= i && i <= x + 1)) MyStack.push(i);
	}else{
		a[mid] = 2, a[mid - 1] = 1, a[mid + 1] = 3, a[mid + 2] = 4;
		rep(i, 5, n) MyStack.push(i);
	}
	rep(i, 1, mid - 2) a[i] = MyStack.top(), MyStack.pop();
	rep(i, mid + 3, n) a[i] = MyStack.top(), MyStack.pop();
	rep(i, 1, n) printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 2864
import io.StdIn._
object Main extends App {
  val primes = Stream.cons(2, Stream.from(3, 2) filter { isPrime(_) })
  def isPrime(i: Int): Boolean = {
    (i > 1) && primes.takeWhile(_ <= math.sqrt(i)).forall(i % _ != 0)
  }

  var n = readInt
  while(!isPrime(n)) {
    n = n + 1
  }
  println(n)
}


Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout <<"vowel"<< endl;
    }
    else cout <<"consonant" <<endl;



}


Measured memory_bytes: 256
A,B=map(int,input().split())
def xor(N):
    if N%4 in [1,2]:
        xor_list=[1]
    else:
        xor_list=[0]
    i=1
    while(2**i<=N):
        if N%(2**(i+1))<2**(i):
            xor_list.append(0)
        else:
            xor_list.append((N+1)%2)
        i+=1
    return int("".join(list(reversed(list(map(str,xor_list))))),2)
print(xor(A-1)^xor(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using lld = long long int;
using ld = long int;
int main()
{
    lld i,n,sum=1000,m;
    cin >> n;
    vector <lld> vec(n);
    for(i=0;i<n;i++)
    {
        cin >> vec[i];
    }
    for(i=0;i<n-1;i++)
    {
        if(vec[i]<vec[i+1])
        {
            m = sum/vec[i];
            sum += m*(vec[i+1]-vec[i]);
        }
    }
    cout << sum;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=0;
	for(int i=2;i<n;i++)
		if(((a[i]>a[i-1])+(a[i]>a[i+1]))==1)sum++;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
// abc134_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  int r;
  cin >> r;
  cout << pow(r, 2)*3 << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int mx = 0;
    map<string,int> mp;
    REP(i,n){
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for(auto p : mp){
        if(p.se==mx){
            cout << p.fi << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23808
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, a, b = sc.nextInt()
  val y = b - a
  if (y <= 0) {
    println("delicious")
  } else if (y <= x) {
    println("safe")
  } else {
    println("dangerous")
  }
}

Measured memory_bytes: 55148
#include<stdio.h>
#include<string.h>
int main()
{
    char s[200000], t[200000];
    int count=0, i, j;

    gets(s);
    gets(t);

    for(i=0, j=0; i<strlen(s), j<strlen(t); i++, j++)
    {
        if(s[i] != t[j])
            count++;
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2032
-- Switching Railroad Cars
import Control.Monad.State

type Stack a = StateT [a] IO a

main = getContents >>= solve

solve :: String -> IO ()
solve = (\xs -> evalStateT (switchRailroad xs) []) . map read . lines

-- reference:
-- Simple StateT use
-- https://wiki.haskell.org/Simple_StateT_use
pop :: Stack Int
pop = do
  (x:xs) <- get
  put xs
  return x

push :: Int -> Stack Int
push x = do
  xs <- get
  put (x:xs)
  return x

switchRailroad :: [Int] -> StateT [Int] IO ()
switchRailroad [] = return ()
switchRailroad (x:xs)
  | x == 0 = do n <- pop
                liftIO $ print n
                switchRailroad xs
  | otherwise = do push x
                   switchRailroad xs

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];
  for(int i = 0; i < N;i++) cin >> x[i];
  for(int i = 0; i < M; i++) cin >> y[i];
  sort(x, x+N);
  sort(y, y+M);
  int ymin = y[0];
  int xmax = x[N-1];
  bool outbreak = false;
  for(int i = X+1; i <=Y;i++){
    if(i>xmax && i <= ymin){
      outbreak = true;
      break;
    }
  }
  if(outbreak) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    cin >> p;
    FORE(x, p) x--;
    
    int ans = 0;
    if (p[0] != 0) ans++;

    vector<vector<int>> g(N);
    REPF(i, 1, N) {
        int a = i, b = p[i];
        g[a].push_back(b);
        g[b].push_back(a);
    }
    auto dfs = [&](auto f, int v, int par) -> int {
        int mxd = 0;
        FORE(w, g[v]) {
            if (w == par) continue;
            int r = f(f, w, v);
            chmax(mxd, r);
        }
        if (par != 0 && v != 0 && mxd == K - 1) {
            ans++;
            return -1;
        }
        return mxd + 1;
    };
    dfs(dfs, 0, -1);
    cout << ans << endl;
    return (0^_^0);
}



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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0;
    cin >> n;
    cout << (float) 2 * 3.14159265358979323846 * n << endl;

    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    string s, t;
    cin >> s >> t;
    int ss = sz(s);
    int st = sz(t);
    int ans = 0;
    rep(i, 0, ss - st + 1)
    {
        int count = 0;
        rep(j, 0, st)
        {
            if (t[j] == s[i + j])
                count++;
        }
        ans = max(ans, count);
    }
    cout << st - ans << endl;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[10];


int main()
{
	scanf("%s\n", s);
	if (s[0] != s[1]) {
		printf("Yes\n");
		return 0;
	}
	if (s[1] != s[2]) {
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
			
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fixed thgrerde
#define f(i,f, t)  for(int i = f; i <  t; i++)
#define fr(i,f, t) for(int i = f; i >= t; i--)

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

const int infint = INT_MAX;
const ll infll   = LLONG_MAX;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, a , b; cin >> n >> a >> b;
    if(a % 2 == b % 2){
        cout << "Alice";
    }else cout << "Borys";

    return 0;
}


Measured memory_bytes: 256