akhauriyash/Code-Regression huggingface dataset:
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

// #define wa(x)       cout << (#x) << " -------- " << (x) << endl
// #define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
// #define line1	    printf("---------------------------\n")

#define wa //
#define line1 //
#define pvi //
#define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

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

//___________________________________________________________________________________________________

int n, m;
vii g;
vi depth;
vi seen;

void dfs(int p){

	printf("In : %d\n", p+1);

	if(seen[p]) return;
	seen[p] = 1;

	depth[p] = 0;

	for(int ch:g[p]){

		// if(seen[ch]) continue;

		dfs(ch);
		wa(depth[ch]);
		depth[p] = max(depth[p], depth[ch]+1);
	}

	pvi(depth);
	printf("Out : %d\n", p+1);
	line1;
}

void solve() {

	cin >> n >> m;

	g.assign(n, vi());
	depth.assign(n,0);
	seen.assign(n,0);

	rep(i,0,m){
		int a, b;
		cin >> a >> b;
		a--, b--;

		g[a].pb(b);
		// g[b].pb(a);
	}

	rep(i,0,n){
		dfs(i);
	}

	pvi(depth);

	ret(*max_element(all(depth)));
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}

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

    // solution comes here

    string S;
    cin >> S;
    if("YAKI" == S.substr(0, 4)) cout << "Yes" << nl;
    else                         cout << "No" << nl;
}

Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Email: hany01@foxmail.com
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define fir first
#define sec second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read()
{
	register int _, __; register char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

inline void File()
{
#ifdef hany01
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
#endif
}

int main()
{
    File();
	LL n, m;
	cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1ll) {
		if (m == 1ll) puts("1");
		else cout << m - 2ll << endl;
	} else {
		cout << (n - 2ll) * (m - 2ll) << endl;
	}
    return 0;
}

Measured memory_bytes: 256
while 1:
	try:
		h=[input() for i in [1]*5]
		if 1 in h and 2 in h:w=1
		elif 1 in h:w=3
		else:w=2
		if len(set(	h))!=2:
			for i in h:print 3
		else:
			for i in h:print 1 if i==w else 2
	except:break

Measured memory_bytes: 4208
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll par[200010];
ll len[200010];
ll ele[200010];
void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        len[i]=0;
        ele[i]=1;
    }
}
ll root(ll n){
    if(par[n]==n)return n;
    return par[n]=root(par[n]);
}
void unit(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(len[a]<len[b]){
        par[a]=b;
        ele[b]+=ele[a];
    }
    else{
        par[b]=a;
        ele[a]+=ele[b];
        if(len[a]==len[b])len[a]++;
    }
}
int main(){
    
    ll n,m;cin>>n>>m;
    ll a[n];rep(i,0,n)cin>>a[i];
    init(n);
    rep(i,0,m){
        ll x,y;cin>>x>>y;
        unit(x,y);
    }
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    if(n==2){
        if(m==0)cout<<a[0]+a[1]<<endl;
        else cout<<0<<endl;
        return 0;
    }
    bool used[n];
    fill(used,used+n,false);
    priority_queue<ll,vector<ll>,greater<ll>> q[n+1];
    ll cnt=0;
    rep(i,0,n){
        ll u=root(i);
        if(used[u]==false)cnt++;
        used[u]=true;
        q[u].push(a[i]);
    }
    if(2*cnt-2>n){
        cout<<"Impossible"<<endl;
        return 0;
    }
    if(cnt==1){
        cout<<0<<endl;
        return 0;
    }
    priority_queue<ll,vector<ll>,greater<ll>> qq;
    ll ans=0;
    rep(i,0,n){
        if(q[i].size()>0){
            ans+=q[i].top();
            q[i].pop();
            while(q[i].size()>0){
                qq.push(q[i].top());
                q[i].pop();
            }
        }
    }
    rep(i,0,2*cnt-2-cnt){
        ans+=qq.top();
        qq.pop();
    }
    cout<<ans<<endl;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll p, q, r;
  cin >> p >> q >> r;
  COUT(min(p+q, min(q+r, r+p)));

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3640
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int a;
  cin >> a;
  

  //process
  
  
  //output
  cout << a+a*a + a*a*a << endl;
}

Measured memory_bytes: 3624
/* SANDEEP YADAV*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define lld long double
#define umap unordered_map<>
#define sz(x) ((ll)((x).size()))
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pi pair<int, int>
#define setp cout<<fixed<<setprecision(6)
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,b,a) for(int i=b-1;i>=a;i--)
#define vl vector<ll>
#define pl pair<ll, ll>
// #define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll gcd(ll a,ll b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){ll r=a%b; a=b; b=r;} return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
const int N=100005;
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}
struct myhash
{
    static uint64_t fxn(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator ()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return fxn(x + FIXED_RANDOM);
    }
};
ll dp[101][N+1];
std::vector<pl> v;
ll knapsack(ll i,ll w)
{
    if(i<0||w<=0)
        return 0;
    if(v[i].fi>w)
        return knapsack(i-1,w);
    if(dp[i][w])
        return dp[i][w];
    return dp[i][w]=max(v[i].se+knapsack(i-1,w-v[i].fi),knapsack(i-1,w));
}
void solve(int tc)
{
    
    ll n,w;
    cin>>n>>w;

    
    for(ll i=0;i<n;i++)
    {
        ll wi,vx;
        cin>>wi>>vx;
        
        v.push_back({wi,vx});
    }

    cout<<knapsack(n-1,w);

    return;
}
int main()
{
    fastio;
    //judge();

    int T=1;
    // cin>>T;
    for(int tc=1;tc<=T;tc++)
    {
        solve(tc);
    }
    return 0;
}

Measured memory_bytes: 69988
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

typedef struct coo {
    int x;
    int y;
};

int main() {
    coo p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    int q;
    cin >> q;
    coo* p = new coo[q];
    for (int i = 0; i < q; i++) {
        cin >> p[i].x >> p[i].y;
        int naiseki = (p[i].x - p1.x) * (p2.x - p1.x) + (p[i].y - p1.y) * (p2.y - p1.y);
        double leng = (double)naiseki / (double)((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
        printf("%6.10f %6.10f\n", (p1.x + (p2.x - p1.x) * leng), (p1.y + (p2.y - p1.y) * leng));
    }
    delete[] p;
    return 0;
}


Measured memory_bytes: 3236
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);

    println!("{}", (N + 1) / 2)
}


Measured memory_bytes: 4352
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

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

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

void solve() {
    string s;
    cin >> s;
    int sum = 0;
    for(auto to: s) {
        sum += to-48;
        sum %= 9;
    }
    cout << (sum==0? "Yes" : "No");
}
/*
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong M, D;
  cin >> M >> D;

  llong ans = 0;
  for (int m = 1; m <= M; ++m) {
    for (int d = 1; d <= D; ++d) {
      if (d/10 == 1 || d%10 == 1) continue;

      ans += (d/10) * (d%10) == m;
    }
  }

  cout << ans << endl;

  return 0;
}

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

string s;
int k, mod = 1e9+7;
int newdp[105][5], olddp[105][5];

int main(){
    cin >> s >> k;
    
    olddp[0][1] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int sum = 0; sum < k; sum++){
            for(int j = 0; j <= 9; j++)
                newdp[(sum+j)%k][0] = (newdp[(sum+j)%k][0] + olddp[sum][0])%mod;
            for(int j = 0; j < s[i]-'0'; j++)
                newdp[(sum+j)%k][0] = (newdp[(sum+j)%k][0] + olddp[sum][1])%mod;
                
            int c = s[i]-'0';
            newdp[(sum+c)%k][1] = (newdp[(sum+c)%k][1] + olddp[sum][1])%mod;
        }
        for(int sum = 0; sum < k; sum++)
            for(int flag = 0; flag < 2; flag++){
                olddp[sum][flag] = newdp[sum][flag];
                newdp[sum][flag] = 0;
            }
    }
    int res = (olddp[0][0] + olddp[0][1] - 1 + mod)%mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int k,s,z,cnt=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            z=s-x-y;
            if(x+y+z==s&&z>=0&&z<=k){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	long ans = 1;
	foreach (i; 0..N)
	{
		ans.modm(i+1);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

int main(){
  int64_t n;
  cin>>n;
  int64_t ans=(n/11)*2;
  n-=ans/2*11;
  if(n>0&&n<7)ans+=1;
  else if(n>6)ans+=2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;scanf("%d%d",&N,&M);
    vector<int> connect[M];
    for(int i=0;i<M;i++){
        int k;scanf("%d",&k);
        for(int j=0;j<k;j++){
            int s;scanf("%d",&s);
            connect[i].push_back(s-1);
        }
    }
    int p[M];
    for(int i=0;i<M;i++)scanf("%d",&p[i]);
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        int now=0;
        for(int i=0;i<M;i++){
            int count=0;
            for(auto k:connect[i]){
                if(bit&(1<<k))count++;
            }
            if(count%2==p[i])now++;
        }
        if(now==M)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashSet;
import java.util.Set;

public class Main{
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long a = sc.nextLong();
      long b = sc.nextLong();
    
      long gcd = gcd(a,b);
      Set<Long> set = new HashSet<Long>();
      set.add(1L);
      for(long i = 2; i*i <= gcd; i++){
       while(gcd % i == 0){
         gcd /= i;
         set.add(i);
       }
     }
     if(gcd > 1) System.out.println(set.size()+1);
     else System.out.println(set.size());
  }

  static long gcd(long a, long b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);
  }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int get(unsigned int i) {
  i |= (i >>  1);
  i |= (i >>  2);
  i |= (i >>  4);
  i |= (i >>  8);
  i |= (i >> 16);
  return i + 1;
}

int main2() {
  int N = nextInt();
  vector<int> A(N);
  REP(i, N) A[i] = nextInt();
  sort(ALL(A));

  multiset<int> ms;
  REP(i, N) ms.insert(A[i]);

  int ans = 0;
  for (;!ms.empty();) {
    int t = *ms.rbegin();
    ms.erase(--ms.end());
    if (!ms.empty()) {
      int T = get(t);
      int s = T - t;
      auto it = ms.lower_bound(s);
      if (*it == s) {
        ms.erase(it);
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

left = 0
right = sum(A)
ans = 202020202020 * 200000

for i in range(N-1):
    tmp = A[i]
    left += tmp
    right -= tmp
    ans = min(ans, abs(right - left))

print(ans)



Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  REP(i, n) {
    int x;
    cin >> x;
    ans += min(x, k - x);
  }
  cout << ans*2 << "\n";
  return 0;
}


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

#define REP(i, n ,N) for(int i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

int N, u, v;
int A, B;
int ans;
const int NODE_SIZE = 101010;
vector<ll> edge[NODE_SIZE];

int dist1[NODE_SIZE];
int dist2[NODE_SIZE];
//幅優先探索 (グラフ: vector)
void bfs_vec(ll start){
    queue<int> q; //<コスト, ノード>
    bool visited[NODE_SIZE];
    for(int i=0; i<N; i++) visited[i]=false;    //初期位置を設定
    for(int i=0; i<N; i++) dist1[i] = -1;// 最後まで-1なら到達不可能
    q.push(start);  //開始ノードを追加
    dist1[start] = 0; // 初期状態のコスト
    while(!q.empty()){
        int curNode = q.front();
        int curStep = dist1[curNode];
        q.pop();
        if(visited[curNode]) continue;
        visited[curNode] = true;

        for(auto nextEdge: edge[curNode]){
            int nextNode = nextEdge;
            if(!visited[nextNode]){     //未到達のノードだけpush.
                q.push(nextNode);
                dist1[nextNode] = curStep + 1;
            }
        }
    }
}

//幅優先探索 (グラフ: vector)
void bfs_vec2(ll start){
	queue<int> q; //<コスト, ノード>
	bool visited[NODE_SIZE];
	for(int i=0; i<N; i++) visited[i]=false;    //初期位置を設定
	for(int i=0; i<N; i++) dist2[i] = -1;// 最後まで-1なら到達不可能
	q.push(start);  //開始ノードを追加
	dist2[start] = 0; // 初期状態のコスト
	while(!q.empty()){
		int curNode = q.front();
		int curStep = dist2[curNode];
		q.pop();
		if(visited[curNode]) continue;
		visited[curNode] = true;

		for(auto nextEdge: edge[curNode]){
			int nextNode = nextEdge;
			if(!visited[nextNode]){     //未到達のノードだけpush.
				q.push(nextNode);
				dist2[nextNode] = curStep + 1;
			}
		}
	}
}
int main(){
	cin >> N >> u >> v;
	u--; v--;
	REP(i,0,N-1){
		cin >> A >> B;
		A--; B--;
		edge[A].push_back(B);
		edge[B].push_back(A);
	}
	bfs_vec(v);
//	REP(i,0,N){
//		p(dist1[i]);
//	}
//	p("");
	bfs_vec2(u);
//	REP(i,0,N){
//		p(dist2[i]);
//	}

	REP(i,0,N){
		if(dist1[i] > dist2[i]){
			ans = max(ans, dist1[i]);
		}
	}
	p(ans - 1);

	return 0;
}

Measured memory_bytes: 7296
import sys,collections
N = int(sys.stdin.readline())
G = tuple(tuple(map(int,sys.stdin.readline().rstrip().split()))[2:] for _ in range(N)) # multi line with multi param
# n x n adjacency matrix
#G = [[-1,2,3],[2,-1,3],[1,2,-1]]
INF = float("inf")
ALL = set(range(N))
mst = set()
distances = [INF]*N # 蟋狗せ0縺九ｉ縺ｮ霍晞屬
distances[0] = 0
parents = [INF]*N
parents[0] = 0

import heapq

dv = []
def add(u):
  mst.add(u)
  if not ALL-mst: return
  for j in range(0,len(G[u]),2):
    v = G[u][j]
    w = G[u][j+1]
    if not v in mst and w + distances[u] < distances[v]: # u繧堤ｵ檎罰縺励◆譁ｹ縺悟ｮ峨＞
      distances[v] = distances[u]+w
      parents[v] = u
      heapq.heappush(dv, (distances[v],v))
  #print(distances)
  d,v = heapq.heappop(dv)
  while v in mst:
    d,v = heapq.heappop(dv)
  return v

n = add(0)
distances[0] = 0
parents[0]=0
while len(mst) < len(G):
  n = add(n)

for i in range(N):
  print(i,distances[i])


Measured memory_bytes: 40372
#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[i];
    vector<int> a2=a;
    sort(a2.begin(),a2.end());
    int l=a2[(n-1)/2];
    int r=a2[n/2];
    for(int i=0;i<n;i++){
        if(a[i]<r){
            cout<<r<<endl;
        }
        else{
            cout<<l<<endl;
        }
    }

    return 0;
}

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

using namespace std;

int N;
string s;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b;
	return 0;
}

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

int main(){
  int x;
  int a, b;
  
  cin >> x;
  if(x == 1){
    cout << "Hello World" << endl;
    return 0;
  }
  cin >> a >> b;
  cout << a + b << 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);
		String s = sc.next();
		int t = s.length() - 2;
		String result = "";
		result = s.charAt(0) + String.valueOf(t) + s.charAt(s.length() -1);
		System.out.println(result);
	}
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int n = sc.nextInt();
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			sum += a;
		}
		
		System.out.println(sum >= h ? "Yes" : "No");
	}
}

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

using namespace std;

int main(){
    int n;
    int d[100];

    cin >> n;
    for(int i=0; i < n; i++){
        cin >> d[i];
    }

    int backet[101] = {0};

    for(int i = 0; i < n; i++){
        backet[d[i]]++;
    }

    int counter = 0;
    for(int i = 1; i <= 100; i++){
        if(backet[i] != 0){
            counter++;
        }
    }
    cout << counter << endl;

    return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

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

signed main() {
    int n, m;
    cin >> n >> m;
    auto total = (n + m) * (n + m - 1) / 2;
    auto rem = n * m;
    cout << total - rem << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double a[100010];
int main()
{	
	int n;
	cin>>n;
	long long int sum=1;
	int fl=0;
	int i,j,k,l;
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<"0";return 0;
		} 
	}
	for(i=1;i<=n;i++){
		if(a[i]>(long double)1000000000000000000/sum){
			cout<<"-1";return 0;
		}
		sum*=a[i];
	}
	cout<<sum;
}


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


int main(){
	char a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	if(a == f && b == e && c == d){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}


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

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll cnt = 1;

  rep(i, n) {
    if (a[i] == cnt) cnt++;
  }

  if (cnt == 1) cout << -1 << endl;
  else cout << n - cnt + 1 << endl;


  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int W = sc.nextInt (); // ????§???§?¨?X
		int H = sc.nextInt (); // ????§???§?¨?y
		int x = sc.nextInt (); // ?????§?¨?x
		int y = sc.nextInt (); // ?????§?¨?y
		int r = sc.nextInt (); // ?????????
		
		if ( x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0 ) {
			System.out.println ( "Yes" );
		} else {
			System.out.println ( "No" );
		}
	}
}

Measured memory_bytes: 26112
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

// nの，k以下の最大の約数
int factor(int n, int k)
{
  for(int i=k; i>0; --i) {
    if (n % i == 0) return i;
  }
  // never reach here
}

int N,M;

int main()
{
  cin >> N >> M;
  int ans = factor(M, M / N);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int t;
long long gcd(ll x,ll y){
    ll r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r =x % y;
    }
    return y;
}
void check(ll a,ll b,ll c,ll d){
    if(a < b){
        cout << "No" << endl;
        return;
    }
    if(b > d){
        cout << "No" << endl;
        return;
    }
    ll g = gcd(d,b);
    ll mx = b - g + (a%g);
    if(mx > c){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
    return;
}
ll A,B,C,D;
int main(){
    cin >> t;
    for(int i = 0; i < t; i++){
        cin >> A >> B >> C >> D;
        check(A,B,C,D);
    }
    return 0;
}


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

using namespace std;

int main() {
int n;
string S;
cin >> n >> S;
string res;
for(int i = 0; i < n; i++){
	if(res.empty()){
		res += S[i];
	} else {
		if(S[i] != res[res.size()-1]){
			res += S[i];
		}
	}
}
cout << res.size() << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int k, s;
	cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z < 0 || z > k) {
				continue;
			}

			if (x + y + z == s) {
				ans++;
			}
		}
	}

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


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a==1&&b==1)cout<<1000000<<endl;
  else if(a==1){
    if(b==2){
      cout<<500000<<endl;
    }
    else if(b==3){
      cout<<400000<<endl;
    }
    else{
      cout<<300000<<endl;
    }
  }
  else if(a==2){
    if(b==1){
      cout<<500000<<endl;
    }
    else if(b==2){
      cout<<400000<<endl;
    }
    else if(b==3){
      cout<<300000<<endl;
    }
    else{
      cout<<200000<<endl;
    }
  }
  else if(a==3){
    if(b==1){
      cout<<400000<<endl;
    }
    else if(b==2){
      cout<<300000<<endl;
    }
    else if(b==3){
      cout<<200000<<endl;
    }
    else{
      cout<<100000<<endl;
    }
  }
  else{
    if(b==1){
      cout<<300000<<endl;
    }
    else if(b==2){
      cout<<200000<<endl;
    }
    else if(b==3){
      cout<<100000<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  int a, b, c, d, e; 
  int copy;
  
  for (int i = A; i <= B; i++) {
    copy = i;
    a = copy % 10;
    copy /= 10;
    b = copy % 10;
    copy /= 10;
    c = copy % 10;
    copy /= 10;
    d = copy % 10;
    copy /= 10;
    e = copy % 10;
    
    if (a == e && b == d) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9)    cout<<a*b<<endl;
    else                cout<<-1<<endl;
    return 0;
}



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

int main( void )
{
    int a, b, c;
    cin >> a >> b >> c;
    if ( ( 2 * b ) == ( a + c ) )
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ws = vector<int>(n);
    for (int i = 0; i < n; i++) {
        cin >> ws[i];
    }
    int min = 10001;
    for (int i = 0; i < n; i++) {
        int s1 = 0, s2 = 0;
        for (int j = 0; j < n; j++) {
            if (i <= j) {
                s1 += ws[j];
            } else {
                s2 += ws[j];
            }
        }
        if (abs(s1 - s2) < min) {
            min = abs(s1 - s2);
        }
    }
    cout << min << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int N, M;
    int L, R;
    int nL, nR;
    int i;
    
    cin >> N >> M;
    
    cin >> L >> R;
    
    if(M > 1){
        for(i=2; i<=M; i++){
            cin >> nL >> nR;
            if(L < nL) L = nL;
            if(R > nR) R = nR;
        }
    }
    
    if(R - L < 0) cout << 0;
    else cout << R-L+1;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200005];
int main() {
    init();
    ll N;
    cin>>N;
    rep(i,N-1){
        ll a;
        cin >> a;
        a--;
        A[a]++;
    }

    rep(i, N) cout << A[i] << "\n";
}

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

int main()
{
  int n;
  char s;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
from fractions import gcd

N=int(input())
T=[0]*N
S=[0]*N
for i in range(N):
  T[i]=int(input())

if N==1:
  print(T[0])
else:
  S[0]=T[0]
  for j in range(1,N):
    a=S[j-1]*T[j]
    S[j]=a//gcd(S[j-1],T[j])
  print(S[-1])

Measured memory_bytes: 5048
fun main(args: Array<String>) = shojin06b()

fun shojin06b() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }

    if (a > b) return println(0)
    if (a == b) return println(1)
    if (n == 1L && a < b) return println(0)

    val answer = 1 + (b - a) * (n - 2)

    println(answer)
}


Measured memory_bytes: 38300
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long b=0,c=0,d=1,e,f=1000000,t,g[100000];
  string a;
  cin>>a;
  b=((a[0]-'0')*100)+((a[1]-'0')*10)+(a[2]-'0');
  c=abs(753-b);
  for(int i=3;i<a.size();i++){
    b%=100;
    b*=10;
    b+=(a[i]-'0');
    if(c>abs(753-b)) c=abs(753-b);
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s;
  cin >> s;
  int arr[500010] = { 0 };
  fi(0, s.size()) {
    if(s[i] == '<')
      arr[i + 1] = arr[i] + 1;
  }
  for(int i = s.size() - 1; i >= 0; --i) {
    if(s[i] == '>')
      arr[i] = max(arr[i], arr[i + 1] + 1);
  }
  // ans = accumulate(arr, arr + s.size() + 1, 0);
  fi(0, s.size() + 1)
    ans += arr[i];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 2820
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		
	
		if ( a.equals("H") && b.equals("H")) 
			System.out.println("H");
		if ( a.equals("H") && b.equals("D")) 
			System.out.println("D");
		if ( a.equals("D") && b.equals("H"))
			System.out.println("D");
		if ( a.equals("D") && b.equals("D")) 
			System.out.println("H");

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

P p[100000];
int h, w, d, q;
ll sum[100000];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w >> d;
	FOR(i, 100000) p[i] = {-1, -1};
	FOR(i, h) FOR(j, w) {
		int a;
		cin >> a;
		p[a] = {i, j};
	}
	FOR(i, 100000) {
		if (i-d >= 0 && p[i-d].first >= 0 && p[i].first >= 0) sum[i] = sum[i-d] + abs(p[i-d].first-p[i].first) + abs(p[i-d].second-p[i].second);
	}
	cin >> q;
	vector<ll> ans(q);
	FOR(i, q) {
		int l, r;
		cin >> l >> r;
		ans[i] = sum[r]-sum[l];
	}
	FOR(i, q) cout << ans[i] << endl;
	return 0;
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  char k = S.at(K-1);
  
  string ans;
  
  for (int i = 0; i < N; i++) {
    if (!(S.at(i) == k)) {
      ans = ans + '*';
    }
    else {
      ans = ans + k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');

            

            for (int i = n -1; i > 0; i--)
            {
                Console.Write(input[i]+" ");
            }
            Console.WriteLine(input[0]);
        }
    }
}

Measured memory_bytes: 8864
N, M = map(int, input().split())
 
def factorized(M):
    d = 2
    f = []
    while d <= M:
        count = 0
        while M % d == 0:
            M //= d
            count += 1
        if count > 0:
            f.append(count)
        d += 1
    return f
 
def tetra(n, m):
    x = 1
    for y in range(1, n):
        x = x * (m + y - 1) // y
    return x
 
x = 1
for f in factorized(M):
    x *= tetra(N, f + 1)
    x %= 10 ** 9 + 7
 
print(x)

Measured memory_bytes: 41068