akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll dp[305][305][305];
ll solve(ll l,ll r,ll k){
    if(k<0)return (-1e9);
    if(r<l+1)return r-l+1;
    if(dp[l][r][k]!=-1)return dp[l][r][k];
    ll &ans = dp[l][r][k];
    ans = max(solve(l+1,r,k),solve(l,r-1,k));
    ll nk = k - (s[l]!=s[r]);
    ans = max(ans , 2 + solve(l+1,r-1,nk));
    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll k;cin>>s>>k;
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,s.size()-1,k);
}

Measured memory_bytes: 221952
A=input()
for i in range(2**3):
  tmp=['+' if ((i>>j)&1) else '-' for j in range(3)]
  if eval(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3])==7:
    print(A[0]+tmp[0]+A[1]+tmp[1]+A[2]+tmp[2]+A[3]+"=7")
    exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

string s;
int a,b;

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

	while(cin>>s) {
	a=0,b=0;
	REP(i,s.size()-2) {
		if(s[i+1]=='O'&&s[i+2]=='I') {
			if(s[i]=='J') a++;
			else if(s[i]=='I') b++;
		}
	}
	cout<<a<<endl<<b<<endl;
	}

	return 0;
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int H, W;
int n;
int sx, sy;
string s[2];
const int maxn = 2e5 + 5;

int a[4][2][maxn];

string p = "UDLR";

int id(char c){
    for(int j = 0;j < 4;j++){
        if(c == p[j])
            return j;
    }
    return 0;
}

bool in(int x, int y){
    if(x >= 1 and x <= H and y >= 1 and y <= W)
        return true;
    return false;
}

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

bool solve(vector<int> dir){
    int ex = sx, ey = sy; 
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 2;j++){
            int k = id(s[j][i]);
            if(k == dir[j]){
                int nx = dx[k] + ex;
                int ny = dy[k] + ey;
                if(j == 0){
                    if(!in(nx, ny))
                        return true;
                    ex = nx, ey = ny;
                }else{
                    if(in(nx, ny)){
                        ex = nx, ey = ny;
                    }
                }
            }
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> H >> W;
    cin >> n;
    cin >> sx >> sy;
    cin >> s[0] >> s[1];
    for(int i = 0;i < 4;i++){
        int j = i ^ 1;
        if(solve({i, j})){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int main() {
  int r, g, b, n;
  cin>>r>>g>>b>>n;
  long long ans = 0;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n; j++) {
      if (n - r * i - g * j < 0) {
        break;
      }
      if ((n - r * i - g * j) % b == 0) {
        ++ans;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main (){
	int time,a,b,c;
	cin >> time;
	c = time % 60;
	b = ((time - c) % 3600) / 60;
	a = (time - b - c) / 3600;
	cout << a << ":" <<b<<":"<<c<<endl;


	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    string S,T; cin >>S>>T;
    T.erase(T.length()-1);
    if (S==T)
    {
      cout <<"Yes"<<endl;
      return 0;
    }
    

    cout << "No" << endl;
    
    return 0;
}


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

int main(){
	long long n;
	cin >> n;
	long long a[n+5] = {0};
	long long b[n+5] = {0};
	for(long long i = 1;i <= n + 1;i++){
		cin >> a[i];
	}
	for(long long i = 1;i <= n;i++){
		cin >> b[i];
	}
	long long sum = 0;
	for(long long i = 1;i <= n;i++){
		if(b[i] > a[i]){
			sum += a[i];
			b[i] -= a[i];
			if(b[i] > a[i+1]){
				sum += a[i+1];
				a[i+1] = 0;
			}
			else{
				sum += b[i];
				a[i+1] -= b[i];
			}
		}
		else{
			sum += b[i];
			b[i] = 0;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1920
import Control.Applicative

fromA :: [Int] -> [Int] -> [Int] -> Int -> [Int]
fromA []    []    deckC _ = deckC
fromA []    deckB deckC n = fromB [] deckB deckC n
fromA deckA deckB deckC n = fromB (drop n deckA) deckB (deckC ++ take n deckA) n

fromB :: [Int] -> [Int] -> [Int] -> Int -> [Int]
fromB []    []    deckC _ = deckC
fromB deckA []    deckC n = fromA deckA [] deckC n
fromB deckA deckB deckC n = fromA deckA (drop n deckB) (deckC ++ take n deckB) n


riffle :: [Int] -> Int -> [Int]
riffle deck n =
  let sizeB = length deck `div` 2
      deckA = drop sizeB deck
      deckB = take sizeB deck
  in
      fromA deckA deckB [] n

solver :: [String] -> [[Int]]
solver [] = []
solver (l1:l2:xs) =
  let (x:_) = map (read :: String -> Int) $ words l1
      ys = map (read :: String -> Int) $ words l2
  in
      riffle' [0..(x-1)] ys : solver xs


riffle' :: [Int] -> [Int] -> [Int]
riffle' deck [] = deck
riffle' deck xs = foldl riffle deck xs


main :: IO()
main = do
  contents <- lines <$> getContents
  mapM_ (print . last) (solver contents)
--   contents <- map lines <$> getContents

Measured memory_bytes: 4620
def main():
    I, O, T, J, L, S, Z = map(int, input().split())
    ans = O
    if L >= 1 and J >= 1 and I >= 1 and (J % 2) + (L % 2) + (I % 2) >= 2:
        J -= 1
        L -= 1
        I -= 1
        ans += 3
    ans += I // 2 * 2
    ans += J // 2 * 2
    ans += L // 2 * 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61524
sx,sy,tx,ty=map(int,input().split())
xd=tx-sx;yd=ty-sy
res='R'*xd+'U'*yd+'L'*xd+'D'*yd+'D'+'R'*(xd+1)+'U'*(yd+1)+'LU'+'L'*(xd+1)+'D'*(yd+1)+'R'
print(res)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, x, a, sum;
	ll ans = 0;

	cin >> n >> x;

	vector<ll> v(n, 0);
	vector<ll> vv(n, 0);

	REP(i, n) {
		cin >> a;
		v[i] = a;
		vv[i] = a;
		ans += a;
	}

	FOR(i, 1, n) {
		sum = x * i;

		REP(j, n) {
			if (j - i < 0) {
				vv[j] = min(vv[j], v[(j - i) % n + n]);
			}
			else {
				vv[j] = min(vv[j], v[(j - i) % n]);
			}
			sum += vv[j];
		}

		if (sum < ans) {
			ans = sum;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N,M,K);
  rep(i,N+1) rep(j,M+1){
    if(i * j + (N - i) * (M - j) == K) die("Yes"); 
  }
  die("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
pair<int,int> arr[200005];
int dp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%d %d",&arr[i].first,&arr[i].second);
	sort(arr,arr+n);
	dp[n]=1;
	stack<pair<int,int> > s;
	s.push({2e9,n});
	for (int i=n-1;i>=0;i--)
	{
		while (arr[i].first+arr[i].second>s.top().first)
		s.pop();
		dp[i]=(dp[i+1]+dp[s.top().second])%mod;
		s.push({arr[i].first,i});
	}
	printf("%d",dp[0]);
}

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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll X;
  cin >> X;
  bool flag = false;
  for (int A=-118; A<=119; A++) {
    for (int B=-119; B<=118; B++) {
      if (pow(A, 5)-pow(B, 5)==X) {
        cout << A << " " << B << endl;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
}


Measured memory_bytes: 4088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][]D = new int[C][C];
		int[][]c = new int[N][N];
		for(int i = 0; i < C; i++) {
			for(int j = 0; j < C; j++) {
				D[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				c[i][j] = sc.nextInt() - 1;
			}
		}
		sc.close();
		int[][] g = new int[C][3];
		for(int i = 0; i < C; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					if(c[j][k] != i) {
						g[i][(j + k) % 3] += D[c[j][k]][i];
					}
				}
			}
		}
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < C; i++) {
			for(int j = 0; j < C; j++) {
				for(int k = 0; k < C; k++) {
					if(i == j || i == k || j == k) continue;
					min = Math.min(min, g[i][0] + g[j][1] + g[k][2]);
				}
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 89664
#include<bits/stdc++.h>
using namespace std;
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
#define p pair<int,int>
int N;
vector<int> as;
map<int,int> mp;

int main(){
    cin >> N;
    int m = 1 << 30, M = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        mp[a]++;

        chmax(M, a);
        chmin(m, a);
    }
    bool flag = true;
    if(M - m > 1) flag = false;
    if(M - m == 1){
        if(mp[m] + 1 > M || M > mp[m] + (mp[M] / 2)) flag = false;
    }
    if(M - m == 0){
        flag  = false;
        if(m + 1 == N) flag = true;
        if(m * 2 <= N) flag = true;
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <sstream>
#include <functional>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

typedef pair<int, int> PII;

const int MAX_WH = 1100;
const int MAX_P = 1000000;

#define mp(x, y) make_pair(x, y)

bool isP[MAX_P+10];

void createPrime ( int num )
{
	fill(isP, isP+MAX_P+10, true);
	isP[0] = isP[1] = false;
	for (int i = 2; i <= num; ++i) {
		if (!isP[i]) { continue; }
		for (int j = i+i; j <= num; j+=i) { isP[j] = false; }
	}
}

#define X first
#define Y second

int mnX, mnY, mxX, mxY;
int fd[MAX_WH][MAX_WH];
PII mat[MAX_P+10];

void createField ( void )
{
	int n = 1, power = 1;
	int x = MAX_WH/2, y = MAX_WH/2;
	bool turn = true;

	for (int i = 0; i < MAX_WH; ++i) {
		fill(fd[i], fd[i]+MAX_WH, -1);
	}
	mnX = mnY = MAX_WH;
	mxX = mxY = -1;
	fd[y][x] = 1;
	mat[1].X = x; mat[1].Y = y;
	while (n < 1000002) {
		if (turn) {
			for (int i = 0; i < power; ++i) {
				++x;
				fd[y][x] = ++n;
				mat[n].X = x; mat[n].Y = y;
			}
			for (int i = 0; i < power; ++i) {
				--y;
				fd[y][x] = ++n;
				mat[n].X = x; mat[n].Y = y;
			}
		}
		else {
			for (int i = 0; i < power; ++i) {
				--x;
				fd[y][x] = ++n;
				mat[n].X = x; mat[n].Y = y;
			}
			for (int i = 0; i < power; ++i) {
				++y;
				fd[y][x] = ++n;
				mat[n].X = x; mat[n].Y = y;
			}
		}
		++power;
		turn = !turn;
		mnX = min(mnX, x); mnY = min(mnY, y);
		mxX = max(mxX, x); mxY = max(mxY, y);
	}
	//cout << mnX << ' ' << mnY << endl;
	//cout << mxX << ' ' << mxY << endl;
}

int dx[] = { -1, 0, 1 };
int asn[MAX_WH][MAX_WH];
int asp[MAX_WH][MAX_WH];
bool visited[MAX_WH][MAX_WH];

void solve ( int m, int n )
{
	for (int i = 0; i < MAX_WH; ++i) {
		fill(asn[i], asn[i]+MAX_WH, 0);
		fill(asp[i], asp[i]+MAX_WH, 0);
		fill(visited[i], visited[i]+MAX_WH, false);
	}
	int ans_num = 0, ans_prime = 0;
	PII v = mat[n], g = mat[m];
	if (isP[fd[v.Y][v.X]]) {
		asn[v.Y][v.X] = ans_num = 1;
		asp[v.Y][v.X] = ans_prime = fd[v.Y][v.X];
	}
	visited[v.Y][v.X] = true;
	for (int y = v.Y+1; y <= mxY; ++y) {
		for (int x = mnX; x <= mxX; ++x) {
			if (-1 < fd[y][x] && fd[y][x] <= m) {
				for (int d = 0; d < 3; ++d) {
					int mx = x + dx[d];
					int my = y - 1;
					if (!visited[my][mx]) { continue; }
					visited[y][x] = true;
					if (isP[fd[y][x]]) {
						if (asn[y][x] < asn[my][mx] + 1) {
							asn[y][x] = asn[my][mx] + 1;
							asp[y][x] = fd[y][x];
						}
						if (asn[y][x] == asn[my][mx] + 1) {
							asp[y][x] = fd[y][x];
						}
					}
					else {
						if (asn[y][x] < asn[my][mx]) {
							asn[y][x] = asn[my][mx];
							asp[y][x] = asp[my][mx];
						}
						if (asn[y][x] == asn[my][mx]) {
							asp[y][x] = max(asp[y][x], asp[my][mx]);
						}
					}
				}
				if (visited[y][x]) {
					if (ans_num < asn[y][x]) {
						ans_num = asn[y][x];
						ans_prime = asp[y][x];
					}
					if (ans_num == asn[y][x]) {
						ans_prime = max(ans_prime, asp[y][x]);
					}
				}
			}
		}
	}
	cout << ans_num << ' ' << ans_prime << endl;
}

int main ( void )
{
	createPrime(MAX_P + 2);
	createField();

	int m, n;
	while (cin >> m >> n, m|n) {
		solve(m, n);
	}
	return 0;
}

Measured memory_bytes: 25312
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void) {
	char s[200001];
	int count = 0, max = 0 ,first_A = -1,last_Z = -1;

	scanf("%s", s);

	for (int i = 0; s[i] != '\0'; i++) {
      if(s[i] == 'A' && first_A < 0)first_A = i;
      if(s[i] == 'Z')last_Z = i;
	}
	printf("%d\n", last_Z - first_A + 1);
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
    cout << '+' << endl;
  } else if (a * b == 15) {
    cout << '*' << endl;
  } else {
    cout << 'x' << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  cout << setprecision(10);

  double r;
  cin >> r;
  double ans = 2.0 *  3.1415 * r;
  cout << ans << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;

int main(){
	cin >> N;

	vector<int> primes(1, 2);
	for(int n=3; n<100; n++){
		bool f = true;
		for(int i=0; i<primes.size(); i++){
			if(n%primes[i]==0){
				f=false;
				break;
			}
		}
		if(f) primes.push_back(n);
	}

	vector<int> n_primes(primes.size());
	for(int i=2; i<=N; i++){
		int n = i;
		int k = 0;
		while(n > 1){
			if(n % primes[k] == 0){
				n_primes[k] += 1;
				n /= primes[k];
			} else {
				k++;
			}
		}
	}

	//for(int i=0; i<n_primes.size(); i++) cout << primes[i] << " " << n_primes[i] << endl;

	map<int, int> cnt;
	for(int a: {2, 4, 14, 24, 74}){
		cnt[a] = 0;
		for(int i=0; i<n_primes.size(); i++){
			if(n_primes[i]>=a) cnt[a]++;
		}
	}

	int ans = 0;
	// 75
	ans += cnt[74];
	// 3*25
	ans += cnt[24]*max(0, cnt[2]-1);
	// 5*15
	ans += cnt[14]*max(0, cnt[4]-1);
	// 3*5*5
	ans += cnt[4]*(cnt[4]-1)/2*max(0, cnt[2]-2);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

int n;
const int NN=301;
vv<vv<vv<dd>>> memo(NN, vv<vv<dd>>(NN,vv<dd>(NN,-1)));
dd dp(ll a, ll b, ll c){
	if(!a && !b && !c) return 0;
	else if(memo[a][b][c]!=-1) return memo[a][b][c];
	dd& ret=memo[a][b][c];
	ret=0;
	if(a>0) ret+=a*(1+dp(a-1,b,c));
	if(b>0) ret+=b*(1+dp(a+1, b-1, c));
	if(c>0) ret+=c*(1+dp(a,b+1, c-1));
	ret+=n-a-b-c;
	ret/=a+b+c;
	return ret;
}
///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

cin>>n;
vi v(n); for(int i=0;i<n;++i) cin>>v[i];
vv<ll> ct(3,0); for(int i=0;i<n;++i) if(v[i]) ct[v[i]-1]++;
for(int i=0;i<3;++i) D(ct[i]);
cout<<dp(ct[0], ct[1], ct[2])<<el;

return 0;
}


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

int main(void){
  int a[3];
  for(int i = 0; i < 3; i++) cin >> a[i];
  sort(a, a + 3);
  if(a[2] == (a[0] + a[1])) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
list0=["000"]
list1=["100","010","001"]
list2=["110","101","011"]
list3=["111"]
if s in list0:
    print(0)
if s in list1:
    print(1)
if s in list2:
    print(2)
if s in list3:
    print(3)


Measured memory_bytes: 2940
from itertools import permutations
from math import sqrt

n = int(input())
towns = [tuple((map(int, input().split()))) for _ in range(n)]
path_length_list = []

for order in permutations(range(n), n):
    curX, curY = towns[order[0]]
    length = 0
    for o in range(1, n):
        nextTown = towns[order[o]]
        length += sqrt((nextTown[0] - curX) ** 2 + (nextTown[1] - curY) ** 2 )
        curX, curY = nextTown
    path_length_list.append(length)

ans = sum(path_length_list) / len(path_length_list)
print(ans)


Measured memory_bytes: 4400
#include <stdio.h>
int main(){
  int n, i, j, flag = 1, tmp, count = 0;
  int A[100];

  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
  }

  while(flag!=0){

    flag = 0;
    
    for(j = n ;1 < j ;j--){
      
      if(A[j] < A[j-1]){
	tmp = A[j];
	A[j] = A[j-1]; 
	A[j-1] = tmp;

	flag = 1;
	count++;
      }
      
    }
  }
  
  for(i=1;i<n;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 200500;
int n, m, in[N], out[N];

int main() {
    
	scanf("%d%d", &n, &m);

	for (int i = 1; i <= m; ++ i) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		if (x == 1) in[y] = 1;
		if (y == n) out[x] = 1;
	}

	int ans = 0;

	for (int i = 1; i <= n; ++ i) ans |= (in[i] & out[i]);
        
	puts(ans ? "POSSIBLE": "IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
long long s[N],p[N],f[N];
int n,A,B;
int main(){
	memset(f,23,sizeof(f));
	scanf("%d%d%d",&n,&A,&B),f[0]=0;
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		for(int j=0;j<=n;j++)
			if(j)	p[j]=min(p[j-1],f[j]);
			else	p[j]=f[j];
		for(int j=0;j<=x;j++)	f[j]+=A;
		for(int j=x+1;j<=n;j++)	f[j]+=B;
		f[x]=min(f[x],p[x]);
	}
	long long ans=f[n+1];
	for(int i=0;i<=n;i++)	ans=min(ans,f[i]);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def main():
    n = I()
    a = sorted([[F(),_] for _ in range(n)])
    r = [0] * n
    ct = collections.defaultdict(int)
    for f,i in a:
        ct[f] += 1
    m = -1
    mi = 0
    for ai in range(n):
        c,i = a[ai]
        if m < c:
            m = c
            mi = ai
        r[i] = mi*3 + ct[c] - 1
    return '\n'.join(map(str,r))


print(main())

Measured memory_bytes: 37700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,time=0;
  cin>>n>>q;
  queue<pair<string,int> > qsi;
  for(int i=0;i<n;i++){
    string str;
    int t;
    cin>>str>>t;
    qsi.push(make_pair(str,t));
  }
  pair<string,int> now;
  while(!qsi.empty()){
    now=qsi.front();
    qsi.pop();
    if(now.second<=q){
      time+=now.second;
      cout<<now.first<<" "<<time<<endl;
    }else if(now.second>q){
      time+=q;
      qsi.push(make_pair(now.first,(now.second-q)));
    }
  }
  return 0;
}

Measured memory_bytes: 6364
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *

H, W = MAP()
A = [input() for _ in range(H)]
cnt = [[-1]*W for _ in range(H)]
q = deque()

for y in range(H):
    for x in range(W):
        if A[y][x] == "#":
            cnt[y][x] = 0
            q.append((y, x))

dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]

while q:
    y, x = q.popleft()
    for i in range(4):
        ny = y + dy[i]
        nx = x + dx[i]
        if 0 <= ny < H and 0 <= nx < W and cnt[ny][nx] == -1:
            cnt[ny][nx] = cnt[y][x] + 1
            q.append((ny, nx))

ans = 0
for i in range(H):
    ans = max(ans, max(cnt[i]))
print(ans)

Measured memory_bytes: 120316
N , M = map ( int , input().strip().split(" ") ) ;
L0 = list ( map ( int , input().strip().split(" ") ) ) ;
L1 = [ 1 for x in range ( N ) ] ;

for x in range ( M ) :
	a , b  = map ( int , input().strip().split(" ") ) ;
	
	if  L0[a-1] > 0 and L0[a-1] <= L0[b-1] :
		L1[a-1] = 0 ;

	if  L0[b-1] > 0 and L0[b-1] <= L0[a-1] :
		L1[b-1] = 0 ;
print ( sum(L1 ) ) ;


Measured memory_bytes: 20044
# https://codeforces.com/blog/entry/78195: Geothermal editorial

n = int(input())
A, B = [], []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if n%2 == 1:
    medA, medB = A[n//2], B[n//2]
    
else:
    medA = A[n//2] + A[n//2 - 1]
    medB = B[n//2] + B[n//2 - 1]

print(medB - medA + 1)







Measured memory_bytes: 99000
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
m = 10000
for i,j in enumerate(h):
	b = t - j * 0.006
	if abs(b-a)< m:
		m = abs(b-a)
		ans = i+1
print (ans)

Measured memory_bytes: 3064
coin = [1, 5, 10, 50, 100, 500]
c = gets.split(' ')
for i in 0..c.size - 1
    c[i] = c[i].to_i
end
sum = 0
for i in 0..c.size - 1
    sum += c[i] * coin[i]
end
if sum >= 1000
    puts 1
else
    puts 0
end



Measured memory_bytes: 6856
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int y=sc.nextInt();
			int m=sc.nextInt();
			int d=sc.nextInt();
			int n=y*10000+m*100+d;
			if(n<=18680907){
				System.out.println("pre-meiji");
			}else if(n>=18680908&&n<=19120729){
				System.out.println("meiji "+(y-1867)+" "+m+" "+d);
			}else if(n>=19120730&&n<=19261224){
				System.out.println("taisho "+(y-1911)+" "+m+" "+d);
			}else if(n>=19261225&&n<=19890107){
				System.out.println("showa "+(y-1925)+" "+m+" "+d);
			}else{
				System.out.println("heisei "+(y-1988)+" "+m+" "+d);
			}
		}
	}
}

Measured memory_bytes: 15364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll ans=0;
    ll mi=1LL<<60;
    bool ok=false;
    int cnt=0;
    rep(i,n){
        ll a;
        cin>>a;
        ans+=abs(a);
        mi=min(mi,abs(a));
        if(a==0) ok=true;
        if(a<0) cnt++;
    }

    if(ok) cout<<ans<<endl;
    else if(cnt%2==0) cout<<ans<<endl;
    else cout<<ans-2*mi<<endl;
}


Measured memory_bytes: 3628
n = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
finish = []
ans = 0
for x in a:
    if x in finish:
        ans += 1
    else:
        try: d[x] += 1
        except: d[x] = 1
        if d[x] == x:
            finish.append(x)
            del d[x]
print(ans + sum(list(d.values())))

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int gcd( int a, int b ){
    if( a < b ) swap(a,b);
    int t;
    while( b ){
        t = b;
        b = a%b;
        a = t;
    }
    return a;
}

int main() {

    int N;
    Scd(N);

    vi a(N);
    Rep(i,N) Scd(a[i]);

    int ans = 2;
    char* anss[3] = { "not", "setwise", "pairwise" };
    vi ex(1e6+1);
    vi te;

    Rep(i,N){
        int ta = a[i];
        te.clear();
        for( int d = 2; d*d <= a[i]; d++ ){
            if( ta % d == 0 ){
                te.push_back(d);
                ta /= d;
                d--;
            }
        }
        if( ta != 1 ) te.push_back(ta);
        for( int d : te ){
            if( ex[d] ){
                ans = 1;
            }
        }
        for( int d : te ){
            ex[d] = 1;
        }
        if( ans != 2 ) break;
    }

    int gg = 0;
    Rep(i,N) {
        gg = gcd(gg, a[i]);
    }
    if( gg != 1 ) ans = 0;

    printf ("%s coprime\n", anss[ans] );


    return 0;
}




Measured memory_bytes: 11172
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    if(d == 0){
        if(n == 100) cout << 101 << endl;
        else cout << n << endl;
    }else if(d == 1){
        // int ans = 0;
        // for(int i = 1; i <= n*n; i++){
        //     if(100*i % 100*100 != 0)ans++;
        //     if(ans == n) cout << ans << endl;
        // }
        if(n == 100) cout << 10100 << endl;
        else cout << n*100 << endl;
    }else{
        // int ans = 0;
        // for(int i = 1; i <= n*n; i++){
        //     if(10000*i % 10000*100 != 0)
        // }
        if(n == 100) cout << 100*100*100+100*100 << endl;
        else cout << n*10000 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
	int a, b;
  cin >> a >> b;
  int sum = a + b;
  int dif = a - b;
  int pro = a*b;
  
  int ans  = max(max(sum,dif),pro);
  cout << ans << endl;
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	LL h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	// keisan
	for(int i=1;i<n;i++){
		if(h[i] > h[i-1]){
			h[i] = h[i] -1;
		}
	}
	// syutsuryoku
	for(int i=0;i<n-1;i++){
		if(h[i] > h[i+1]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 4324
N,x=map(int,input().split())
A=list(map(int,input().split()))

ans=0

if A[0]>x:
    ans += A[0]-x
    A[0]=x

for i in range(1,N):
    if A[i-1]+A[i] > x:
        ans += A[i-1]+A[i]-x
        A[i] -= A[i-1]+A[i]-x
print(ans)

Measured memory_bytes: 14252
import collections

n = int(input())
s = [input() for _ in range(n)]

num = collections.Counter(s)
print("AC x {}".format(num["AC"]))
print("WA x {}".format(num["WA"]))
print("TLE x {}".format(num["TLE"]))
print("RE x {}".format(num["RE"]))

Measured memory_bytes: 16636
n = gets.to_i
ws = gets.split.map(&:to_i)

overall = ws.inject(:+)
ans = overall

s1 = 0
ws.each do |w|
  s1 += w
  s2 = overall - s1
  abs = (s1 - s2).abs

  ans = abs if abs <= ans
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>

int Fib(int);
int fib[44];

int main(void){
  int n;
  scanf("%d",&n);
  printf("%d\n",Fib(n));
  return 0;
}

int Fib(int n){
  int i;

  fib[0]=1;
  fib[1]=1;

  for(i=2;i<=n;i++)
    fib[i]=fib[i-1]+fib[i-2];

  return fib[n];
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll f,a,b;
vector<vector<ll>> dp(10000005);
set<ll> g;
void dfs(ll i,ll p,vector<vector<p2>> &v){
    if(i==b){
        f=1;
        return;
    }
    for(ll j=0;j<v[i].size();j++)
    if(v[i][j].first!=p){
        dfs(v[i][j].first,i,v);
        if(f==1){
            g.insert(v[i][j].second);
            return;
        }
    }
}
void func(vector<ll> &jok,vector<ll> &v){
    set<ll> s=g;
    for(ll i=0;i<jok.size();i++)
    s.insert(jok[i]);
    for(auto it=s.begin();it!=s.end();it++)
    v.push_back(*it);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,cnt=1,res=0;
    cin>>n;
    vector<vector<p2>> v(n+1);
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        v[a].push_back({b,cnt});
        v[b].push_back({a,cnt});
        cnt++;
    }
    cin>>m;
    for(ll qc=0;qc<m;qc++){
        cin>>a>>b;
        f=0;
        g.clear();
        dfs(a,0,v);
        ll p=pow(2,qc);
        for(ll bit=0;bit<pow(2,qc);bit++)
        func(dp[bit],dp[bit+p]);
    }
    for(ll i=0;i<pow(2,m);i++){
        ll k=i,cnt=0,x=dp[i].size();
        while(k>0){
            if(k&1)
            cnt++;
            k/=2;
        }
        if(cnt%2)
        res-=pow(2,n-x-1);
        else
        res+=pow(2,n-x-1);
    }
    cout<<res;
} 


Measured memory_bytes: 774656
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
ll n,k;
cin>>n>>k;
ll a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int y=0;
for(int i=k;i<n;i++)
{
    if(a[i-k]<a[i])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}
	return 0;
}


Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <climits>
#include <cstring>
#include <cstdio>

using namespace std;
typedef long long int llg;

const int INF = 1000001000;
#define REP(var, count) for(int var=0; var<count; var++)

template <typename T>
using reverse_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

vector<int> rin[105];
pair<int, int> res[105];

int dfs(int a, int time) {
	res[a].first = time;
	for ( int r : rin[a] ) {
		if ( res[r].first != -1 ) { continue; }
		time = dfs(r, time + 1);
	}
	res[a].second = time + 1;
	return res[a].second;
}

int main(void) {
	int N;
	cin >> N;
	
	for(int i=1; i<=N; i++) {
		rin[0].push_back(i);
	
		res[i].first = -1;
		res[i].second = -1;
		
		int U, K;
		cin >> U >> K;
		REP(j, K) {
			int x;
			cin >> x;
			rin[U].push_back(x);
		}
	}
	
	dfs(0, 0);
	
	for(int i=1; i<=N; i++) {
		printf("%d %d %d\n", i, res[i].first, res[i].second);
	}
}

Measured memory_bytes: 3248
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;
 

void solveCase() {
   int n;
   string s, t;
   cin >> n >> s >> t;
   if(s.length() + t.length() <= n) {
      cout << s.length() + t.length() << endl;
      return;
   }

   // [0....l1-1]
   int l1 = s.length();
   int l2 = t.length();
   int ans = l1 + l2;
   for(int l = l1 + l2 - 1; l >= max(l1, l2); l--) {
      string tmp = s.substr(0, l - l2);
      tmp = tmp + t;
      if(tmp.substr(0, l1) == s) {
         ans = min(ans, l);
      }
   }
   cout << ans << endl;
}

 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int x, y;
    cin >> x >> y;

    rep(i2, x + 1)
    {
        int i4 = x - i2;

        int leg = 2 * i2 + 4 * i4;
        if (leg == y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int, int> pii;
 
#define PB push_back
#define MP make_pair
 
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int __sv;scanf("%d", &(__sv));vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL
 
int n, a[200014], res[200014];
vector<int> g[200014];
multiset<int> s;
 
void go (int x, int p)
{
  s.insert(a[x]);
  auto it = s.lower_bound(a[x]);
  ++it;
  int erased = -1;
  if (it != s.end()) 
  {
    erased = *it;
    s.erase(it);
  }
  res[x] = s.size();
  //handle neighbors
  for (auto y : g[x]) if (y != p) go(y, x);
  //remove lis stuff
  if (erased != -1) s.insert(erased);
  s.erase(s.find(a[x]));
}
 
int main ()
{
  R1(n);
  FOR(i, 0, n) R1(a[i]);
  FOR(i, 0, n - 1)
  {
    int from, to;
    R2(from, to);--from;--to;
    g[from].PB(to);
    g[to].PB(from);
  }
  go(0, -1);
  FOR(i, 0, n) printf("%d\n", res[i]);
  return 0;
}

Measured memory_bytes: 33532
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
            cin >> S;
                if(S.at(5) == '1'){
                    cout << "TBD" << endl;
                }else if(S.at(6) >= '5'){
                    cout << "TBD" << endl;
                }else if(S.at(5) <= '4'){
                    cout << "Heisei" << endl;
                }

    return 0;}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		int[] a = new int[N];
		Arrays.setAll(a, i -> sc.nextInt());
		int x = 0;
		int[][] ans = new int[H][W];
		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++) {
				if(a[x] <= 0)
					x++;
				ans[i][j] = x + 1;
				a[x]--;
			}
		for(int i = 0; i < H; i++) {
			if(i % 2 == 0)
				for(int j = 0; j < W; j++)
					System.out.print(ans[i][j] + " ");
			else
				for(int j = W-1; j >= 0; j--)
					System.out.print(ans[i][j] + " ");
			System.out.println();
		}
	}

}


Measured memory_bytes: 35448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);
#define INF 0x3f3f3f3f3f

int main() {

    fastio;

    ll n,k;
    vector<ll> height(100005);
    vector<ll> dp(100005);

    cin >> n >> k;
    for(ll i = 0; i < n; i++) cin >> height[i];

    //OPTIMAL SUBPROBLEM :

    // dp[i] = total minimum penalty incurred after jumping to the ith stone

    // BASE CASE :

    dp[0] = 0;
    for(ll i = 1; i < n; i++) dp[i] = INF;
    for(ll i = 1; i < k; i++){
        for(ll j = i-1; j >= 0; j--){
            dp[i] = min(dp[i] , dp[j] + abs(height[j] - height[i]));
        }
    }

    // RECURSIVE RELATION :

    for(ll i = k; i < n; i++){
        for(ll j = i-1; j >= i - k; j--){
            dp[i] = min(dp[j] + abs(height[i] - height[j]) , dp[i]);
        }
    }

    //OPTIMAL SOLUTION :

    cout << dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int X = N;
  int sum_digit= 0;
  while(X>0){
    sum_digit += X%10;
    X /= 10;
  }
  
  if( N%sum_digit==0 ){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    rng(i,1,10){
        if(n % i == 0){
            if(n/i < 10){
                yes();
                return 0;
            }
        }
    }
    no();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c = tolower(s[k -1]);
  s[k -1] = c;
  
  cout << s << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    b = [int(i) for i in input().split()]

    sum = 0
    now = 0
    bf = 0
    for i in range(n):
        if i ==0:
            sum = sum + b[i]
        if i == n -1:
            sum = sum + b[i-1]
        else:
            if bf > b[i]:
                sum = sum +b[i]
            else:
                sum = sum +bf
            bf = b[i]
    print(sum)


Measured memory_bytes: 3060
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);

        return a <= b ? "Yes" : "No";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 11092
A, B = (int(x) for x in input().split())

S = A
num  = 1
i = 1

if (B == 1):
    print("0")
elif (A >= B):
    print("1")
else:
    while(S < B):
        S = (A * (i + 1)) - i
        num += 1
        i += 1
    print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int gcd(int a, int b, int c) {
  int m, n;
  while (b!=0) {
    m=a%b;
    a=b;
    b=m;
  }
  m=a;
  
  while (c!=0) {
    n=m%c;
    m=c;
    c=n;
  }
  n=m;
  return n;
}


int main() {
  int K, S=0;
  cin >> K;
  for (int i=1; i<=K; i++) {
    for (int j=1; j<=K; j++) {
      for (int k=1; k<=K; k++) {
        S+=gcd(i,j,k);
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3620