akhauriyash/Code-Regression huggingface dataset:
N,T =  map(int, input().split())
distArray = [[]]
for num in range(0,N):   
    c,t =  map(int, input().split())
    if t<=T:
        distArray.append([c,t])

if len(distArray)>1:
    tmp=distArray[1][0]
    for num in range(2,len(distArray)):     
        
        if distArray[num][0]<tmp:   
            tmp=distArray[num][0]       

    print(tmp)
else:        
    print("TLE")


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

int main() {
	int n,odd=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a%2==1){
			odd++;
		}
	}
	if(odd%2==1){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 1000;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
int SUM = 0;
array<array<int, SZ>, D> S;

struct State {
	array<int, SZ> last = {};
	array<int, D> ans;
	int score = 0, sum = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		sum -= C[t] * (d + 1 - last[t]);
		last[t] = d + 1;
		sum += SUM;
		score -= sum;
	}

	int next_eval(int d, int t){
		int res = score;
		res += S[d][t];
		rep(i, SZ){
			if (i != t) res -= C[i] * (d + 1 - last[i]);
		}
		return res;
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.update_score(d, t);
		return res;
	}

	array<int, D> answer() {
		return ans;
	}
};

array<int, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.next_eval(d, t) > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, SZ) SUM += C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (int i : ans) cout << i + 1 << endl;

	return 0;
}


Measured memory_bytes: 6828
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
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); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> a(m);
    vector<int> b(m);
    rep(i, m) cin >> a[i] >> b[i];

    vector<int> h1(n);
    h1 = h;

    rep(i, m)
    {
        if (h[a[i] - 1] == h[b[i] - 1])
        {
            h1[a[i] - 1] = 0;
            h1[b[i] - 1] = 0;
        }
        else if (h[a[i] - 1] < h[b[i] - 1])
        {
            h1[a[i] - 1] = 0;
        }
        else
        {
            h1[b[i] - 1] = 0;
        }
    }

    h1.erase(std::remove(h1.begin(), h1.end(), 0), h1.end());

    cout << h1.size() << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
ll bucket[5]={0};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int p[10]={0,0,0,0,0,0,1,1,1,2};
  int q[10]={1,1,1,2,2,3,2,2,3,3};
  int r[10]={2,3,4,3,4,4,3,4,4,4};
  for(int i = 0; i < n; ++i) {
    string s; cin >> s;
    if(s[0] == 'M') bucket[0]++;
    else if(s[0] == 'A') bucket[1]++;
    else if(s[0] == 'R') bucket[2]++;
    else if(s[0] == 'C') bucket[3]++;
    else if(s[0] == 'H') bucket[4]++;
  }
  ll ans = 0;
  for(int d = 0; d < 10; ++d) {
    ans += bucket[p[d]]*bucket[q[d]]*bucket[r[d]];
  }
  cout << ans << endl;


  return 0;
}

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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define Pb push_back
#define mk make_pair
#define MAX 100010
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef unsigned long long int ull;
int w[110], v[110], N, W;
ll pd[110][MAX];

ll knapsack() {
	REP(i, 1, N)
		REP(j, i, W)
			if(w[i] <= j)
				pd[i][j] = max(pd[i-1][j], pd[i-1][j-w[i]] + v[i]);
			else pd[i][j] = pd[i-1][j];
	return pd[N][W];
}

int main(int argc, char** argv) {
	scanf("%d%d", &N, &W);
	REP(i, 1, N) scanf("%d%d", &w[i], &v[i]);
	printf("%lld\n", knapsack());
	return 0;
}


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


const ll MOD = 1e9 + 7;
template<ll MOD> struct ModInt {
    ll value;
    ModInt() : value(0) {}
    ModInt(const ll& v) : value(v % MOD) {
        if ( value < 0 ) value += MOD;
    }
    ModInt<MOD>& operator=(const ModInt& o) {
        value = o.value;
        return *this;
    }
    inline bool operator==(const ModInt& o) {
        return value == o.value;
    }
    inline bool operator!=(const ModInt& o) {
        return value != o.value;
    }
    ModInt<MOD>& operator+=(const ModInt& o) {
        value += o.value;
        if ( value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator-=(const ModInt& o) {
        value += MOD - o.value;
        if (value >= MOD ) value -= MOD;
        return *this;
    }
    ModInt<MOD>& operator*=(const ModInt& o) {
        value *= o.value;
        value %= MOD;
        return *this;
    }
    ModInt<MOD>& operator/=(const ModInt& o) {
        value *= inverse(o.value);
        value %= MOD;
        return *this;
    }
    ModInt<MOD> operator-() {
        return ModInt<MOD>(-value);
    }
    ModInt<MOD> operator+(const ModInt& o) {
        ModInt<MOD> r(*this);
        r += o;
        return r;
    }
    ModInt<MOD> operator-(const ModInt& o) {
        ModInt<MOD> r(*this);
        r -= o;
        return r;
    }
    ModInt<MOD> operator*(const ModInt& o) {
        ModInt<MOD> r(*this);
        r *= o;
        return r;
    }
    ModInt<MOD> operator/(const ModInt& o) {
        ModInt<MOD> r(*this);
        r /= o;
        return r;
    }
    ModInt<MOD> pow(ll n) {
        ModInt<MOD> t(*this), r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) r *= t;
            t *= t;
            n >>= 1;
        }
        return r;
    }
private:
    ll inverse(ll a) {
        ModInt<MOD> t(a);
        return t.pow(MOD - 2).value;
    }
};
template<ll MOD> std::ostream& operator<< (std::ostream& os, const ModInt<MOD>& o) {
    os << o.value;
    return os;
}
template<ll MOD> std::istream& operator>> (std::istream& is, ModInt<MOD>& o) {
    is >> o.value;
    return is;
}

using Int = ModInt<MOD>;

ll solve() {
    ll N, x, y;
    cin >> N;
    vector<vector<ll>> G(N);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    vector<Int> dpw(N), dpb(N);

    vector<int> pa(N,-1);
    vector<int> depth(N,-1);
    function<void(int,int)> dfs = [&](int v, int p) {
        dpw[v] = 1;
        dpb[v] = 1;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            dfs(u, v);
            dpb[v] *= dpw[u];
            dpw[v] *= dpw[u] + dpb[u];
        }
    };
    dfs(0,-1);
    Int ans = dpw[0] + dpb[0];
    return ans.value;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 16384
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();	
	        long ans=0;
	        long m=2;
	        while(m<N) {
	        	long Q = N/m;
	        	long R = N%m;
	        	if(R!=0&&R%Q==0) {
	        		ans=ans+m+R/Q-1;
	        	}
	        	m=m+R/Q+1;
	        }
	        
	        
	    	System.out.println(ans);
	    	
	        		
	    }
	    

	}

Measured memory_bytes: 23508
T = int(input())

def floor_sum(n, m, a, b):
    res = 0
    while True:
        if a >= m:
            res += (n-1)*n*(a//m)//2
            a %= m
        if b >= m:
            res += n*(b//m)
            b %= m
 
        yMax = (a*n+b) // m
        xMax = yMax*m - b
        if yMax == 0:
            break
        res += (n-(xMax+a-1)//a) * yMax
        n, m, a, b = yMax, a, m, (-xMax)%a
    return res

ans = []
for _ in range(T):
    N, M, A, B = map(int, input().split())
    ans.append(floor_sum(N, M, A, B))

print(*ans, sep='\n')

Measured memory_bytes: 13836
using System;
using System.IO;

namespace CA {
	class Prg {
		static void Main() {
			using(StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }){
				int i = 1, x;
				int n = int.Parse(Console.ReadLine());
				while (++i <= n) {
					x = i;
					if (x % 3 == 0 || x % 10 == 3) {
						sw.Write(" " + i);
						continue;
					}
					while (true) {
						x /= 10;
						if (x != 0) {
							if (x % 10 == 3) {
								sw.Write(" " + i);
								break;
							}
						} else break;
					}
				}
				sw.WriteLine();
			}
        }
	}
}

Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long>;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    ll n; cin >> n;
    vll x(n);
    rep(i, n) cin >> x[i];

    ll ans = 1;
    rep(i, n) ans = lcm(ans, x[i]);

    cout << ans << endl;
    return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,l; cin>>n>>l;
	vector<string> s(n);
	for (int i=0; i<n; i++) cin>>s[i];
	sort(s.begin(),s.end());
	for (auto x : s)
		cout << x;
	cout << endl;
	return 0;
}


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

using namespace std;
const int maxn = 2e5 + 10;
int Next[maxn][30], now[30], now_tot[maxn];
char s[maxn];
set<int>S;
vector<int>ans;
int main()
{
    ios::sync_with_stdio(false);
cin >> s+1;
        ans.clear();
        int len = strlen(s+1);
        int tot = 0;

        S.clear();
        for(int i = len; i >= 1; i--)
        {
            now_tot[i] = tot;
            S.insert(s[i]-'a');
            if(S.size() == 26)
            {
                tot++;
                S.clear();
            }
        }
        if(tot == 0)
        {
            for(int i = 0; i < 26; i++)
            {
                if(S.count(i) == 0)
                {
                    ans.push_back(i+'a');
                    break;
                }
            }
        }
        else
        {
            for(int i = len; i>= 1; i--)
            {
                for(int  j = 0; j < 26; j++)
                {
                    Next[i][j] = now[j];
                }
                now[s[i]-'a'] = i;
            }
            int tmp = 0;
            for(int i = 0; i < 26; i++)
            {
                if(S.count(i) == 0)
                {
                    tmp = now[i];
                    ans.push_back(s[tmp]);
                    break;
                }
            }
            for(int i = 1; i < tot; i++)
            {
                for(int j = 0; j < 26; j++)
                {
                    if(now_tot[Next[tmp][j]] == now_tot[tmp]-1)
                    {
                        tmp = Next[tmp][j];
                        ans.push_back(s[tmp]);
                        break;
                    }
                }
            }
            for(int i = 0; i < 26; i++)
            {
                if(Next[tmp][i] == 0)
                {
                    ans.push_back(i+'a');
                    break;
                }
            }
        }
        for(int i = 0; i < ans.size(); i++)
        {
            cout << char(ans[i]);
        }
        cout << endl;
    return 0;
}


Measured memory_bytes: 24704
import sys
sys.setrecursionlimit(10**7)
INF=10**18

def main():
    N,Z,W=map(int,input().split())
    a=list(map(int,input().split()))
    dic={}
    def rec(z,w,now,t):
        if dic.get((now,t),None)!=None:
            return dic[(now,t)]
        if now>=N-1:
            return abs(z-w)
        if not t:
            res=-INF
            for i in range(now+1,N):
                r=rec(a[i],w,i,1)
                res=max(res,r)
        else:
            res=INF
            for i in range(now+1,N):
                r=rec(z,a[i],i,0)
                res=min(res,r)
        dic[(now,t)]=res
        return res

    return rec(Z,W,-1,0)
    
print(main())

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

string a, b;

int main()
{
    cin >> a >> b;
    int n1 = a.length();
    int n2 = b.length();
    if(n1 + 1 != n2) 
    {
        puts("No");
        return 0;
    }
    for(int i=0; i<n1; i++)
    {
        if(a[i] != b[i]) 
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

int main()
{
    long long n;
    cin>>n;
    int i,j=n,c=0;
    while(1)
    {

        for(i=2; i<=sqrt(j); i++)
        {
            if(j%i==0)
            {
                c=1;
                break;
            }
        }
        if(c==1)
        {
            j++;
            c=0;
            //cout<<"not prime\n";
        }
        else
        {
            cout<<j<<endl;
            //cout<<"Prime\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x;
	int odd, gusu;
	cin >> x;
	if (x % 2 == 1) {
		odd = (x + 1) / 2;
		gusu = (x - 1) / 2;

	}
	else {
		odd = x / 2;
		gusu = x / 2;
	}
	cout << odd * gusu << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    double A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;
    if( abs(B-A)<=(V-W)*T){
        cout<<"YES"<<endl;
        return 0;
    }
    cout<<"NO"<<endl;
    return 0;
    
  
}


Measured memory_bytes: 3724
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,k;
  cin >> n >> k;
  int cur = 1;
  for(int i=0;;i++){
    if(cur>n){
      cout << i << endl;
      return 0;
    }
    else {
      cur*=k;
    }
  }
  


return 0;
}
///....


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  
  int k=0;
  
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      k++;
      cout << "NO" << endl;
      break;
    }
  }
  
  if(k==0)
    cout << "YES" << endl;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 3000 + 10;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
ll dp[maxn][maxn];
int a[maxn];
const ll mod=998244353;
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    int n = readint();
    int s = readint();
    repd(i, 1, n)
    {
        a[i] = readint();
    }
    dp[0][0] = 1;
    repd(i, 1, n)
    {
        repd(j, a[i], s)
        {
            dp[i][j] += dp[i - 1][j - a[i]];
            dp[i][j] %= mod;
        }
        repd(j, 0, s)
        {
            dp[i][j] += dp[i - 1][j] * 2;
            dp[i][j] %= mod;
        }
    }
    printf("%lld\n", dp[n][s] );
    return 0;
}




Measured memory_bytes: 74328
evenNumber = []
judg = []
n = int(input())
immigration = list(map(int, input().split()))

for i in immigration:
    if i % 2 == 0:
        evenNumber.append(i)
        
for i in evenNumber:
    judg.append(i % 3 == 0 or i % 5 == 0)

if False in judg:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3064
import collections

n = int(input())
a = [int(input()) for i in range(n)]
m = sorted(list(set(a)))
c =collections.Counter(a)

t = [max(a)]*n

if c[max(a)] == 1:
    t[a.index(max(a))] = m[-2]

[print(i) for i in t]


Measured memory_bytes: 28268
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N = ni()
A = na()
minas=0
tmp=10**9
for i in range(N):
    tmp = min(tmp,abs(A[i]))
    if(A[i]<0):
        minas +=1
        A[i]=-A[i]

#負の数が奇数個
if(minas%2==1):
    #print(tmp)
    print(sum(A)-2*tmp)
else:
    print(sum(A))


Measured memory_bytes: 15020
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using L = long long;

#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define REP(i, n) FOR(i, 0, n - 1)
constexpr int inf = 0x3f3f3f3f;
template<class T> int size(T &x) {
	return int(x.size());
}

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

	string s, t;
	cin >> s >> t;
	int n = size(s), m = size(t);
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	FOR(x, 1, n)
		FOR(y, 1, m)
			if(s[x - 1] == t[y - 1])
				dp[x][y] = dp[x - 1][y - 1] + 1;
			else
				dp[x][y] = max(dp[x - 1][y], dp[x][y - 1]);

	int x = n, y = m;
	string out;
	while(x != 0 && y != 0)
		if(s[x - 1] == t[y - 1])
			out += s[--x], --y;
		else if(dp[x - 1][y] > dp[x][y - 1])
			x--;
		else
			y--;
	for(int i = size(out) - 1; i >= 0; --i)
		cout << out[i];
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vi>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define inf             1e18
#define deb(x)          cout << #x << "=" << x << '\n';
#define ps(x,y)         fixed<<setprecision(y)<<x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void solve() {

    int n;
    cin >> n;
    vi h(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }

    vi dp(n+1);

    dp[n] = 0;
    dp[n-1] = abs(h[n-1]-h[n]);

    for(int i = n-2; i>=1; i--) {
        dp[i] = min(dp[i+1]+abs(h[i]-h[i+1]), dp[i+2]+abs(h[i]-h[i+2]));
    }

    cout <<  dp[1] << '\n';
}

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


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

int main(){
  string str;
  int sum;

  cin >> str;

  while(str != "0"){
  	sum = 0;
  	for (int i = 0; i < str.length(); i++){
  		sum += str[i] - '0';
  	}

  	cout << sum << endl;
  	cin >> str;
  }

}


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX<<2];
int h[MAX],cnt=1;
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;}
bool fl;int sum;
int dep[MAX];bool vis[MAX];
int n,m;ll ans;
void dfs(int u,int ff)
{
	vis[u]=true;++sum;
	for(int i=h[u];i;i=e[i].next)
		if(vis[e[i].v]&&e[i].v!=ff)fl|=dep[u]==dep[e[i].v];
		else if(!vis[e[i].v])dep[e[i].v]=dep[u]^1,dfs(e[i].v,u);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int u=read(),v=read();
		Add(u,v);Add(v,u);
	}
	int node=0,t1=0,t2=0;
	for(int i=1;i<=n;++i)
	{
		if(vis[i])continue;
		fl=false;sum=0;dfs(i,0);
		if(sum==1)ans+=n*2-1,++node;
		else if(!fl)ans+=2,++t1;
		else ++ans,++t2;
	}
	ans-=1ll*(node-1)*node;
	ans+=1ll*t1*(t1-1)*2+1ll*t2*(t2-1)+1ll*t1*t2*2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll n,a,b,sum,set,over;
cin >> n >> a >> b;

sum = a + b;
set = n / sum;
over = n % sum;
if(over <= a) cout << set*a + over << endl;
else cout << set*a + a << endl;




//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
const ll N = (1 << 16);
ll dp[N];
ll p[N];

void func(ll pos , vector<ll>v , ll mask , ll group , ll points)
{
    if(pos == (ll)v.size())
    {
        dp[mask] = max(dp[mask] , points+p[group]);
        return;
    }

    func(pos+1 , v , mask , group , points);
    func(pos+1 , v , (mask^(1 << v[pos])) , (group^(1 << v[pos])) , points);
}


int main() {
   ll n;
   cin >> n;
   ll g[n][n];
   for(ll i = 0 ; i < n ; i++)
   {
       for(ll j = 0 ; j < n ; j++)
       cin >> g[i][j];
   }

   for(ll mask =0 ; mask < (1 << n) ; mask++)
   {
       for(ll i =0 ; i < n ; i++)
       {
           if((mask&(1 << i)))
           {
               for(ll j = i+1 ; j < n ; j++)
               {
                    if((mask&(1 << j)))
                    {
                        p[mask] += g[i][j];
                    }    
               }
           }
       }
   }



   for(ll mask = 0 ; mask < (1 << n) ; mask++)
   {
       vector<ll>v;
       for(ll i = 0 ; i < n ; i++)
       {
           if(!(mask & (1 << i)))
            v.push_back(i);
       }
       func(0 , v , mask , 0 , dp[mask]);
   }

   cout << dp[(1 << n)-1];  
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
const int inf = 1e9+7;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> x(n+1), y(n+1);
	vector<pair<int,int> > xy(n+1);
	for(int i=0; i<n; i++){
		cin >> x[i] >> y[i];
		xy[i] = make_pair(x[i],y[i]);
	}
	x[n]=inf; y[n]=inf;
	xy[n]=make_pair(inf,inf);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	sort(xy.begin(), xy.end());
	
	vector<pair<int, int> > nx, ny;
	for(int i=0; i<n+1; i++){
		nx.push_back(make_pair(x[i], 1));
		for(int j=i+1; j<n+1; j++){
			if(x[i]==x[j]){
				nx.back().second++;
			}else{
				i=j-1;
				break;
			}
		}
	}
	for(int i=0; i<n+1; i++){
		ny.push_back(make_pair(y[i], 1));
		for(int j=i+1; j<n+1; j++){
			if(y[i]==y[j]){
				ny.back().second++;
			}else{
				i=j-1;
				break;
			}
		}
	}
	
	vector<vector<int> > lsum(nx.size(), vector<int>(ny.size()));
	int pidx = 0;
	int remain = n+1;
	for(int i=0; i<(int)nx.size(); i++){
		lsum[i][0] = remain;
		for(int j=1; j<(int)ny.size(); j++){
			lsum[i][j] = lsum[i][j-1] -ny[j-1].second;
		}
		while(xy[pidx].first == nx[i].first){
			remain--;
			vector<pair<int,int> >::iterator it;
			it = lower_bound(ny.begin(), ny.end(), make_pair(xy[pidx].second, 0));
			it->second--;
			pidx++;
		}
	}
	
	for(int i=0; i<m; i++){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		vector<pair<int, int> >:: iterator it;
		it = lower_bound(nx.begin(), nx.end(), make_pair(x1, 0));
		x1 = it-nx.begin();
		it = lower_bound(nx.begin(), nx.end(), make_pair(x2+1, 0));
		x2 = it-nx.begin();
		it = lower_bound(ny.begin(), ny.end(), make_pair(y1, 0));
		y1 = it-ny.begin();
		it = lower_bound(ny.begin(), ny.end(), make_pair(y2+1, 0));
		y2 = it-ny.begin();
		cout << lsum[x1][y1] -lsum[x2][y1] -lsum[x1][y2] +lsum[x2][y2] << endl;
	}

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const intll INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ;
  cin >> s ;
  int now = 0 ;
  
  rep(i,s.size()){
    if(s.at(i) == 'x') now ++ ;
  }
  
  if(now <= 7) cout << "YES" ;
  else         cout << "NO" ;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 long double a,b;
	
	cin>>a>>b;
	if(a>0&&b>0)
	{
	if(a>b)
	printf("GREATER");
	else if(a<b)
	printf("LESS");
	else
	printf("EQUAL");
   }


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string s,t;cin >> s >> t;
    int a = s.size(),b = t.size(),i,j,dp[a+1][b+1] = {};
    for(i=1;i<=a;i++) dp[i][0] = i;
    for(i=1;i<=b;i++) dp[0][i] = i;
    for(i=1;i<=a;i++){
        for(j=1;j<=b;j++){
            if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1];
            else dp[i][j] = min({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]})+1;
        }
    }
    cout << dp[a][b] << endl;
}


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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int p[n];
      int j[n-1];
      long long int sum=0;
      for(int i=0;i<n;i++)
	{
	  cin>>p[i];
	  sum+=p[i];
	}
      for(int i=0;i<n-1;i++)
	cin>>j[i];
      sort(j,j+n-1);
      long long int ans=sum*n;

      for(int i=n-2;i>=0;i--)
	{
	  sum+=j[i];
	  n--;
	  ans=max(ans,sum*n);
	}
      cout<<ans<<endl;

    }

}

Measured memory_bytes: 1684
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {

	string s;
	ll K;
	cin >> s >> K;
	string x;
	
	ll size = s.size();
	int cnt = 0;
	for (int i = 0; i < size; ++i) {
		if (s[0] == s[i]) cnt++;
	}
	if (cnt == size) {
		cout << size * K / 2 << endl;
		return 0;
	}

	cnt = 0;
	ll k = 1;
	ll ans = 0;
	for (int i = 1; i < size; ++i) {
		if (s[i] == s[i - 1]) {
			++k;
		}
		else {
			cnt += (k / 2);
			k = 1;
		}
	}
	cnt += (k / 2);
	ans = cnt * K;
	if (s[0] != s.back()) {
		cout << ans << endl;
		return 0;
	}

	else {
		int a = 1, b = 1;
		for (int i = 1; i < size; ++i) {
			if (s[i] == s[i - 1]) {
				a++;
			}
			else {
				break;
			}
		}
		for (int i = size - 1; i >= 0; --i) {
			if (s[i] == s[i - 1]) {
				b++;
			}
			else break;
		}
		ans = ans - ( (a/2) + (b/2) - ((a+b) / 2) ) * (K - 1);
		cout << ans << 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();
      if(H>W){
        if(N%H==0){
          System.out.println(N/H);
        }else{
        	System.out.println(N/H+1);       
        }
      }else{
                if(N%W==0){
          System.out.println(N/W);
        }else{
        	System.out.println(N/W+1);       
        }
      }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 4;
const ll MOD = 998244353;
bool visited[N];
vector<int> edge[N];
vector<int> conc[N];
int c = 0, f = 1;

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % MOD;
        exponent = exponent >> 1;
        base = (base * base) % MOD;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void DFS(int src){
    visited[src] = 1;
    conc[c].pb(src);
    for(auto i : edge[src]){
        if(!visited[i]) DFS(i);
    }
}

int main(){
    int n;
    cin>>n;
    ll a[n + 1], l[N], r[N];
    memset(l, 0, sizeof(l));
    memset(r, 0, sizeof(r));
    rep(i, 1, n + 1){
        cin>>a[i];
        if(i + a[i] < N) l[i + a[i]]++;
        if(i - a[i] > 0) r[i - a[i]]++; 
    }
     ll ans = 0;
    rep(i, 1, N){
        ans += l[i] * r[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 17648
def resolve():
    n = int(input())
    a = list(map(int,input().split()))
    x = [0]*n
    b = set()

    for j in range(n):
        i = n - j -1
        if sum(x[i::i+1])%2 != a[i]:
            x[i] = 1
            b.add(i+1)
    cnt = len(b)

    if cnt == 0:
        print(0)
    else:
        print(cnt)
        print(*b)


resolve()


Measured memory_bytes: 17204
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main(){
    int n, c; cin >> n >> c;
    vector<vector<int>> D(c, vector<int>(c));
    rep(i, c){
        rep(j, c){
            cin >> D[i][j];
        }
    }
    vector<vector<int>> grid(n, vector<int>(n));
    rep(i, n){
        rep(j, n){
            cin >> grid[i][j];
        }
    }
    vector<int> X(c+1), Y(c+1), Z(c+1); //余り0, 1, 2の順
    for(int i=0; i<3; i++){
        for(int j=1; j<=c; j++){
            int cost = 0;
            rep(y, n){
                rep(x, n){
                    if((y+x+2)%3 != i) continue;
                    cost += D[grid[y][x]-1][j-1];
                }
                if(i==0) X[j] = cost;
                else if(i==1) Y[j] = cost;
                else if(i==2) Z[j] = cost;
            }
        }
    }
    int res = INF;
    for(int i=1; i<=c; i++){
        for(int j=1; j<=c; j++){
            for(int k=1; k<=c; k++){
                if(i==j || j==k || k==i) continue;
                chmin(res, X[i]+Y[j]+Z[k]);
            }
        }
    }

    cout << res << ln;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()

int main(){
  vi A(3);
  cin>>A[0]>>A[1]>>A[2];
  sort(all(A));
  if(A[0]==5 && A[1]==5 && A[2]==7){
    cout<<"YES\n";
    return 0;
  }else{
    cout<<"NO\n";
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// jsc2019-qual
int main(){

    int m, d; cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            if(j < 10 or j >= 100)continue;
            int d1 = j % 10;
            int d2 = j / 10;
            if(d1 >= 2 and d2 >= 2 and d1 * d2 == i){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 /* #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("result.txt", "w", stdout);
  #endif*/
  ll r;
  cin>>r;
  cout<<3*r*r<<"\n"; 
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();
    REP(i, n - 8)
        cout << s[i];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <set>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; for (auto& e : a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; for (auto& e : a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; for (auto& r : a) { for (auto& e : r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; for (auto& e : a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

#define forn(a, e) for (int a = 0; a < (int)e; a++)
#define forr(a, s, e) for (int a = s; a < (int)e; a++)

using i64 = long long;

template<typename T>
using Pair = array<T, 2>;

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

    int n;
    while (cin >> n) {
        vector<vector<int>> a(n, vector<int>(n - 1));
        forn(i, n) forn(j, n - 1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        vector<int> p(n);
        queue<pair<int, int>> q;
        vector<int> used(n);
        forn(i, n) {
            // logss(a[i][0], a[a[i][0]][0]);
            if (i == a[a[i][0]][0]) {
                q.emplace(i, 1);
            }
        }
        int d = 0;
        while (!q.empty()) {
            auto cur = q.front();
            q.pop();
            // logs(q.size());
            // logv(p);
            // logss(cur.first, cur.second);

            d = max(d, cur.second);
            p[cur.first]++;
            int from = cur.first;
            // logss(from, p[from]);
            if (p[from] == n - 1) {
                continue;
            }
            int to = a[from][p[from]];
            // logss(from, a[to][p[to]]);
            if (from == a[to][p[to]]) {
                q.emplace(from, cur.second + 1);
                q.emplace(to, cur.second + 1);
            }
        }
        bool ok = true;
        forn(i, n) {
            if (p[i] != n - 1) {
                ok = false;
                break;
            }
        }
        if (ok) {

            cout << d << endl;
        } else {
            cout << -1 << endl;
        }
    }
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  vector<long long>Ans;
  long long mark=-1;
  long long cnt=0;
  for(int i=0;i<N;i++){
    if(mark==A.at(i)){
      cnt++;
      if(cnt==2){
        Ans.push_back(A.at(i));
        cnt=0;
      }
    }
    else{
      cnt=1;
      mark=A.at(i);
    }
  }
  if(Ans.size()<2){
    cout<<0<<endl;
  }
  else{
    cout<<Ans.at(0)*Ans.at(1)<<endl;
  }
}
    
    

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Computation of Salary
 * PCK2013 ??¬???2
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));

		Map<Integer, Map<Integer, Integer>> map = new HashMap<>();

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			if (line.equals("0 0 0")) break;
			StringTokenizer st = new StringTokenizer(line);
			int s, t, e;
			s = parseInt(st.nextToken());
			t = parseInt(st.nextToken());
			e = parseInt(st.nextToken());
			map.putIfAbsent(s, new HashMap<>());
			map.get(s).put(t, e);
		}

		int L = parseInt(br.readLine());

		for (int i = 0; i < L; i++) {
			int[] b = new int[M + 1];
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int j = 1; j <= M; j++) {
				b[j] = parseInt(st.nextToken());
			}

			List<String> list = new ArrayList<>();

			for (int j = 1; j <= N; j++) {
				int c = 0;
				if (map.containsKey(j)) {
					for (int t : map.get(j).keySet()) {
						c += b[t] * map.get(j).get(t);
					}
				}
				list.add(String.valueOf(c));
			}

			System.out.println(String.join(" ", list));
		}
	}
}

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

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

    int i;

    for (i=N; i<1000; i++){
        string ans = to_string(i);
        if (ans[0]==ans[1] && ans[1]==ans[2]){
            cout << ans[0] << ans[1] << ans[2] << '\n';
            break;
            }
    }
    

}

Measured memory_bytes: 256