akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct mint {
    long long x;
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};
mint mod_pow(ll x, ll n){
    mint res = 1, a = x;
    for(; n>0;a=a*a, n>>=1)
        if(n & 1) res *= a;
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll m, n;
    cin >> m >> n;
    cout << mod_pow(m, n).x << endl;
    return 0;
}


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

public class HelloWorld
{
    static double A;
    static double B;
    static double C;
    static double D;
    static double E;
    static double F;
    
    static int sugar;
    static int water;
    static double max;
    
    static int[,] dp = new int[3001,3001];
    
    static public void Main ()
    {
        var inp = Console.ReadLine().Split().Select(a => double.Parse(a)).ToArray();
        
        A = inp[0];
        B = inp[1];
        C = inp[2];
        D = inp[3];
        E = inp[4];
        F = inp[5];
        for(int i = 0;i < 3001;i++){
            for(int j = 0;j < 3001;j++){
                dp[i,j] = 0;
            }
        }
       max = 0;
       sugar = 0;
       water = 0;
        
        exp(0,0);
        
        Console.WriteLine ((water+sugar)+" "+sugar);
    }
    static void exp(double W,double S){
        if((int)W+(int)S > (int)F || dp[(int)W,(int)S] == 1){
            return;
        }
        
        if(S/(W+S) >= max && S <= E*(W/100)){
            max = S/(W+S);
            sugar = (int)S;
            water = (int)W;
        }
        dp[(int)W,(int)S] = 1;   
        
        exp(W+100*A,S);
        exp(W+100*B,S);
        if(S <= E*(W/100)){
            exp(W,S+C);
            exp(W,S+D);
        }
        
    }
}


Measured memory_bytes: 48468
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	int N,H,W,c=0;
	
	cin >> N>>H>>W;
	vector<ll> A(N);
	vector<ll> B(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i)>>B.at(i);
		if (A.at(i) >= H && B.at(i) >= W) {
			c++;
		}
	}




	cout <<c<< endl;
	
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);
        if (b < a)
        {
            Console.WriteLine(a - 1);
        }
        else
        {
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define debug(x) cerr << #x << "=" << x << endl;
#define lgx cerr << "----------" << endl;
typedef long long LL;
const int MaxN = 1e5 + 10;

int main() {
    string n;
    while(cin >> n) {
        char a = n[0];
        int cnt = 1;
        for (int i = 1; i < n.size(); i++) {
            if(a == n[i]) cnt++;
            else if(cnt < 3 && a != n[i]) {
                cnt = 1;
                a = n[i];
            }
        }
        if(cnt >= 3) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b; cin >> a >> b;
    for(int i = 1; i <= 1000; i++){
        int j = i+1;
        int k = (i*i)-i;
        k/=2;
        int q = (j*j)-j;
        q/=2;
        if(k-a == q-b){
            cout << k-a << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a, b = list(map(int, input().split())), list(map(int, input().split()))

    p, m = 0, 0
    for i in range(n):
        if a[i] > b[i]:
            m += a[i] - b[i]
        else:
            p += (b[i]-a[i]+1) // 2

    dif_sum = sum(b) - sum(a)
    if dif_sum == 0 and p == 0 and m == 0:
        print("Yes")
    elif dif_sum <= 0:
        print("No")
    elif dif_sum >= m and dif_sum >= p:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair

using namespace std;

typedef long long ll;
const int nax=2e3+3;
const int mod=1e9+7;
int dp[nax];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  dp[0]=1;
  for(int i=3;i<=n;i++){
    for(int j=3;j<=i;j++)dp[i]=(dp[i]+dp[i-j])%mod;
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  map<int,int> M;
  rep(i,0,N) M[A[i]]++;
  int ans=0;
  for(auto p:M) ans+=p.second*(p.second-1)/2;
  rep(i,0,N){
    int X=ans;
    X-=M[A[i]]*(M[A[i]]-1)/2;
    X+=(M[A[i]]-1)*(M[A[i]]-2)/2;
    cout<<X<<endl;
  }
  }


Measured memory_bytes: 11008
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int calc(int p, int x){
	return p*(100+x)/100;
}

int main()
{
	int X,Y,S;

	while(cin >> X >> Y >> S && X)
	{
		int ans=0;
		REP( y, 1, S ){
			REP( x, 1, S ){	
				if(calc(x,X)+calc(y,X) == S){
					int x2 = calc(x,Y);
					int y2 = calc(y,Y);
					ans = max(x2+y2,ans);
				}
			}
		}
			
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
// Author: Sayantanu
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
const int mod = 1e9 + 7;
#define float double
int n;
vector<float> arr(3000);

vector<vector<float>> dp(3000,vector<float>(3000,-1));

float answer(int ind, int head){
    int maxhead = head + (n - ind + 1);
    int currtail = ind - head - 1;
    if(maxhead<currtail){
        return 0;
    }
    if(ind>n){
        return 1;
    }
    if(dp[ind][head]!=-1){
        return dp[ind][head];
    }
    float ans = arr[ind]*answer(ind+1,head+1);
    ans+= ((float)1-arr[ind])*answer(ind+1,head);
    dp[ind][head] = ans;
    return ans;
}

int main() {
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    float ans = answer(1,0);
    cout<<setprecision(11)<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  long long a, b;
  cin >> n >> a >> b;
  vector<long long> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  long long ans = 0;
  for(int i = 1; i < n; i++){
    ans += min(a * (x.at(i) - x.at(i-1)), b);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4004
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] dp = new int[160000];
		dp[0] = 0;
		for(int i=1;i<160000;++i) dp[i] = Integer.MAX_VALUE;
		int[] six = {6,36,216,1296,7776,46656};
		int[] nine = {9,81,729,6561,59049};
		
		for(int i=0;i<100000;++i){
			for(int ones=1;ones<=5;ones++) dp[i+ones] = Math.min(dp[i+ones], dp[i]+ones);
			for(int j=0;j<6;++j) dp[i+six[j]] = Math.min(dp[i+six[j]], dp[i]+1);
			for(int j=0;j<5;++j) dp[i+nine[j]] = Math.min(dp[i+nine[j]], dp[i]+1);
		}
		
		System.out.println(dp[N]);
		return;
	}
}

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

string s;
bool ATGC(char c) {
  return ~string("ATGC").find(c);
}

int main() {
  cin >> s;
  
  int mx = 0;
  int j = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (j < i) ++j;
    while (j < s.size() && ATGC(s[j])) {
      ++j;
    }
    mx = max(mx, j - i);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():

    n = getN()
    anums = getList()
    bnums = getList()
    if sum(anums) < sum(bnums):
        print(-1)
        return
    husoku = 0
    ans = 0
    tari = []
    for a, b in zip(anums, bnums):
        if b > a:
            husoku += b - a
            ans += 1
        else:
            tari.append(a - b)

    tari.sort(reverse=True)
    if husoku == 0:
        print(0)
        return
    # ans = 0
    for t in tari:
        ans += 1
        husoku -= t
        if husoku <= 0:
            print(ans)
            return
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 100204
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k, q) = (v[0] as usize, v[1], v[2] as usize);
    let mut points = vec![k - q as i64; n];
    for i in 0..q {
        let a = read::<usize>() - 1;
        points[a] += 1;
    }
    for point in points {
        if point > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

#define MAX 1000000000000L

signed main(void){
    ios::sync_with_stdio(false);

    ull n, k;
    cin >> n >> k;

    vull as = vull(n);
    rep(i, n) cin >> as[i];

    ull ans = 0;

    for (ull cur = 1L << 60; 0 < cur; cur >>= 1) {
        ull zsum = 0;
        ull osum = 0;
        rep (i, n) {
            if (cur & as[i]) osum++;
            else zsum++;
        }

        if (osum < zsum) {
            ull nxt = ans + cur;
            if (nxt <= k) {
                ans = nxt;
            }
        }
    }


    ull X = ans;
    ull res = 0;
    rep(i, n) {
        res += X ^ as[i];
    }
    cout << res << endl;

    return 0;
}


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

#define inf 1e18
#define mod 1000000007

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll T;cin >> T;while(T--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,x;
	cin >> n;
	ll ans = 1;
	vector <ll> v(n);
	for0(i,n){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	if(v[0] == 0){
		cout << "0"<<endl;
		return 0;
	}
	ll prev = ans;
	for0(i,v.size()){
		// cout << ans <<" " <<  prev << endl;
		ans *= v[i] ;
		// cout << ans <<" " <<  prev << endl;
		if(ans > 1000000000000000000 || ans < prev){
			cout << "-1" << endl;
			return 0;
		}
		prev = ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3992
a,b,c,x,y = map(int,input().split())
if 2*c >= a+b:
    print(a*x+b*y)
else:
    if x>= y:
        count = c*2*y
        count += min(c*2*(x-y),a*(x-y))
        print(count)
    else:
        count = c*2*x
        count += min(c*2*(y-x),b*(y-x))
        print(count)

Measured memory_bytes: 3064
n = int(input())

global ans
ans = 0

def dfs(s):
    global ans
    if s:
        if int(s) > n:
            return
    if s:
        if "3" in s and "5" in s and "7" in s:
            ans += 1
    dfs(s + "3")
    dfs(s + "5")
    dfs(s + "7")

dfs("")


print(ans)

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
	int n;
	cin>>n;
	long double arr[n],ans[n+1][2];
	
	for(int i = 0;i<n;i++){
		cin>>arr[i];
		ans[i][0] = 0;
		ans[i][1] = 0;
	}
	ans[n][0] = 0;
	ans[n][1] = 0;
	
	for(int i = 0;i<n;i++){
		for(int j = 0;j<=i+1;j++){
			ans[j][0] = 0;
			if(j==0){
				ans[j][0] = ans[j][1]*(1-arr[i]);
				if(i==0)
					ans[j][0] = (1-arr[i]);
			}else{
				if(i==0){
					ans[j][0] = arr[i];
				}else{				
					ans[j][0] += ans[j-1][1]*arr[i];
					
					if(j<=i){
						ans[j][0] += ans[j][1]*(1-arr[i]);
					}
				}
			}
			
			//cout<<ans[j][0]<<" ";
		}
		
		for(int j = 0;j<=i+1;j++)
			ans[j][1] = ans[j][0];
		//cout<<endl;
	}
	
	long double an = 0;
	
	for(int i = n;i>n/2;i--){
		an = an + ans[i][0];
	}
	
	cout<<prec(10)<<an;
	return 0;
}

//Total solved problems:- 13



Measured memory_bytes: 384
using System;
using System.Diagnostics;

namespace Coin_Changing_Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Split(' ');
            int n = int.Parse(temp[0]); int m = int.Parse(temp[1]); //n??¨m?????\???
            int[] coin = new int[m];
            temp = Console.ReadLine().Split(' ');
            for(int i = 0; i < m; i++)
            {
                coin[i] = int.Parse(temp[i]); //coin[]???coin?????????????¨??????????????????????
            }
            int[] dp = new int[n+1]; //dp[x]???x?????????????????????????°?????????°??¨??????
            for(int i= 1; i <= n; i++)
            {
                if (i == 1) dp[i] = 1;
                else dp[i] = 32767;
            }
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    if (i + coin[j] <= n) dp[i + coin[j]] = Math.Min(dp[i + coin[j]], dp[i] + 1);
                    else continue;
                }
            }
            Console.WriteLine(dp[n]);
        }
    }
}

Measured memory_bytes: 9316
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M, K;
    cin >> N >> M >> K;

    Rep (i, N+1) {
        Rep (j, M+1) {
            if (i * M + j * N - 2 * i * j == K) {
                cout << "Yes\n";
                return 0; 
            }
        }
    }

    cout << "No\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100010];
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n,m,a,b,c,d;
	cin>>n>>m>>a>>c>>b>>d;
	if((a>b&&c>d)||(b>a&&d>c)||(a>b&&a*n+c*m>b*n+d*m)||(b>a&&b*n+d*m>a*n+c*m))cout<<0<<endl;
	else if(a*n+c*m==b*n+d*m)puts("infinity");
	else{
		int x=abs(a*n+c*m-b*n-d*m),y=abs(a*n-b*n);
		cout<<1+(y/x)*2-(int)((y/x)*x==y)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    for(int i=n;i<=1000;i++){
        string s=to_string(i);
        if((s[0]==s[1]&&s[0]==s[2])){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N = int(input())

count = -1

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

tf = True

while tf is True:
    count += 1
    for i in range(N):
        if a[i] % 2  != 0:
            tf = False
            break
        else:
            a[i] = a[i] / 2

print(count)

Measured memory_bytes: 3060
from bisect import bisect_right

N = int(input())
S = input()

nums = {i:[] for i in range(10)}

for idx, s in enumerate(S):
    nums[int(s)].append(idx+1)
    
length = {i:len(nums[i]) for i in range(10)}
ans = 0
for i in range(1000):
    idx = 0   
    
    for j in str(i).zfill(3):
        n = int(j)
        x = bisect_right(nums[n], idx)
        if length[n] == x: break
        idx = nums[n][x]
    else: 
        ans += 1

print(ans)

Measured memory_bytes: 4340
import numpy as np

N = int(input())
s = []
for i in range(N):
  s.append(input())
    
M = int(input())
t = []
for i in range(M):
  t.append(input())

s = np.array(s)
t = np.array(t)
s_uni = np.unique(s)

ans = 0
for i,ch_s in enumerate(s_uni):
  ans_tmp = (s==ch_s).sum()
  ans_tmp -= (t==ch_s).sum()
  if ans_tmp > ans:
    ans = ans_tmp
print(int(ans))

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 200005;

int n, m, K, A[N], B[N];

int main() {
    scanf("%d %d %d", &n, &m, &K);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    
    for (int i = 1; i <= m; i++) {
        scanf("%d", &B[i]);
    }
    
    int sumB = 0;
    int ptrB = 0;
    while (ptrB < m && sumB <= K) {
        ptrB++;
        sumB += B[ptrB];
    }
    while (ptrB > 0 && sumB > K) {
        sumB -= B[ptrB];
        ptrB--;
    }
    
    int ans = ptrB;
    int sumA = 0;
    for (int i = 1; i <= n; i++) {
        sumA += A[i];
        while (ptrB > 0 && sumA + sumB > K) {
            sumB -= B[ptrB];
            ptrB--;
        }
        if (sumA + sumB > K) {
            break;
        }
        ans = max(ans, i + ptrB);
    }
    
    printf("%d\n", ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size(), u = 1, v = 1;
  bool b = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) b = true;
  if(b || s[0] != '1' || s[n - 1] != '0') {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n / 2 + 1) s[n / 2 + 1 + i] = '0';
  rep(i, n - 1) {
    cout << u << ' ' << ++v << '\n';
    if(s[n - 2 - i] == '1') u = v;
  }
}

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

int main() {
	string a,b;
	vector <char> vec;
	cin>>a>>b;
//	cout<<a<<" "<<b<<endl;
	int m,n;
	m=a.length();
	n=b.length();
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0||j==0)
            dp[i][j]=0;
            else{
                if(a[i-1]==b[j-1])
                dp[i][j]=1+dp[i-1][j-1];
                else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
   // for(int i=0;i<=m;i++)
   // {
     //   for(int j=0;j<=n;j++)
      //  { cout<<dp[i][j]<<" ";
     //   }
      //  cout<<endl;
   // }
 int  i=m;
  int  j=n;
            while(i!=0&&j!=0)
           { 
            
                int k=max(dp[i-1][j],dp[i][j-1]);
                if(dp[i][j]>k)
                {  // cout<<a[i-1]<<endl;
                    vec.push_back(a[i-1]);
                    i--;
                    j--;
                }
                else{ if(dp[i][j]==dp[i-1][j])
                       i=i-1;
                       else j=j-1;
                    
                }
            }
            for(int i=vec.size()-1;i>=0;i--)
            cout<<vec[i];
            cout<<endl;
        
    
	return 0;
}


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

using namespace std;
#define sync   freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define ll long long
const unsigned int M = 1000000007;
int main(){
	// sync;
	int h,w;
	cin>>h>>w;;

	vector<vector<char>>grid(h+1,vector<char>(w+1)); 
	vector<vector<ll >>ans(h+1,vector<ll>(w+1,0));
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cin>>grid[i][j];
	}
for(int i=1;i<=h;i++){
	if(grid[i][1]=='.'){
		ans[i][1]=1;
	}
	else 
		break;
}

for(int i=1;i<=w;i++){
	if(grid[1][i]=='.'){
		ans[1][i]=1;
	}
	else 
		break;
}
	for(int i=2;i<=h;i++){
		for(int j=2;j<=w;j++){
			if(grid[i][j]=='.'){
				if(grid[i-1][j]=='.'){
					ans[i][j]=(ans[i][j]+ans[i-1][j]%M)%M;
				}
				if(grid[i][j-1]=='.'){
					ans[i][j]=(ans[i][j]+ans[i][j-1]%M)%M;
				}		

			}
		}
	}
cout<<ans[h][w]<<endl;
}


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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  const long double PI = 3.14159265358979323l;
  long double rad = 2 * PI * (H / 12.0l + (M / 60.0l) / 12.0l - M / 60.0l);
  cout << fixed << setprecision(10)
       << sqrt(A * A + B * B - 2 * A * B * cosl(rad)) << endl;
}


Measured memory_bytes: 4148
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <string>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
  int i,j,k,l;
  int n,m;
  int valid[50005] = {1,0,};
  int kazu[50005] = {0};
  cin >> n >> m;
  rep(i,m) {
    int c;
    cin >> c;
    rep(j,50000) {
      if(j+c > 50000) break;
      if(valid[j]) {
        if(valid[j+c] == 0 
          || kazu[j+c] > kazu[j]+1) {
          valid[j+c] = 1;
          kazu[j+c] = kazu[j]+1;
        }
      }
    }
  }
  cout << kazu[n] << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll res = 0, cur;
    cin >> cur;
    for (ll i = 1, x; i < n; ++i) {
        cin >> x;
        res += min(a * (x - cur), b);
        cur = x;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    string s , t;
    cin >> s >> t;
    int n = int (s.length());
    int m = int (t.length());
    int ans = inf;
    for (int i = 0; i + m - 1 < n; i++){
        int ch = 0;
        for (int j = i; j <= i + m - 1; j++){
            ch += s[j] != t[j - i];
        }
        ans = min (ans , ch);
    }
    cout << ans << endl;
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



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

int main(void)
{
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
    int ans=inf;
    for(int i=0;i<=n-m;++i)
    {
        int now=0;
        for(int j=0;j<m;++j)
            now+=s[i+j]==t[j]?0:1;
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-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()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    dd0 = [(0,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(0,0)]
    dd1 = [(0,1),(1,1),(1,0),(0,-1),(-1,0),(-1,1),(0,0)]
    dd = [dd0, dd1]

    def f(n):
        sx,sy,gx,gy = LI()
        n = I()
        fs = set([tuple(LI()) for _ in range(n)])
        lx,ly = LI()

        def search(s, g):
            d = collections.defaultdict(lambda: inf)
            s = tuple(list(s) + [0])
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                if (u[0],u[1]) == g:
                    return k
                v[u] = True
                ddi = 0 if u[0] % 2 == 0 else 1
                di,dj = dd[ddi][abs(u[0]*u[1]*u[2])%6]
                nu = (u[2] + 1) % 6
                uv = (u[0]+di, u[1]+dj, nu)
                if d[uv] > k and abs(uv[0]) <= lx and abs(uv[1]) <= ly and not ((uv[0],uv[1]) in fs):
                    d[uv] = k
                    heapq.heappush(q, (k, uv))

                vd = k + 1
                for di,dj in dd[ddi]:
                    uv = (u[0]+di, u[1]+dj, nu)
                    if v[uv] or abs(uv[0]) > lx or abs(uv[1]) > ly or (uv[0],uv[1]) in fs:
                        continue
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            return None
        r = search((sx,sy),(gx,gy))
        if r is None:
            return -1
        return r

    while 1:
        n = 1
        if n == 0:
            break
        rr.append(f(n))
        break
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 58324
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
vector<int> v[100005];
deque<int> ans;
bool vis[100005];
void dfs(int node,int pos)
{
	for (int u:v[node])
	{
		if (!vis[u])
		{
			if (pos)
			ans.push_back(u);
			else
			ans.push_front(u);
			vis[u]=1;
			dfs(u,pos);
			break;
		}
	}
}
int main()
{
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	while (m--)
	{
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vis[a]=1;
	vis[b]=1;
	ans.push_back(a);
	ans.push_back(b);
	dfs(a,0);
	dfs(b,1);
	printf("%d\n",ans.size());
	for (int i:ans)
	printf("%d ",i);
}

Measured memory_bytes: 10496
s=gets
a=s[0,2].to_i
b=s[2,2].to_i
 
 
 
if(0<a && a<=12 && 0<b && b<=12 )
    print "AMBIGUOUS"
elsif(0<a && a<=12 )
    print "MMYY"
elsif(0<b && b<=12)
    print "YYMM"
else
    print "NA"
end

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

signed main(){
	int N, M;
	cin >> N >> M;
	vector<ll> H(N);
	for(int i = 0; i < N; i++)
		cin >> H.at(i);
	vector<int> A(M), B(M);
	for(int i = 0; i < M; i++)
		cin >> A.at(i) >> B.at(i);

	vector<bool> hills(N, true);
	for(int i = 0; i < M; i++){
		if(H.at(A.at(i)-1) < H.at(B.at(i)-1))
			hills.at(A.at(i)-1) = false;
		else if(H.at(A.at(i)-1) > H.at(B.at(i)-1))
			hills.at(B.at(i)-1) = false;
		else{
			hills.at(A.at(i)-1) = false;
			hills.at(B.at(i)-1) = false;
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++)
		if(hills.at(i))
			ans++;

	cout << ans << endl;

	return 0;	
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int L;

signed main()
{
    cin >> L;
    int n = 1, cnt = 0ll;
    while(n <= L){
        n *= 2;
        cnt++;
    }
    n /= 2;
    int l = L;
    int M = 0ll;
    while(l){
        if(l & 1ll){
            M++;
        }
        l >>= 1;
    }
    printf("%lld %lld\n", cnt, M - 1 + (cnt - 1) * 2);
    int a = 1;
    for(int i = 1; i < cnt; i++){
        printf("%lld %lld %lld\n", i, i + 1, a);
        printf("%lld %lld %lld\n", i, i + 1, 0);
        a *= 2ll;
    }
    l = L;
    for(int i = cnt - 2; i >= 0; i--){
        if(L & (1ll << i)){
            printf("%lld %lld %lld\n", i + 1, cnt, L - (1ll << i));
            L -= (1ll << i);
        }
    }

    return 0;
}

/*


*/


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt();
  	int[] nums=new int[n];
  	int[] fnums=new int[n];
  	nums[0]=0;
  	for(int i=1;i<n;i++){
  		nums[i]=sc.nextInt();
  		fnums[nums[i]-1]++;
  	}
  	for(int i=0;i<n;i++){
  		System.out.println(fnums[i]);
  	}
  }
}

Measured memory_bytes: 63072
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b && a != c || a == c && a != b || b == c && b != a) printf("Yes\n");
	else printf("No\n"); 
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>


int main(void){
	char str[100000];
	scanf("%s",str);
	int length=strlen(str);
	int half=(length+1)/2;
	char odd[half];
	int temp;
	for(int i=0;i<length;i++){
		if(i%2==0){
			printf("%c",str[i]);
		}
	}
	/*for(int i=0;i<half;i++){
		temp=i*2;
		odd[i]=str[temp];
	}
	
	printf("%s",odd);*/
	return 0;
} 

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

cnt=[0]*(n+2-k)
for i in range(n+2-k):
    imin=int((i+k-1)*(i+k)/2)
    imax=int((2*n-i-k+1)*(i+k)/2)
    #print(imin,imax)
    num=imax-imin+1
    cnt[i]=num
print(sum(cnt)%(10**9+7))

Measured memory_bytes: 66900
import           Control.Applicative
import           Control.Monad
import           Data.List

main = do
    n <- readLn
    r <- map read <$> replicateM n getLine :: IO [Int]
    print . snd . foldl' f (head r, -9999999999) $ tail r
  where
    f :: (Int, Int) -> Int -> (Int, Int)
    f (minv, maxv) r =
        let maxv' = max maxv (r - minv)
            minv' = min minv r
        in (minv', maxv')



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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int r;
    cin>>r;
    if(r<1200)
        cout<<"ABC";
    else if(r<2800)
        cout<<"ARC";
    else
        cout<<"AGC";
    cout<<'\n';
    return 0;
}   

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	string a, b;
	cin >> a >> b;
	int answer = 0;
	for (int i = 0; i < 3; i++) if (a[i] == b[i]) answer += 1;
	cout << answer;

	return 0;
}


Measured memory_bytes: 764
""" C
    https://atcoder.jp/contests/aising2020/tasks/aising2020_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N):
    maxi = int(math.sqrt(N))
    result = dict()
    for x in range(1, maxi+1):
        for y in range(1, maxi+1):
            for z in range(1, maxi+1):
                n = pow(x, 2) + pow(y, 2) + pow(z, 2) + x*y + y*z + z*x
                if n not in result.keys():
                    result[n] = 1
                else:
                    result[n] += 1

    for n in range(1, N+1):
        if n in result.keys():
            print(result[n])
        else:
            print(0)

if __name__ == "__main__":
    _N = readInteger()

    main(_N)

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

int main() {
  int n,temp,a,sum;
  cin >> temp;
  a=temp;
  n=a/10+1;
  for(int i=0;i<n;i++){
    sum+=a%10;
    a/=10;
  }
  string ans;
  if(temp%sum==0){
    ans="Yes";
  }else{
    ans="No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,l;
    cin >> n >> l;
    vector<string> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for(auto e:v){
        cout << e;
    }
    cout << endl;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$H = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$P = explode(" ",trim(fgets(STDIN)));
//$H = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}

/*
$q = new SplQueue();

$q->enqueue($H);
$res = 1;
while($q->isEmpty()==false) {
  $v = $q->dequeue();
  if ($v == 1) continue;
  $q->enqueue(intdiv($v,2));
  $q->enqueue(intdiv($v,2));
  $res += 2;
}
printf("%d\n",$res);
 */
$r = 1;
while(1) {
  $ww = pow(2,$r);
  if ($ww > $H) break;
  $r+=1;
}
printf("%d\n",$ww-1);


Measured memory_bytes: 4732
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_L (100000)

string WORDS[4] = {"dream", "dreamer", "erase", "eraser"};
string S;

bool match(int n) {
  if (n == S.size()) return true;

  for (int i = 0; i < 4; i++) {
    string w = WORDS[i];
    bool flag = true;
    for (int j = 0; j < w.size(); j++) {
      if (n + j > S.size() || w[j] != S[n + j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      if (match(n + w.size())) return true;
    }
  }

  return false;
}

void solve() {
  if (match(0)) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}

int main() {
  for (int i = 0; i < 4; i++) {
    std::reverse(WORDS[i].begin(), WORDS[i].end());
  }
  cin >> S;
  std::reverse(S.begin(), S.end());
  
  solve();
  
  return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>

typedef unsigned long long ull;

const ull B=100000007;

using namespace  std;

void RabinKarp(string,string,string);

char ap[]="apple",pe[]="peach";
string str;

int main(void){
  getline(cin,str);
  RabinKarp("apple","peach",str);
  cout << str << endl;
}

void RabinKarp(string a,string b,string c){
  int al=a.size(),bl=b.size(),cl=c.size();

  ull t=1;
  for(int i=0;i<al;i++)t*=B;

  ull ah=0,bh=0,ch=0;
  for(int i=0;i<al;i++){
    ah=ah*B+a[i];
    bh=bh*B+b[i];
    ch=ch*B+c[i];
  }

  for(int i=0;i+al<=cl;i++){
    if(ah==ch)for(int j=i;j<i+al;j++)str[j]=pe[j-i];
    else if(bh==ch)for(int j=i;j<i+bl;j++)str[j]=ap[j-i];

    if(i+al<cl)ch=ch*B+c[i+al]-c[i]*t;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include<map>
#include<vector>
using namespace std;
void factorize(int a,vector<int> vec,map<int,int> &mp)
{
    int k=vec[0];
    int i=0;
    int count=0;
    while(a&&i<vec.size())
    {
        if(a%k==0)
       {
       a=a/k;
       count++;
       }
        else {
            mp[k]+=count;
        i++;
        k=vec[i];
        count=0;
        }
    }
   
}

int main() {
   int n;
   cin>>n;
   int arr[1001];
   for(int i=0;i<1001;i++)
   arr[i]=1;
   for(int i=2;i<1001;i++)
   {
       if(arr[i])
       {
           for(int j=i*i;j<1001;j+=i)
           arr[j]=0;
       }
   }
   vector<int> vec;
  // map<int,int> mp;
   for(int i=2;i<1001;i++)
   {
       if(arr[i])
       vec.push_back(i);
   }
   map<int,int> mp;
   for(int i=2;i<=n;i++)
   {
       factorize(i,vec,mp);
   }
   long long int res=1;
   for(auto it=mp.begin();it!=mp.end();it++)
   {
      res=(res*(it->second+1))%1000000007;
   }
   cout<<res%1000000007<<endl;
}


Measured memory_bytes: 256
// review
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;
const int MAXN = 10010;
const string INVALID_STR = "invalid";

vector<int> mCount = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int n, m;
int a[10];
string dp[MAXN];

void update(string &l, string r) {
  if (l == INVALID_STR || l.size() < r.size() ||
      (l.size() == r.size() && l < r)) {
    l = r;
  }
}

void solve() {
  for (int i = 0; i <= n; i++) {
    dp[i] = INVALID_STR;
  }
  dp[0] = "";
  for (int i = 0; i <= n; i++) {
    if (dp[i] == INVALID_STR) {
      continue;
    }
    for (int j = 0; j < m; j++) {
      stringstream ss;
      ss << a[j];
      string str = ss.str();
      update(dp[i + mCount[a[j] - 1]],
             (dp[i][0] > str[0]) ? dp[i] + str : str + dp[i]);
    }
  }
  cout << dp[n] << endl;
}

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


Measured memory_bytes: 34944
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, T, p, m, s, t, V;
vector<edge> G[20005];
llint dist[20005];
void dijkstra(vector<edge> G[], llint S, llint dist[])
{
	for(int i = 0; i < V; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue<P, vector<P>, greater<P> > Q;
	Q.push(P(0, S));
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push(P(dist[G[v][i].to], G[v][i].to));
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> n >> T >> p >> m >> s >> t;
		if(n == 0) break;
		
		V = (T+1)*n;
		for(int i = 0; i < V; i++) G[i].clear();
		
		llint x;
		for(int i = 1; i <= p; i++){
			cin >> x;
			for(int j = 0; j < T; j++) G[(j+1)*n+x].push_back(edge(j*n+x, 1));
		}
		
		llint u, v, w;
		for(int i = 1; i <= m; i++){
			cin >> u >> v >> w;
			for(int j = 0; j+w <= T; j++){
				G[j*n+u].push_back(edge((j+w)*n+v, w));
				G[j*n+v].push_back(edge((j+w)*n+u, w));
			}
		}
		
		dijkstra(G, s, dist);
		
		llint ans = inf;
		for(int i = 0; i <= T; i++) ans = min(ans, dist[i*n+t]);
		if(ans > inf/2) cout << "Help!" << endl;
		else cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7632