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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();

            int[] array = toArray(N);

            int max = 0;
            int count = 1;
            for (int i = 1; i < array.length; i++) {
                if (array[i - 1] == array[i]) {
                    count++;
                } else {
                    count = 1;
                }
                max = Math.max(max, count);
            }
            System.out.println(max >= 3 ? "Yes" : "No");
        }
    }

    private static int[] toArray(int n) {
        int[] array = new int[4];
        for (int i = 0; i < array.length; i++) {
            array[i] = n % 10;
            n /= 10;
        }
        return array;
    }
}


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

inline void fastRead_int(int &x) {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;

    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());

    if(c=='-') {
      neg = 1;
      c = getchar_unlocked();
    }

    for(; c>47 && c<58 ; c = getchar_unlocked()) {
      x = (x<<1) + (x<<3) + c - 48;
    }

    if(neg)
      x = -x;
}

int main(){

	int n, W;
	fastRead_int(n); fastRead_int(W);

	int val[n], wt[n];
	for (int i = 0; i < n; ++i)	{
		fastRead_int(wt[i]);
		fastRead_int(val[i]);
	}

	int maximumValue = 1000 * 100;
    long long result[maximumValue + 1][n+1];
 
    result[0][0] = 0;
    for (int v = 1; v < maximumValue + 1; v++) {
        result[v][0] = INT_MAX;
    }
 
    for (int m = 1; m < n+1; m++) {
 
        long long weight = wt[m-1];
        long long vals = val[m-1];
 
        for (int v = 0; v < maximumValue + 1; v++) {
            result[v][m] = result[v][m-1];
        }
 
        for (int v = vals; v < maximumValue + 1; v++) {
            result[v][m] = min(result[v][m], result[v - vals][m-1] + weight);
        }
 
    }
 
    long long finalResult = 2e9;
    for (int v = 0; v < maximumValue + 1; v++) {
        if (result[v][n] <= W) {
            finalResult = v;
        }
    }
 
    printf("%lld\n", finalResult);
	return 0;
}

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

int main() {

  int n;
  cin >> n;
  
  vector<long int> a(n);
  int min = 1000001;
  int max = -1000001;
  long int sum = 0;
  
  for(int i=0; i<n; i++){
	cin >> a.at(i);
    if (a.at(i) < min) {
	  min = a.at(i);
    }
    if (a.at(i) > max) {
      max = a.at(i);
    }
    sum += a.at(i);
  }
  
  cout << min << ' ' << max <<  ' ' << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3144
n = int(input())

def dfs(cur, use, cnt):
    if cur > n:
        return
    if use == 0b111:
        cnt.append(1)

    dfs(cur*10+7, use|0b001, cnt)
    dfs(cur*10+5, use|0b010, cnt)
    dfs(cur*10+3, use|0b100, cnt)

cnt = []
dfs(0, 0, cnt)
print(len(cnt))

Measured memory_bytes: 9412
def main():
    n = int(input())
    a1 = list(map(int,input().split()))
    a2 = list(map(int,input().split()))

    anslst = []
    for i in range(n):
        ans = 0
        for j in range(n):
            if i > j:
                ans += a1[j]
            elif i == j:
                ans +=  a1[j] + a2[j]
            elif i < j:
                ans += a2[j]
        anslst.append(ans)

    print(max(anslst))



if __name__ == "__main__":
        main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>
#include <utility>

#define rep(i,first,end) for(int i = first; i < end; i++)

using namespace std;


int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    
    string s;
    cin >> s;
    
    vector<int> count(n,0);
    
    vector<pair<int, int>> vec(q);
    
    rep(i,0,q){
        int l,r;
        cin >> l >> r;
        vec[i].first = l-1;
        vec[i].second = r-1;
        
    }
    rep(j,0,n-1){
        if(s[j] == 'A' && s[j+1] == 'C'){
            count[j+1] = count[j] + 1;
        }
        else{
            count[j+1] = count[j];
        }
    }
    
    

    rep(i,0,q){

        cout << count[vec[i].second] - count[vec[i].first] << endl;
    }

    
    

    
    
}
    




Measured memory_bytes: 2256
while 1:
    n = input()
    if n == 0: break
    p = set([tuple(map(int, raw_input().split())) for i in range(n)])
    ans = 0
    for x1, y1 in p:
        for x2, y2 in p:
            mx = x2 - x1
            my = y2 - y1
            if mx==0 and my==0: continue
            if (x2+my, y2-mx) in p:
                if(x2+my-mx, y2-mx-my) in p:
                    ans = max(ans, mx**2 + my**2)
    print ans

Measured memory_bytes: 7132
from collections import Counter

N= int(input())

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

x = Counter(a)

ok = False
if len(x) == 3 and len(a) % 3 == 0:
    for i in a:
        if x[i] != len(a) // 3:
            break
    else:
        w = 0
        for j in x:
            w ^= j
        if w == 0:
            ok = True
elif len(x) == 1:
    if x.get(0) is not None:
        ok = True
elif len(x) == 2 and len(a) % 3 == 0:
    if x.get(0) is not None and x[0] == len(a) // 3:
        ok = True

if ok:
    print("Yes")
else:
    print("No")


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

int main()
{
	string str;
	cin >> str;
	int alpha[26] = { 0 };
	int cnt = 0;
	for( int i = 0; i < str.size(); i++ )
	{
		alpha[str[i] - 'A']++;
		if( alpha[str[i] - 'A'] == 2 )
			cnt++;
		else if( alpha[str[i] - 'A'] > 2 )
			break;
	}

	if( cnt == 2 )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    int n;
    cin >> n;
    cout << (n % 10 == 9 || n / 10 == 9 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string s = Console.ReadLine ();

            for (int i = 0; i < (1 << 3); i++)
            {
                string m = s[0].ToString ();
                int sum = int.Parse (m);
                for (int j = 0; j < 3; j++)
                {
                    if ((i >> j & 1) > 0)
                    {
                        m += "+" + s[j + 1];
                        sum += int.Parse (s[j + 1].ToString ());
                    }
                    else
                    {
                        m += "-" + s[j + 1];
                        sum -= int.Parse (s[j + 1].ToString ());
                    }
                }
                if (sum == 7)
                {
                    Console.WriteLine (m + "=7");
                    return;
                }
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,A,B;cin>>K>>A>>B;
  bool can=false;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      can=true;
      break;
    }
  }
  if(can) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		if (a > b + W) {
			ans = a - (b + W);
		} else if (b > a + W) {
			ans = b - (a + W);
		}
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 21844
date = input().split("/")
bomb = 0
for d in range(len(date)):
  if d == 0:
    if int(date[d]) < 2019:
      bomb += 1
      break
  elif d == 1:
    if int(date[0]) == 2019:
      if int(date[d]) <= 4:
        bomb += 1
        break
if bomb == 0:
  print("TBD")
else:
  print("Heisei")

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

vector<int> ps;
int nfac[101];

// a1, a2, a3は素数の順番
// b1, b2, b3はそれぞれの素数の指数
bool check(int a1, int a2, int a3, int b1, int b2, int b3){
	if(b1 > nfac[ps[a1]]) return false;
	if(b2 > nfac[ps[a2]]) return false;
	if(b3 > nfac[ps[a3]]) return false;
	return true;
}

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

	int n;
	cin >> n;

	ps.push_back(2);
	for(int i = 3; i <= 100; i += 2){
		bool ok = true;
		for(int p: ps){
			if(i % p == 0) {
				ok = false;
			 	break;
			}
		}
		if(ok) ps.push_back(i);
	}

	// rep(i, ps.size()) cout << ps[i] << " ";
	// cout << endl;

	rep(i, 101) nfac[i] = 0;
	for(int i = 1; i <= n; i++){
		int x = i;
		while(x > 1){
			for(int p: ps){
				while(x % p == 0){
					nfac[p]++;
					x /= p;
				}
			}
		}
	}

	/*
	for(int p: ps){
		cout << p << " " << nfac[p] << endl;
	}
	cout << endl;
	*/
	
	int ans = 0;
	for(int i = 0; i < ps.size(); i++){
		for(int j = i+1; j < ps.size(); j++){
			for(int k = j+1; k < ps.size(); k++){
				if(check(i, j, k, 2, 4, 4)) ans++;
				if(check(i, j, k, 4, 2, 4)) ans++;
				if(check(i, j, k, 4, 4, 2)) ans++;
			}
		}
	}
	for(int i = 0; i < ps.size(); i++){
		for(int j = i+1; j < ps.size(); j++){
			if(check(i, j, 1, 2, 24, -1)) ans++;
			if(check(i, j, 1, 24, 2, -1)) ans++;
			if(check(i, j, 1, 4, 14, -1)) ans++;
			if(check(i, j, 1, 14, 4, -1)) ans++;
			// (2+1) * (24+1) = 75
		}
	}

	for(int i = 0; i < ps.size(); i++){
		if(check(i, 1, 1, 74, -1, -1)) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  vector<int> a(3);
  for (int i = 0; i < (int)3; ++i) cin >> a[i];

  sort((a).begin(), (a).end());
  cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  int countAC=0;
  int countWA=0;
  int countTLE=0;
  int countRE=0;
  
  for(int i=0;i<N;i++){
    if(A.at(i)=="AC"){countAC++;}
    if(A.at(i)=="WA"){countWA++;}
    if(A.at(i)=="TLE"){countTLE++;}
    if(A.at(i)=="RE"){countRE++;} 
  }
  
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;

}
      

Measured memory_bytes: 6428
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

ll N, M;
vector<ll> p;
vector<pair<ll, ll>> xy;

vector<int> uni;

void init(int N)
{
    uni.resize(N);
    for (int i = 0; i < N; i++)
        {
            uni[i] = -1;
        }
}

int root(int a)
{
    if (uni[a] < 0) return a;
    else return uni[a] = root(uni[a]);
}

bool connect(int a, int b)
{
    a = root(a);
    b = root(b);
    if (a == b) return false;
    if (uni[a] > uni[b]) swap(a, b);
    uni[a] += uni[b];
    uni[b] = a;
    return true;
}

void swap(int a, int b)
{
    int c = a;
    a = b;
    b = c;
}

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

    cin >> N >> M;
    REP(i, N) {
        ll t;
        cin >> t;
        p.push_back(t -1);
    }

    init(N);


    REP(i, M) {
        ll x, y;
        cin >> x >> y;
        connect(x-1, y-1);
    }

    REP(i, N) {
        if (uni[i] >= 0) {
            uni[i] = root(i);
        }
    }

    REP(i, N) {
        if (uni[i] != -1 && uni[i] < 0) uni[i] = i;
        // debug(uni[i]);
    }

    vector<int> g(N);
    REP(i, N) {
        g[p[i]] = uni[i];
    }

    ll ans = 0;
    REP(i, N) {
        // debug(g[i]);
        if (g[i] != -1 && g[p[i]] == g[i]) {
            ans++;
        } else if (g[i] == -1 && p[i] == i) {
            ans++;
        }
    }

    // debug(ans);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1780
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      FAST()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main()
{
	FAST();

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,x,a,i;
           string s;
           cin>>x>>n;
           ll ar[105]={0};
           for(i=0;i<n;i++){
            cin>>a;
            ar[a]=1;
           }
          // sort(ar,ar+n);
          ll mn=INT_MAX,ans=0;
           for(i=0;i<=101;i++){
            if(ar[i]==0){
                ll dif=abs(i-x);
                if(dif<mn){
                    mn=dif;
                    ans=i;
                }
            }
           }
           cout<<ans<<endl;

        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree() {
        int sz = 201000;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);

        for(int i=0; i<sz; i++) node[i+n-1] = INF;
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void eval(int k, int l, int r) {
        if(lazy[k] != INF) {
            chmin(node[k], lazy[k]);
            if(r - l > 1) {
                chmin(lazy[2*k+1], lazy[k]);
                chmin(lazy[2*k+2], lazy[k]);
            }
            lazy[k] = INF;
        }
    }

    void set(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            chmin(lazy[k], x);
            eval(k, l, r);
        }
        else {
            set(a, b, x, 2*k+1, l, (l+r)/2);
            set(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

    ll getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);

        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }

};

ll N, Q, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    LazySegmentTree row, column;
    row.set(0, N, N - 2);
    column.set(0, N, N - 2);
    for(int q = 0; q < Q; q++) {
        int t, x;
        cin >> t >> x;
        x -= 2;
        if(t == 1) {
            ll c = row.getmin(x, x + 1);
            ans += c;
            column.set(0, c, x);
        } else {
            ll c = column.getmin(x, x + 1);
            ans += c;
            row.set(0, c, x);
        }
    }
    cout << (N - 2) * (N - 2) - ans << endl;
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll A,B,C,K;cin>>A>>B>>C>>K;
    ll ans=0;
    if(K<=A){cout<<K<<endl;}
    if(A<K&&K<=A+B){cout<<A<<endl;}
    if(A+B<K&&K<=A+B+C){cout<<A-(K-A-B)<<endl;}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, ans;
	cin >> a >> b;
	if(a+b >= 24){
		ans = a+b-24;
	}else{
		ans = a + b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,a,n;
    scanf("%d",&n);
     x=n%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9)
        printf("hon");
    else if(x==0 || x==1 || x==6 || x==8)
        printf("pon");
    else if(x==3)
        printf("bon");
    return 0;
}


Measured memory_bytes: 1680
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

signed main() {
    int H, W, K;
    cin >> H >> W >> K;
    K--;

    vector<vector<int>> dp(H+1, vector<int>(W, 0));

    dp[H][K] = 1;

    for (int i = H - 1; i >= 0; i--) {
        for (int j = 0; j < (1 << (W - 1)); j++) {
            bool skip = false;
            for (int k = 0; k < W - 1; k++) {
                if ((j >> k) & 1 && (j >> (k + 1) & 1)) skip = true;
            }
            if (skip) continue;

            for (int k = 0; k < W; k++) {
                if (k > 0 && (j >> (k-1)) & 1) { // 左にあみだ
                    dp[i][k] += dp[i+1][k-1];
                } else if (k < W - 1 && (j >> k) & 1) { // 右にあみだ
                    dp[i][k] += dp[i+1][k+1];
                } else { // 左右にあみだなし
                    dp[i][k] += dp[i+1][k];
                }

                dp[i][k] %= MOD;
            }

        }
    }

    cout << dp[0][0] << endl;

    return 0;
}

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

void solve() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> v(H, vector<char>(W));
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
        cin >> v[i][j];
    }

    int ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        set<int> st;
        for (int j = 0; j < H; ++j) {
            if ((i & (1 <<j)) != 0) st.insert(j);
        }
        for (int x = 0; x < (1 << W); ++x) {
            set<int> st1;
            for (int y = 0; y < W; ++y) {
                if ((x & (1 << y)) != 0) st1.insert(y);
            }
            int black = 0;
            for (int r = 0; r < H; ++r) {
                for (int c = 0; c < W; ++c) {
                    if (not st.count(r) && not st1.count(c) && v[r][c] == '#') black++;
                }
            }
            if (black == K) ans++;
        }
    }
    cout << ans << endl;
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
double distance(double x1, double y1, double x2, double y2){
  return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main() {
  string s;cin>>s;
  map<string,int> a;
  a["SUN"]=7;
  a["MON"]=6;
  a["TUE"]=5;
  a["WED"]=4;
  a["THU"]=3;
  a["FRI"]=2;
  a["SAT"]=1;
  cout<<a[s]<<endl;
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int mod = 1e9+7;

//ll binpow(ll a, ll n);
//ll modp(ll a, ll b, int m);
//ll binmul(ll a, ll b, ll c);

void solve(){
	
}
int a[10001];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin>>n;
	ll ans = 0;
	for(int i = 0 ; i < n ; i++){
		cin>>a[i];
		ans+=a[i];
	}
	cout<<ans-n<<"\n";
	return 0;
}

//ll binpow (ll a, ll n) {
//	ll res = 1;
//	while (n) {
//		if (n & 1)
//			res *= a;
//		a *= a;
//		n >>= 1;
//	}
//	return res;
//}

//long long modp(long long a, long long b, int m)
//{
//    int result = 1;
//    while (b > 0)
//    {
//        if (b % 2 == 1)
//            result = (result * a) % m;
//        b = b >> 1;
//        a = (a * a) % m;
//    }
//    return result;
//}

//ll binmul(ll a, ll b, ll c) {
//	if(b == 0) return 0;
//	if(b % 2 == 1) {
//		ll x = binmul(a, b-1, c);
//		return (x+a) % c;
//	}
//	ll x = binmul(a, b/2, c);
//	return x * 2 % c;
//}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;

    for (ll i = 0; i < s.length(); i+=2) {
      cout <<s[i];
    }
    cout <<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 592
#include <stdio.h>
#include <math.h>
 
int main(void) {
   
   int X;
   
   scanf("%d", &X);
   
   int DP[X + 10];
   
   int i,j;
   
   DP[0] = 1;
   
   for (i = 1; i <= X; i++) {
      
      int c1 = (0 <= i - 100 && DP[i - 100] == 1);
      int c2 = (0 <= i - 101 && DP[i - 101] == 1);
      int c3 = (0 <= i - 102 && DP[i - 102] == 1);
      int c4 = (0 <= i - 103 && DP[i - 103] == 1);
      int c5 = (0 <= i - 104 && DP[i - 104] == 1);
      int c6 = (0 <= i - 105 && DP[i - 105] == 1);
      
      if (c1 || c2 || c3 || c4 || c5 || c6) {
         DP[i] = 1;
      }
      else {
         DP[i] = 0;
      }

   }
  
   printf("%d\n", DP[X]);
   
   
   
   return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int n,m,a[200001];
  cin>>n>>m;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  long long ans=0;
  for(int i=0;i<n-m;i++)
    ans+=a[i];
  cout<<ans;
  }

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] nyuryokuStr = line.split("[\\s]+");

		int weight = Integer.parseInt(nyuryokuStr[0]);
		int height = Integer.parseInt(nyuryokuStr[1]);
		int x_zahyo = Integer.parseInt(nyuryokuStr[2]);
		int y_zahyo = Integer.parseInt(nyuryokuStr[3]);
		int hankei = Integer.parseInt(nyuryokuStr[4]);

		if ((x_zahyo - hankei >= 0) && (y_zahyo + hankei > 0)) {
			if ((x_zahyo + hankei <= weight) && (y_zahyo + hankei <= height)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24588
import sys

for inp in map(str, [line.strip() for line in sys.stdin]):
	lenip = len(inp)
	if lenip%2==0:
		print "Yes" if inp[:lenip/2] == inp[lenip/2:][::-1] else "No"
	else:
		print "Yes" if inp[:lenip/2] == inp[(lenip+1)/2:][::-1] else "No"

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a[2]={};
  for(char c:s){
    if(c=='0')a[0]++;
    else a[1]++;
  }
  cout<<2*min(a[0],a[1])<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
     
    int main(void){
    int r,g,b;
    scanf("%d %d %d",&r,&g,&b);
    if((r*100 + g*10 + b) % 4 == 0) printf("YES");
    else printf("NO");
    }

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  double min, max, tmp;

  cin >> tmp;
  min = max = tmp;
  while (cin >> tmp) {
    if (tmp < min)
      min = tmp;
    if (tmp > max)
      max = tmp;
  }
  cout << max-min << endl;
  return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int d, g; cin>>d>>g;
    vector<int> p(d), c(d);
    for(int i=0; i<d; i++) cin>>p[i]>>c[i];

    int MIN=MOD;
    for(int i=0; i<(1<<d); i++){
        int sum=0, cnt=0;

        for(int j=0; j<d; j++){
            
            if(i & (1<<j)){
                sum += p[j] * 100 * (j + 1) + c[j];
                cnt += p[j];
            }
        }

        if(sum >= g) MIN = min(MIN, cnt);
        else{
            for(int j=d-1; j>=0; j--){

                if(!(i & (1<<j))){
                    int cnt2=0;
                    while(sum < g && cnt2 <= p[j]){
                        sum += 100 * (j + 1);
                        cnt++;
                        cnt2++;
                    }
                    break;
                }
            }
            if(sum >= g) MIN = min(MIN, cnt);
        }
    }
    cout << MIN << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        long cnt = 0;
        if (N == 1 && M == 1) {
            cnt = 1;
            System.out.println(cnt);
        } else if (N == 1) {
            cnt = M - 2;
            System.out.println(cnt);
        } else if (M == 1) {
            cnt = N - 2;
            System.out.println(cnt);
        } else {
            BigInteger v = new BigInteger(String.valueOf(N - 2), 10).multiply(new BigInteger(String.valueOf(M - 2), 10));
            System.out.println(v.toString());
        }

        return;
    }

}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x;
  cin >> a >> b;
  
  if(a < 1) {
    cout << "a(first input) must be greater than or equal to 1.";    
    return 0;
  }
  
  if(b > 100) {
  	cout << "b(second input) must be smaller than or equal to 100.";
    return 0;
  }
  
  x = ceil((a + b) / 2.0);

  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int A = 20190430;
        
        S = S.replace("/","");
        int num = Integer.parseInt(S); 
 
        System.out.println(num - A <= 0 ? "Heisei" : "TBD");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

int main() {


    zoom;    
    ll N; cin >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i += 1)
        cin >> A[i];
    vector<ll> dp(N, 0);
    dp[N - 2] = (ll)abs(A[N - 1] - A[N - 2]);
    for(ll i = N - 3; i >= 0; i -= 1) {
        ll one = (ll)abs(A[i] - A[i + 1]) + dp[i + 1];
        ll two = (ll)abs(A[i] - A[i + 2]) + dp[i + 2];
        dp[i] = (ll)min(one, two);
    }
    cout << dp[0];
    return 0;
}

Measured memory_bytes: 1792
#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;
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

const int MAX_N = 110;
const int MAX_V = 100010;

int N;
ll W, weight[MAX_N], value[MAX_N];
ll dp[MAX_N][MAX_V];

int main() {
  IOS;
  constexpr char endl = '\n';

  int R;
  cin >> R;
  cout << 2.0 * M_PI * R << endl;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////
using type = pair<int,ll>;//1: query, 0; delete, -1: insert
using event = pair<ll,type>;

int main(){
  int N,Q;cin >> N >> Q;
  vector<event> v;
  for(int i=0;i<N;i++){
    int s,t,x; cin >> s >> t >> x;
    v.push_back({s-x,type(-1, x)});//歩いていても通行止めにかぶらない範囲
    v.push_back({t-x,type(0,  x)});//通行止めの範囲
  }
  //クエリ
  for(int i=0;i<Q;i++){
    int d;cin >> d;
    v.push_back({d,type(1,i)});
  }
  sort(all(v));
   vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;//操作の種類
        long long val = p.second.second;//通行止めの座標
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
}


Measured memory_bytes: 27876
import java.util.Scanner;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> result = new ArrayList<String>();

        while(true){
            String s = sc.nextLine();
            if(s.equals(".")) break;

            Deque<String> deque = new ArrayDeque<>();
            deque.push("start");

            for(int i = 0; i < s.length(); i++){
                if(s.charAt(i) == '(') deque.push("(");
                if(s.charAt(i) == ')'){
                    if(deque.peek().equals("(")){
                        deque.pop();
                    }else{
                        deque.push(")");
                        break;
                    }
                }
                if(s.charAt(i) == '[') deque.push("[");
                if(s.charAt(i) == ']'){
                    if(deque.peek().equals("[")){
                        deque.pop();
                    }else{
                        deque.push("]");
                        break;
                    }
                }
            }

            if(deque.size() == 1){
                result.add("yes");
            }else{
                result.add("no");
            }
        }

        for(String i : result){
            System.out.println(i);
        }

        sc.close();
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        var ABN = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var (A, B, N) = (ABN[0], ABN[1], ABN[2]);

        var x = (N < B - 1) ? N : B - 1;

        var ans = (A * x / B) - A * (x / B);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28132
import sys
N = int(input())
ans = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i, j in factorization(N):
    if i == 1:
        print("0")
        sys.exit()
    n= 1
    while 2*j >= n*(n+1):
        n += 1
        ans += 1
    
print(ans)

Measured memory_bytes: 9380
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int a[m];
	rep (i, m) cin >> a[i];

	int cntl = 0, cntr = 0;
	rep (i, m) {
		if (a[i] < x) cntl++;
		else cntr++;
	}

	cout << min(cntr, cntl) << endl;
	return 0;
}

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

typedef long long ll;

using namespace std;


int main(void) {
    string S;
    cin >> S;
    int S1 = std::stoi(S.substr(0, 2));
    int S2 = std::stoi(S.substr(2, 4));

    if (1 <= S1 && S1 <= 12 && 1 <= S2 && S2 <= 12)  {
        cout << "AMBIGUOUS" << endl;
    }

    if (1 <= S1 && S1 <= 12) {
        if (S2 < 1 || 12 < S2) {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= S2 && S2 <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
	int a,b,c,d,i,j;
	int n[5];
	c=0;d=0;
	for(i=0;i<3;i++)
	{
		scanf("%d",&n[i]);
		if(n[i]==5)
		c+=1;
		else if(n[i]==7)
		d+=1;
	}
	if(c==2&&d==1)
	printf("YES\n");
	else
	printf("NO\n");

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(void){
    int H,W,h,w;cin>>H>>W>>h>>w;cout<<(H-h)*(W-w)<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll x;
    cin >> x;

    int l = 64 - __builtin_clzll(x);
    vector<vector<int>> a(l, vector<int>(n));

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        t--;

        a[0][i] = t;
    }
    for (int k = 0; k < l - 1; k++) {
        for (int i = 0; i < n; i++) {
            a[k + 1][i] = a[k][a[k][i]];
        }
    }

    int i = 0;
    for (int k = 0; k < l; k++) {
        if (x >> k & 1) {
            i = a[k][i];
        }
    }

    cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 50940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
int dp[100003]={},vis[100003]={},ans=0;
vector<int> adj[100003];
int dfs(int curr)
{
  if(vis[curr]==1) { return dp[curr]; }
  else
    {
      // cout<<curr<<"\n";
      vis[curr]=1;
    }
      for(int child:adj[curr])
      {
        dp[curr]=max(dp[curr],1+dfs(child));
      }
      ans=max(ans,dp[curr]);
      // cout<<"curr="<<curr<<"dp="<<dp[curr]<<"\n";
      return dp[curr];
     // }
}
// int32_t main()
int main()
{  ios_base::sync_with_stdio(false); cin.tie(NULL);
   int i,n,m,x,y;cin>>n>>m;
   for(i=0;i<m;i++)
  {
    cin>>x>>y;
    adj[x].push_back(y);
  }
  for(i=1;i<=n;i++)
  {if(vis[i]!=1) dfs(i);}
  cout<<ans;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int s[a],t[b];
  int i,j;
  for(i=0;i<b;i++){
    t[i]=a;
  }
  for(j=0;j<a;j++){
    s[j]=b;
  }
  if(a>b){
    for(j=0;j<a;j++){
      cout << s[j];
    }
  }else{
    for(i=0;i<b;i++){
      cout << t[i];
    }
  }
}
    
  

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

using namespace std;

using ll=long long;

int main(){
    vector<int> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end(),greater<int>());
    int ans=v[0]-v[1];
    int b=v[0]-v[2]-ans;
    if(b%2)ans+=max(1,b/2+1)+1;
    else ans+=b/2;
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>H(N);
  for(int i=0; i<N; i++)cin >> H.at(i);
  
  string ans ="Yes";
  for(int i=N-1; i>0; i--){
    if(H.at(i)-H.at(i-1)<-1){
      ans = "No";
      break;
    }
    else if(H.at(i)-H.at(i-1)==-1)H.at(i-1)--;
  }
  
  cout << ans << endl;
}

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

struct restaurant{
	string name;
	int score,id;
}r[1004];

bool cmp(restaurant a,restaurant b){
	if(a.name<b.name)return true;
	if(a.name==b.name){
		if(a.score>=b.score)return true;
	}
	return false;
}
int main(void){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>r[i].name>>r[i].score;
		r[i].id=i+1;
	}
	sort(r,r+n,cmp);
	for(int t=0;t<n;t++)cout<<r[t].id<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

int main()
{

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

	ll n; cin >> n;
	ll res = 0;

	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 and i % 5 != 0) res += i;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define pb        emplace_back
#define fi        first
#define se        second
#define show(...)  fprintf(stderr, __VA_ARGS__ )
#define outl(x)   cout << (x) << '\n'
#define rep(i,n)     for(int i=0; i<(n); ++i)
#define inside(x,y,w,h) ((x)>=0 && (y)>=0 && (x)<(w) && (y)<(h))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int       INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};

int N;
char str[300010];
int r[300010];
int l[300010];

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

    cin >> N >> str+1;

    for (int i=1; i <= N; ++i) {
        if (str[i] == 'E') {
            ++r[i];
        } else {
            ++l[i];
        }
    }

    for (int i=1; i<=N; ++i) {
        r[i] += r[i-1];
        l[i] += l[i-1];
    }

    int ans = INF;
    for (int i=1; i <= N; ++i) {

        int rcase;

        { // 右向いてる
            int tmp  = 0;
            tmp = l[i-1] - l[0];
            tmp += r[N] - r[i];   // 左向き人数
            rcase = tmp;
        }
        // {
        //     int tmp;
        //     tmp = r[i-1] - r[0];
        //     tmp += r[N] - r[i];
        //     lcase = tmp;
        // }
        // fprintf(stderr, "%d %c %d %d\n", i, str[i], rcase, lcase);
        // chmin(ans, min(rcase, lcase));
        chmin(ans, rcase);
    }

    outl(ans);

}



Measured memory_bytes: 2944
#include <stdio.h>

int main(void){
		int a,b,c,d;
		int max = 0;
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("%d",&c);
		scanf("%d",&d);
		if(a<b){
			max+=a;
		}
		else{
			max+=b;
		}
		if(c<d){
			max+=c;
		}
		else{
			max+=d;
		}
	
	printf("%d\n",max);
	
		return 0;
}

Measured memory_bytes: 128
n = int(input())
k = int(input())
lis = list(map(int, input().split()))

ans = 0
for i in range(n):
    a = lis[i]
    b = abs(k - lis[i])
    
    if a <= b:
        ans += 2*a
    else:
        ans += 2*b

print(ans)

Measured memory_bytes: 9072
#include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;

int p[1000001];
int memo[1000001];
int memo2[1000001];

int solve(int n, int count){
  
  if(!n) return 0;
  if(n <= 0 || !count) return INF;
  if(memo[n]) return memo[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n; i++) ans = min(ans, solve(n-p[i], count-1)+1);
  
  return memo[n] = ans;
}

int solve2(int n){
  
  if(!n) return 0;
  if(n<0) return INF;
  if(memo2[n]) return memo2[n];
  
  int ans = INF;
  for(int i=0;p[i]<=n;i++){
    if(!(p[i]%2)) continue;
    ans = min(ans, solve2(n-p[i])+1);
  }
  
  return memo2[n] = ans;
}

int main(){
  
  int n;
  
  for(int i=0;i<=1000000;i++) p[i] = i*(i+1)*(i+2)/6;
  for(int i=1;i<=1000000;i++) solve(i, 5), solve2(i);
  
  while(cin >> n, n) cout << solve(n, 5) << " " << solve2(n) << endl;
}

Measured memory_bytes: 12880