akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  xs <- getc solve
  mapM_ putStrLn . concat . intersperse [""] $ xs

solve :: String -> [String]
solve = transpose . map tr . fill0

fill0 :: String -> String
fill0 s = replicate (5 - length s) '0' ++ s

tr :: Char -> String
tr c
  | c == '0' = "* = ****"
  | c == '1' = "* =* ***"
  | c == '2' = "* =** **"
  | c == '3' = "* =*** *"
  | c == '4' = "* =**** "
  | c == '5' = " *= ****"
  | c == '6' = " *=* ***"
  | c == '7' = " *=** **"
  | c == '8' = " *=*** *"
  | c == '9' = " *=**** "

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, i, j, k, p, ans;
	cin >> n >> p;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0));
	dp[0][0] = 1;
	for (i = 0; i < n; i++) {
		dp[i + 1][(0 + (a[i] % 2)) % 2] += dp[i][0];
		dp[i + 1][(1 + (a[i] % 2)) % 2] += dp[i][1];
		dp[i + 1][0] += dp[i][0];
		dp[i + 1][1] += dp[i][1];
	}
	ans = dp[n][p];
	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
// #define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

const int MAX = 100;
// const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
template <typename T>
long long COM(T n, T k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k,n-k);
    ll res = 1;
    rep(i,k){
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}

int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<ll> v(n);
    map<ll, int> mp, used, clear;
    rep(i,n){
        cin >> v[i];
        mp[v[i]]++;
    }
    sort(all(v), greater<ll>());
    ld mean = 0;
    ll num = 0;
    COMinit();
    for(int i = a; i <= b; i++){
        ll temp = 0;
        rep(j,i){
            temp += v[j];
            used[v[j]]++;
        }
        ld m = temp * (ld)1.0 / i;
        debug(temp);
        debug(m);
        if(mean < m){
            mean = m;
            num = com(mp[v[i-1]], used[v[i-1]]);
        }
        else if(mean == m){
            debug(num);
            debug(mp[v[i-1]]);
            debug(used[v[i-1]]);
            debug(com(mp[v[i-1]], used[v[i-1]]));
            // debug(num);
            num += com(mp[v[i-1]], used[v[i-1]]);
        }
        else break;
        used = clear;
    }

    cout << fixed << setprecision(10) << mean << endl;
    cout << num << endl;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;

const LL lim = 1e6+10;
bool cross[lim];
LL f[lim];
LL a[lim];

int main(){
    LL n;
    SL(n);
    FOR(i,1,n) SL(a[i]) , f[a[i]]++;

    for( LL i = 1 ; i<lim ; i++ ){
        if( f[i] ){
            for(LL j = i+i ; j<lim ; j+=i ) cross[j] = true;
        }
        if(f[i]>1) cross[i] = true;
    }

    LL ans = 0;
    FOR(i,1,n) if( cross[a[i]] == false ) ans++;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 14020
#include<bits/stdc++.h>
	using namespace std;
	#define ll long long
	#define vv vector<ll>
	#define pp pair<ll,ll>
	#define ff first
	#define ss second
	#define vp vector<pp>
	#define ld long double
	#define pb push_back
	#define mp make_pair
	const ll mod=7+1e9;
	const ll N=400004;
	bool prime[N];
	void isprime()
	{
		memset(prime,true,N);
		for(ll i=2;i*i<N;i++)
		{
			if(prime[i]==true)
			{
				for(ll j=i*i;j<N;j+=i)
				{
					prime[j]=false;
				}
			}
		}
	}
	ll power(ll a,ll n)
	{
		ll ans=1;
		a=a%mod;
		while(n>0)
		{
			if(n&1)
			{
				ans=(ans*a)%mod;
			}
			n=n>>1;
			a=(a*a)%mod;
		}
		return ans;
	}
	
	bool comp(pair<ll,ll> const &a,pair<ll,ll> const &b)
	{
		return a.first > b.first;
	}
	
	
	int main() 
	{
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll a,p;
	    cin>>a>>p;
	    a=a*3;
	    cout<<(a+p)/2;
	return 0;
	}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n=0,s=0,e=0,w=0,l=0;
	string a;
	cin>>a;
	l=a.length();
	for(int i=0;i<l;i++){
		if(a.substr(i,1)=="E")e=1;
		if(a.substr(i,1)=="W")w=1;
		if(a.substr(i,1)=="N")n=1;
		if(a.substr(i,1)=="S")s=1;
	}
	if(n+s==1 || e+w==1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


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

int main(){
    int n;cin >> n;
    int ans = 0;

    for(int i=1;i<=n;i++){
        if(i%2 == 0)continue;
        int sum = 0;
        for(int j=1;j<=i;j++) if(i%j == 0) sum++;
        if(sum == 8) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define endl '\n'

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  if (n&1) {
    cout << 0 << endl;
    return 0;
  }
  ll p = 5;
  ll ans = 0;
  while (p < n) {
    p *= 5;
  }

  while (p > 1) {
    ans += (n/p)/2;
    p /= 5;
  }
//  ans += n/50;

  cout << ans << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n+1],b[n];
	For(i,0,n+1) cin>>a[i];
	For(i,0,n) cin>>b[i];

	ll ans = 0;
	For(i,1,n+1){
		ll j = i-1;
		ans += min(b[j],a[i-1]);
		b[j] = max(b[j]-a[i-1],0LL);

		ans += min(b[j],a[i]);
		a[i] = max(a[i]-b[j],0LL);
	}
	cout<<ans<<endl;































	
}

Measured memory_bytes: 1792
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int H, W;
    cin >> H >> W;

    int c[10][10];
    FOR(i, 0, 10){
        FOR(j, 0, 10){
            cin >> c[i][j];
        }
    }

    FOR(i, 0, 10){ // 経由点
        FOR(j, 0, 10){ // 始点
            FOR(k, 0, 10){ // 終点
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    ll cost = 0;
    FOR(i, 0, H){
        FOR(j, 0, W){
            int a;
            cin >> a;
            if(a!=-1){
                cost += c[a][1];
            }
        }
    }

    p(cost);
    
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long cnt = 0;
		int xa = 0;
		int bx = 0;
		int ba = 0;
		foreach(var s in S){
			for(int j=0;j<s.Length - 1; j++){
				if(s[j] == 'A' && s[j + 1] == 'B') cnt++;
			}
			if(s[0] == 'B') bx++;
			if(s[s.Length - 1] == 'A') xa++;
			if(s[0] == 'B' && s[s.Length - 1] == 'A'){
				bx--; xa--; ba++;
			}
		}
		
		if(xa == 0 && bx == 0){
			if(ba > 1) cnt += ba - 1;
			Console.WriteLine(cnt);
			return;
		}
		
		
		int xabx = Math.Min(xa, bx);
		cnt += xabx;
		xa -= xabx;
		bx -= xabx;
		
		int rest = Math.Max(xa, bx);
		int restba = Math.Min(rest, ba);
		cnt += restba;
		rest -= restba;
		ba -= restba;
		
		cnt += ba;
		Console.WriteLine(cnt);
		
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13232
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt
  as <- getIntVec n

  let findMax i res | i >= n = res
                    | otherwise = let a = as V.! i
                                      res' = max a res
                                  in findMax (i+1) res'

      findAj ai i res
        | i >= n = res
        | otherwise = let a = as V.! i
                          ai_half = fromIntegral ai / 2
                          res' = if abs (fromIntegral a - ai_half) < abs (fromIntegral res - ai_half)
                                 then a else res
                      in findAj ai (i+1) res'

      ai = findMax 0 0
      aj = findAj ai 0 0

  putStrLn $ show ai ++ " " ++ show aj

Measured memory_bytes: 8064
x1,x2,x3,x4,x5,=map(int,input().split())
if 0 == x1:
    print("1")
elif 0 == x2:
    print("2")
elif 0 ==x3:
    print("3")
elif 0 == x4:
    print("4")
else:
    print("5")


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,n,a,b,counter;
  counter = 0;
  cin >> n;
  vector<int> vecx(0);
  for (int j = 0; j < n; j++) {
   cin >> x;
   vecx.push_back(x);
  }
  sort(vecx.begin(), vecx.end());
  for (int j = 0; j < n-1; j++) {
    a = vecx.at(j);
    b = vecx.at(j+1);
    if (a == b) {
      counter++;
    }
  }
  cout << n-counter << endl;
}

Measured memory_bytes: 3552
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

void solveCase(int caseNo)
{
    int n;
    cin >> n;
    vector<ll> a, b;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        a.pb(x);
        b.pb(y);
    }
    ll res = 0, extra = 0;
    pc(a, b);
    for (int i = n - 1; i >= 0; --i)
    {
        a[i] += extra;
        ll temp = a[i] % b[i];
        db(i, a[i], b[i], temp);
        if (temp == 0)
            continue;
        temp = b[i] - temp;
        res += temp;
        extra += temp;
        a[i] += temp;
    }
    pc(a, b);
    cout << res << '\n';
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m,q;
  cin >> n >> m >> q;
  mat lr(n+2,vec(n+2));
  for(ll i=0;i<m;i++) {
    ll l,r;
    cin >> l >> r;
    lr[l][r]++;
  }
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<=n;j++) {
      lr[i+1][j]+=lr[i][j];
    }
  }
  for(ll i=0;i<=n;i++) {
    for(ll j=0;j<n;j++) {
      lr[i][j+1]+=lr[i][j];
    }
  }
  while(q--) {
    ll l,r;
    cin >> l >> r;
    cout << lr[r][r]-lr[r][l-1]-lr[l-1][r]+lr[l-1][l-1] << endl;
  }
}

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

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
	string answer = "No";
	if (a < b) {
		if (b < c) {
			answer = "Yes";
		}
	}
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 3176
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    cunt1=0
    for i,ss in enumerate(s):
        if int(ss)==i%2:cunt1+=1
    cunt2=0
    for i,ss in enumerate(s):
        if int(ss)!=i%2:cunt2+=1   
    print(min(cunt1,cunt2))

if __name__=='__main__':
    main()

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

	ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }
	ll lcm(ll x, ll y){ return (x  / gcd(x, y) * y ); }

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	cin >>a >>b;
	cout << lcm(a,b) <<"\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
 
str = input()

r = str.count('R')
g = str.count('G')
b = str.count('B')
sum = r * g * b
for i in range(n-2):
  for j in range(i+1, n-1):
    k = 2 * j - i
    if k < n:
      if str[i] != str[j] and str[i] != str[k] and str[j] != str[k] :
        sum -= 1
    
print(sum)

Measured memory_bytes: 9076
#include <iostream>

using namespace std;

int main() {
    int accumurate_sum[100] = {};
    int sum = 0;

    // O(N)
    int N; cin >> N;
    for(int i = 0; i < N; i++) {
        int tmp; cin >> tmp;
        sum += tmp;
        if(i == 0) accumurate_sum[0] = tmp;
        else accumurate_sum[i] = accumurate_sum[i-1] + tmp;
    }

    int min_diff = 10000;
    for(int i = 0; i < N; i++) {
        int diff = abs(sum - 2 * accumurate_sum[i]);
        // 差の最小値より探索中の差が大きければ最小値を出力して終了
        if(min_diff < diff) {
            cout << min_diff << endl;
            return 0;
        } else {
            min_diff = diff;
        }
    }
}


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

int main()
{
    int a, b, c[100], sum = 0;
    priority_queue<int>d;

    cin >> a >> b;
    c[0] = 0;
    for(int i = 1;i <= a; i++)
    {
        c[i] = b+i-1;
        sum+=c[i];
        d.push(-abs(c[i]));
    }
    int h = (sum >= 0) ? (sum + d.top()) : (sum - d.top());
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll a, b, c, n, m, ans = 0,x=0;
	string s;
	cin >> n;
	/*rep(i, s.size()) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
		return 0;*/
	s = to_string(n);
	rep(i, s.size()) {
		ans += (s[i] - '0');
	}
	//cout << s << " " << ans << endl;
	if (n % ans == 0) {
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a+b>=a-b&&a+b>=a*b)cout<<a+b<<endl;
  else if(a-b>a+b&&a-b>=a*b)cout<<a-b<<endl;
  else if(a*b>a+b&&a*b>a-b)cout<<a*b<<endl;
  else cout<<a+b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <sstream>
using namespace std;

struct Node{
	int key;
	Node *prev, *next;
};

Node *nil;

void init(){
	nil = new Node;
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key){
	Node *x = new Node;
	x->key = key;
	// ???????????´??????????´??????????
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key){
	Node *cur = nil->next;	// ??????????¬????????´?????????????
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if(t == nil) return;	// t??????????????´?????????????????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	delete t;
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deletekey(int key){
	// ????´¢????????????????????????
	deleteNode(listSearch(key));
}

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

	int n;
	cin >> n;

	init();
	for(int i = 0; i < n; ++i){
		string s;
		int a;
		cin >> s;
		if(s == "insert" || s == "delete"){
			cin >> a;
			if(s == "insert"){
				insert(a);
			}
			if(s == "delete"){
				deletekey(a);
			}
		}
		else {
			if(s == "deleteFirst"){
				deleteFirst();
			}
			if(s == "deleteLast"){
				deleteLast();
			}
		}
	}

	Node *cur = nil->next;
	int i0 = 0;
	while(1){
		if(cur == nil) break;
		if(i0 > 0) cout << " ";
		cout << cur->key;
		cur = cur->next;
		++i0;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 32484
#include <bits/stdc++.h>
using namespace std;
#define N 8

vector<int> row(N,-1),col(N,-1),dpos(2*N-1,-1),dneg(2*N-1);
vector<vector<int>> X(N,vector<int>(N,0));

void printBoard(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(X[i][j]){
                if(row[i]!=j) return;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<(row[i]==j?'Q':'.');
        }
        cout<<endl;
    }
}

void recursive(int i){
    if(i==N){
        printBoard();
    }
    for(int j=0;j<N;j++){
        if(col[j]==1||dpos[i+j]==1||dneg[i-j+N-1]==1) continue;
        row[i]=j;
        col[j]=dpos[i+j]=dneg[i-j+N-1]=1;
        recursive(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=-1;
    }
}

int main(){
    int k;
    cin>>k;
    int a,b;
    for(int i=0;i<k;i++){
        cin>>a>>b;
        X[a][b]=1;
    }

    recursive(0);
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(9);
for(int i=0;i<9;i++){
  cin>>vec.at(i);
}
 int N;
 cin>>N;
 for(int i=0;i<N;i++){
   int b;
   cin>>b;
   for(int j=0;j<9;j++){
     if(vec.at(j)==b){
       vec.at(j)=0;
     }
   }
 }
if((vec.at(0)+vec.at(1)+vec.at(2))==0||(vec.at(3)+vec.at(4)+vec.at(5))==0||(vec.at(6)+vec.at(7)+vec.at(8))==0||(vec.at(0)+vec.at(3)+vec.at(6))==0||(vec.at(1)+vec.at(4)+vec.at(7))==0||(vec.at(2)+vec.at(5)+vec.at(8))==0||(vec.at(0)+vec.at(4)+vec.at(8))==0||(vec.at(2)+vec.at(4)+vec.at(6))==0){
cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
function main(lines) {
  const S = s();
  const T = s();
  
  const N = S.length;
  const M = T.length;
  let ans = M;
  for (let i = 0; i <= N-M; i++) {
    let cnt = 0;
    for (let j = 0; j < M; j++) {
      if (S[i+j] != T[j]) cnt++;
    }
    ans = Math.min(ans, cnt);
  }
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 32544
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

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

	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i = 0; i < n; i++)
	{
	    cin>>v[i];
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	for(ll i = 0; i < n-k; i++)
	{
	    sum = sum + v[i];
	}
	cout<<sum;
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;

using ll = int64_t;

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define LOOP(i,N) for(ll i=0;i<N;i++)
#define LOOP1(i,N) for(ll i=1;i<=N;i++)
typedef pair<ll,ll> P;
typedef pair<ll,pair<ll,ll> > PP;
// #define int long long

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	for (ll i = 0; i < n + 1; i++) {
			cin >> a[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> b[i];
	}

		ll ans = 0;
		//1村での処理
		//モンスター＞勇者の許容量なら
		if (a[0] <= b[0]) {
			ans += a[0];
			//勇者の許容量を減らす
			b[0] -= a[0];
		}
		//モンスター＜勇者の許容量なら
		else {
			ans += b[0];
			//勇者の許容量を次に引き継がせない
			b[0] = 0;
		}

		//2～n村目の処理
		for (ll i = 1; i < n; i++) {
			//モンスター＜i-1とiの勇者の許容量のときモンスター数を答えに足す
			if (a[i] <= b[i] + b[i - 1]) {
				ans += a[i];
				//モンスター数がi-1番目の勇者が倒しきれないときi番目の勇者の許容量を減らす
				if (a[i] >= b[i - 1]) {
					b[i] = b[i] - a[i] + b[i - 1];
				}
			}
			//モンスター＞i-1とi番目の勇者の時勇者の許容量を足す
			else {
				ans += b[i] + b[i - 1];
				b[i] = 0;
			}
		}

		//n+1村の処理
		if (a[n] <= b[n - 1]) {
			ans += a[n];
		}
		else {
			ans += b[n - 1];
		}
		cout << ans << endl;;

	return 0;
}


Measured memory_bytes: 1792
//Vol5 588
#include<stdio.h>
#include<string.h>
int main()
{
	int n,s=0;
	char c,l='+';
	while(1){
		scanf("%d\n",&n);
		scanf("%c",&c);
		if(l=='+'){
			s+=n;
		}else if(l=='-'){
			s-=n;
		}else if(l=='*'){
			s*=n;
		}else{
			s/=n;
		}
		l=c;
		if(c=='='){
			printf("%d\n",s);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2712
/*input
9
1 1 1 2 2 1 2 3 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> ans;
int a[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) a[i]--;
	while(n--){
		pii bst=MP(-INF,0);
		REP(i,n+1) bst=max(bst,MP(a[i]-i,i));
		if(bst.F!=0){
			cout<<"-1\n";
			return 0;
		}
		ans.pb(a[bst.S]);
		for(int i=bst.S;i<n;i++){
			a[i]=a[i+1];
		}
		// REP(i,n) cout<<a[i]<<" \n"[i==n-1]; 
	}
	reverse(ALL(ans));
	for(int i:ans) cout<<i+1<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int X;
    cin >> X;
    bool flag = true;
    int ans = 0;
    while(flag) {
        ll flag2 = true;
        REP(i, 2, (int)sqrt(X)){
            if (X % i == 0) {
                flag2 = false;
                break;
            }
        }
        if (flag2) {
            flag = false;
            ans = X;
        }
        X++;
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);

ll solve(){
	int n;
	cin>>n;
	int a[n];
	for(int &i:a) cin>>i;
	//aj+ai = j-i aj-j=-(ai+i)
	//aj+ai = i-j aj+j=-(ai-i)
	int m[n],p[n];
	unordered_map<int,int> mm;
	for(int i=0;i<n;i++){
		m[i]=a[i]-i;
		p[i]=a[i]+i;
		mm[m[i]]++;
	}
	ll ans=0;
	for(int i:p){
		ans+=(mm[-i]);
	}
	return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 20808
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input()) 
    d = list(map(int, input().split()))
    mod = 998244353
    from collections import Counter as cc
    c = cc(d)
    if c[0] != 1 or d[0] != 0:
        print(0)
        return
    m = max(d)
    ans = 1
    for i in range(1, m+1):
        ans *= pow(c[i-1], c[i], mod)
        ans %= mod
    print(ans)
    
    
if __name__ == '__main__':
    main()

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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = a; i <= b; i++) {
    int i1 = i / 10000;
    int i2 = (i - i1 * 10000) / 1000;
    int i3 = (i - i1 * 10000 - i2 * 1000) / 100;
    int i4 = (i - i1 * 10000 - i2 * 1000 - i3 * 100) / 10;
    int i5 = i % 10;
    int rev = i5 * 10000 + i4 * 1000 + i3 * 100 + i2 * 10 + i1;
    if (i == rev) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N, D;
  cin >> N >> D;
  vector<ll> X(N);
  vector<ll> Y(N);
  int ans = 0;
  for (int i=0; i<N; i++) {
    cin >> X[i] >> Y[i];
    if (sqrt(pow(X[i], 2) + pow(Y[i], 2)) <= D) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int H, W, A, B;

int main(){
  cin >> H >> W >> A >> B;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << ((i < B) != (j < A));
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
#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;
    ll d;
    cin>>n>>d;
    int ans=0;
    rep(i,n){
        ll x,y;
        cin>>x>>y;
        ll tmp1=x*x+y*y;
        ll tmp2=d*d;
        if(tmp1<=tmp2) ans++;
    }
    cout<<ans<<endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll X;
    cin >> X;
    for(int i=0;i<=101010;i++){
    	if(100*i <= X && 105*i >= X){
    		cout << 1 << endl;
    		return 0;
    	}
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import statistics

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

b = []

for i in range(n):
    b.append(a[i]-i)

bf = int(statistics.median(b))

ans = 0

for i in range(n):
    ans += abs(a[i] - bf - i)

print(ans)


Measured memory_bytes: 27244
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	vector<string> s, t;
	string str;
	int n, m, max = 0;
	sfd(n);
	getchar();
	for( int i=0; i<n; i++ ) {
		cin >> str;
		s.push_back(str);
	}
	sfd(m);
	getchar();
	for( int i=0; i<m; i++ ) {
		cin >> str;
		t.push_back(str);
	}
	for( int i=0; i<n; i++ ) {
        int a = count(s.begin(), s.end(), s[i]);
        int b = count(t.begin(), t.end(), s[i]);
		int c = a-b;
		if( max<c ) {
			max = c;
		}
	}
	pfd(max);
	
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		Btn = new int[N + 1];
	}

	int[] Btn;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		Btn[cnt] = Integer.parseInt(str);
	}

	public void solve() {
		// for (int i = 1; i <= N; i++)
		// System.out.println(Btn[i]);
		int ans = 0;
		for (int b = 1; b != 2 && ans < N; b = Btn[b]) {
			ans++;
		}
		if (ans < N)
			System.out.println(ans);
		else
			System.out.println(-1);
	}
}


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

const int INF = 1001001001;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    mint col = m;
    mint ans = 0;
    combination c(n-1);
    for (int i = n-1; i >= 0; i--) {
      mint now = col;
      now *= c(n-1, i);
      if (i <= k) ans += now;
      col *= m-1;
    }
    cout << ans.x << endl;
    return 0;
}

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

using namespace std;

const int mod = int(1e9) + 7;

int n, dp[200005][2], sum[200005], arr[200005];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", arr + i);
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		dp[i][0] = (dp[i - 1][1] + dp[i - 1][0]) % mod;
		if (arr[i] != arr[i - 1]) {
			dp[i][1] = sum[arr[i]];
			sum[arr[i]] = (sum[arr[i]] + dp[i][0]) % mod;
		}
	}
	printf("%d\n", (dp[n][0] + dp[n][1]) % mod);
}

Measured memory_bytes: 6956
//1-7-B
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, x;
    while(true){
        cin >> n >> x;
        if(n==0&&x==0)break;
            int count=0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k=j+1; k<=n; k++){
                    if((3*n-3)<x||x<=5)
                        count=0;
                    else if((i+j+k)/x==1&&(i+j+k)%x==0)
                        count++;
                }
            }
        }
        cout << count << endl;
    }
}



Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
X = int(input())

max_n = 100003
primes = [True] * (max_n+1)

for i in range(2,max_n+1):
  if primes[i] == True:
    if i >= X:
      print(i)
      break
    for j in range(i+i, max_n+1, i):
      primes[j] = False

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int K = 19;
const int KM = 1 << (K - 1);
int dat[1 << K];
int laz[1 << K];
int zero = 2e9;

void update(int L, int R, int X, int A, int l, int r) {
	if (r <= L || R <= l) return;
	if (L <= l && r <= R) {
		laz[A] = min(laz[A], X);
		return;
	}
	update(L, R, X, A * 2, l, (l + r) / 2);
	update(L, R, X, A * 2 + 1, (l + r) / 2, r);
}

void add(int L, int R, int X) {
	update(L, R, X, 1, 0, KM);
}

int check(int L, int A, int l, int r) {
	if (laz[A] != zero) {
		if (A * 2 < 1 << K) {
			laz[A * 2] = min(laz[A * 2], laz[A]);
			laz[A * 2 + 1] = min(laz[A * 2 + 1], laz[A]);
		}
		dat[A] = min(dat[A], laz[A]);
		laz[A] = zero;
	}
	if (r <= L || L + 1 <= l) return zero;
	if (L <= l && r <= L + 1) return dat[A];
	return min(check(L, A * 2, l, (l + r) / 2), check(L, A * 2 + 1, (l + r) / 2, r));
}

int query(int L) {
	return check(L, 1, 0, KM);
}

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


	int N, Q;
	cin >> N >> Q;
	pair<int, pair<int, int>> XST[200000];
	rep(i, N) {
		int S, T, X;
		cin >> S >> T >> X;
		XST[i] = mp(X, mp(S, T));
	}
	sort(XST, XST + N);
	int D[200002];
	D[0] = 0;
	D[Q + 1] = zero;
	rep1(i, Q) cin >> D[i];
	rep(i, 1 << K) {
		dat[i] = zero;
		laz[i] = zero;
	}

	rep(i, N) {

		int L = 0, R = Q + 1;
		while (L + 1 < R) {
			int H = (L + R) / 2;
			if (D[H] + XST[i].first >= XST[i].second.first) R = H;
			else L = H;
		}
		int L2 = 0, R2 = Q + 1;
		while (L2 + 1 < R2) {
			int H = (L2 + R2) / 2;
			if (D[H] + XST[i].first >= XST[i].second.second) R2 = H;
			else L2 = H;
		}

		if (R <= L2) {
			add(R, L2 + 1, XST[i].first);
		}

	}

	rep1(i, Q) {
		int kari = query(i);
		if (kari == zero) co(-1);
		else co(kari);
	}

	Would you please return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S / 60 / 60;
        int m = S / 60 % 60;
        int s = S % 60;
        System.out.printf("%d:%d:%d\n", h, m, s);
        sc.close();
    }
}



Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll m[3][3],mm[3][3];
ll cur[3];
set<int>bad;
vector<vector<ll> >poww(ll v){
	ll ret[3][3]={};
	ret[0][0]=ret[1][1]=ret[2][2]=1;
	ll c[3][3]={};
	rep(i,3)rep(j,3)c[i][j]=m[i][j];
	rep(i,30){
		if(((v>>i)&1)){
			ll ret2[3][3]={};
			rep(a,3)rep(b,3)rep(cc,3){
				ret2[a][b] += ret[a][cc]*c[cc][b]%mod;
				ret2[a][b] %= mod;
			}
			rep(a,3)rep(b,3) ret[a][b]=ret2[a][b];
		}
		ll c2[3][3]={};
		rep(a,3)rep(b,3)rep(cc,3){
			c2[a][b] += c[a][cc]*c[cc][b]%mod;
			c2[a][b] %= mod;
		}
		rep(a,3)rep(b,3) c[a][b]=c2[a][b];
	}
	vector<ll>A[3];
	rep(i,3)rep(j,3) A[i].pb(ret[i][j]);
	vector<vector<ll> >res;
	rep(i,3) res.pb(A[i]);
	return res;
}
int main(){
	m[0][0]=1;m[0][1]=1;m[0][2]=0;
	m[1][0]=1;m[1][1]=2;m[1][2]=2;
	m[2][0]=1;m[2][1]=1;m[2][2]=1;
	int n,k;cin>>n>>k;
	rep(i,k){int a;cin>>a;bad.insert(a);} bad.insert(n+1);
	int cur2 = -1;
	for(int i=1;i<=n;i++){
		if(bad.find(i) == bad.end()){
			cur[0] = 1LL*i*i%mod;
			cur[1] = (1LL*(2*i+1)+1LL*i*i)%mod;
			cur[2] = (1LL*i*i+1)%mod;
			//cout<<cur[0]<<cur[1]<<cur[2]<<endl;
			cur2 = i;
			break;
		}
	}
	while(cur2 != n){
		set<int>::iterator it = bad.upper_bound(cur2);
		int x = *it;
		//cur2->x-1
		vector<vector<ll> >mat = poww(x-1-cur2);
		//rep(i,3)rep(j,3)cout<<mat[i][j];
		ll cur3[3]={};
		rep(i,3)rep(j,3){
			cur3[i] += mat[i][j]*cur[j]%mod;
			cur3[i] %= mod;
		}
		for(int i=0;i<3;i++) cur[i] = cur3[i];
		//rep(i,3)cout<<cur[i]<<endl;
		cur2 = x;
		if(cur2 > n) break;
		vector<ll>zip;
		while(1){
			ll cur4[3]={};
			rep(i,3)rep(j,3){
				cur4[i] += m[i][j]*cur[j]%mod;
				cur4[i] %= mod;
			}
			zip.pb(cur4[0]);
			rep(i,3) cur[i] = cur4[i];
			if(bad.find(cur2) == bad.end()) break;
			cur2++;
		}
		//cout<<cur2<<endl;
		//rep(i,3) cout<<cur[i]<<endl;
		zip.pop_back();
		ll c = 1;
		for(int i=zip.size()-1;i>=0;i--){
			rep(j,3){
				cur[j] -= zip[i] * c % mod * c;
				cur[j] = (cur[j]%mod+mod)%mod;
			}
			cur[1] -= zip[i]*(c*2+1)%mod;
			cur[1] = (cur[1]%mod+mod)%mod;
			cur[2] -= zip[i];
			cur[2] = (cur[2]%mod+mod)%mod;
			c++;
		}
	}
	cout<<cur[0]<<endl;
}

Measured memory_bytes: 4992