akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll MOD = 1e9 + 7;
ll Hash[1001][1001], a[1001][1001];

int main(void)
{
	ll h, w;
	cin >> h >> w;

	for(int i = 0; i < h; i++)
		for(int j= 0; j < w; j++)
			Hash[i][j] = a[i][j] = 0;

	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
		{
			char s;
			cin >> s;
			if(s == '#')
				Hash[i][j] = -1;
		}

	a[0][0] = 1;
	for(int i = 1; i < h; i++)
	{
		if(Hash[i][0] != -1)
			a[i][0] = a[i - 1][0];
		else
			a[i][0] = 0;
	}

	for(int i = 1; i < w; i++)
	{
		if(Hash[0][i] != -1)
			a[0][i] = a[0][i - 1];
		else
			a[0][i] = 0;
	}

	for(int i = 1; i < h; i++)
		for(int j = 1; j < w; j++)
		{
			if(Hash[i][j] != -1)
				a[i][j] = (a[i - 1][j] + a[i][j - 1]) % MOD;
		}


	cout << a[h - 1][w - 1] << endl;








	return 0;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

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

    int N;
    cin >> N;

    int counter = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a & 1)
            counter++;
    }

    if (counter & 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
 
class Program {
    static void Main (string[] args) {
          
 
        int n = int.Parse(Console.ReadLine ());
        string[] p = Console.ReadLine ().Split(' ');
 
        int ans = 0;
        for(int i=1;i<n -1 ;i++){
            int bef = int.Parse(p[i-1]);
            int cur = int.Parse(p[i]);
            int aft = int.Parse(p[i+1]);
            if(bef < cur && cur < aft || aft < cur && cur < bef) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>

using namespace std;

int s[10][10];

int main()
{
	for (int i=1;i<=3;i++)
		for (int j=1;j<=3;j++)
			scanf ("%d",&s[i][j]);
	
	bool flag = true;
	for (int i=2;i<=3;i++)
		for (int j=2;j<=3;j++)
			if ((s[i][j]-s[i-1][j] != s[i][1]-s[i-1][1]) || (s[i][j]-s[i][j-1] != s[1][j]-s[1][j-1]))
				flag = false;
	if (flag)
		printf ("Yes\n");
	else
		printf ("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e11
using namespace std;

const int maxn = 310000;

int n,K;
ll f[maxn]; bool v[maxn];

int main()
{
	scanf("%d%d",&K,&n);
	if(K%2==0)
	{
		printf("%d ",K/2);
		for(int i=2;i<=n;i++) printf("%d ",K);
		return 0;
	}
	f[0]=1;
	for(int i=1;i<=n;i++) 
	{
		if(v[i-1]) { v[i]=true;continue; }
		f[i]=f[i-1]*(ll)K+1ll;
		if(f[i]>=inf) v[i]=true;
	}
	ll now=0,ct=-1,oth;
	for(int i=1;i<=n;i++)
	{
		if(v[n-i+1])
		{
			now++; printf("%d ",K/2+1);
		}
		else
		{
			if(ct==-1) ct=now,oth=now+f[n-i+1]-1;
			else ++ct;
			int l=1,r=K;
			if(ct*2>=oth) break;
			while(l<=r)
			{
				int mid=l+r>>1;
				if((ct+(ll)mid*f[n-i])*2>=oth) r=mid-1;
				else l=mid+1;
			}++r; ct+=(ll)(r-1)*f[n-i];
			printf("%d ",r);
			if(ct*2>=oth) break;
		}
	}
	
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


struct edge
{
    int to, d;
};

vector<vector<edge>> G;
vector<int> seen;

void dfs(int pos, int from){
    for(auto next: G[pos]){
        if (next.to == from){
            continue;
        }
        if(seen[next.to] == -1){
            seen[next.to] = seen[pos] ^ next.d;
            dfs(next.to, pos);
        }
    }
}


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

   G.assign(N,vector<edge>());
    REP(i,N-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        w%=2;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }

    seen.assign(N,-1); //0...W, 1...B

    seen[0] = 0;

    dfs(0,-1);

    REP(i,N){
        cout << seen[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10704
gets
ds = gets.split.map(&:to_i).each_with_object(Hash.new(0)) do |c, h|
  h[c] += 1
end

gets
ts = gets.split.map(&:to_i).each_with_object(Hash.new(0)) do |t, h|
  h[t] += 1
end

puts ts.keys.all? { |t| ts[t] <= ds[t] } ? "YES" : "NO"


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

using namespace std;

long long p[200005], v[1003];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, k;
	double m, sum = 0;
	cin >> n >> k;
	for(long long i = 0; i < n; ++i) cin >> p[i];
	v[1] = 1;
	for(long long i = 2; i <= 1000; ++i) v[i] = i + v[i - 1];
	for(long long i = 0; i < k; ++i){
		sum += double(v[p[i]]) / double(p[i]);
//		cout << sum << " ";
	}
	m = sum;
//	cout << sum << endl;
	for(long long i = 0; i + k < n; ++i){
		sum -= double(v[p[i]]) / double(p[i]);
		sum += double(v[p[i + k]]) / double(p[i + k]);
		m = max(m, sum);
	}
	cout << fixed << setprecision(12) << m;

	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  ll mod=1000000007;
  int N;
  cin >> N;
  string s1,s2;
  cin >>s1 >> s2;
  ll ans =0;
  if(s1[0]==s2[0]) ans=3;
  else ans=6;
  for(int i=ans/3;i<N;i++){
    if(s1[i]==s2[i]){
      if(s1[i-1]==s2[i-1])ans = (ans*2)%mod;
      else ans = ans*1;
    }       
    else{
      if(s1[i-1]==s2[i-1])ans = (ans*2)%mod;
      else ans = (ans*3)%mod;
      i++;
    }
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll linf = 0x3f3f3f3f3f3f3f3f;

inline void chk_min(ll &a,ll b){ if(a>b) a=b;}

struct Queue
{
	int q[MAXN],hd,tl;
	Queue(void){ hd=tl=0;}
	inline bool empty(void){ return hd>=tl;}
	inline int front(void){ return q[hd+1];}
	inline int back(void){ return q[tl];}
	inline void push(int x){ q[++tl]=x;}
	inline void pop(void){ ++hd;}
}q;

int a[MAXN];
ll dp[MAXN];

int main(void)
{
	int n,e,t;
	scanf("%d%d%d",&n,&e,&t);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	memset(dp,0x3f,sizeof(dp));
	
	dp[0]=0;
	q.push(0);
	ll mn=linf;
	for(int i=1; i<=n; ++i)
	{
		while(!q.empty() && (a[i]-a[q.front()+1])*2 > t)
			chk_min(mn, dp[q.front()] - 2*a[q.front()+1]),
			q.pop();
		
		if(!q.empty()) chk_min(dp[i], dp[q.front()]+t);
		
		chk_min(dp[i], mn+2*a[i]);
		q.push(i);
	}
	printf("%lld\n",dp[n]+e);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	V count(27, 0);
	rep(i, n) {
		count[s[i] - 'a']++;
	}
	VVL dp(27, VL(27, 0)); // i番目までのアルファベットをj個ピックした時の部分列の個数
	dp[0][0] = 1;
	rep(i, 26) rep(j, 26) {
		dp[i + 1][j] += dp[i][j];
		dp[i + 1][j + 1] += dp[i][j] * count[i];
		dp[i + 1][j + 1] %= MOD;
	}
	ll ans = 0;
	rep1(i, 26) {
		ans += dp[26][i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0,A+1):
    for j in range (0,B+1):
        for k in range(0,C+1):
            tmp = i* 500 + j* 100 + k*50
            if tmp == X:
                ans +=1;
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

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

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

int main(){
  const ll INF=1e10;
  ll n,k;
  cin >> n >> k;

  ll dp[100010];
  rep(i,100010)dp[i]=INF;

  ll h[100010];
  rep(i,n)cin >> h[i];
  dp[0]=0;
  rep(i,n){
    rep(j,k+1){
      if(i-j>=0)chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
fun main() {
    val n = readLine()!!.toInt()

    var ac = 0
    var wa = 0
    var tle = 0
    var re = 0
    for (i in 0 until n) {
        val input = readLine()!!

        when(input) {
            "AC" -> ac++
            "WA" -> wa++
            "TLE" -> tle++
            "RE" -> re++
        }
    }

    println("AC x $ac")
    println("WA x $wa")
    println("TLE x $tle")
    println("RE x $re")
}

Measured memory_bytes: 57180
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    int n,i;
    cin>>n;
    int p=0;
    ll ans=0;
    for(i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x<p){
          ans+=p-x;
          x=p;
        }
        p=x;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int N, Q;
string s;
char t[223456], d[223456];

// 消えないならtrue
bool isOK(int idx){
	rep(i, Q){
		if (s[idx] == t[i]){
			if (d[i] == 'L') idx--;
			else idx++;
		}
		if (idx < 0) return false;
		if (idx >= N) return false;
	}
	return true;
}

signed main(){

	cin >> N >> Q;
	cin >> s;

	rep(i, Q)
		cin >> t[i] >> d[i];

	// 左側から何番目が消えないか
	int ok = N;
	int ng = -1;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		cerr << mid << " " << isOK(mid) << endl;
		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	int left = ok;


	// 右側から何番目までが右に消えないか
	ok = -1;
	ng = N;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		cerr << mid << " " << isOK(mid) << endl;
		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	int	right = ok;

	cout << max(0LL, right - left + 1) << endl;

	return 0;
}

Measured memory_bytes: 1028
def main():
    S = input()

    l = int(S[:2])
    r = int(S[2:])

    if (l > 12 or l == 0) and (r > 12 or r == 0):
        print("NA")
        exit()

    if l > 12 or l == 0:
        print("YYMM")
        exit()

    if r > 12 or r == 0:
        print("MMYY")
        exit()

    print("AMBIGUOUS")


main()


Measured memory_bytes: 3060
/********   In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;
#define inf 1e18L + 7
#define sci(a) scanf("%d", &a)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s, t;
    cin >> s >> t;
    int ss = s.size(), tt = t.size();
    vector<vector<int>> dp(ss + 1, vector<int>(tt + 1, 0));

    for (int i = 1; i <= ss;i++)
    {
        for (int j = 1; j <= tt;j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i][j - 1], dp[i-1][j]);
            }
        }
    }
    string ans;
    int i = ss, j = tt;
    //cout << dp[ss][tt];
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans.push_back(s[i-1]);
            i--, j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int po[4];
	for(int i = 0; i < 4; ++i) po[i] = s[i] - '0';
	for(int i = 0; i <= 1; ++i){
		for(int j = 0; j <= 1; ++j){
			for(int k = 0; k <= 1; ++k){
				int a = po[0];
				if(i) a += po[1];
				else a -= po[1];
				if(j) a += po[2];
				else a -= po[2];
				if(k) a += po[3];
				else a -= po[3];
				if(a == 7){
					cout << po[0] << (i ? '+' : '-') << po[1] << (j ? '+' : '-') << po[2] << (k ? '+' : '-') << po[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())

ch, cw = map(int, input().split())

dh, dw = map(int, input().split())

ch -= 1
cw -= 1
dh -= 1
dw -= 1

maze = []
for i in range(H):
    h = list(input())
    maze.append(h)

dist = [[float("inf") for _ in range(W)] for _ in range(H)]
dist[ch][cw] = 0

queue = deque([(ch, cw, 0)])

while queue:
    y, x, d = queue.popleft()

    if y == dh and x == dw:
        print(d)
        exit()

    for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
        new_y, new_x = y + i, x + j
        if 0 <= new_y < H and 0 <= new_x < W:
            if maze[new_y][new_x] != '#':
                if dist[new_y][new_x] > d:
                    dist[new_y][new_x] = d
                    queue.appendleft((new_y, new_x, d))

    for i in range(-2, 3):
        for j in range(-2, 3):
            new_y, new_x = y + i, x + j
            if 0 <= new_y < H and 0 <= new_x < W:
                if maze[new_y][new_x] != '#':
                    if dist[new_y][new_x] > d+1:
                        dist[new_y][new_x] = d+1
                        queue.append((new_y, new_x, d+1))

print(-1)

Measured memory_bytes: 165376
#include <stdio.h>

int main(void)
{
    int n;
    int a[101];
    int i;
    int maxNum = 0, minNum = 1000;
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(a[i] < minNum){
            minNum = a[i];
        }
        
        if(a[i] > maxNum){
            maxNum = a[i];
        }
    }
    
    printf("%d\n", maxNum - minNum);
    
    return 0;
}


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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;

int main(void) {
	lint N, A, B, C, D;
	scanf("%lld %lld %lld %lld %lld", &N, &A, &B, &C, &D);

	N--;
	if (A > B) {
		std::swap(A, B);
	}
	if (N % 2 == 0) {
		lint ind = 0;
		for (lint i = N; i >= 0; i -= 2) {
			lint left = A + C * i - ind * (D - C);
			lint right = A + D * i + ind * (D - C);
			if (left <= B && B <= right) {
				printf("YES");
				return 0;
			}
			ind++;
		}
	}
	else {
		lint ind = 0;
		for (lint i = N; i >= 1; i -= 2) {
			lint left = A + C * i - ind * (D - C);
			lint right = A + D * i + ind * (D - C);
			if (left <= B && B <= right) {
				printf("YES");
				return 0;
			}
			ind++;
		}
	}
	
	printf("NO");

	return 0;
}

Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

////////////////////////////////////////////////

fn main(){
    let n = read_int();
    let xs = read_ints2(5);

    let m : i64= *xs.iter().min().unwrap();

    println!("{}",(n+m-1)/m+4);
}

Measured memory_bytes: 4352
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    W,H,x,y=map(int,readline().split())

    if x==W/2 and y==H/2:
        print(W*H/2,1)
    else:
        print(W*H/2,0)
if __name__=="__main__":
    main()

Measured memory_bytes: 2940
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
int32_t main(){
    FastIO;
    ll n;
    cin >> n;
    vc <ll> div(n+1, 0);
    for(int i=1; i<=n; i++) {
        for(int j=1; j*i <=n; j++) div[i*j]++;
    }
    ll ans = 0;
    for(int i=1; i<=n; i++) {
        ans += i*div[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81340
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
long long int dp[101][4][4];
int main(void)
{
	int i,j,k,n,m,a,b[101],c;
	long long int sum,x;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=3;j++){
			for(k=0;k<=3;k++) dp[i][j][k]=0;
		}
	}
	for(i=1;i<=n;i++) b[i]=0;
	for(i=1;i<=m;i++){
		cin>>a;
		cin>>b[a];
	}
	if(b[1]>0) dp[1][b[1]][0]=1;
	else{
		for(i=1;i<=3;i++) dp[1][i][0]=1;
	}
	for(i=1;i<n;i++){
		for(j=1;j<=3;j++){
			if(dp[i][j][0]+dp[i][j][1]+dp[i][j][2]+dp[i][j][3]>0){
				for(k=0;k<=3;k++){
					if(b[i+1]>0){
						if(b[i+1]!=k||b[i+1]!=j){
							dp[i+1][b[i+1]][j]+=dp[i][j][k];
							dp[i+1][b[i+1]][j]%=10000;
						}
					}
					else{
						if(k!=1||j!=1){
							dp[i+1][1][j]+=dp[i][j][k];
							dp[i+1][1][j]%=10000;
						}
						if(k!=2||j!=2){
							dp[i+1][2][j]+=dp[i][j][k];
							dp[i+1][2][j]%=10000;
						}
						if(k!=3||j!=3){
							dp[i+1][3][j]+=dp[i][j][k];
							dp[i+1][3][j]%=10000;
						}
					}
				}
			}
		}
	}
	sum=0;
	for(i=1;i<=3;i++){
		for(j=0;j<=3;j++) sum+=dp[n][i][j];
	}
	x=sum%10000;
	cout<<x<<endl;	
	return 0;
}

Measured memory_bytes: 3040
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,b[110],a[110];

signed main(){
    I(n);
    REP(i,n) I(b[i]);
    REPN(i,n){
        int ins = b[i];
        REP(j,n){
            if (!a[j]) ins--;
            if (!ins) {
                a[j] = b[i];
                break;
            }
            if(j == n-1 && ins){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    REP(i,n){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	sum := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		sum += tmp
	}
	if sum >= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(X[int(input())-1])

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    sort(rall(A));

    ll result = A[0];

    FOR(i, 2, N) {
        result += A[i / 2];
    }

    cout << result << endl;

    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N,0), B(N,0);

    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    sort(ALL(B), greater<int>());

    int itr = 0;
    REP(i,N){
        if(A[i] == B[i]){
            while(A[itr]==B[i] || B[itr]==B[i]){
                if(itr == N-1){
                    cout << "No" << endl;
                    return 0;
                }
                itr++;
            }
            swap(B[i],B[itr]);
        }
    }
    cout << "Yes" << endl;
    REP(i,N) cout << B[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k){
    cout<<k<<endl;
  }
  else if(a<k && a+b-k>=0){
    cout<<a<<endl;
  }
  else if(a+b<k){
    cout<<a-(k-a-b)<<endl;
  }
}

Measured memory_bytes: 3632
class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)


from operator import itemgetter


def compress(array):
    """座標圧縮したリストを返す"""
    set_ = set()
    for num in array:
        set_.add(num[0])
        set_.add(num[1])
    array2 = sorted(set_)
    memo = {value: index for index, value in enumerate(array2)}
    for i in range(len(array)):
        array[i] = (memo[array[i][0]], memo[array[i][1]])
    return array

def on_line(x, y):
    return x == 0 or x == r or y == 0 or y == c

def val(x, y):
    if y == 0:
        return x
    if x == r:
        return r + y
    if y == c:
        return r + c + (r - x)
    if x == 0:
        return r + c + r + (c - y)

r, c, n = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

res = []
for i in range(n):
    x1, y1, x2, y2 = info[i]
    if on_line(x1, y1) and on_line(x2, y2):
        left = val(x1, y1)
        right = val(x2, y2)
        if left > right:
            left, right = right, left
        res.append((left, right))


res = sorted(res, key=itemgetter(1))
res = compress(res)

bit = BIT(2 * len(res))
for left, right in res:
    if bit.get_val(left) != 0:
        print("NO")
        exit()
    else:
        bit.add(left, right + 1, 1)
print("YES")




Measured memory_bytes: 82756
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    
    long dx=x2-x1,dy=y2-y1;
    
    long x3=x2-dy,y3=y2+dx;
    long x4=x3-dx,y4=y3-dy;
    
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

#define NMAX (101)
#define INF (100000000)
#define p(a, b) make_pair(a, b)

typedef int COST_TYPE;
typedef pair<COST_TYPE, int> pi;

int N, M;
int a[1000], b[1000], c;

int e[101][101];
bool used[1000];

vector<pi> G[NMAX];
COST_TYPE cost[NMAX];
bool done[NMAX];

void dijkstra(int root)
{
	priority_queue<pi, vector<pi>, greater<pi> > PQ;
	pi current;	/* first: cost, second: index */
	COST_TYPE next_cost;
	int current_index, next_index, size;

	rep(i, NMAX) {
		done[i] = false;
		cost[i] = INF;
	}

	cost[root] = 0;
	PQ.push(make_pair(0, root));

	while (!PQ.empty()) {
		current = PQ.top();
		PQ.pop();

		current_index = current.second;

		if (done[current_index]) continue;
		done[current_index] = true;

		size = (int)G[current_index].size();
		rep(i, size) {
			next_index = G[current_index][i].second;
			next_cost = G[current_index][i].first;

			if ((!done[next_index])
				&& (cost[next_index] > cost[current_index] + (COST_TYPE)next_cost)) {
				cost[next_index] = cost[current_index] + (COST_TYPE)next_cost;
				PQ.push(make_pair(cost[next_index], next_index));
			}
		}
	}
}

void check_used(int root)
{
	queue<int> q;
	q.push(root);

	while (!q.empty()) {
		int current = q.front(); q.pop();
		int size = G[current].size();

		rep(i, size) {
			pi item = G[current][i];
			int len = item.first;
			int next = item.second;

			if (cost[current] + len == cost[next]) {
				used[e[current][next]] = true;
				q.push(next);
			}
		}
	}
}

int main()
{
	int ans = 0;

	cin >> N >> M;
	rep(i, M) {
		cin >> a[i] >> b[i] >> c;
		e[a[i]][b[i]] = i;
		e[b[i]][a[i]] = i;
		G[a[i]].push_back(p(c, b[i]));
		G[b[i]].push_back(p(c, a[i]));
	}

	repc(i, 1, N) {
		dijkstra(i);
		check_used(i);
	}

	rep(i, M) if (!used[i]) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
N = int(input())
odd = []
even = []
four = []
for x in map(int,input().split()):
    if x % 4 == 0:
        four.append(x)
    elif x % 2 == 0:
        even.append(x)
    else:
        odd.append(x)
if len(four) >= len(odd):
    print("Yes")
elif len(four) == len(odd)-1 and len(even) == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20520
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n,q; cin >> n >> q;

    vector<int> v(n+1);
    vector<vector<int>> r(n+1,vector<int>());

    REP(i,n-1) {
        int a,b; cin >> a >>b;
        r[a].emplace_back(b);
    }
    REP(i,q) {
        int p,x; cin >> p >> x;
        v[p] += x; 
    }

    FOR(i,1,n+1) {

        for(auto j:r[i]) {
            v[j] += v[i];
        }

        cout << v[i] << " ";

    }

    
    return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  a--;
  b--;
  c--;
  d--;

  if(b < c && c < d){
    // ABCD
    for(int i = a; i < d; ++i){
      if(s[i] == '#' && s[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;    
  }
  else if(c < b){
    // ACBD
    for(int i = a; i < c; ++i){
      if(s[i] == '#' && s[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int i = b; i < d; ++i){
      if(s[i] == '#' && s[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  else{
    // ABDC
    for(int i = a; i < c; ++i){
      if(s[i] == '#' && s[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int i = b; i <= d; ++i){
      if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
def main(): 
    s = int(input())
    MOD = 10**9+7

    n = 5000
    fact = [1]*(n+1)
    fact_inv = [1]*(n+1)
    temp = 1
    for i in range(1,n+1):
        temp = temp*i%MOD
        fact[i] = temp
    temp = pow(temp,MOD-2,MOD)
    fact_inv[n] = temp
    for i in range(n,0,-1):
        temp = temp*i%MOD
        fact_inv[i-1] = temp

    def comb(n,k):
        return fact[n]*fact_inv[n-k]*fact_inv[k]%MOD if k<=n else 0

    ans = 0
    n = 1
    while 3*n <= s:
        m = s - 3*n
        ans += comb(m+n-1,min(m,n-1))
        ans%=MOD
        n+=1
    print(ans)
main()

Measured memory_bytes: 64488
#include<iostream>
#include<vector>
#include<math.h>
#include <utility>
#include <iomanip>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int, int> > t(n);
  for(int i=0;i<n;i++){
    int x, y;
    cin>>x>>y;
    t[i]=make_pair(x, y);
  }
  double res=0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < i; j++){
      pair<int, int> a=t[i];
      pair<int, int> b=t[j];
      res += sqrt(pow(a.first-b.first, 2)*1.0+pow(a.second-b.second, 2)*1.0);
    }
  }
  res = (2.0* res)/n;
  cout<< setprecision(8) << res <<endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var h = int.Parse(Console.ReadLine());

            Console.WriteLine((a + b) * h / 2);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll k ; cin >> k ;
	if(k%2==0||k%5==0) cout << -1 << endl ;
	else{
		ll ans = 1 ;
		ll rem = 7%k ;
		ll sum = rem ;
		while(sum!=0){
			ans++ ;
			rem = rem*10%k ;
			sum = (sum+rem)%k ;
		}
		cout << ans << endl ;
	}
}



Measured memory_bytes: 3528
import math
n, d = map(int, input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
count = 0

def dist(i,j,x, d):
    distance = 0
    for k in range(d):
        distance += (x[i][k] - x[j][k])**2
    distance = math.sqrt(distance)
    return distance
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            distance = dist(i,j,x, d)
            if distance.is_integer() == True:
                count += 1
print(count//2)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();

		for (int i = c.length - 1; i >= 0; i--) {
			System.out.print(c[i]);
		}
		System.out.println();

		sc.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17128
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#define INF 1000000000

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> v[100];
	int a[100], b[100];
	for(int i=0; i<n-1; i++){
		int a1, b1;
		scanf("%d %d", &a1, &b1);
		a1--;
		b1--;
		v[a1].push_back(b1);
		v[b1].push_back(a1);
		a[i]=a1, b[i]=b1;
	}
	
	int d[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==j){
				d[i][j]=0;
			}else{
				d[i][j]=INF;
			}
		}
	}
	for(int i=0; i<n; i++){
		queue<int> que;
		que.push(i);
		int used[100]={};
		while(!que.empty()){
			int x=que.front();
			que.pop();
			if(used[x]==1) continue;
			used[x]=1;
			for(int j=0; j<v[x].size(); j++){
				if(d[i][v[x][j]]>d[i][x]+1){
					d[i][v[x][j]]=d[i][x]+1;
					que.push(v[x][j]);
				}
			}
		}
	}
	int R=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(d[i][j]>R) R=d[i][j];
		}
	}
	int r[100], rmin=INF;
	vector<int> c;
	for(int i=0; i<n; i++){
		r[i]=0;
		for(int j=0; j<n; j++){
			if(d[i][j]>r[i]) r[i]=d[i][j];
		}
		if(rmin>=r[i]){
			
			rmin=r[i];
		}
	}
  for(int i=0; i<n; i++){
    if(rmin==r[i]) c.push_back(i);
  }
	int re[100], remin=INF;
	vector<int> ce;
	for(int i=0; i<n-1; i++){
		re[i]=0;
		for(int j=0; j<n; j++){
			if(min(d[a[i]][j], d[b[i]][j])>re[i]) re[i]=min(d[a[i]][j], d[b[i]][j]);
		}
		if(remin>=re[i]){
			
			remin=re[i];
		}
	}
  for(int i=0; i<n-1; i++){
    if(remin==re[i]) ce.push_back(i);
  }
	long long int ans;
	for(int i=0; i<c.size(); i++){
		long long int ans1=1;
		int cent=c[i];
		set<int> deg[100];
		for(int j=0; j<n; j++){
			deg[d[j][cent]].insert(v[j].size());
		}
		for(int t=0; t<=rmin; t++){
			auto itr=deg[t].end();
			itr--;
			if(t==0){
				ans1*=(*itr);
			}else{
				ans1*=(max(*itr-1, 1));
			}
         
		}
		if(i==0){
			ans=ans1;
		}else{
			if(ans>ans1) ans=ans1;
		}
     
	}
	long long int anse;
	for(int i=0; i<ce.size(); i++){
		long long int ans1=2;
		int cent=ce[i];
		set<int> deg[100];
		for(int j=0; j<n; j++){
			deg[min(d[j][a[cent]], d[j][b[cent]])].insert(v[j].size());
		}
		for(int t=0; t<=remin; t++){
			auto itr=deg[t].end();
			itr--;
			ans1*=(max(*itr-1, 1));
		}
		if(i==0){
			anse=ans1;
		}else{
			if(anse>ans1) anse=ans1;
		}
    
	}
  rmin++;
	remin++;
	if(rmin>remin){
		printf("%d %lld\n", remin, anse);
	}else if(rmin<remin){
		printf("%d %lld\n", rmin, ans);
	}else{
		printf("%d %lld\n", rmin, min(ans, anse));
	}
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- readInts
	print $ length $ filter is_pal [ a .. b ]

is_pal x = let s = show x in s == reverse s


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(int)(n);i++)
using namespace std;
int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> A(Q);
  vector<int>B(N,K-Q);
  rep(i,Q){
    cin>>A.at(i);
    A.at(i)--;
    B.at(A.at(i))++;
}
  rep(i,N){
    if(B.at(i)<=0)
      puts("No");
    else
     puts("Yes");
  }
}

    
    

Measured memory_bytes: 1408
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let ((a (sort (read-line) #'char<))
	  (b (sort (read-line) #'char>)))
  (princ (if (string< a b)
		   "Yes"
		   "No")))


Measured memory_bytes: 11956
import math
A,B,C = map(int,input().split())

ans = 0
while(1):
  tmp_A,tmp_B,tmp_C = A,B,C
  if((tmp_A%2 == 1)or(tmp_B%2 == 1)or(tmp_C%2 == 1)):
    break   
  A,B,C = (tmp_B+tmp_C)//2, (tmp_C+tmp_A)//2, (tmp_A+tmp_B)//2
  if((tmp_A == A)and(tmp_B == B)and(tmp_C == C)):
    ans = -1
    break
  ans += 1

print(ans)  

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

int main () {
ios_base::sync_with_stdio(false);
   cin.tie(NULL);
	int n;
	cin>>n;
	ll a[n];
	string s;
	ll dp[102][102],store[102][102];
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			dp[i][j]=0;
			store[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>s;
		ll temp=0;
		int index=-1;
		int p2=0,p5=0;
		for(int j=0;j<s.length();j++){
			if(s[j]=='.'){
				index=j;
				continue;
			}
			temp=temp*10+(s[j]-'0');
		}
		if(index!=-1){
			p2-=(s.length()-index-1);
			p5-=(s.length()-index-1);
		}
		while(temp%2==0){
			temp/=2;
			++p2;
		}
		
		while(temp%5==0){
			temp/=5;
			++p5;
		}
		
	//	cout<<p2<<" "<<p5<<"\n";
		
		++dp[p2+50][p5+50];
		++store[p2+50][p5+50];
	}
	for(int i=100;i>=0;i--){
		for(int j=100;j>=0;j--){
			dp[i][j]+=(dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]);
		}
	}
	
/*		for(int i=0;i<=20;i++){
		for(int j=0;j<=20;j++){
			cout<<dp[i][j]<<" ";
		 }
		 cout<<"\n";
	   }*/
	ll ans=0,ans1=0;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			int p2=i-50,p5=j-50;
			p2=-p2,p5=-p5;
			p2+=50,p5+=50;
			if(p2<0||p5<0)
			continue;
			if(p2<=i&&p5<=j){
				ans+=(store[i][j])*(dp[p2][p5]-store[i][j]);
				ans1+=((store[i][j])*(store[i][j]-1))/2;
			}
			else{
				ans+=(store[i][j])*(dp[p2][p5]);
			}
		}
	}
	ans/=2;
	cout<<ans+ans1<<"\n";
	return 0;
}

Measured memory_bytes: 3804
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        long x = 1;
        long y = 1;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            x *= 3;
            y *= (a[i] % 2 ^ 1) + 1;
        }
        System.out.println(x - y);
    }
}

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

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

const long long INF = 1LL << 60;


int main(void){
	int n;cin >> n;
	while(n>0){
		int a;
		a = n%10;
		if(a==7){
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10; 
	}
	cout << "No" << endl;
	return 0;
}



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


static class NagataKanaIsAGenius {
    public static void Main() {
        int[]HW=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[]hw=Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine((HW[0]-hw[0])*(HW[1]-hw[1]));
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(all(a));
    
    // まずa[i]が必要かどうかは
    // 「要素の総和がk-a[i]以上k未満のa[i]を含まない部分集合が存在するならa[i]は必要。そうでなければ不必要」
    // と判定できる。

    // 次に解の単調性 「a[i] < a[j]のとき、a[j]が不必要 ⇒ a[i]も不必要」 を示す。
    // 仮定より要素の総和がk-a[j]以上k未満のa[j]を含まない部分集合は存在しない。
    // つまりa[j]を含まない部分集合の要素の総和はk-a[j]未満またはk以上。
    // k-a[j] < k-a[i] より要素の総和がk-a[i]以上k未満のa[i]もa[j]も含まない部分集合は存在しない。
    // a[j]を含む部分集合の要素の総和はk未満またはk+a[j]以上なので、
    // a[j]を含むがa[i]は含まない部分集合の要素の総和はk-a[i]未満またはk+a[j]-a[i]以上。
    // k < k + (a[j] - a[i]) より要素の総和がk-a[i]以上k未満のa[j]を含むがa[i]は含まない部分集合は存在しない。
    // 以上よりa[j]を含むかどうかによらずa[i]は不必要。

    // 判定問題「a[x]は不必要か？」を二分探索で解く
    ll left = -1;
    ll right = n;
    while(right - left > 1) {
        ll x = (left + right)/2;
        vector<vector<bool>> dp(n+1, vector<bool>(k+1, false));  // dp[i+1][j] : a[i]までで総和をjにできるならtrue
        dp[0][0] = true;
        rep(i, n) {
            exrep(j, 0, k) {
                if(dp[i][j]) {
                    dp[i+1][j] = true;
                }
                if(i == x) {
                    continue;
                }
                if(j >= a[i] && dp[i][j - a[i]]) {
                    dp[i+1][j] = true;
                }
            }
        }
        bool noneed = true;
        exrep(j, max(0LL, k-a[x]), k-1) {
            if(dp[n][j]) {
                noneed = false;
            }
        }
        if(noneed) {
            left = x;
        }
        else {
            right = x;
        }
    }

    out(right);
    re0;
}

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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  double ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ans = a[0];
  for(int i = 1; i < n; i++){
    ans = (a[i] + ans) / 2;
  }
  cout << ans << endl;
}

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

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

    set<int> d;

    rep(i,n){
        int tmp;
        cin >> tmp;
        d.insert(tmp);
    }

    cout << d.size() << endl;
}

Measured memory_bytes: 256