akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [u128; n]
    }

    let mut ans = 1;
    if a.contains(&0) {
        println!("0");
        std::process::exit(0)
    }
    for i in a {
        ans *= i;
        if ans > 10u128.pow(18) {
            println!("-1");
            std::process::exit(0)
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 5596
#include<stdio.h>
int main()
{
int i;
int j;
int N;
int K;
int OKASHI[101];
int OKASHI_dare[1000];
int OKASHI_kazu;
int tmp_dare[1000];
int count=0;

for(i=1;i<N+1;i++){
  OKASHI[i]=0;
  tmp_dare[i]=0;
}
scanf("%d %d",&N,&K);

for(i=1;i<K+1;i++){

scanf("%d",&OKASHI_kazu);

for(j=1;j<OKASHI_kazu+1;j++){
scanf("%d ",&tmp_dare[j]);
OKASHI[tmp_dare[j]]=OKASHI[tmp_dare[j]]+1;
}

}

for(i=1;i<N+1;i++){
if(OKASHI[i]==0){count=count+1;}
}

printf("%d",count);

return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

const ll MAX_V = 1000000;  // 制約に従う
Graph G(MAX_V);  // 隣接リスト表現
ll d[MAX_V];
// 実際の頂点数Vはここで定義する必要なし


void dijkstra(ll s){  // 始点 (0-based)
    priority_queue<pll, vector<pll>, greater<pll>> pq;  // 経路長, 頂点番号
    FILL(d, INF);
    d[s] = 0;
    pq.push(pll(0, s));

    while(!pq.empty()){
        pll p = pq.top(); pq.pop();
        ll v = p.second;  // 確定させる候補の頂点番号
        if(d[v] < p.first) continue;  // より小さいのが後で来るのでスルー
        rep(i, G[v].size()){
            edge e = G[v][i];
            if(chmin(d[e.to], d[v] + e.cost)) pq.push(pll(d[e.to], e.to));
        }
    }
}


int main(){
    ll h, w, sh, sw, gh, gw; cin >> h >> w >> sh >> sw >> gh >> gw; sh--, sw--, gh--, gw--;
    vector<string> maze(h);
    rep(i, h) cin >> maze[i];
    rep(hi, h){
        rep(wi, w){
            if(maze[hi][wi] == '#') continue;
            Rep(i, max(0LL, hi-2), min(h, hi+3)){
                Rep(j, max(0LL, wi-2), min(w, wi+3)){
                    if(maze[i][j] == '#' || (i == hi && j == wi)) continue;
                    ll dist = abs(i - hi) + abs(j - wi), cost = dist == 1 ? 0 : 1;
                    // 無向
                    G[hi*w + wi].push_back(edge{i*w + j, cost});
                    G[i*w + j].push_back(edge{hi*w + wi, cost});
                }
            }
        }
    }
    dijkstra(sh*w + sw);
    if(d[gh*w + gw] == INF) cout << -1 << endl;
    else cout << d[gh*w + gw] << endl;
}


Measured memory_bytes: 292340
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

string s,t;

int main()
{
	cin>>s>>t;
	cout<<t<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) vl a(n + 1, 0); fab(i,0,n) cin>>a[i]
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N =(ll)3e5;
const ll inf =(ll)1e18 + 7;
const ll mod =(ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    for(ll i = 3;i * i <= n; i += 2)
        if(prime[i])
            for(ll j = i; j * i <= n; j += 2)
                prime[j * i] = false;
        
    for(ll i = 3; i <= n; i += 2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result = n;
    for(ll p = 2; p * p <= n; p++)
    {
        if(n % p == 0)
        {
            while(n % p == 0)
                n /= p;
            result -= result/p;
        }
    }

    if(n > 1)
        result -= result/n;
    return result;
}

ll nCr(ll n, ll k) 
{ 
    vl C(k + 1, 0); 
    ll i, j; 
    C[0] = 1; 
    for (i = 1; i <= n; i++) { 
        for (j = min(i, k); j > 0; j--) { 
            add(C[j], C[j - 1]); 
        } 
    }
    return C[k] % mod; 
}


int main()
{
	sup;
    
    string s, t, u;
    cin >> s >> t;
    ll n, p;
    cin >> n >> p >> u;
    if(u == s)
        n--;
    else 
        p--;
    prr(n, p);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]
b=[d//a[i] for i in range(n)]
c=0
for i in range(n):
	if b[i]==d:
		c += b[i]
	elif d%a[i]==0:
		c += b[i]
	else:
		c += b[i]+1
print(c+x)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    if(a < b){
        if(b < c){
            cout << a << " " << b << " " << c << endl;
        }
        else if(a < c){
            cout << a << " " << c << " " << b << endl;
        }
        else{
            cout << c << " " << a << " " << b << endl;
        }
    }
    else{
        if(c < b){
            cout << c << " " << b << " " << a << endl;
        }
        else if(a < c){
            cout << b << " " << a << " " << c << endl;
        }
        else{
            cout << b << " " << c << " " << a << endl;
        }
    }

    return 0;
}


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

#define ll int long long
#define dll double long long
#define forei(i,n,x) for(int i=n;i<=x;i++)
#define fored(i,n,x) for(int i=n;i>=x;i--)
#define forni(i,n,x) for(int i=n;i<x;i++)
#define fornd(i,n,x) for(int i=n;i>x;i--)
#define SQ(a) (a)*(a)
#define MOD 1000000007
#define sortvi(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pv(v) for(auto it: v) cout<<it
#define endl '\n'   //Take care in case of interactive problems
#define  MAX2 200005
#define  MAX1 100005
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INPA(arr,n) forni(i,1,n)cin>>arr[i]


typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
    /* write your code here */
    
    char c;cin>>c;
    if((int)c >= 97)
    cout<<"a"<<endl;
    else cout<<"A"<<endl;
    
    return 0;
}






Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
ll get() {
    ll sm = 0;
    rep(i, 0, N - 1) sm += abs(B[i + 1] - B[i]);
    return sm;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N);

    ll ans = -1;
    if (N % 2 == 0) {
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i];
        rep(i, 0, N / 2) B[i * 2] = A[i + N / 2];
        ans = get();
    } else {
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i];
        B[N-1] = A[N/2];
        rep(i, 0, N / 2) B[i * 2] = A[i + N / 2 + 1];
        chmax(ans, get());

        B[0] = A[N / 2];
        rep(i, 0, N / 2) B[i * 2 + 2] = A[i];
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i + N / 2 + 1];
        chmax(ans, get());
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - h * W - H * w + h * w << endl;
}

Measured memory_bytes: 256
object Main {
    def main(args: Array[String]) = {
        val inf = Int.MaxValue-100000
        val in = io.Source.stdin.getLines
        val v = in.next.toInt
        val g = Array.fill(v)(inf)
        val e = in.flatMap(x => {val y = x.split(" ").map(_.toInt); y.drop(2).grouped(2).map(y(0) +: _)}).toList
        g(0) = 0
        var flag = true
        while(flag) {
            flag = false
            for (b <- e) if (g(b(0)) + b(2) < g(b(1))) {g(b(1)) = g(b(0)) + b(2); flag = true}
        }
        g.zipWithIndex.foreach(p => println(p._2 + " " + p._1))
    }
}

Measured memory_bytes: 53848
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int n;
string s;
int d[1234567],m[1234567],c[1234567];
int getsumd(int l,int r){
	int val=d[r];
	if(l)
		val-=d[l-1];
	return val;
}
int getsumm(int l,int r){
	int val=m[r];
	if(l)
		val-=m[l-1];
	return val;
}
int getsumc(int l,int r){
	int val=c[r];
	if(l)
		val-=c[l-1];
	return val;
}
ll solve(int k){
	ll ans=0;
	ll tot=0;
	int i,val;
	fd(i,n-2,0){
		val=i+k;
		if(val<=n-1){
			if(s[val]=='C'){
				ans-=getsumm(i+1,val);
			}
		}
		val--;
		val=min(val,n-1);
		if(s[i]=='M'){
			ans+=getsumc(i,val);
			//cout<<c[val]<<endl;
		}
		if(s[i]=='D'){
			tot+=ans;
		}
	}
	return tot;
}
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
  	cin>>n;
  	cin>>s;
  	int i;
  	rep(i,n){
  		//cout<<s[i];
  		if(s[i]=='D')
  			d[i]=1;
  		else if(s[i]=='M')
  			m[i]=1;
  		else if(s[i]=='C'){
  			c[i]=1;
  		}
  	}
  	f(i,1,n){
  		d[i]+=d[i-1];
  		m[i]+=m[i-1];
  		c[i]+=c[i-1];
  	}
  	int q;
  	cin>>q;
  	int val;
  	rep(i,q){
  		cin>>val;
  		cout<<solve(val)<<endl;
  	}
    return 0;   
}


Measured memory_bytes: 15644
using System;
using System.Linq;

namespace Linear_Search
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            var a = Console.ReadLine().Split().Distinct().ToArray();
            Console.ReadLine();
            var b = Console.ReadLine().Split();
            Console.WriteLine("{0}", a.Where(e => b.Contains(e)).Count());
        }
    }
}

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

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;

int l[maxn], r[maxn];
int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c;
    cin >> s;
    for(int i=1; i <= n; i++){
        if(i > c + 1 && s[i - 1] == 'o')l[i] = max(l[i - 1], l[i - c - 1] + 1);
        else if(s[i - 1] == 'o')l[i] = max(1, l[i - 1]);
        else l[i] = l[i - 1];
    }
    for(int i = n; i >= 1; i--){
        if(s[i - 1] == 'o')r[i] = max(r[i + 1], r[i + c + 1] + 1);
        else r[i] = r[i + 1];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(s[i - 1] == 'o' && l[i - 1] + r[i + 1] < k)cout << i << "\n";
    }


    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,1));
	queue<pair<int,int>> q;
	deque<bool> flag(H*W,true);
	REP(i,H){
		REP(j,W){
			char c = in<char>();
			if(c=='#'){
				M[i][j] = 0;
				q.emplace(j+i*W,0);
				flag[j+i*W] = false;
			}
		}
	}

	int maxD=0;
	while(!q.empty()){
		auto p = q.front();
		maxD = max(maxD,p.second);
		q.pop();
		int u = p.first%W,v = p.first/W;
		if(u>0 && M[v][u-1]){
			int w = u-1+v*W;
			if(flag[w]){
				flag[w] = false;
				q.emplace(w,p.second+1);
			}
		}
		if(u<W-1 && M[v][u+1]){
			int w = u+1+v*W;
			if(flag[w]){
				flag[w] = false;
				q.emplace(w,p.second+1);
			}
		}
		if(v>0 && M[v-1][u]){
			int w = u+(v-1)*W;
			if(flag[w]){
				flag[w] = false;
				q.emplace(w,p.second+1);
			}
		}
		if(v<H-1 && M[v+1][u]){
			int w = u+(v+1)*W;
			if(flag[w]){
				flag[w] = false;
				q.emplace(w,p.second+1);
			}
		}
	}

	cout << maxD << endl;
	return 0;
}


Measured memory_bytes: 13456
def main():
    n = input()
    k = map(int,raw_input().split())
    for i in range(1,n+1):
        print "node {0}: key = {1},".format(i,k[i-1]),
        p_id = i/2
        l_id = 2*i
        r_id = 2*i+1

        if 0 < p_id <= n:
            print "parent key = {0},".format(k[p_id-1]),
        if l_id <= n:
            print "left key = {0},".format(k[l_id-1]),
        if r_id <= n:
            print "right key = {0},".format(k[r_id-1]),
        print ""

if __name__ == "__main__":
    main()

Measured memory_bytes: 6424
#include <cstdio>
#include <algorithm>

const int MAXN = 1005;
const int MOD = 1000000007;

char mat[MAXN][MAXN];
int f[MAXN][MAXN];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%s", mat[i]);

    f[0][0] = 1;
    for (int i = 0; i < n; i++) for (int j = (i == 0); j < m; j++) if (mat[i][j] == '.') {
        if (i && mat[i - 1][j] == '.') {
            f[i][j] += f[i - 1][j];
            f[i][j] >= MOD ? f[i][j] -= MOD : 0;
        }
        if (j && mat[i][j - 1] == '.') {
            f[i][j] += f[i][j - 1];
            f[i][j] >= MOD ? f[i][j] -= MOD : 0;
        }
    }

    printf("%d\n", f[n - 1][m - 1]);
    
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cin >> vec[i];}
#define printVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
//#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
/*
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 */
//----------------------------------------------------------------------------------------------------------------------
 
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e17;
 
void no(){
    cout <<"NO" << endl;
   //exit(0);
}
 
void yes(){
    cout <<"YES" << endl; //exit(0);
}
 
const ll md = 998244353;


void sl(){
	int n,k; cin >> n >> k;
	vector< int > arr (n); scanVec(arr);
	vector< bool > ans (k + 1);
	ans[0] = false;
	for(int i = 0;i < SZ(ans);i++){
		if(ans[i]) continue;
		for(auto it : arr){
			if(i + it < SZ(ans)){
				ans[i + it] = true;
			}
		}
	}
	
	if(ans[k]) {
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	}
}

 
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ts = 0;
    if(ts == 1) cin >> ts;
    else ts = 1;
    while(ts--) sl(); 
    return 0;
} 


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


public class my
{
	
	private static StringBuilder sb = new StringBuilder();
	
	public static void Main()
	{
		Console.ReadLine();
		var S = my.GetIntArray();
		Console.ReadLine();
		var T = my.GetIntArray();
		
		var cnt = 0;
		foreach(var t in T) {
			if( my.BinarySearch(S, t, 0, S.Length - 1) >= 0) {
				//Console.Write("COUNTUP. ");
				cnt++;
			}
		}
		
		Console.WriteLine(cnt);
	}
	
	private static int BinarySearch(int[] A, int t, int imin, int imax)
	{
		if(imin > imax) { 
			//Console.Write("NOTFOUND. ");
			return -1;
		} else {
			int i = (imin + imax) / 2;
			
			if(A[i] > t) {
				return my.BinarySearch(A, t, imin, i-1);
			} else if(A[i] < t) {
				return my.BinarySearch(A, t, i+1, imax);
			} else {
				//Console.Write( imin+":"+ i +":"+  imax + ":FOUND. ");
				return i;
			}
		}

		//Console.Write(imin + ":" + imax + ":ERROR! ");

		//return -2;
	}
	
	private static int CountChar(string s, char c)
	{
		return s.Length - s.Replace(c.ToString(), "").Length;
	}
	
	private static void Flush()
	{
		Console.Write(sb);
		sb.Length = 0;
	}
	
	private static void AppendLine(int v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(long v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(string[] v)
	{
		sb.AppendLine(string.Join(" ", v));
	}

	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 19000
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String str=input.readLine();
		String[] str2=str.split(" ");
		int a=Integer.parseInt(str2[0]);
		int b=Integer.parseInt(str2[1]);
		int c=Integer.parseInt(str2[2]);
		int x;
		if(a>b){
			x=a;
			a=b;
			b=x;
		}
		if(b>c){
			x=b;
			b=c;
			c=x;
		}
		if(a>b){
			x=a;
			a=b;
			b=x;
		}
		System.out.println(a+" "+b+" "+c);

	}
}

Measured memory_bytes: 24052
#include<stdio.h>
#include<math.h>

int main(){
  int D,E;
  double min;
  int i,j;
  while(scanf("%d%d",&D,&E),D+E){

    min=fabs(sqrt(D*D)-E);

    for(i=0,j=D;j>=0;i++,j--)
      if( min > fabs((sqrt(i*i+j*j)-E)) )
        min=(sqrt(i*i+j*j)-E);

    printf("%.10f\n",min);
  }

  return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
  
  val input = readLine()!!.split(" ").map(String::toInt)
  val HP = input[0]
  
  val ATKs = readLine()!!.split(" ").map(String::toInt)
  var sum = 0
  for(ATK in ATKs) {
   	sum += ATK 
  	if(sum >= HP) break
  }
  
  if(sum >= HP)	println("Yes")
  else 			println("No")
  
}

Measured memory_bytes: 48056
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	int N,Q;
	int[] a;
	long[] x;
    public void solve() {
		 N = nextInt();
		 Q = nextInt();
		 
		 a = new int[N];
		 x = new long[Q];
		 
		 for(int i = 0;i < N;i++){
		 	a[i] = nextInt();
		 }
		 
		 for(int i = 0;i < Q;i++){
		 	x[i] = nextLong();
		 }
		 
		 for(int i = 0;i < Q;i++){
		 	int right = 0;
			long sum = 0;
			long count = 0;
			for(int left = 0;left < N;left++){
				while(right < N && sum + a[right] <= x[i]){
					sum += a[right];
					right++;
				}
				count += (right - left);
				sum -= a[left];
			}
			
			out.println(count);
		 }
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 41936
/*
	Walking in the Hospital
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>
#include	<utility>

using namespace std;

typedef pair<int, int> P_II;

int main(void) {
	while(1) {
		int n;
		vector<P_II> LIST;
		
		cin >> n;
		if(n == 0) { break; }
		for(int i = 0; i < n; i++) {
			int buf_d1, buf_d2, buf_hosnum;
			
			cin >> buf_hosnum >> buf_d1 >> buf_d2;
			LIST.push_back( P_II( buf_d1+buf_d2, buf_hosnum ) );
		}
		sort( LIST.begin(), LIST.end() );
		
		cout << LIST.rbegin()->second << ' ' << LIST.rbegin()->first << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
import sys
input = sys.stdin.readline

n = int(input())
v = list(map(int,input().split()))
e, o =[], []
for i in range(n//2):
    e.append(v[2*i])
    o.append(v[2*i+1])
e.sort()
o.sort()
e.append(-1)
o.append(-1)
# print(e,o)

e1, e2, o1, o2 = 0,0,0,0
E1, O1 = e[0], o[0]
c = 1
for i in range(0,n//2):
    if e[i]==e[i+1]:
        c+= 1
        continue
    if c>e1:
        e2 = e1
        e1 = c
        E1 = e[i]
    elif c>e2:
        e2 = c
    c = 1

c=1
for i in range(0,n//2):
    if o[i]==o[i+1]:
        c+= 1
        continue
    if c>o1:
        o2 = o1
        o1 = c
        O1 = o[i]
    elif c>o2:
        o2 = c
    c = 1
    
# print(e1,e2,E1,o1,o2,O1)

if E1==O1:
    print(min(n-e1-o2,n-e2-o1))
else:
    print(n-e1-o1)

Measured memory_bytes: 13756
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

const ll INF = 1e18;
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,K; cin >> n >> K;
    vector<ll> h(n+1);
    h[0]=0;
    rep(i,n) cin >> h[i+1];
    
    if(n==K){
        cout << 0 << endl;
        return 0;
    }
    
    ll dp[n+1][n+1];
    rep(i,n+1)rep(j,n+1)dp[i][j]=INF;
    
    dp[0][0]=0;
    rep(i,n+1) dp[i][1]=max(0LL,h[i]-h[0]);
    
    for(int i=1;i<=n;i++){
        for(int j=0;j+1<=i;j++){
            ll res=INF;
            for(int k=1;k<i;k++){
                chmin(res,dp[k][j]+max(0LL,h[i]-h[k]));
            }
            chmin(dp[i][j+1],res);
        }
    }
    ll ans=INF;
    for(int i=1;i<=n;i++){
        chmin(ans,dp[i][n-K]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}


int main() {
  int n; cin >>n;
  ll res = 1;
  rep(i, n){
    ll t; cin >>t;
    res = lcm(res, t);
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,n):
  dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
  if i > 1:
    dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Measured memory_bytes: 20512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	private class Node<T> {
		T value;
		Node<T> left;
		Node<T> right;
		int pos;
		public Node(T value) {
			this.value = value;
			left = right = null;
			pos = -1;
		}
		public String toString() {
			return value.toString();
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] pre = new int[n];
		int[] in = new int[n];
		StringTokenizer st1 = new StringTokenizer(reader.readLine());
		StringTokenizer st2 = new StringTokenizer(reader.readLine());
		int rootId = 0;
		for (int i = 0; i < n; i++) {
			pre[i] = Integer.parseInt(st1.nextToken());
			in[i] = Integer.parseInt(st2.nextToken());
			if (i == 0) {
				rootId = pre[i];
			}
		}
		reader.close();
		
		Node<Integer> rootNode = new Node<Integer>(rootId);
		for (int i = 1; i < n; i++) {
			Node<Integer> current = new Node<Integer>(pre[i]);
			addNode(rootNode, current, in);
		}
		System.out.println(postOrder(rootNode));
	}

	private String postOrder(Node<Integer> rootNode) {
		StringBuilder sb = new StringBuilder();
		Stack<Node<Integer>> stack = new Stack<Node<Integer>>();
		Node<Integer> current = rootNode;
		Node<Integer> lastVisited = null;
		while (current != null || !stack.isEmpty()) {
			if (current != null) {
				stack.push(current);
				current = current.left;
			} else {
				Node<Integer> peekNode = stack.peek();
				if (peekNode.right != null && peekNode.right != lastVisited) {
					current = peekNode.right;
				} else {
					if (sb.length() != 0) {
						sb.append(" ");
					}
					sb.append(peekNode);
					lastVisited = stack.pop();
				}
			}
		}
		return sb.toString();
	}

	private void addNode(Node<Integer> rootNode, Node<Integer> newNode, int[] in) {
		newNode.pos = findPos(in, newNode.value);
		Stack<Node<Integer>> stack = new Stack<Node<Integer>>();
		stack.push(rootNode);
		while (!stack.isEmpty()) {			
			Node<Integer> current = stack.pop();
			if (current.pos == -1) {
				current.pos = findPos(in, current.value);
			}
			if (newNode.pos < current.pos) {
				if (current.left == null) {
					current.left = newNode;
					return;
				} else {
					stack.push(current.left);
				}
			} else {
				if (current.right == null) {
					current.right = newNode;
					return;
				} else {
					stack.push(current.right);
				}
			}
		}
	}

	private int findPos(int[] in, int id) {
		for (int i = 0; i < in.length; i++) {
			if (in[i] == id) {
				return i;
			}
		}
		return -1;
	}
}



Measured memory_bytes: 24292
a = gets.chomp!

case a
when 'SUN'
  puts 7
when 'MON'
  puts 6
when 'TUE'
  puts 5
when 'WED'
  puts 4
when 'THU'
  puts 3
when 'FRI'
  puts 2
when 'SAT'
  puts 1
else
  
end


Measured memory_bytes: 1788
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )

main :: IO ()
main = do
  [d,t,s] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  putYN $ t * s >= d 

putYN :: Bool -> IO ()
putYN True  = putStrLn "Yes"
putYN False = putStrLn "No"


Measured memory_bytes: 3768
fun main(args : Array<String>) {
    val (h, w, m) = readLine()!!.split(" ").map { it.toInt() }
    val hasBomb = mutableMapOf<Pair<Int, Int>, Boolean>()
    val hBombs = IntArray(h) {0}
    val wBombs = IntArray(w) {0}

    repeat(m) {
        val (bh, bw) = readLine()!!.split(" ").map { it.toInt()-1 }
        hasBomb[Pair(bh, bw)] = true
        hBombs[bh]++
        wBombs[bw]++
    }

    val hMax = hBombs.max()!!
    val wMax = wBombs.max()!!
    val hIndexes = hBombs.withIndex().filter { it.value == hMax }.map { it.index }
    val wIndexes = wBombs.withIndex().filter { it.value == wMax }.map { it.index }

    hIndexes.forEach { hIdx ->
        wIndexes.forEach { wIdx ->
            if (hasBomb[Pair(hIdx, wIdx)] != true) {
                println(hMax+wMax)
                return
            }
        }
    }

    println(hMax+wMax-1)
}

Measured memory_bytes: 114520
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

fac = [-1] * (10**7+1)
finv = [-1] * (10**7+1)
inv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod
initNCMMod(100001)

def main():
    N, M = LI()
    ans = 0
    if abs(N-M) == 1:
        ans = fac[N] * fac[M] % mod
    elif abs(N-M) == 0:
        ans = 2 * fac[N] * fac[N] % mod
    else:
        ans = 0
    print(ans)
main()



Measured memory_bytes: 250656
def f(n, x):
    if n % x == 0:
        return (n // x * 2 - 1) * x
    else:
        return (n // x * 2) * x + f(x, n % x)
n, x = map(int,input().split())
ans = n + f(n - x, x)
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,x,y;
  int ans=1;
    cin>>n>>k;
  for(int i=0;i<n;i++){
    x=ans*2;
    y=ans+k;
    ans=min(x,y);
  }

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


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

int main(){
  int a,b=0,i,array[201],c;
  cin>>a;
  for(i=0;i<a;i++){
    cin>>array[i];
  }
  for( ; ; ){
  for(c=0;c<a;c++){
    if(array[c]%2==1){
      goto LAST;
      }else{
      array[c]/=2;
      b++;
      }
  }
  }
  LAST:cout<<b/a<<endl;
}

Measured memory_bytes: 256
// Aizu 2441: FizzBuzz
// 2017.9.26 bal4u@uu

#include <stdio.h>
#include <string.h>

char ans[500];

long long calc(long long a)
{
	int j;
	long long l, r, p, ans;
	
	ans = (a/3 + a/5) << 2;
	for (j = 0, p = 1; p <= a; p*=10) {
		j++;
		r = p*10; if (r > a) r = a;
		l = p - 1;
		ans += ((r-r/3-r/5+r/15) - (l-l/3-l/5+l/15))*j;
	}
	return ans;
}

int main()
{
	long long s, i, k, l, r, m;
	char *p;

	scanf("%lld", &s);
	l = 0, r = 200000000000000000LL;
	while (l + 1 < r) {
		m = (l + r) >> 1;
		if (calc(m) >= s) r = m;
		else              l = m;
	}
	for (p = ans, k = l+1, i = 1; i < 20; i++, k++) {
		if      (k % 15 == 0) memcpy(p, "FizzBuzz", 8), p += 8;
		else if (k %  3 == 0) memcpy(p, "Fizz", 4), p += 4;
		else if (k %  5 == 0) memcpy(p, "Buzz", 4), p += 4;
		else {
			sprintf(p, "%lld", k); while (*p) p++;
		}
	}
	*p = 0;
	k = s - calc(l) - 1;
	ans[k+20] = 0;
	puts(ans+k);
	return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
// problem G
const int MAX = 100005;
int visited[MAX], dp[MAX];
vector<int> adj[MAX];

int dfs(int v){

    //if the current vertex is already visited then it already have its max length from this 
    // vertex in the dp array, so we will simply return dp[v];
    if(visited[v])
        return dp[v];


    visited[v] = 1;  

    int best = 0;

    // we will check for every child of vertex;
    for(auto child : adj[v])
    {
        best = max(best, dfs(child) + 1);
    }

    // once done then return the best length from this particular vertex.
    return dp[v] = best;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    
    int n, m;
    cin>>n >> m;

    for(int i = 0 ; i< m ; i++){
        int x, y;
        cin>> x>>y;

        adj[x].push_back(y);
    }

    int ans = 0;

    // now we are running dfs for every unvisited vertex.

    for(int i = 1; i<=n; i++)
    {
        if(!visited[i])
        ans = max(ans, dfs(i));
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 11948
#include<stdio.h>
int main(void){
  int count=0,i,j;
  char s[5];
  scanf("%s",s);
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(s[i]==s[j]){
        count++;
      }
    }
  }
  if(count==8){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <random>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	static unordered_map<ll, ll> memo;

	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	if (memo.find(b) == memo.end()) {
		ll k = 1;
		FOR(i, 2, b + 1) {
			k *= i;
			k %= MOD;
		}
		memo[b] = pow(k, MOD - 2);
	}
	c *= memo[b];
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}
/*
-- bit --
REP(i, (1 << n)) {
	REP(j, n) {
		cout << (1 & (i >> j));
	}
	cout << endl;
}
*/

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

int main() {

	VL p2 = { 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,4294967296,8589934592,17179869184 };

	ll n;
	cin >> n;
	multiset<ll> s;
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		s.emplace(tmp);
	}


	ll count = 0;
	RREP(i, p2.size()) {
		ll to = p2[i];

		for (auto itr = s.begin(); itr != s.end();) {
			auto vItr = s.find(to-*itr);
			if (vItr == s.end()||itr==vItr) { ++itr; continue; }
			
			if (*itr + *vItr == to) {
				++count;
				itr = s.erase(itr);
				if (itr == vItr) {
					itr = s.erase(vItr);
				} else {
					s.erase(vItr);
				}
			} else {
				++itr;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 11648
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b,c ,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    N, C = na[0], na[1]
    x, v = [], []
    for i in range(N):
        na = list(map(int, input().split()))
        x.append(na[0])
        v.append(na[1])

    cw1 = [0] * N
    cw2 = [0] * N
    acw1 = [0] * N
    acw2 = [0] * N

    sum_v = 0
    m1 = m2 = 0
    for i in range(N):
        sum_v += v[i]
        m1 = max(m1, sum_v - x[i])
        cw1[i] = m1
        m2 = max(m2, sum_v - x[i] * 2)
        cw2[i] = m2

    sum_v = 0
    m1 = m2 = 0
    for i in range(N - 1, -1, -1):
        sum_v += v[i]
        m1 = max(m1, sum_v - (C - x[i]))
        acw1[i] = m1
        m2 = max(m2, sum_v - (C - x[i]) * 2)
        acw2[i] = m2

    m = max(cw1[N - 1], acw1[0])
    for i in range(N - 1):
        m = max(m, cw1[i] + acw2[i + 1], cw2[i] + acw1[i + 1])

    print(m)


if __name__ == '__main__':
    main()



Measured memory_bytes: 23620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    VL a(N), b(M), aa(N+1, 0), bb(M+1, 0);
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, M) cin >> b[i];
    rep(i, 0, N) aa[i+1] = aa[i] + a[i];
    rep(i, 0, M) bb[i+1] = bb[i] + b[i];
    ll ans = 0;
    rep(i, 0, N+1){
        ll rem = K - aa[i];
        if(rem < 0) continue;
        auto itr = upper_bound(ALL(bb), rem);
        auto pos = itr - bb.begin();
        // cerr << rem << " " << pos-1 << endl;
        ans = max(i + pos - 1, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9592