akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int res = 0;
        for (int i = 0; i <= a; i++)
        {
            for (int j = 0; j <= b; j++)
            {
                for (int k = 0; k <= c; k++)
                {
                    if (i * 500 + j * 100 + k * 50 == x) res++;
                }
            }
        }
        Console.WriteLine(res);
    }
}


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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}


void Solve() {
	LL x, y;
	cin >> x >> y;

	auto cal = [&] (int x, int y) {
		if (x > y) return INF;
		else return y - x;
	};

	int ans = Smin(cal(x, y), cal(-x, y) + 1, cal(-x, -y) + 2, cal(x, -y) + 1);
	cout << ans << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3588
N, _ = (int(i) for i in input().split())
data = [[int(i) for i in input().split()] for i in range(N)]

import numpy as np
from scipy.spatial import distance

distance = distance.cdist(data, data, metric='euclidean')
count = 0
for n in range(0,N):
  for d in range(n+1,N):
    if distance[n][d].is_integer() and distance[n][d] != 0 :
      count+=1
print(count)

Measured memory_bytes: 19440
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    char ch;
    cin >> ch;
    cout << char(ch+1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    char s[11];
    char t[11];
    char u[11];
    int a = 0;
   int b = 0;
    scanf("%s %s\n", s, t);
    scanf("%d %d\n", &a, &b);
    scanf("%s\n", u);
    if (*s == *u)
    {
        printf("%d %d", a - 1, b);
    }
    else if (*t == *u)
    {
        printf("%d %d", a, b - 1);
    }
    return 0;
}

Measured memory_bytes: 128
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)
      
N=int(input())

ans=num2alpha(N)

print(ans)

Measured memory_bytes: 9172
//file_name:ABC106_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    ll n;
    scanf("%lld",&n);

    rep(i,n){
        if(s[i]=='1'){
            ;
        }else{
            cout << s[i] << endl;
            return 0;
        }
        //cout << i << endl;
    }

    int ans = 1;

    cout << '1' << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>


using namespace  std;
int main()
{
	long long x;
	cin>>x;
	long long happiness = 0;
	while(x>0)
	{
	if(x/500>0)
	{
		happiness += x/500*1000;
		x =x%500;
	}
	else if(x/5>0)
	{
		happiness += x/5*5;
		x=x%5;
	}
	else 
		x--;
}
cout<<happiness;
	return 0;
}

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

const int MAX_N = 2 * 1e5 + 2;
const int MAX_Q = 2 * 1e5 + 2;

char T[MAX_Q], D[MAX_Q];

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    for (int i = 0; i < Q; i++) {
        cin >> T[i] >> D[i];
    }
    int left_left = 0, left_right = N + 1;
    while (left_right - left_left > 1) {
        int mid = (left_left + left_right) / 2;
        int cur_pos = mid;
        for (int i = 0; i < Q; i++) {
            if (cur_pos == 0 || cur_pos == N + 1) break;
            if (S[cur_pos - 1] == T[i]) {
                if (D[i] == 'R') cur_pos++;
                else cur_pos--;
            }
        }
        if (cur_pos == 0) left_left = mid;
        else left_right = mid;
    }
    int right_left = 0, right_right = N + 1;
    while (right_right - right_left > 1) {
        int mid = (right_left + right_right) / 2;
        int cur_pos = mid;
        for (int i = 0; i < Q; i++) {
            if (cur_pos == 0 || cur_pos == N + 1) break;
            if (S[cur_pos - 1] == T[i]) {
                if (D[i] == 'R') cur_pos++;
                else cur_pos--;
            }
        }
        if (cur_pos == N + 1) right_right = mid;
        else right_left = mid;
    }
    cout << right_right - left_left - 1 << endl;
    return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

double dp[3005][3005];
double v[3005];

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

	for(int i = 1; i <= n; i++)
		scanf("%lf", &v[i]);

	dp[0][0] = 1.0;

	for(int i = 1; i <= n; i++) {
		dp[i][0] = dp[i-1][0]*(1-v[i]);
		for(int j = 1; j <= i; j++) {
			dp[i][j] = dp[i-1][j-1]*v[i] + dp[i-1][j]*(1-v[i]);
		}
	}

	double ans = 0;
	for(int i = (n+1)/2; i <= n; i++)
		ans += dp[n][i];
	printf("%.15lf\n", ans);

    return 0;
}

Measured memory_bytes: 68992
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#define ALL(v) v.begin(),v.end()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll r;
    cin >> r;
    cout << 3 * r * r<<endl;
    return 0;
}

Measured memory_bytes: 888
n,m,k=map(int,input().split())
mod=10**9+7
x=1
y=1
for i in range(1,k-1):
    y*=i
    y%=mod
for i in range(k-2):
    x*=n*m-2-i
    x%=mod
x*=pow(y,mod-2,mod)
x%=mod
def f(n,m):
    s=0
    for i in range(1,n):
        s+=i*(n-i)
        s%=mod
    return s*m*m%mod
print((f(n,m)+f(m,n))*x%mod)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}

ull X=0;
void test_b(ll i) {
    if(X & ((ll)1<<i)){
        printf("1\n");
    }else{
        printf("0\n");
    }
}

void set_b(ll i){
    X = X | ((ll)1<<i);
}

void clear_b(ll i){
    X = X & ~((ll)1<<i);
}

void flip_b(ll i){
    X = X ^ ((ll)1<<i);
}

void all_b(){
    if((X ^ ~0) == 0){
        printf("1\n");
    }else{
        printf("0\n");
    }
}
 
void any_b(){
    if((X | 0) == 0){
        printf("0\n");
    }else{
        printf("1\n");
    }
}

void none_b(){
    if((X | 0) == 0){
        printf("1\n");
    }else{
        printf("0\n");
    }
}

void count_b(){
    ll ans = 0;
    // cout << bitset<64>(X) << endl;
    for(ll i=0; i<64; i++){
        if((X & ((ll)1<<i)) > 0) {
        ans++;
        }
    }
    cout << ans << endl;
}

void count_b_(ll tmp){
    ll ans = 0;
    for(ll i=0; i<64; i++){
        if((tmp & ((ll)1<<i)) > 0) {
            cout << bitset<64>((ll)1<<i) << endl;
            ans++;
        }
    }
    cout << ans << endl;
}

void val_b(){
    cout << X << endl;
}

int main()
{
    ll q;
    cin >> q;
    ll c, i;

    //0, 1,...,8 は操作の種類を示し、それぞれtest(i), set(i), clear(i), flip(i), all, any, none, count, val を表します。
    rep(k, q){
        scanf("%lld", &c);
        if(c==0){
            scanf("%lld", &i);
            test_b(i);

        }else if(c==1){
            scanf("%lld", &i);
            set_b(i);
        }else if(c==2){
            scanf("%lld", &i);
            clear_b(i);
        }else if(c==3){
            scanf("%lld", &i);
            flip_b(i);
        }else if(c==4){
            all_b();
        }else if(c==5){
            any_b();
        }else if(c==6){
            none_b();
        }else if(c==7){
            count_b();
        }else if(c==8){
            val_b();
        }
        // cout << bitset<64>(X) << endl;
    }
    return 0;
}


Measured memory_bytes: 3204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, x, m := scanInt(), scanInt(), scanInt()
	u := make([]bool, m)
	a := []int{x}
	u[x] = true
	for i := 0; i < n; i++ {
		x = x * x % m
		if u[x] {
			break
		}
		u[x] = true
		a = append(a, x)
	}

	s := make([]int, len(a)+1)
	for i := 0; i < len(a); i++ {
		s[i+1] = s[i] + a[i]
	}

	ans := 0
	for i := 0; i < len(a); i++ {
		if a[i] == x {
			ans += (n / len(a[i:])) * (s[len(a)] - s[i])
			n -= n / len(a[i:]) * len(a[i:])
			if n == 0 {
				break
			}
		}
		ans += a[i]
		n--
		if n == 0 {
			break
		}
	}

	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q;
	cin>>n>>q;
	vl d(q),ans(q),next(q);
	vector<pair<ll,pll>> v(n);
	rep(i,n){
		ll s,t,x;
		cin>>s>>t>>x;
		s-=x;t-=x;
		v[i].fs=x;
		v[i].sc.fs=s;
		v[i].sc.sc=t;
	}
	sort(all(v));
	rep(i,q)cin>>d[i];
	
	rep(i,n){
		
		auto itr=lower_bound(all(d),v[i].sc.fs)-d.begin();
		while(itr<q&&d[itr]<v[i].sc.sc){
			if(ans[itr]==0){
				ans[itr]=v[i].fs;next[itr]=v[i].sc.sc;
				itr++;
			}
			else{
				itr=lower_bound(all(d),next[itr])-d.begin();
			}
		}
	}
	
	rep(i,q){
		cout<<(ans[i]!=0?ans[i]:-1)<<"\n";
	}
}


Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  bool ng=false;
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0)ng=true;
    }
  }
  if(ng)cout<<"DENIED";
  else cout<<"APPROVED";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1


ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, m, l;

struct edge {
	int to;
	ll cost;
	ll enemy;
};

ll d[110][110];
vector<edge> G[110];

void dijkstra() {
	rep(i, 110)rep(j, 110)d[i][j] = INF;
	d[0][l] = 0;

	typedef pair<P, ll> Pi;

	priority_queue<Pi, vector<Pi>, greater<Pi>> que;
	que.push({ P(0, l), 0 });

	while (!que.empty()) {
		Pi p = que.top();
		que.pop();
		ll v = p.second;
		ll ln = p.first.second;
		ll en = p.first.first;
		if (d[v][ln] < p.first.first || v == n - 1)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (ln >= e.cost) {
				if (d[e.to][ln - e.cost] > d[v][ln]) {
					d[e.to][ln - e.cost] = d[v][ln];
					que.push({ P(d[e.to][ln - e.cost], ln - e.cost),e.to });
				}
			}
			if (d[e.to][ln] > d[v][ln] + e.enemy) {
				d[e.to][ln] = d[v][ln] + e.enemy;
				que.push({ P(d[e.to][ln], ln),e.to });
			}
		}
	}
}


int main() {
	while (cin >> n >> m >> l&&n + m + l) {
		rep(i, 110)G[i].clear();
		rep(i, m) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			a--;
			b--;
			G[a].push_back({ b,c,d });
			G[b].push_back({ a,c,d });
		}
		dijkstra();
		ll ans = INF;
		rep(i, l + 1) {
			ans = min(ans, d[n - 1][i]);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 4412
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

string S;

int dp[100100];
int dfs(int pos) {
	int& ret = dp[pos];
	if (ret >= 0) return ret;
	if (pos == S.size()) return ret = 1;
	if (S.substr(pos, 5) == "dream") {
		if (dfs(pos+5)) return ret = 1;
	}
	if (S.substr(pos, 7) == "dreamer") {
		if (dfs(pos+7)) return ret = 1;
	}
	if (S.substr(pos, 5) == "erase") {
		if (dfs(pos+5)) return ret = 1;
	}
	if (S.substr(pos, 6) == "eraser") {
		if (dfs(pos+6)) return ret = 1;
	}
	return ret = 0;
}

int main() {
	cin >> S;
	memset(dp, -1, sizeof(dp));
	if (dfs(0)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 2176
import random
import numpy as np
import sys
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
s = np.array(s)
c = np.array(c)
#print(s)
#with open('output.txt', 'w') as f:
'''dice = list(range(26))
w = list(map(lambda x: x*x, c))
samples = random.choices(dice, k=d, weights=w)
for one in samples:
    print(one+1, file=f)'''
def p(text):
    print(text)

with open('output.txt', 'w') as f:
    for i in range(d):
        #if random.random()>0.05:
        if max(s[i])>15000:
            #増やす
            p(s[i].argmax()+1)
        else:
            #減少を抑える
            dice = list(range(26))
            w = c**2
            samples = random.choices(dice, k=1, weights=w)
            for one in samples:
                p(one+1)
            #print(c.argmax()+1, file=f)

Measured memory_bytes: 27296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


vector<int>A;
int N;
int cnt1, cnt2,pre;

bool check() {
	if (A[0] != 0)return 0;
	REP(i, N - 1) {
		if (A[i + 1] > A[i] + 1)return 0;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	A.resize(N);
	ll ans = 0;
	FOR(i,0, N) {
		cin >> A[i];
		
		if (A[i] == 1)cnt1++;
		else if (A[i] >= 2) {
			cnt2++;
			pre++;
			if (i>=1&&A[i - 1] == A[i] - 1)pre--;
		}
	}
	FOR(i,1, N) {
		if (A[i] == A[i - 1]+1)ans++;
		else if (A[i] > A[i - 1] + 1) {
			print(-1); return 0;
		}
		else ans += A[i];
		//printf("%lld %lld\n", i, ans);
	}
	//print("here");
	if (!check()) {
		print(-1); return 0;
	}
	//ans = cnt1 + cnt2 + pre;
	print(ans);
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "YES";
const string NO = "NO";

struct UnionFind {
    vector<LL> data;
    UnionFind(LL size) : data(size, -1) { }
    
    bool unionSet(LL x, LL y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    
    bool findSet(LL x, LL y) {
        return root(x) == root(y);
    }
    
    LL root(LL x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    LL size(LL x) {
        return -data[root(x)];
    }
};

VI G[200002];
bool used[200002];

void dfs(int idx) {
    used[idx] = true;

    REP(i, G[idx].size()) {
        int next = G[idx][i];
        if(used[next]) continue;

        dfs(next);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    UnionFind uf(100001);
    set<int> lang[100001];

    int x;
    REP(i, N) {
        int K;
        cin >> K;
        REP(j, K) {
            int tmp;
            cin >> tmp;
            G[i].PB(100000 + tmp);
            G[100000 + tmp].PB(i);
        }
    }

    dfs(0);
    bool flag = true;
    REP(i, N) {
        flag &= used[i];
    }

    cout << (flag ? YES : NO) << endl;
    return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long sum=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



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

        vll A(N);
        rep(i, 0, N) cin >> A[i];

        ll prod = 1;
        rep(i, 0, N) {
                if (even(A[i])) prod *= 2;
        }

        ll ans = intpow(3, N) - prod;
        cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s ;
  cin >> s;
  vector<int> v('z'-'a'+1);
  for(int i=0;i<4;i++) v[s[i] - 'A']++;
  int cnt = 0;
  for(int i=0;i<v.size();i++){
    if(v[i] == 2) cnt++;
  }
  cout << (cnt == 2? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,a;
    cin >> n >> a;
    cout << n * n - a << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int sum = 0;
    for(int i = 0; i < n; i++) {
      if(Integer.parseInt(sc.next())>=k)
        sum++;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 46844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e10;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

ll n, d, a, ans;
VLL X;
vector<pair<ll, ll>> monsters;
VLL sum;

int main()
{
    cin>>n>>d>>a;
    sum.resize(n+1);
    REP(i,n) {
        ll x, h;
        cin>>x>>h;
        X.push_back(x);
        monsters.push_back({x, h});
    }
    monsters.push_back({INF, INF});
    SORT(X);
    SORT(monsters);
    REP(i,n) {
        if (monsters[i].e2 > sum[i]) {
            ll tmp = (monsters[i].e2 - sum[i] + a - 1) / a;
            ans += tmp;
            sum[i] += tmp * a;
            int idx = upper_bound(ALL(X), X[i] + 2 * d) - X.begin();
            sum[idx] -= tmp * a;
        }
        //cout<<i<<":"<<ans<<"_"; REPALL(i,sum) cout<<sum[i]<<" "; nextline;

        sum[i+1] += sum[i];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 8548
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n, kk;
	cin >> n >> kk;
	vector<ll> p(n+1), c(n+1);
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	for(int i = 1; i <= n; i++)
		cin >> c[i];

	vector<ll> res1[n+1];
	for(int i = 1; i <= n; i++)
	{
		vector<bool> done(n+1, 0);
		ll curr = i;
		while(!done[curr])
		{
			res1[i].push_back(c[p[curr]]);
			done[curr] = 1;
			curr = p[curr];
		}
	}
	ll ans[n+1];
	for(int i = 1; i <= n; i++)
		ans[i] = LLONG_MIN;
	for(int i = 1; i <= n; i++)
	{
		ll k = kk;
		vector<ll> v = res1[i];
		ll ans1 = 0, zz = 0, nn = v.size();
		for(int j = 0; j < min(k, nn); j++)
		{
			ans1 += v[j];
			ans[i] = max(ans[i], ans1);
			zz += v[j];
		}
		k -= min(nn, k);
		ll xx = k / nn;
		if( k == xx * nn)
			xx = max(xx - 1, 0ll);
		ans1 += zz * xx;
		ans[i] = max(ans[i], ans1);
		k -= xx * nn;
		for(int j = 0; j < min(k, nn); j++)
		{
			ans1 += v[j];
			ans[i] = max(ans[i], ans1);
		}
	}
	ll fans = LLONG_MIN;
	for(int i = 1; i <= n; i++)
	{
		fans = max(fans, ans[i]);
	}
	cout << fans << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 218932
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    int x = INT_MAX;
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(a[i] < x)
            ++ ans;
        x = min(x, a[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
require 'set'; require 'prime'
INF=Float::INFINITY
h,w = gets.chomp.split.map(&:to_i)
grid=[]
h.times do
  grid.push gets.chomp.split(//).map(&:to_sym)
end

kuro = Set.new()
h.times do |i|
  w.times do |j|
    if grid[i][j] == :'#'
      kuro.add [i,j]
    end
  end
end

ans = 0
finished_kuro = Set.new()
kuro.each do |y,x|
  q = [[y,x, :'#']]
  yx = "#{y},#{x}"
  next if finished_kuro.include?(yx) # 通過済み
  black = Set.new([yx])
  white = Set.new()

  until q.empty?
    y,x,iro = q.pop
    ny = y-1; nx = x
    nyx = "#{ny},#{nx}"
    if (0 <= ny) && grid[ny][nx] != iro && !white.include?(nyx) && !black.include?(nyx)
      if grid[ny][nx] == :'.'
        white.add nyx
      else
        black.add nyx
      end
      q.push [ny, nx, grid[ny][nx]]
    end
    ny = y+1; nx = x
    nyx = "#{ny},#{nx}"
    if (ny < h) && grid[ny][nx] != iro && !white.include?(nyx) && !black.include?(nyx)
      if grid[ny][nx] == :'.'
        white.add nyx
      else
        black.add nyx
      end
      q.push [ny, nx, grid[ny][nx]]
    end
    ny = y; nx = x-1
    nyx = "#{ny},#{nx}"
    if (0 <= nx) && grid[ny][nx] != iro && !white.include?(nyx) && !black.include?(nyx)
      if grid[ny][nx] == :'.'
        white.add nyx
      else
        black.add nyx
      end
      q.push [ny, nx, grid[ny][nx]]
    end
    ny = y; nx = x+1
    nyx = "#{ny},#{nx}"
    if (nx < w) && grid[ny][nx] != iro && !white.include?(nyx) && !black.include?(nyx)
      if grid[ny][nx] == :'.'
        white.add nyx
      else
        black.add nyx
      end
      q.push [ny, nx, grid[ny][nx]]
    end
  end

  ans += black.size * white.size
  finished_kuro.merge black
end

puts ans


Measured memory_bytes: 51708
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int arr[upperlimit+1];
int dp[upperlimit+1];
vi indices[upperlimit+1];
//int iska[upperlimi];
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
ll m, n;
cin>>n>>m;
if((m*n)%2==0)
{
	cout<<"Even"<<endl;
	
}
else
{
	cout<<"Odd"<<endl;
}




return 0;
}



Measured memory_bytes: 24832
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(c);
        System.out.println(a);
        System.out.println(b);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int a,b;
	std::cin >> a>>b;
	std::cout << a*b << " "<<(a+b)*2<< std::endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846


int main()
{
    string s;
    cin >> s;

    int len = s.length();
    int count = 0;
    for (int i = 0; i < len/2; i++)
    {
        if (s[i]!=s[len-i-1])
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int a[1001][1001],dp[1001][1001];
int main()
{
	n=2;cin>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=max(dp[i-1][j]+a[i][j],dp[i][j-1]+a[i][j]);
		}
	}
	cout<<dp[n][m];
	return 0;
 } 

Measured memory_bytes: 2304
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        for (int x=1; x<=5; x++) {
            if(nextInt()==0){
                System.out.println(x);
                return;
            }
        }

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32404
def extgcd(a,b,list=[1,0,0,1]):
    x1,y1,x2,y2 = list
    if b != 0:
        f1 = x2;f2 = y2
        x2 = x1 - int(a/b)*x2
        y2 = y1 - int(a/b)*y2
        list = [f1,f2,x2,y2]
        x,y,a = extgcd(b,a%b,list)
    else:
        x,y = list[:2]
        return x,y,a

    return x,y,a

a,b,c,d = map(int, input().split())
minus = (c*d)//(extgcd(c,d)[2])
ans = b//c + b//d - b//minus
res = (a-1)//c + (a-1)//d - (a-1)//minus
ans = ans-res
t = b-a+1
print(t-ans)


Measured memory_bytes: 3064
N = int(input())
S = input()

MOD = 1000000007

atoz = list(map(chr,range(97,123)))
cd = dict()
for c in atoz:
    cd[c] = 0

for s in S:
    cd[s] += 1

ans = 1
for val in cd.values():
    if val == 0: continue
    ans = ans * (val + 1)
    ans %= MOD

ans -= 1
ans %= MOD

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<svec> sgrid;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;
vec dp;
grid edges;
unsigned n,m,x,y;

int calculate(unsigned index)
{
    if(dp[index] != -1)
    {
        return dp[index];       
    }
    // int temp=0;
    dp[index]=0;
    for(auto item : edges[index])
    {
        dp[index]=max(dp[index],1+calculate(item));
    }
    return dp[index];
}    

int main()
{
    cin>>n>>m;
    edges.resize(n);
    dp.resize(n,-1);
    while(m--)
    {
        cin>>x>>y;
        --x;--y;
        edges[x].push_back(y);
    }
    int result=0;
    for(unsigned i=0;i<n;++i)
    {
        result=max(result,calculate(i));
    }
    cout<<result;

}

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

int main(){
  int n,x;
  cin >> n >> x;
  int i,s=0,c=1,l;
  for(i=0;i<n;i++){
    cin >> l;
    s += l;
    if(s>x){
      cout << c << endl;
      return 0;
    }else{
      c++;
    }
  }
  
  cout << c << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace tree {
struct union_find {
  vector<int> par, rank, size;
  int compnum;

  union_find(int N) {
    compnum = N;
    par.resize(N), rank.resize(N), size.resize(N);
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int main() {

  for(int N; cin >> N && N;) {
    int toy[N][N], tox[N][N];
    rep(i, N) {
      rep(j, N) {
        int x, y; cin >> x >> y;
        toy[i][j] = y;
        tox[i][j] = x;
      }
    }

    tree::union_find uf(N * N);
    rep(_i, N) rep(_j, N) {
      int i = _i, j = _j;
      if((i == toy[i][j] && j == tox[i][j]) || !uf.same(i * N + j, toy[i][j] * N + tox[i][j])) {
        while(!uf.same(i * N + j, toy[i][j] * N + tox[i][j])) {
          uf(i * N + j, toy[i][j] * N + tox[i][j]);
          tie(i, j) = make_pair(toy[i][j], tox[i][j]);
        }
      }
    }
    cout << uf.num_of_comps() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n, m, c, b[22];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m >> c;
	for (int i = 0; i < m; ++i)
	{
		cin >> b[i];
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int res = c, a;
		for (int j = 0; j < m; ++j) {
			cin >> a;
			res += a * b[j];
		}

		if (res > 0)
			++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
for a in A:
    if a % 2 == 1:
        continue
    else:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            print('DENIED')
            break
else:
    print('APPROVED')

Measured memory_bytes: 2940
fun main(args: Array<String>) {
    var lr = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    var min = 2019L
    if (lr[1] >= lr[0] + 2019) min = 0L
    else {
        var tmp: Long
        for (i in lr[0] until lr[1]) {
            for (j in i + 1 until lr[1] + 1) {
                tmp = (i * j) % 2019L
                if (tmp < min) min = tmp
            }
        }
    }
    println(min)
}


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

int main() {
	// your code goes here
	int l, r, n , m =0;
	
	cin>>n>>m;
	int mi= n; 
	int ma=-1;
	
	for(int i=0; i<m ; i++){
		
		cin>>l>>r;
	
		if(ma < l)ma= l;
		if(mi > r)mi=r;
		
		
	
		
	}
	
	cout<<max(mi-ma+1,0);
	
	return 0;
}

Measured memory_bytes: 3516