akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> VI;
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
signed main()
{
	fastio;
	unsigned int n, m;
	cin >> n >> m;
	if (n == 1 || m == 1) {
		cout << 1 << endl;
	}
	else
	cout << ((n + 1) / 2)*((m + 1) / 2) + (n - (n + 1) / 2)*(m / 2) << endl;

}


Measured memory_bytes: 256
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.isP, self.P = self.compute(N)

    def compute(self, N):
        isP, P = [True] * (N + 1), []
        for i in range(2, N+1):
            if isP[i]:
                P.append(i)
                for j in range(2*i, N+1, i):
                    isP[j] = False
        return isP, P

    def factorization(self, x):
        ret = []
        for p in self.P:
            cnt = 0
            while x % p == 0:
                x /= p
                cnt += 1
            ret.append((x, cnt))
        if x > 1:
            ret.append((x, 1))
        return ret

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p, cnt in pn.factorization(N):
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
print(ans)

Measured memory_bytes: 82368
#include<bits/stdc++.h>
using namespace std;
int i,j,x,y,r,W,n,m[4],a[4][100];
int dfs(int s,int i,int w,int v)
{
	if(s>3)return r=r<v?r:v;
	dfs(s+1,0,w,v);
	if(i<m[s]&&x+s<=w)
	{
		dfs(s,i+1,w-x-s,v+a[s][i]);
		dfs(s+1,0,w-x-s,v+a[s][i]);
	}
}
int main()
{
	scanf("%d%d%d%d",&n,&W,&x,&y);
	a[0][m[0]++]=-y;
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&y);
		a[j-x][m[j-x]++]=-y;
	}
	for(i=0;i<4;++i)
		sort(a[i],a[i]+m[i]);
	dfs(0,0,W,0);
	printf("%d",-r);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		for (int i = a; i <= b; i++) {
			if(i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}


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

using namespace std;

const int INF = (1<<28);
int dp[1010][210];

int main()
{
    
    int n,m,x,y,t,r,z[1010],ans;
    char sl;
    int land[210][210],sea[210][210];
    
    while(cin >> n >> m,n!=0||m!=0){
        
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                land[i][j] = INF;
                sea[i][j] = INF;
            }
            land[i][i] = 0;
            sea[i][i] = 0;
        }
    
        for(int i=0;i<m;i++){
            cin >> x >> y >> t >> sl;
            if(sl == 'L'){
                land[x][y] = t;
                land[y][x] = t;
            }
            else if(sl == 'S'){
                sea[x][y] = t;
                sea[y][x] = t;
            }
        }
    
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                for(int k=1;k<=n;k++){
                    land[j][k] = min(land[j][k],land[j][i]+land[i][k]);
                    sea[j][k] = min(sea[j][k],sea[j][i]+sea[i][k]);
                }
            }
        }
    
        cin >> r >> z[0];
        fill_n(*dp,1010*210,INF);
        dp[0][ z[0] ] = 0;
        for(int i=1;i<r;i++){
            cin >> z[i];
            for(int j=1;j<=n;j++){
                dp[i][j] = min(dp[i][j],dp[i-1][j]+land[ z[i-1] ][ z[i] ]);
                for(int k=1;k<=n;k++){
                    dp[i][k] = min(dp[i][k],dp[i-1][j]+land[ z[i-1] ][j]+sea[j][k]+land[k][ z[i] ]);
               }
            }
        }
    
        ans = INF;
        for(int i=1;i<=n;i++) ans = min(ans,dp[r-1][i]);
        cout << ans << endl;
    }
    
    return(0);
}


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

int main(){
 string s;
  cin>>s;
  int n=s.size();
  bool a=true,b=true,c=true;
  for(int i=0;i<n;i++){
  	if(s[i]!=s[n-1-i]){
    	a=false;
    }
  }
  for(int i=0;i<(n-1)/2;i++){
  	if(s[i]!=s[(n-1)/2-1-i]){
    	b=false;
    }
  }
  for(int i=(n+3)/2-1;i<n;i++){
  	if(s[i]!=s[n-i+(n+3)/2-2]){
    	b=false;
    }
  }  
  if(a&&b&&c) cout<<"Yes";
  else cout<<"No";
 
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define MAX_Q 100001
typedef long long ll;
const int DAT_SIZE = (1 << 18) - 1;
// 入力
int N, Q;
// int A[MAX_N];
int q[MAX_Q], s[MAX_Q], t[MAX_Q], x[MAX_Q];
// セグメント木
ll data[DAT_SIZE], datb[DAT_SIZE];
// [a, b)にxを加算する
// kは節点の番号で、区間[l, r)に対応する
void add(int a, int b, int x, int k, int l, int r) {
	if (a <= l && r <= b) {
		data[k] += x;
	}
	else if (l < b && a < r) {
		datb[k] += (min(b, r) - max(a, l)) * x;
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
	}
}
// [a, b)の和を計算する
// kは節点の番号で、区間[l, r)に対応する
ll sum(int a, int b, int k, int l, int r) {
	if (b <= l || r <= a) {
		return 0;
	}
	else if (a <= l && r <= b) {
		return data[k] * (r - l) + datb[k];
	} else {
		ll res = (min(b, r) - max(a, l)) * data[k];
		res += sum(a, b, k * 2 + 1, l, (l + r) / 2);
		res += sum(a, b, k * 2 + 2, (l + r) / 2, r);
		return res;
	}
}

int main(){
	cin >> N >> Q;
	// for (int i = 0; i < N; i++) {
	// 	add(i, i+1, A[i], 0, 0, N);
	// }
	for (int i = 0; i < Q; i++) {
		cin >> q[i];
		if (q[i] == 0) {
			cin >> s[i] >> t[i] >> x[i];
		} else {
			cin >> s[i] >> t[i];
		}
	}
	for (int i = 0; i < Q; i++) {
		if (q[i] == 0) {
			add(s[i]-1, t[i], x[i], 0, 0, N);
		} else {
			cout << sum(s[i]-1, t[i], 0, 0, N) << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 7716
program main
  implicit none
  integer :: h, w, x, y, l, r
  character(2000) :: s(2000)
  integer, allocatable :: tate(:, :), yoko(:, :)
  read *, h, w
  allocate (tate(w, h), yoko(w, h))
  do y = 1, h
    read *, s(y)
  end do
  yoko = 0
  tate = 0
  do y = 1, h
    do l = 1, w
      if ((l == 1 .or. s(y)(l - 1:l - 1) == "#") .and. s(y)(l:l) == ".") then
        do r = l, w
          if (r == w .or. s(y)(r + 1:r + 1) == "#") exit
        end do
        do x = l, r
          yoko(x, y) = r - l + 1
        end do
      end if
    end do
  end do
  do x = 1, w
    do l = 1, h
      if ((l == 1 .or. s(l - 1)(x:x) == "#") .and. s(l)(x:x) == ".") then
        do r = l, h
          if (r == h .or. s(r + 1)(x:x) == "#") exit
        end do
        do y = l, r
          tate(x, y) = r - l + 1
        end do
      end if
    end do
  end do
  print "(i0)", maxval(yoko + tate - 1)
end program main


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int a, b;
  cin >> a >> b;

  int sum = 0;
  if (a >= b) {
    sum += a;
    sum += max(a - 1, b);
  } else {
    sum += b;
    sum += max(a, b - 1);
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> t(n-1);
    for(int i=0; i<n-1; ++i)
        cin >> t[i];

    vector<vector<int> > dp(n/2+1, vector<int>(2, INT_MAX/2));
    dp[0][0] = 0;
    for(int i=0; i<n-1; ++i){
        vector<vector<int> > nextDp(n/2+1, vector<int>(2));
        for(int j=0; j<=n/2; ++j){
            nextDp[j][0] = dp[j][1] + t[i];
            nextDp[j][1] = dp[j][1];
            if(j > 0){
                nextDp[j][0] = min(nextDp[j][0], dp[j-1][0]);
                nextDp[j][1] = min(nextDp[j][1], dp[j-1][0] + t[i]);
            }
        }
        dp.swap(nextDp);
    }

    int ret = min(dp[n/2-1][0], dp[n/2][1]);
    cout << ret << endl;
}

Measured memory_bytes: 1220
int main(void)
{
    char s[11],t[12];
    scanf("%s\n%s",s,t);
    if(strncmp(s,t,strlen(s))==0){
        if(strlen(t) - strlen(s) == 1){
            printf("Yes\n");
        }else{printf("No\n");
        }
    }else{
        printf("No\n");
    }
    return 0;
}

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

using namespace std;

int main(){
        int a, b;
        cin>>a>>b;
        int res=0;
        for(int i=a;i<=b;i++){
                if(i%10==i/10000&&(i%100)/10==(i/1000)%10){
                        res++;
                }
        }
        cout<<res<<endl;
        return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
map<char, int> mp;

int main(void){
    char s[4];
    cin >> s;
    
    for(int i = 0; i < 4; i++){
        auto itr = mp.find(s[i]);        // "xyz" が設定されているか？
        if( itr != mp.end() ) {
            mp[s[i]] += 1;
        } else {
            mp[s[i]] = 1;
        }
    }
    
    if(mp.size() != 2){
        cout << "No" << endl;
        return 0;
    } else{
        for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
            if(itr->second != 2){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	double x, h;
	while (cin >> x >> h)
	{
		if (x == 0 && h == 0)
		{
			break;
		}

		double s = x * x;

		double y = sqrt((x * x / 4) + h * h);

		s += 2 * (x * y);
		cout << fixed << setprecision(6) << s << endl;
	}
}


Measured memory_bytes: 3264
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+1;
const ll inf = 1e12;


ll ans[MAX];
int main(){
	ll n,l,r,d;
	cin >> n;
	
	f(i,1,101){
		f(j,1,101){
			f(k,1,101){
				ll aux = i*i + j*j + k*k + i*j + j*k +i*k;	
				if(aux<MAX)
					ans[aux]++;
			}
		}
	}
	f(i,1,n+1) cout << ans[i] << endl;
}



Measured memory_bytes: 4088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x:usize,
        y:usize,
        z:usize,
    }
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include<stdio.h>

#define MAX 500000
#define SIZE 1000000001

int cnt = 0;
int array [MAX];
int LEFT [MAX], RIGHT [MAX];

int main() {
	int number;
	scanf("%d", &number);
	for (int i = 0; i < number; i++) {
		scanf("%d", &array[i]);
	}
	mergeSort(array, 0, number);

	for (int i = 0; i < number; i++) {
		printf("%d", array[i]);
		if (i != number - 1)printf(" ");
	}
	printf("\n%d\n", cnt);
	return 0;
}

void merge(int array[], int left, int mid, int right) {
	int num1 = mid - left;
	int num2 = right - mid;
	int I, J;
	for (int i = 0; i < num1; i++) {
		LEFT[i] = array[left + i];
	}
	for (int i = 0; i < num2; i++) {
		RIGHT[i] = array[mid + i];
	}
	LEFT[num1] = SIZE; RIGHT[num2] = SIZE;
	I = 0; J = 0;
	for (int k = left; k < right; k++) {
		if (LEFT[I] <= RIGHT[J]) {
			array[k] = LEFT[I];
			I++;
			cnt++;
		}
		else {
			array[k] = RIGHT[J];
			J++;
			cnt++;
		}
	}
}

void mergeSort(int array[], int left, int right) {
	if (left + 1 == right)return;
	int mid = (left + right) / 2;
	mergeSort(array, left, mid);
	mergeSort(array, mid, right);
	merge(array, left, mid, right);
}




Measured memory_bytes: 5596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <stack>
#define Clear( x , y ) memset( x , y , sizeof(x) );
#define Qcin() std::ios::sync_with_stdio(false);
using namespace std;
typedef long long LL;
const int Maxn = 1e6 + 7;
const int Inf = 1e9 + 7;
int N , K;
int main()
{
	while( cin >> N >> K ){
		int x = N / K , y = x;
		if( N % K != 0 )	y += 1;
		printf("%d\n",abs(y-x));
	}
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();
        var res = 0L;
        for (var i = 1; 2 * n > i; i += 2)
        {
            res += a[i];
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 51780
#include<stdio.h>
#include<algorithm>
int a[100005];

int main()
{
	int n,i,x,X=0;
	long long s=0;
	scanf("%d", &n);
	for(i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	std::sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		s+=a[i];
		if(2*s<a[i+1])X=i;
	}
	printf("%d", n-X);
	return 0;
}

Measured memory_bytes: 640
k = list(map(int, input().split()))
if k[0] * 2 > k[1] or k[0] * 4 < k[1] or k[1] % 2 != 0:
  print("No")
else:
  a = []
  for i in range(k[0] + 1):
    a.append((i, k[0] - i))
  
  for i in a:
    re = i[0] * 2 + i[1] * 4
    if re == k[1]:
      print("Yes")
      break

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

A = []
for i in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

b = []
for i in range(N):
    b.append(int(input()))


result = 'No'

for i in range(3):
    if set(A[i]) <= set(b):
        result = 'Yes'

for i in range(3):
    if set([A[0][i], A[1][i], A[2][i]]) <= set(b):
        result = 'Yes'

if set([A[0][0], A[1][1], A[2][2]]) <= set(b):
    result = 'Yes'

if set([A[0][2], A[1][1], A[0][2]]) <= set(b):
    result = 'Yes'

print(result)

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

long addplus(int arr[], long sum, int idx, int len, string res) {    
    if(idx == len-1)
        if (res.length() != 0)
            return sum + stol(res + to_string(arr[idx]));
        else
            return sum + long(arr[idx]);
    else {
        return addplus(arr, sum + stol(res + to_string(arr[idx])), idx+1, len, "") + 
            addplus(arr, sum, idx+1, len, res + to_string(arr[idx]));     
    }
}

int main() {
    string tmp;
    cin >> tmp;
    int num[tmp.length()];
    for (int i=0; i<tmp.length(); ++i){
        num[i] = tmp[i] - '0';
    }    
    cout << addplus(num, 0, 0, tmp.length(), "") << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
3
1 1
1 1
2 1
*/
#include <bits/stdc++.h>
using namespace std;

int read() {
	int x = 0, c = getchar();
	for(; !(c > 47 && c < 58); c = getchar());
	for(; (c > 47 && c < 58); c = getchar()) x = x * 10 + c - 48;
	return x;
}

const int maxm = 2005;
const int maxn = 200005;
const int mod = 1e9 + 7;

void add(int &a, int b) {
	a = (a + b) % mod;
}

pair<int, int> p[maxn];

int n;
int f[maxm << 1][maxm << 1];
int mark[maxm << 1][maxm << 1];
int mul[maxn], inv[maxn];

int C(int k, int n) {
	if(k > n) return 0;
	return 1ll * mul[n] * inv[n - k] % mod * inv[k] % mod;
}

int main(){
	mul[0] = inv[0] = inv[1] = 1;
	for(int i = 1; i < maxn; ++ i) mul[i] = 1ll * i * mul[i - 1] % mod;
	for(int i = 2; i < maxn; ++ i) inv[i] = -1ll * (mod / i) * inv[mod % i] % mod + mod;
	for(int i = 2; i < maxn; ++ i) inv[i] = 1ll * inv[i] * inv[i - 1] % mod;

	n = read();
	for(int i = 1; i <= n; ++ i) {
		int x = read(), y = read();
		mark[x + maxm][y + maxm] ++;
		p[i] = make_pair(x, y);
	}

	for(int i = (maxm << 1) - 1; i; -- i)
		for(int j = (maxm << 1) - 1; j; -- j) {
			add(f[i][j], mark[i][j]);
			add(f[i - 1][j], f[i][j]);
			add(f[i][j - 1], f[i][j]);	
		}

	int Ans = 0;
	for(int i = 1; i <= n; ++ i) {
		int x = p[i].first, y = p[i].second;
		int cur = (0ll + f[maxm - x][maxm - y] + mod - C(x + x, (x + y) << 1)) % mod;
		add(Ans, 1ll * cur * (mod + 1) / 2 % mod);
	}
	printf("%d\n", Ans);
}

Measured memory_bytes: 97792
import sys
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    n,m = map(int,input().split())
    dist = [[1] * n for _ in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        dist[a][b] = 0
        dist[b][a] = 0
    
    cnt = 0
    for ptr in permutations(range(1,n)):
        flag = True
        if  dist[0][ptr[0]]:
            continue

        for i in range(n - 2):
            if dist[ptr[i]][ptr[i + 1]]:
                flag = False
                break
        
        if flag:
            cnt += 1
    
    print(cnt)

if __name__=='__main__':
    main() 

Measured memory_bytes: 3700
<?php
define('MOD', 998244353);
fscanf(STDIN, "%d", $N);
$D = explode(' ', trim(fgets(STDIN)));
$max = max($D);
$array = array_pad(array(), $max + 1, 0);
for ($i = 0; $i < $N; $i++) {
    $array[$D[$i]]++;
}
$ans = 1;
for ($i = 0; $i < $max; $i++) {
    for ($j = 0; $j < $array[$i + 1]; $j++) {
        $ans *= $array[$i];
        $ans %= MOD;
    }
}
if ($D[0] !== "0") {
    $ans = 0;
}
for ($i = 1; $i < $N; $i++) {
    if ($D[$i] === "0") {
        $ans = 0;
    }
}
printf("%d", $ans);


Measured memory_bytes: 16884
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long i = 1; i * i <= N; i++){
    if (N % i == 0){
      if (i < N / i - 1){
        ans += N / i - 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll                  long long
#define rep(i,n)            for(ll i=0;i<n;i++)
#define hell                1000000007LL
#define sd(x)               scanf("%d",&x)
#define slld(x)             scanf("%lld",&x)
#define ss(x)               scanf("%s",x)
#define slf(x)              scanf("%lf",&x)
#define vi                  vector<ll>
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll Max(ll a, ll b) { return a > b ? a : b; }
ll Min(ll a, ll b) { return a < b ? a : b; }
ll power(ll x, ll y,ll p)
{
    ll res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=((res%p)*(x%p))%p;
        y=y>>1;
        x=((x%p)*(x%p))%p;
    }
    return res;
}
int main()
{
    ll a,b,ans;
   slld(a);slld(b);
if(a<=0 && b>=0) ans=0;
else if(a>0) ans=1;
else
{
if((abs(a-b)+1)%2==0) ans=1;
else ans=-1;
}
if(ans==0) cout<<"Zero";
else if(ans==-1) cout<<"Negative";
else cout<<"Positive";
    return 0;
}

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

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            
            var line = Input.Line();
            Console.WriteLine(Sum(line, new List<int> { -1 }, 0));
        }

        static long Sum(String line, List<int> plus, int id) {
            if (id == line.Length - 1) {
                long s = 0;
                plus.Add(id);

                for (int i = 1; i < plus.Count; i++) {
                    s += long.Parse(line.Substring(plus[i - 1] + 1, plus[i] - plus[i - 1]));
                }
                return s;
            }

            return Sum(line, plus.Concat(new[] { id }).ToList(), id + 1) + Sum(line, plus, id + 1);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#20131114

while true
	n,m,p = gets.split(" ").map{|e|e.to_i}
	break if n==0 && m==0 && p==0
	array=[]
	count=0
	n.times{|t|
		array.push gets.to_i
		count+=array[t]
	}
	money = count*(100-p)
	p money/array[m-1] if array[m-1] != 0
	p 0 if array[m-1] == 0

end

Measured memory_bytes: 6104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h == 0) break;

        vector<int> posy(256), posx(256);
        for(int i=0; i<h; i++){
            string s;
            cin >> s;
            for(int j=0; j<w; j++){
                posy[s[j]] = i;
                posx[s[j]] = j;
            }
        }
        string s;
        cin >> s;
        int y=0, x=0;
        int ans = 0;
        for(char c: s){
            int p = c;
            ans += abs(posy[p]-y);
            ans += abs(posx[p]-x);
            ans++;
            y = posy[p];
            x = posx[p];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!

using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	vector<long long>data(N);
	for (int i = 0; i < N; i++) {
		cin >> data[i];
	}
	if (N <= K) {
		cout << 0 << endl;
		return 0;
	}
	sort(data.begin(), data.end());
	long long ans = 0;
	for (int i = 0; i < N - K; i++) {
		ans += data[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> PLI;
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int ufp[123456];
int ufr[123456];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 0;
	}
}

int ufind(int x){
	int ans;
	if(ufp[x] == x){
		return x;
	}else{
		ans = ufind(ufp[x]);
		ufp[x] = ans;
		return ans;
	}
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(ufr[x] > ufr[y]){
		ufp[y] = x;
	}else{
		ufp[x] = y;
	}
	if(ufr[x] == ufr[y]){
		ufr[y]++;
	}
}

int main(void){
	int n,i;
	ll xi,yi,ans=0ll;
	E e;
	vector<PLI> x,y;
	priority_queue< E, vector<E>, greater<E> > pq;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> xi >> yi;
		x.push_back(PLI(xi,i));
		y.push_back(PLI(yi,i));
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(i=1; i<n; ++i){
		pq.push(E(x[i].first-x[i-1].first,P(x[i-1].second,x[i].second)));
		pq.push(E(y[i].first-y[i-1].first,P(y[i-1].second,y[i].second)));
	}
	ufinit(n);
	while(!pq.empty()){
		e = pq.top();
		pq.pop();
		if(ufind(e.from) == ufind(e.to)){
			continue;
		}
		unionf(e.from,e.to);
		ans += e.cost;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9572
n = gets.to_i
l = gets.split.map(&:to_i).sort
cnt = 0
n.pred.times do |i|
  i.next.upto(n.pred) do |j|
    m = l[j] + l[i]
    x = l.bsearch_index{|z| z >= m}
    if x.nil?
      cnt += n - j - 1
    else
      cnt += x - j - 1
    end
  end
end
puts cnt

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef sweety_candy
	freopen("input.txt","rt",stdin);
	freopen("ouput.txt","w",stdout);
#endif	
	int a, b, x;
	cin >> a >> b >> x;                           	
	if (a <= x && a+b >= x)	cout << "YES";	
	else cout << "NO"; 
		
#ifdef sweety_candy
	cout << " Time elapsed: " << 1.0*clock() / LOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  int A[M];
  for(int i=0;i<M;i++){
    cin>>A[i];
  }
  int cost0=0;
  int costN=0;
  for(int i=X;i<=N;i++){
    for(int j=0;j<M;j++){
      if(A[j]==i)costN++;
    }
  }
  for(int i=X;i>=0;i--){
    for(int j=0;j<M;j++){
      if(A[j]==i)cost0++;
    }
  }
  cout<<min(cost0,costN)<<endl;
  return 0;
}

Measured memory_bytes: 256
#金額
num = input().split()
firstList = list( map((lambda x:int(x)),num))
num = input().split()
secoundList = list( map((lambda x:int(x)),num))
num = input().split()
thirdList = list( map((lambda x:int(x)),num))

t = firstList + secoundList + thirdList

flag = 0

if (t[0]-t[3]) == (t[1]-t[4]) == (t[2]-t[5]):
    if (t[6]-t[3]) == (t[7]-t[4]) == (t[8]-t[5]):
        if (t[6]-t[0]) == (t[7]-t[1]) == (t[8]-t[2]):
            if (t[1]-t[0]) == (t[4]-t[3]) == (t[7]-t[6]):
                if (t[1]-t[2]) == (t[4]-t[5]) == (t[7]-t[8]):
                    if (t[0]-t[2]) == (t[3]-t[5]) == (t[6]-t[8]):
                        flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 10000001;
  for (int p = 1; p <= 100; p++)
  {
    int suma = 0;
    for (int i = 0; i < n; i++)
      suma += (a[i] - p) * (a[i] - p);
    ans = min(suma, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
/*
PS C:\Users\cs18003\OneDrive\cpp> .\a.exe
7
2 1 3 1 1 2 1
4
*/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

int N;

int main() {
  cin >> N;
  vector<int> suretsu(N);
  for(int i = 0; i < N; i++){
    cin >> suretsu[i];
  }
  
  int plus = 0;//0 未定 1 上昇 2下降
  int count = 1;
  bool tancho = true;
  for(int i = 0; i < N-1; i++){
    if(suretsu[i] < suretsu[i+1]){
      plus = 1;
      break;
    }
    else if(suretsu[i] > suretsu[i+1]){
      plus = 2;
      break;
    }
  }

    for(int i = 0; i < N-1; i++){
      if(suretsu[i] < suretsu[i+1]){
        if(plus == 2){
          tancho = false;
          count++;
          plus = 0;
        }
        else{
          plus = 1;
        }
      }
      else if(suretsu[i] > suretsu[i+1]){
        if(plus == 1){
          tancho = false;
          count ++;
          plus = 0;
        }
        else{
         plus = 2;
        }
      }
    }

  if(tancho){
    cout << 1 <<endl;
  }
  else{
    cout << count <<endl;
  }
}


Measured memory_bytes: 640
#include<stdio.h>

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

	int a[n-1];
	int b[n];
	for(i=0;i<n;i++){
		b[i]=0;
	}
	for(i=0;i<n-1;i++){
		scanf("%d",&a[i]);
		b[a[i]-1]++;
	}

	for(i=0;i<n;i++){
		printf("%d\n",b[i]);
	}
	return 0;
}


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


int main() {
  int n, m, c; cin >> n >> m >> c;
  int B[m];
  for(int i = 0; i < m; i++) cin >> B[i];
  int A[n][m];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++)
      cin >> A[i][j];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int sum = 0;
    for(int j = 0; j < m; j++){
      sum += A[i][j]*B[j];
    }
    if(sum+c>0)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3508
import math
N = int(input())
flg = 0

ans = 0

for x in range(50000):
	if math.floor(x * 1.08) == N:
		flg = 1
		ans = x
		break
	elif math.floor(x * 1.08) > N:
		break
		
if flg:
	print(ans)
else:
	print(":(")

Measured memory_bytes: 38768
import Foundation
var str = readLine()!.components(separatedBy:" ")
var num = [Int]()
for i in str {
  num.append(Int(i)!)
}
var n = num[0]
var k = num[1]
var a = [Int]()
for j in 1...k {
  var d = Int(readLine()!)!
  var aa = readLine()!.components(separatedBy:" ")
  for l in aa {
    a.append(Int(l)!)
  }
}
let aset = Array(Set(a))
var vol = aset.count
print(n-vol)

Measured memory_bytes: 14372
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define NMAX 100000

int K = 1;
vector<int> tree[NMAX];
int colors[NMAX];

void dfs(int p, int p_color){
	int color = 1;
	for(int c:tree[p]){
		if(colors[c]) continue;
		colors[c] = color==p_color? ++color: color;
		K = max(K, color);
		dfs(c, color++);
	}
}

int main(){
	int N; cin>>N;
	int C[N-1];
	for(int i=0; i<N-1; ++i){
		int p; scanf("%d%d", &p, C+i); p--,C[i]--;
		tree[p].push_back(C[i]);
	}
	colors[0] = NMAX;
	dfs(0, -1);
	printf("%d\n", K);
	for(int c:C) printf("%d\n", colors[c]);
}

Measured memory_bytes: 7680
#include <stdio.h> 
int main() {
  long A, B, r, x, tmp;
  scanf("%ld", &A);
  scanf("%ld", &B);
  x = A * B;
  if(A < B){
    tmp = A;
    A = B;
    B = tmp;
  }
  r = A % B;
  while(r != 0){
    A = B;
    B = r;
    r = A % B;
  }
  printf("%ld\n", x/B);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int sum = 0;
    REP(i, a+1) {
        REP(j, b+1) {
            REP(k, c+1) {
                if(i*500 + j*100 + k*50 == x) sum++;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k,i,temp,check=0;
  scanf("%d%d",&n,&k);
  int num[11];
  for(i=0;i<10;i++)
    num[i]=0;
  for(i=0;i<k;i++){
    scanf("%d",&temp);
    num[temp]=1;
  }
  while(1){
    int temp=n;
    check=0;
    while(temp!=0){
      if(num[temp%10]!=0)
        check=1;
      temp/=10;
    }
    if(check==0){
      printf("%d\n",n);
      return 0;
    }
    else
      n++;
  }
  return 0;
}


Measured memory_bytes: 1712
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val k = sc.nextLong()

  println(abc161c(n, k))
}

private fun abc161c(n: Long, k: Long): Long {

  if (n <= k) {
    var ans = n
    val ansList = mutableListOf<Long>()
    while (!ansList.contains(ans)) {
      ansList.add(ans)
      ans = diff(ans, k)
    }
    return ansList.min()!!
  }

  val d = n % k
  val ans = Math.min(d, diff(d, k))

  return ans

}

private fun diff(n: Long, k: Long): Long {
  if (n > k) return n - k

  return k - n
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> P(m), Y(m);
    rep(i, m) cin >> P[i] >> Y[i];

    vector<vector<int>> vals(n + 1);
    rep(i, m) vals[P[i]].push_back(Y[i]);
    rep(i, n + 1) sort(vals[i].begin(), vals[i].end());

    rep(i, m)
    {
        printf("%06d", P[i]);
        int id = lower_bound(vals[P[i]].begin(), vals[P[i]].end(), Y[i]) - vals[P[i]].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 7808
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
#define INF 1e+9
#define MAX_V 300015

// <最短距離, 頂点の番号>
int d[MAX_V];

int main() {
    int n,m; cin >> n >> m;
    priority_queue<pair<int, int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    vector<vector<int>> g(3*n);
    rep(i,m){
        int u,v; cin >> u >> v;
        for(int j=0;j<3;j++){
            g[3*(u-1)+j].push_back(3*(v-1) + ((j+1)%3));
        }
    }
    int s,t; cin >> s >> t;
    rep(i,3*n) d[i] = INF;
    s = 3*(s-1);
    t = 3*(t-1);
    d[s] = 0;
    q.push({0,s});
    while(!q.empty()){
        int num = q.top().first;
        int v = q.top().second;
        q.pop();
        for(int i=0; i< g[v].size();i++){
            if(d[g[v][i]] > d[v]+1){
                d[g[v][i]] = d[v]+1;
                q.push({d[v]+1, g[v][i]});
            }
        }
    }
    if(d[t] == INF) cout << -1 << endl;
    else cout << (d[t]/3) << endl;
    return 0;
}

Measured memory_bytes: 17792
N = int(input())
D = [list(map(int,input().split())) for c in range(N)]
cnt = 0
ma = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt +=1
        if cnt>ma:
            ma = cnt
    else:
        cnt = 0

if ma >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
import java.util.Scanner;

public 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();
        int k = sc.nextInt();
        
        int max = Math.max(a, Math.max(b, c));
        int total = -max;
        for (int i = 0; i < k; i++) {
            max *= 2;
        }
        
        total += a + b + c + max;
        
        System.out.print(total);
    }
}


Measured memory_bytes: 21972
#E
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(N):
    B.append([A[i],i+1])
    
B.sort(reverse=True)

DP = [[0 for _ in range(N+1)] for _ in range(N+1)] #dp[x][y] x->1,2,3... y->N,N-1,N-2...
for i in range(N):
    I = i+1
    b,ind = B[i]
    
    for j in range(I+1):
        if j == 0:
            DP[j][I-j] = DP[j][I-j-1] + b*abs(N-(I-j)-ind+1)
        elif I-j == 0:
            DP[j][I-j] = DP[j-1][I-j] + b*abs(ind-j)
        else:
            DP[j][I-j] = max(DP[j][I-j-1]+b*abs(N-(I-j)-ind+1),DP[j-1][I-j]+b*abs(ind-j))
        
        
ans = 0
for i in range(N+1):
    ans = max(ans,DP[i][N-i])
    
#print(B)
print(ans)

Measured memory_bytes: 101836
#include<iostream>
using namespace std;
int main() {
	int a;
	int b;
	cin >> a;
	cin >> b;
	if (a + b > 16 || a > 8 || b > 8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
def fibonacci(n)
    memo = Array.new(100)
    memo[0] = 1
    memo[1] = 1
    for i in 2..n do
        memo[i] = memo[i - 1] + memo[i - 2]
    end
    return memo[n]
end

n = gets.to_i
res = fibonacci(n)
puts res


Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back

int mod,n;
vector<vector<int>> G;
vector<int> res,ans;
void dfs1(int u,int fa){
    res[u]=1;
    for(auto to:G[u]){
        if(to==fa) continue;
        dfs1(to,u);
        res[u]=ll(res[to]+1)*res[u]%mod;
    }
}
void dfs2(int root,int fa,ll now){
    ans[root]=((now+1)*res[root])%mod;
    vector<pii> pre,suf;
    for(auto to:G[root]){
        if(to==fa) continue;
        pre.pb({res[to]+1,to});
        suf.pb({res[to]+1,to});
    }
    for(int i=1;i<sz(pre);i++) pre[i].F=ll(pre[i-1].F)*pre[i].F%mod;
    for(int i=sz(suf)-2;i>=0;i--) suf[i].F=ll(suf[i+1].F)*suf[i].F%mod;
    for(int i=0;i<sz(pre);i++){
        ll l=(i==0?1:pre[i-1].F),r=(i==sz(pre)-1?1:suf[i+1].F);
        dfs2(pre[i].S,root,l*r%mod*(now+1)%mod);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>mod;
    G.resize(n+1);
    res.resize(n+1);
    ans.resize(n+1);
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs1(1,0);
    dfs2(1,0,0);
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 25316
from collections import deque

N, K, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

def solve(a, b):
    D = [-1] * (N + 1)

    if a == b:
        Q = deque([a])
        r = K // 2
        D[a] = 0
    else:
        Q = deque([a, b])
        r = (K - 1) // 2
        D[a] = D[b] = 0

    cnt = len(Q)
    while Q:
        v = Q.popleft()

        d = D[v] + 1
        if d > r:
            break

        for u in E[v]:
            if D[u] == -1:
                cnt += 1
                D[u] = d
                Q.append(u)

    return N - cnt


if K % 2 == 1:
    print(min(solve(a, b) for a, b in zip(*[iter(AB)] * 2)))
else:
    print(min(solve(a, a) for a in range(1, N + 1)))

Measured memory_bytes: 3948
/**
*    author:  yuya1234
*    created: 29.08.2020 21:11:38
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  ll n;
  cin>>n;

  ll *a=new ll[n];
  ll sum=0;

  REP(i,n)
  {
    cin>>a[i];
    sum+=a[i];
  }

  ll ans=0;
  ll mod=1000000007;

  REP(i,n-1)
  {
    sum-=a[i];
    ans+=(sum%mod)*a[i];
    ans%=mod;
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 5212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int c500 = X / 500;
		X %= 500;
		int c5 = X / 5;

		System.out.println(1000*c500 + 5*c5);

	}

}

Measured memory_bytes: 35688
s=list(set(input()))
test=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
test.sort()
s.sort()
if len(s)==len(test):
    print("None")
    exit()

i=0
while True:
    if len(s)<=i:
        print(test[i])
        break
        
    if test[i]!=s[i]:
        print(test[i])
        break
    i+=1
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  long result = S.size();
  for (long i = 0; i < S.size(); i++) {
    if (S[i] == S[i+1]) {
      result--;
      i+=2;
    }
  }
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<vector<ll>> dp(N, vector<ll>(S + 1, 0));
    vector<ll> sum(S + 1, 0);
    sum[0] = 1;
    rep(i, N) {
        dp[i] = sum;
        rep(j, S + 1){
            if(j - A[i] >= 0) {
                ll add = sum[j - A[i]];
                if(j - A[i] == 0) (add *= i + 1) %= mod;
                if(j == S) (add *= N - i) %= mod;
                (dp[i][j] += add) %= mod;
            }
        }
        rep(j, S + 1) {
            sum[j] = dp[i][j];
        }
    }
    output(sum[S]);

    
    return 0;
}


Measured memory_bytes: 70784
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,k=get_i
puts Math.log(n,k).to_i+1

Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B, T;
    cin >> A >> B >> T;
    cout << (int)((T + 0.5) / A) * B << endl;
}

Measured memory_bytes: 384