akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();

  int ans = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'O'){
      int j = 0;
      while( (i+j<n) && (s[i+j] == 'O') )j++;
      
      int k = 0;
      while( (0<=i-1-k) && (k<j) && (s[i-1-k] == 'J'))k++;
      
      int l = 0;
      while( (i+j+l<n) && (l<j) && (s[i+j+l] == 'I'))l++;

      if(j==k && j==l)ans = max(ans,j);

      i += j+l-1;
    }
  }
  cout << ans << endl;
}

      
      

Measured memory_bytes: 1984
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int n, m;
vector<vector<int>> g;
vector<bool> seen;

int dfs(int v, int depth)
{
    if (depth == n - 1)
    {
        return 1;
    }
    int res = 0;
    seen[v] = true;
    for (auto u : g[v])
    {
        if (!seen[u])
        {
            res += dfs(u, depth + 1);
        }
    }
    seen[v] = false;
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    g.resize(n);
    seen.resize(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout << dfs(0, 0) << endl;
}

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

int k;

#define maxn 1000010
#define T 1000000

#define dist _dist

long long int dist[T+10];

int mul[maxn];

int sum (long long int n){
    int res= 0;
    while (n) {
        res+=n%10;
        n/=10;
    }
    return res;
}
#define inf 10000000000

int getlast (int t){
    int res;
    while (t){
        res= t%10;
        t/=10;
    }
    return res;
}   

set <int> s;

int ext (int t){
    while (t<100000) t*=10;
}

void comp (){
    while (!s.empty()){
        int v= *s.begin();
        s.erase(s.begin());
        for (int i=0; i<10; i++){
            int t= 10*mul[i]+v;

            int add= t%10;
            t/=10;
            if (dist[t]>dist[v]+add) {
                dist[t]= dist[v]+add;
                s.insert(t);
            }
        }
    }
}


int main(){
    cin>>k;
    for (int i=1; i<10; i++) mul[i]= i*k;
    long long int ans= sum(k);
    for (int i=0; i<T+6; i++) dist[i]= inf;
    for (int i=1; i<10; i++){
        dist[0]= 0;
        s.insert(0);
    }
    comp();
        
    for (int j=1; j<=T; j++) ans= min(ans, dist[j]+sum(j));
        
    cout<<ans<<endl;
}

Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

int N;
vector<string> S;
int itr = 0;

pair<int, char> parse(string s) {
	int dot;
	for(dot = 0; s[dot] == '.'; ++dot);
	return make_pair(dot, s.back());
}

int add(int);

int mul(int depth) {
	int ret = 1;

	while (itr < N) {
		int dot;
		char sig;
		tie(dot, sig) = parse(S[itr]);
		if (dot < depth) break;

		++itr;
		int res = 0;
		if (sig == '+') {
			res = add(depth + 1);
		} else if (sig == '*') {
			res = mul(depth + 1);
		} else {
			res = sig - '0';
		}

		ret *= res;
		
	}

	return ret;
}

int add(int depth) {
	int ret = 0;

	while (itr < N) {
		int dot;
		char sig;
		tie(dot, sig) = parse(S[itr]);
		if (dot < depth) break;

		++itr;
		int res = 0;
		if (sig == '+') {
			res = add(depth + 1);
		} else if (sig == '*') {
			res = mul(depth + 1);
		} else {
			res = sig - '0';
		}

		ret += res;
	}

	return ret;
}

bool solve() {
	itr = 0;
	cin >> N;
	if (N == 0) return false;

	S.resize(N);
	for(auto& s : S) cin >> s;

	cout << add(0) << endl;
	return true;
}

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



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll gcdExtended(ll a,ll b,ll *x,ll *y)
{
    if(a==0)
    {
        *x=0,*y=1;
        return(b);
    }
    ll x1,y1;
    ll gcd=gcdExtended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return(gcd);
}*/
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
/*ll modInverse(ll a, ll m)
{
    ll x,y;
    ll g = gcdExtended(a, m,&x,&y);
    return((x%m+m)%m);
}*/
/*long combi(int n,int k)
{
    long ans=1;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}*/
/*struct cmp{
    bool operator()(const pair<ll,ll>&a,const pair<ll,ll>&b)
    const{
        int lena=a.second-a.first+1;
        int lenb=b.second-b.first+1;
        if(lena==lenb) return a.first<b.first;
        return lena>lenb;
    }
};*/
void solve()
{
    int n;
    cin>>n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 3608
N, Q = gets.split.map(&:to_i)
S = gets.chomp
query = Q.times.map { gets.split.map(&:to_i) }

counter = Array.new(N + 2, 0)

0.upto(N - 2) do |i|
  if S[i..(i + 1)] == 'AC'
    counter[i + 1] = counter[i] + 1
  else
    counter[i + 1] = counter[i]
  end
end

query.each do |l, r|
  puts counter[r - 1] - counter[l - 1]
end


Measured memory_bytes: 11004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n==m ? "Yes":"No")<<endl;
    return 0;
}

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

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    while(k--){
        if(a >= b){
            b *= 2;
        }
        else if(b >= c){
            c *= 2;
        }
    }
    if(a<b && b<c)  cout << "Yes" << endl;
    else            cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define INF 1e18
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll n,x,dp[200010][5],a[200010];
int main(){
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=0;i<=n+1;i++)
		for (int j=0;j<=4;j++) dp[i][j]=INF;
	dp[0][0]=0;
	for (int i=1;i<=n+1;i++){
		for (int j=0;j<=4;j++){
			for (int k=0;k<=j;k++) dp[i][j]=min(dp[i][j],dp[i-1][k]);
			if (abs(j-2)<=1){
				if (a[i]%2==j%2) dp[i][j]++;
				if (a[i]==0&&j%2==1)dp[i][j]+=2;
			}else{
				dp[i][j]+=a[i];
			}
		}
	}
	cout<<dp[n+1][4]<<endl;
	return 0;
}

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

int main() {
  int r, g, b, n; cin >> r >> g >> b >> n;
  ll ans = 0;
  rep(i,n/r+1) {
    rep(j,n/g+1) {
      int sum = i*r + j*g;
      if (sum > n) continue;
      if (sum == n) ans++;
      else if ((n - sum) % b == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i <= n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int k,s;
    cin >> k >> s;
    int res = 0;
    forn(i,0,k)
        forn(j,0,k) {
            int z = s-i-j;
            if(z >= 0 && z <= k)
                res++;
        }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
clst = [0, 0, 0, 0, 0, 0, 0, 0, 0]

N = int(input())
a = list(map(int, input().split()))

for i in a:
    if i <= 399:
        clst[0] += 1
    elif i <= 799:
        clst[1] += 1
    elif i <= 1199:
        clst[2] += 1
    elif i <= 1599:
        clst[3] += 1
    elif i <= 1999:
        clst[4] += 1
    elif i <= 2399:
        clst[5] += 1
    elif i <= 2799:
        clst[6] += 1
    elif i <= 3199:
        clst[7] += 1
    else:
        clst[8] += 1
minans = 0
maxans = 0

for i in range(9):
    if 0 < clst[i] and i != 8:
        minans += 1
    if i == 8 and minans == 0:
        minans += 1
maxans = minans + clst[8]

if sum(clst[:8]) == 0:
    maxans -= 1

print(minans, maxans)

Measured memory_bytes: 3064
N,K,Q = map(int, input().split())
#A = [K] * N

A = [0] * N

for i in range(Q):
	a = int(input())
	A[a-1] += 1

sm = sum(A)

for j in range(N):
	if K - (sm-A[j]) > 0:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 4680
n=int(input())
h=list(map(int,input().split()))

ans=cnt=0
i=0
while True:
    if i==n-1:
        ans=max(ans,cnt)
        break
    if h[i]>=h[i+1]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
    i+=1

print(ans)


Measured memory_bytes: 20516
import java.util.Scanner;

public class Main {
    
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] in = new String[2];
		double x=0,y=0;
		int theta=0;
		while(s.hasNext()){
			in = s.next().split(",");
			if(in[0].equals("0")&&in[1].equals("0"))
				break;
			int d = Integer.parseInt(in[0]);
			x += d*Math.sin(Math.toRadians(theta));
			y += d*Math.cos(Math.toRadians(theta));
			theta += Integer.parseInt(in[1]);			
		}		
		System.out.println((int) x);
		System.out.println((int) y);
    }
}

Measured memory_bytes: 12000
def solve():
    import math
    N,D = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        x,y = [int(i) for i in input().split()]
        if math.sqrt(x**2+y**2) <= D:
            ans += 1
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9096
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 105
using namespace std;

typedef long long ll;
ll n, mx, a[N], v[N];

void f(ll p, ll q) {
	int i, t[N];
	if (p > n) {mx = max(mx, q); return;}
	f(p + 1, q + a[p]);
	if (a[p] < 0) {
		for (i = p; i <= n; i += p) t[i] = a[i], a[i] = 0;
		f(p + 1, q);
		for (i = p; i <= n; i += p) a[i] = t[i];
	}
}

int main()
{
	ll i, j, t;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (i = n; i > n / 4; i--) {
		for (j = i, t = 0; j <= n; j += i) t += a[j];
		if (t < 0) for (j = i; j <= n; j += i) a[j] = 0;
	}
	f(1, 0);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
X,Y = map(int, input().split())
ans = 0
for i in range(X+1):
    cranes = i
    turtles = X - cranes
  
    if cranes*2+turtles*4 == Y:
        ans += 1
        break

if ans >= 1:
    print("Yes")
elif X == 0 and Y == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9184
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))

A = sorted(A, reverse=True)

total = 0
for i in range(N):
    total += A[i]
if A[M-1] >= total / (4 * M):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int K; cin >> K;

VI k{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};


cout << k[K-1]  << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <unsigned int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    ModInt inverse() const { return pow(mod - 2); }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
};

const int mod = 1000000007;
using mint = ModInt<mod>;

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    map<ll, int> mp;
    rep(i, n) {
        auto X = prime_factor(A[i]);
        for (auto x : X) {
            chmax(mp[x.fi], x.se);
        }
    }
    mint G = 1;
    for (auto x : mp) {
        G *= mint(x.fi).pow(x.se);
    }
    mint ans = 0;
    rep(i, n) {
        ans += G / A[i];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 4288
package main
import . "fmt"
import "sort"
func main() {
  var n,x,y int
  var a []int
  Scan(&n)
  a = make([]int,n)
  for i:=0;i<n;i++ { Scanf("%d",&a[i]) }
  sort.Sort(sort.Reverse(sort.IntSlice(a)))
  x,y = 0,0
  for i:=0;i<n;i++ {
    if i%2 == 0 {
      x += a[i]
    } else {
      y += a[i]
    }
  }
  Println(x-y)
}

Measured memory_bytes: 512
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    s = list(map(int,list(input())))
    n = len(s)
    ans = 1000
    for i in range(n-2):
        ans = min(ans,abs(753-(100*s[i]+10*s[i+1]+s[i+2])))
    
    print(ans)

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int h,w;cin>>h>>w;
    vector<vector<int>>dp(10,vector<int>(10,INF));
    rep(i,10)rep(j,10)cin>>dp[i][j];
    rep(k,10)rep(i,10)rep(j,10)cmin(dp[i][j],dp[i][k]+dp[k][j]);
    int ans=0;
    rep(i,h)rep(j,w){
        int temp; cin>>temp;
        if(temp==-1||temp==1)continue;
        ans+=dp[temp][1];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, M;
  
  multimap<int, int> ab;
  
  REP(i,M){
    int ta,tb;
    cin >> ta >> tb;
    ab.emplace(ta, tb);
    ab.emplace(tb, ta);
  }
  vector<int> r(N-1, -1);
  vector<bool> visit(N+1, false);
  deque<int> que = {1};
  
  while (!que.empty()) {
    int current = que.front(); que.pop_front();
    visit[current] = true;
    for (auto it = ab.lower_bound(current); it != ab.upper_bound(current); ++it)
      if (!visit[it->second]) {
        if (r[it->second - 2] == -1)
          r[it->second - 2] = current;
    visit[it->second] = true;

        que.push_back(it->second);
      }
  }


  cout << "Yes" << endl;
  for (auto i : r)
    cout << i << endl;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/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; }



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

  int n;
  cin >> n;
  vector<pair<int, P>> v(n); // pair = (sum, (takahashi, aoki));
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a+b, make_pair(a, b));
  }
  sort(rall(v));
  ll t = 0, a = 0;
  rep(i,n) {
    if(i % 2 == 0) t += v[i].se.fi;
    else a += v[i].se.se;
  }
  cout << t - a << endl;
}

Measured memory_bytes: 1408
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

int main() {

    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C >= 22)cout << "bust";
    else cout << "win";
}

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

using namespace std;

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

  int a[n];
  std::vector<int> A;
  for(int i=0; i<n; i++){
    cin >> a[i];
    A.push_back(a[i]);
  }

  std::sort(A.begin(), A.end());
  A.erase(std::unique(A.begin(), A.end()), A.end());

  for(int k=0; k<A.size(); k++){
    cout << A[k];
    if(k != A.size()-1) cout << " ";
  }
    cout << endl;

  return 0;
}



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

using namespace std;

int main() {
	int x, n;
	cin >> x >> n;

	set<int> s;
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		s.insert(p);
	}

	int dist = INT_MAX;
	int m = 0;

	for (int i = 0; i <= 101; i++) {
		if (!s.count(i)) {
			if (abs(i - x) < dist) {
				m = i;
				dist = abs(i - x);
			}	
		}
	}

	cout << m;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
long long dp[100000];
int main()
{
	long long n;
	cin>>n;
dp[0]=2;
dp[1]=1;
for (int i = 2 ; i <= n ; i++)
dp[i]=dp[i-1]+dp[i-2];
cout<<dp[n];
}


Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
ns=[]
n.times{ns << gets.split.map(&:to_i)}
ans=0
ns.sort.each do |ni|
  if m>=ni[1]
    ans+=ni[0]*ni[1]
  else
    ans+=ni[0]*m
    break
  end
  m-=ni[1]
end
puts ans


Measured memory_bytes: 11128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    
    while(true){
      
      int count = 0;
      for (int i = 2; i < (X-1); i++){
        if (X % i == 0){
          count++;
        }
      }
      
      if (count == 0){
        System.out.println(X);
        return;
      }
      X++;
    }
  }
}

Measured memory_bytes: 21972
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int > A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    bitset<24> B(0);
    long long sum = 0;
    long long ans = 0;

    int right = 0;
    for (int left = 0; left < N; left++) {
        if (right <= left) right = left;
        while (right < N && (sum + A[right]) == (B ^ (bitset<24>(A[right]))).to_ullong()) {
            sum += A[right];
            B ^= bitset<24>(A[right]);
            right++;
        }
        ans += (right - left);
        sum -= A[left];
        B ^= A[left];
    }

    cout << ans << endl;

    return 0;
}














































Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    ABCD = input()

    op = ['+', '-']
    result = ''

    for i in range(2**3):
        bins = list(map(int, format(i, '03b')))
        f = ABCD[0] + op[bins[0]] + ABCD[1] + \
            op[bins[1]] + ABCD[2] + op[bins[2]] + ABCD[3]
        if eval(f) == 7:
            result = f + '=7'
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <unordered_map>

using namespace std;
int KEY = 1;
unordered_map<int, int> DICTIONARY;

int getChar(char c) {
    switch(c) {
    case 'A':
        return 1;
        break;
    case 'C':
        return 2;
        break;
    case 'G':
        return 3;
        break;
    case 'T':
        return 4;
        break;
    default:
        break;
    }
    return 0;
}

int getKey(string str) {

    int len = str.length();
    if (len <= 0) return len;

    int sum = 0;
    int loop = 1;
    for (int i = 0; i < len; i++) {
        sum += getChar(str[i]) * loop;
        loop *= 5;
    }

    return sum;
}

bool insertToDic(string str) {
    int key = getKey(str);
    if (key <= 0) return false;

    auto p1 = DICTIONARY.insert(make_pair(key,1));
    return p1.second;
}

bool findFrDic(string str) {
    int key = getKey(str);
    if (key <= 0) return false;

    auto p1 = DICTIONARY.find(key);
    return p1 != DICTIONARY.end();
}


int main()
{
    int num;
    cin >> num;
    for (int i = 0; i < num; i++) {
        string command, key;
        
        cin >> command >> key;
        if (command[0] == 'i') insertToDic(key);
        else if (command[0] == 'f') {
            if (findFrDic(key)) cout << "yes\n";
            else cout << "no\n";
        }
    }
}


Measured memory_bytes: 16840
l = [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]
k = int(input())
print(l[k - 1])


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int m,c,i=4,s=0;
  
  while(i--){
    scanf("%d",&c);
    s+=c;
  }
  m=s/60;
  c=s-(m*60);
  printf("%d\n%d\n",m,c);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int N=S.size();
  int cnt=0,ans=0;
  rep(i,0,N-1){
    if(S[i]=='A') cnt++;
    else if(S[i]=='B'){
      if(S[i+1]=='C'){
        ans+=cnt;
        i++;
      }
      else cnt=0;
    }
    else cnt=0;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 640
H, W = map(int, input().split())
c = []
for _ in range(H):
    c.append(list(map(int, input().split())))
    
dp = [[0] * W for i in range(H)] 

for i in range(H):
    if c[i][0] == 0: #?????£??????????????????????????£?????¢??????
        dp[i][0] = 1
for j in range(W):
    if c[0][j] == 0:
        dp[0][j] = 1

for i in range(H-1):
    for j in range(W-1):
        if c[i+1][j+1] == 0:
            dp[i+1][j+1] = min(dp[i][j], dp[i][j+1], dp[i+1][j]) + 1
            
#print(dp)
print(max([max(p) for p in dp]) **2 )

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    FAST
    long double n;
    cin>>n;
    cout<<2.0*n*PI<<endl;

    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long a,q,tmp1,tmp2;
    string s;
    cin>>a>>q;
    cin>>s;
    L dp(a+1,0);
    for(int i=1  ;i<s.size()  ;i++){
        if (s[i-1]=='A' and s[i]=='C'){
            dp[i]=dp[i-1]+1;
        }else{
            dp[i]=dp[i-1];
        }
    }
    
    for(int i=0  ;i<q  ;i++){
        cin>>tmp1>>tmp2;
        cout<<dp[tmp2-1]-dp[tmp1-1]<<endl;
    }
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[200100], i, cnt[200100]={0};
    cin >> n;
    for(i=0;i<n-1;i++){
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    for(i=0;i<n;i++){
        cout << cnt[i] <<endl;
    }
    return 0;
}

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

  int N,M;
  cin>>N>>M;
  vector<int>ans(N,0);
  vector<int>A(M);
  vector<int>B(M);
  for(int i=0;i<=M-1;i++){
  
    cin>>A[i];
    ans[A[i]-1]++;
    cin>>B[i];
    ans[B[i]-1]++;
  }
  for(int i=0;i<=N-1;i++){
  
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

std::string N;
ll K;
ll dp[110][2][5];

int main()
{
  std::cin >> N >> K;

  dp[0][0][0] = 1;

  rep( i, N.size() )
  {
    rep( j, 2 )
    {
      rep( k, K+1 )
      {
        rep( d, (j ? 9 : N[i]-'0')+1 )
        {
          dp[i+1][j || d < (N[i]-'0')][k+(d?1:0)] += dp[i][j][k];
        }
      }
    }
  }

  printf( "%lld\n", dp[N.size()][0][K]+dp[N.size()][1][K] );

  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AT
//
//  Created by 黄道煜 on 2018/7/7.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;

int a, b;

int main()
{
    scanf("%d%d", &a, &b);
    if(a+b==15)printf("+");
    if(a*b==15)printf("*");
    if(a+b!=15 && a*b!=15)printf("x");
}


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

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N=2;
const LL MOD = 1e9 + 7;





int main()
{
  FastRead;
  LL R,C;
  cin>>R>>C;
  LL ans=0;
  LL temp1,temp2,row1,row2;

  if(R==1 || C==1)
  cout<<"1"<<"\n";


else{
  if(C%2==0)
  {
    temp2=C/2;
    temp1=temp2;


  }
  else
  {
    temp2=C/2;
    temp1=temp2+1;
  }


  if(R%2==0)
  {
    row1=R/2;
    row2=R/2;
  }
  else
  {
    row2=R/2;
    row1=row2+1;
  }

  ans+=(row1*temp1);
  ans+=(row2*temp2);
  cout<<ans;
}















   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    REP(i,3){
        string st;cin>>st;
        cout<<st[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 

//     String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:bo){
//if(tem.equals(nyu))res="vowel";
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);

int res=0;
for(int i=0;i<=D;i++){
res+=i;
}

//if(D<=E){
//double res=Math.ceil((AB)/2);

//System.out.println(D*F);
//}else if(B<A){
//System.out.println("Alice");

//}else{
System.out.println(res);
//}




	}
}

Measured memory_bytes: 21460
import java.util.*;

public class Main {
	static int[][] J;
	static int[][] O;
	static int[][] I;
	static char[][] field;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt(), N = sc.nextInt(), K = sc.nextInt();
		field = new char[M][N];
		J = new int[M][N];
		O = new int[M][N];
		I = new int[M][N];
		for (int i = 0; i < M; i++) {
			field[i] = sc.next().toCharArray();
			for (int j = 0; j < N; j++) {
				if (i > 0) {
					J[i][j] += J[i - 1][j];
					O[i][j] += O[i - 1][j];
					I[i][j] += I[i - 1][j];
					if (j > 0) {
						J[i][j] -= J[i - 1][j - 1];
						O[i][j] -= O[i - 1][j - 1];
						I[i][j] -= I[i - 1][j - 1];
					}
				}
				if (j > 0) {
					J[i][j] += J[i][j - 1];
					O[i][j] += O[i][j - 1];
					I[i][j] += I[i][j - 1];
				}
				switch (field[i][j]) {
				case 'J':
					J[i][j]++;
					break;
				case 'O':
					O[i][j]++;
					break;
				case 'I':
					I[i][j]++;
					break;
				}
			}
		}
		for (int i = 0; i < K; i++) {
			int a = sc.nextInt() - 1, b = sc.nextInt() - 1, c = sc.nextInt() - 1, d = sc
					.nextInt() - 1;
			int resultJ = J[c][d], resultO = O[c][d], resultI = I[c][d];
			if (a > 0) {
				resultJ -= J[a - 1][d];
				resultO -= O[a - 1][d];
				resultI -= I[a - 1][d];
				if (b > 0) {
					resultJ += J[a - 1][b - 1];
					resultO += O[a - 1][b - 1];
					resultI += I[a - 1][b - 1];
				}
			}
			if (b > 0) {
				resultJ -= J[c][b - 1];
				resultO -= O[c][b - 1];
				resultI -= I[c][b - 1];
			}
			System.out.println(resultJ + " " + resultO + " " + resultI);
		}
		sc.close();
	}
}

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

int main() {
  long N,K;
  cin >> N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  int ans =0;
  for(int i=0;i<N;i++){
    if(a[i]>=K) ans++;
  }
  cout<<ans<<endl;

  }


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; ++x) for (int y = 0; y <= min(s - x, k); ++y) if (s - x - y <= k) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc107_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int x = input[0];
            int y = input[1];

            string[,] arr = new string[x, y];

            for(int i=0; i<x; i++){
                string str = Console.ReadLine();
                for(int j=0; j<y; j++){
                    arr[i,j] = str[j].ToString();
                }
            }

            for(int i=0; i<x; i++){
                bool value = true;
                for(int j=0; j<y; j++){
                    if(arr[i,j] == '#'.ToString()){
                        value = false;
                        break;
                    }
                }

                if(value){
                    for(int j=0; j<y; j++){
                        arr[i,j] = '0'.ToString();
                    }
                }
            }

            for(int i=0; i<y; i++){
                bool value = true;
                for(int j=0; j<x; j++){
                    if(arr[j,i] == '#'.ToString()){
                        value = false;
                        break;
                    }
                }

                if(value){
                    for(int j=0; j<x; j++){
                        arr[j,i] = '0'.ToString();
                    }
                }
            }

            for (int i = 0; i < x; i++)
            {
                bool value = false;
                for (int j = 0; j < y; j++)
                {
                    if(arr[i,j] != '0'.ToString()){
                        Write(arr[i,j]);
                        value = true;
                    }
                }
                if(value) WriteLine();
            }
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n;
    vector<ll> t(n);
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> t[i];
        sum += t[i];
    }

    cin >> m;
    for (ll i = 0; i < m; i++)
    {
        ll _p, _x;
        cin >> _p >> _x;
        _p--;
        cout << sum - t[_p] + _x << endl;
    }
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main() {
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>c;
    Cout(a+b+c);
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n, m;
    cin >> n >> m;

    vector<ll> x(n), y(m);
    rep(i, n) {
        cin >> x[i];
    }
    rep(i, m) {
        cin >> y[i];
    }

    ll X = 0;
    rep(i, n) {
        X += (2*i-n+1)*x[i];
        X %= mod;
    }

    ll Y = 0;
    rep(i, m) {
        Y += (2*i-m+1)*y[i];
        Y %= mod;
    }

    cout << X*Y%mod << endl;
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(a, b);
    if (a <= 5) {
        std::cout << 0 << std::endl;
    } else if (a >= 13) {
        std::cout << b << std::endl;
    } else {
        std::cout << b/2 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long min = 2000000, max = -2000000, sum = 0;
		for (int i = 0; i < n; ++i) {
			int a = scanner.nextInt();
			min = Math.min(min, a);
			max = Math.max(max, a);
			sum += a;
		}
		System.out.printf("%d %d %d\n", min, max, sum);
		scanner.close();
	}
}



Measured memory_bytes: 42476
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

minv = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())

    tmp = a[x-1] + b[y-1] - c

    if tmp < minv:
        minv = tmp

print(minv)


Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define updmax(dp,x) dp=(dp.first == 0 ? x : max(dp,x))

using P = pair<int,int>;

int main(void){
    int n;
    while(cin>>n, n){
        vector<int> p(n);
        rep(i,n) cin>>p[i];
        map<int,P> cur; // cur[coin] = <get,pay>
        rep(i,n){
            map<int,P> nxt;
            updmax(cur[0],P(0,0));
            for(auto &itr : cur){
                int coin = itr.first;
                int k = itr.second.first;
                int pay = itr.second.second;
                updmax(nxt[coin], P(k,pay));
                pay -= p[i];
                coin += (1000-p[i]%1000)%1000;
                if(coin >= 500){
                    updmax(nxt[coin-500], P(k+1, pay));
                }else if(p[i]%1000){
                    updmax(nxt[coin], P(k,pay));
                }
            }
            cur = move(nxt);
        }

        P res = {0,0};
        for(auto itr : cur){
            res = max(res,itr.second);
        }
        cout<<res.first<<" "<<-res.second<<endl;
    }
    return 0;
}



Measured memory_bytes: 4916