akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{   
	    Scanner sc = new Scanner(System.in);
	    System.out.println(sc.nextInt()+sc.nextInt()/2);
	    
	}
}


Measured memory_bytes: 23380
# ABC139 D - ModSum

#import itertools
N = int(input())
print(N * (N - 1) // 2)
"""
P = [i + 1 for i in range(N)]

for v in itertools.permutations(P, N):
    val = 0
    for i in range(N):
        val += (i + 1) % v[i]
    if val == 78:
        print(v, val)
"""

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

int main() {
    int n, s_tmp, t_tmp, w_tmp;
    cin >> n;
    vector<vector<vector<int> > > g(n);
    vector<int> dis_0(n, -1);
    vector<int> vtmp(2);
    for (int i = 0; i < n - 1; ++i) {
        cin >> s_tmp >> t_tmp >> w_tmp;
        vtmp[0] = t_tmp;
        vtmp[1] = w_tmp;
        g[s_tmp].push_back(vtmp);
        vtmp[0] = s_tmp;
        g[t_tmp].push_back(vtmp);
    }
    //printv3(&g);
    queue<int> que;
    que.push(0);
    dis_0[0] = 0;
    int front;
    vector<int> far(2, 0);
    while (!que.empty()) {
        //cout << "hh" << endl;
        front = que.front();
        que.pop();
        for (int i = 0; i < g[front].size(); ++i) {
            if (dis_0[g[front][i][0]] == -1) {
                dis_0[g[front][i][0]] = dis_0[front] + g[front][i][1];
                que.push(g[front][i][0]);
                if (dis_0[g[front][i][0]] > far[1]) {
                    far[1] = dis_0[g[front][i][0]];
                    far[0] = g[front][i][0];
                }
            }
        }
    }
    //printv1(&dis_0);
    vector<int> dis_far(n, -1);
    dis_far[far[0]] = 0;
    que.push(far[0]);
    while (!que.empty()) {
        //cout << "hh" << endl;
        front = que.front();
        que.pop();
        for (int i = 0; i < g[front].size(); ++i) {
            if (dis_far[g[front][i][0]] == -1) {
                dis_far[g[front][i][0]] = dis_far[front] + g[front][i][1];
                que.push(g[front][i][0]);
                if (dis_far[g[front][i][0]] > far[1]) {
                    far[1] = dis_far[g[front][i][0]];
                    far[0] = g[front][i][0];
                }
            }
        }
    }
    //printv1(&dis_far);
    cout << far[1] << endl;
    return 0;
}
/*
3
0 2 4
0 1 6
 */


Measured memory_bytes: 19444
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <list>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;
#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VPI;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define db(x) cerr << #x << " = " << x << endl
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
const int INF = 1000000404;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ld EPS = 1e-9;
template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); }
template <typename t1, typename t2> inline void upmin(t1 &a, t2 b) { a = min(a, (t1)b); }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }
template <typename T>inline bool pal(T &x)
{
	int n = SZ(x); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1;
}
template <typename T>inline void rev(T &x) { int n = SZ(x); REP(i, 0, n / 2) swap(x[i], x[n - i - 1]); }
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
inline ll mp(ll a, ll b) { return (a << 31) + b; }
class compare{
public:
	bool operator()(const int a, const int b) const {
		return 1;
	}
};
int SQ = 400;

#define debug 1
#define N 111111
int t[N];
int x[N];
int y[N];
void solve()
{
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	int n;
	cin >> n;
	REP(i, 1, n + 1) {
		cin >> t[i] >> x[i] >> y[i];
		int f = t[i] - t[i - 1] - (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]));
		if (f < 0 || f % 2 == 1) {
			db(f);
			cout << "No";
			return;

		}
	}
	cout << "Yes";

}

int main()
{
	//freopen("codeforces.in", "r", stdin);
	//freopen("codeforces.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	//cin>>t;

	while (t--) {
		solve();
	};


	getchar();
	getchar();
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define up upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define ll long long
#define vi vector < ll > 
#define pi pair < ll , ll > 
#define ld long double
#define iPair pair< ll , ll >

#define lp(n,i) for(ll i=0;i<n;i++)
#define rlp(n) for(ll i=n-1;i>=0;i--)
//#define e 1000000009
//#define e  998244353
#define inf 9999999999999999
#define pri1 1000000007
#define pri2 1000001001
#define PI 3.14159265
 /*
ll pw(ll a, ll b)
{
    ll t=1;
    
    if(b==0)return t;
    if(b%2)
    {
        t=t*a;
    }
   t%=e;
    ll x=pw(a,b/2);
    x=x*x;
    x%=e;
    t*=x;
    t%=e;
    return t;
}/*
vector < ll > pr;
ll vis[10000005]={0};
void seive ( ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(vis[i]==0)
        {
            
            for(ll j=i*i;j<=n;j+=i)vis[j]=1;
        }
    } 
    
    for(ll i=2;i<=n;i++)
    {
        if(vis[i]==0)pr.pb(i);
    }
}
 
#define N 100005
ll z[N];
vector < ll > v;
void getz(string s)
{
    ll n=s.length();
    ll l=0,r=0;
    for(ll i=1;i<n;i++)
    {
        if(i<=r)
        {
            z[i]=min(r-i+1,z[i-l]);
        }
        
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]])z[i]++;
        
        if((i+z[i]-1)>r)
        {
            l=i;
            r=i+z[i]-1;
        }
    }
    
   for(ll i=0;i<n;i++)
   {
       v.pb(z[i]);
   }
  
    sort(v.begin(),v.end());
    
}
*/
 vector < ll > ad[100005];
ll vis[100004];
ll p[100004];
 
 void dfs( ll cr)
 {
     vis[cr]=1;
     for(ll i=0;i<ad[cr].size();i++)
     {
         if(vis[ad[cr][i]])continue;
         p[ad[cr][i]]=cr;
         dfs(ad[cr][i]);
         
     }
     
 }
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
 
   
 ll ti=1;
//cin>>ti;
 
 for (ll io=0;io<ti;io++)
 {
     ll n,m;
     cin>>n>>m;
     for(ll i=0;i<m;i++)
     {
         ll x,y;
         cin>>x>>y;
         ad[x].pb(y);
         ad[y].pb(x);
     }
 
 ll cnt=0;
 for(ll i=1;i<=n;i++)
 {
     if(vis[i])continue;
  dfs(i);
  cnt++;
 }
 if(cnt==1)
 {
     cout<<"Yes"<<endl;
     queue < ll > q;
     q.push(1);
     ll v[100005]={0};
     v[1]=1;
     while(!q.empty())
     {
         ll cr=q.front();
         q.pop();
         for(ll i=0;i<ad[cr].size();i++)
         {
             if(v[ad[cr][i]])continue;
             p[ad[cr][i]]=cr;
             v[ad[cr][i]]=1;
             q.push(ad[cr][i]);
         }
         
     }
     for(ll i=2;i<=n;i++)cout<<p[i]<<endl;
     
 }
 else cout<<"No"<<endl;
 }
 return 0;	
}

Measured memory_bytes: 17436
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    static String decrypt(String x) {
        int dec = Integer.parseInt(x, 2);
        if (dec <= 25) {
            return String.valueOf((char) ('A' + dec));
        } else if (dec == 26) {
            return " ";
        } else if (dec == 27) {
            return ".";
        } else if (dec == 28) {
            return ",";
        } else if (dec == 29) {
            return "-";
        } else if (dec == 30) {
            return "\'";
        } else if (dec == 31) {
            return "?";
        }

        return "*****"; // unreachable
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = { " ", "\'", ",", "-", ".", "?", "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" };
        String[] f = { "101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010", "0101", "0001",
                "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100", "10011001", "10011110",
                "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", "000010", "10010010",
                "10010011", "10010000" };

        String line;
        while ((line = br.readLine()) != null) {
            StringBuilder sb = new StringBuilder();
            for (char c : line.toCharArray()) {
                for (int i = 0; i < s.length; i++) {
                    if (s[i].equals(String.valueOf(c))) {
                        sb.append(f[i]);
                        break;
                    }
                }
            }
            for (int i = 0; i < sb.length()%5; i++) {
                sb.append("0");
            }

            StringBuilder result = new StringBuilder();

            while (sb.length() > 5) {
                String x = sb.substring(0, 5);
                sb.delete(0, 5);
                result.append(decrypt(x));
            }

            result.append(decrypt(sb.toString()));

            System.out.println(result);
        }
    }
}


Measured memory_bytes: 37920
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <forward_list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n);
    makev(a, n);
    int x = 0;
    for(int i = 0; i < n; ++i){
        x ^= a[i];
    }
    for(int i = 0; i < n; ++i){
        cout << (x ^ a[i]) << ' ';
    }

    return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt(),a = sc.nextInt(),b = sc.nextInt();
		if(a < b) {
			int aw_b = b-(a+W);
			if(aw_b > 0) System.out.println(aw_b);
			else System.out.println(0);
		}else {
			int bw_a = a-(b+W);
			if(bw_a > 0) System.out.println(bw_a);
			else System.out.println(0);
		}
	}
}

Measured memory_bytes: 19796
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0)cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	rep(i,n){
		int a;
		cin >> a;
		sum += a-1;
	}
	cout << sum << '\n';
	return 0;
}


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

int main(void){
    string str, order, tmp;
    char *p, t;
    int n, a, b;
    cin >> str >> n;

    for(int i = 0; i < n; i++){
        cin >> order >> a >> b;
        if(order.compare("print") == 0){
            cout << str.substr(a, b - a + 1) << endl;
        }else if(order.compare("reverse") == 0){
            reverse(str.begin() + a, str.begin() + b + 1);
        }else if(order.compare("replace") == 0){
            cin >> tmp;
            str.replace(a, b - a + 1, tmp);
        }
    }
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <math.h>
 
using namespace std;
 
int main() {
int a;
int b;
  int c=2;
  
  1<=a;
  b<=100;
  cin >> a >>b;
  int ave;
  double ans;
  ave = a+b;
  double ceil(double);
  ans = ceil((double)ave/(double)c);
  cout << ans << endl;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> a(N);
	for (auto& e: a) scanf("%d", &e);
	int sum{};
	for (auto& e: a) sum += e;
	int ans{};
	for (int i{}; i < N; i++)
		if (std::abs(a[i] * N - sum) < std::abs(a[ans] * N - sum))
			ans = i;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    ll n,a,b,ma,mi;
    cin>>n>>a>>b;
    a--,b--,n--;
    if(a>b)swap(a,b);
    if((b-a)%2==0)
        cout<<(b-a)/2;
    else {

      cout<<min(a,n-b)+(b-a+1)/2;
    }

}


Measured memory_bytes: 256
n=int(input())
max1=0
max2=0
max1_i=0

for i in range(n):
    a=int(input())
    if a>max1:
        max2=max1
        max1=a
        max_i=i
    elif a>max2:
        max2=a
    else:
        pass

for i in range(n):
    if i==max_i:
        print(max2)
    else:
        print(max1)


Measured memory_bytes: 4540
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val X, Y = in.next().toInt
  val A, B, C = in.next().toInt
  val p = new Array[Long](A+1)
  val q = new Array[Long](B+1)
  val r = new Array[Long](C+1)
  for (i <- 1 to A)
    p(i) = in.next().toLong
  for (i <- 1 to B)
    q(i) = in.next().toLong
  for (i <- 1 to C)
    r(i) = in.next().toLong


  //
  val p1 = p.sorted.reverse.take(X)
  val q1 = q.sorted.reverse.take(Y)

  val ans = (p1 ++ q1 ++ r).sorted.reverse.take(X+Y).sum
  println(ans)
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 79432
N, A, B = map(int, input().split())
S = input()

import sys

T = A + B
Ta = B

for p in S:
  if p == "c":
    print("No")
    continue
    
  elif p == "a":
    if T > 0:
      print("Yes")
      T -= 1
    else:
      print("No")
      
  else:
    if T > 0 and Ta > 0:
      print("Yes")
      Ta -= 1
      T -= 1
    else:
      print("No")


Measured memory_bytes: 4016
def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]
    Q = int(input())
    queries = [[int(item) for item in input().split()] for _ in range(Q)]

    memo = [0 for _ in range(10**5+1)]

    for item in A_list:
        memo[item] += 1
        

    base = sum(A_list)

    for b, c in queries:
        memo[c] += memo[b]
        base = base + memo[b]*c - memo[b]*b
        memo[b] = 0
        print(base)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 31296
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports, dead_code)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($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<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (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")
    };
}

// Pythonからの移行組としては苦しすぎるのでライブラリ濫造
fn gcd(a:usize, b:usize) -> usize {
    if b == 0 {return a};
    return gcd(b, a % b);
}

// エントリーポイント
fn main() {
    input! {
        N : usize,
        A : [usize; N]
    }
    let mut max_a = 0usize; 
    let mut max_a_count = 0usize;
    let mut second_max_a = 0usize;
    for a in &A {
        if max_a == *a {
            max_a_count = 2;
            continue;
        }
        if max_a < *a {
            second_max_a = max_a;
            max_a = *a;
            max_a_count = 1;
            continue;
        }
        if second_max_a < *a {
            second_max_a = *a;
        }
    }
    for a in &A {
        if *a == max_a && max_a_count == 1 {
            println!("{}", second_max_a);
        }
        else {
            println!("{}", max_a);
        }
    }
}


Measured memory_bytes: 7676
#! /usr/bin/env python


def print_heap (heap, i):
    ret = "node {0}: key = {1}, ".format(i + 1, heap[i])

    p = get_parent_node(i)
    if p is not None:
        ret += "parent key = {0}, ".format(heap[p])

    len_heap = len(heap)
    l = get_left_node(i)
    r = get_right_node(i)

    if l < len_heap:
        ret += "left key = {0}, ".format(heap[l])
    if r < len_heap:
        ret += "right key = {0}, ".format(heap[r])

    print(ret)
    return

def get_parent_node (i):
    p = (i - 1) // 2
    if p < 0:
        return None
    else:
        return p

def get_left_node (i):
    l = (i + 1) * 2 - 1
    return l

def get_right_node (i):
    r = (i + 1) * 2
    return r

def proc_inputs ():
    num_inputs = int(input())
    inputs = [i for i in input().split()]
    return num_inputs, inputs



def main ():
    num_inputs, inputs = proc_inputs()
    heap = [None] * num_inputs
    for i, node in enumerate(inputs):
        heap[i] = node

    for i, node in enumerate(inputs):
        print_heap(heap, i)
    # print(heap)
    exit(0)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5632
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include <string>
#include <cstring>
#include <cstdio>
#include<stack>
using namespace std;

int main()
{
int i,j,t;
int  w,h,n;
cin>>w>>h>>n;
int r=0,l=0;
for(i=1;i<=n;i++)
{
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1)
    {
        if(x>l)l=x;
    }
    if(a==2)
    {
        if(x<w)w=x;
    }
    if(a==3)
    {
        if(y>r)r=y;
    }
    if(a==4)
    {
        if(y<h)h=y;
    }
}
if(h>r&&w>l)
printf("%d\n",(h-r)*(w-l));
else printf("0\n");
    return 0;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int a,b,c,d,e,f,g,h,i;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;

    int ans = 1;

    if(a-d!=b-e||a-d!=c-f||d-g!=e-h||d-g!=f-i||a-b!=d-e||a-b!=g-h||b-c!=e-f||b-c!=h-i){
        ans = 0;
    }

    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<climits>
#include<cctype>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main(){
 
	int n;
	cin >> n;
	
	int ans = 1e9;
	
	for(int i = 0;i <= n;i++){
	   int ch = 0;
	   int t = i;
	   while(t > 0){
		   ch += t%6;
		   t/=6;
	   }
	   int u = n-i;
	   while(u > 0){
		   ch += u%9;
		   u/=9;
	   }
	   if(ans > ch) ans = ch;
	}

	 cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int a[1000];
    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%d", a + i);
    }
    int e, tmp, j;
    for (int k = 0; k < n; k++)
    {
        printf("%d", a[k]);
        if (k != n - 1)
        {
            printf(" ");
        }
    }
    printf("\n");
    for (i = 1; i < n; i++)
    {
        e = a[i];
        j = i - 1;
        while (j >= 0 && e < a[j])
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = e;
        for (int k = 0; k < n; k++)
        {
            printf("%d", a[k]);
            if (k != n - 1)
            {
                printf(" ");
            }
        }
        printf("\n");
    }
}


Measured memory_bytes: 2052
(print (labels ((r ()
		    (read-from-string (concatenate 'string "(" (read-line) ")"))))
	   (let ((lista (sort (r) #'>))
		 (k (read)))
	     (+ (* (car lista)
		   (expt 2 k))
		(cadr lista)
		(caddr lista)))))

Measured memory_bytes: 12772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  string N;
  cin >> N;
  bool flag = false;
  for(int i=0;i<N.size();++i){
    if(N[i]=='7') flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
N,M,X=map(int,input().split())
A=[]
C=[]
for i in range(N):
  tmp=list(map(int,input().split()))
  A.append(tmp[1:])
  C.append(tmp[0])

ans=10**10
for n in range(2**N):
  bit=format(n,'0'+str(N)+'b')
  bit=list(map(int,bit))
  nedan=0
  tmp=[0]*M
  for a,c,b in zip(A,C,bit):
    if b==0:continue
    nedan+=c
    for i in range(M):
      tmp[i]+=a[i]
  if min(tmp)>=X and nedan<ans:
    ans=nedan
if ans==10**10:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9264
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(void){
   int r,D,x;
   cin >> r;
   cin >> D;
   cin >> x;
   for (int i = 0; i < 10; i++) {
      x  = x * r - D;
      cout << x << endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int m=1000000007;
int main()
{
string s;
cin>>s;
long long int n,j,k;
n=s.length();
long long int i,dp[n+1][13]={0},nxt,rem;
dp[0][0]=1;
for(i=0;i<n;i++)
{
for(j=0;j<=9;j++)
{
nxt=(s[i]-'0');
if(s[i]=='?')
nxt=j;
for(k=0;k<=12;k++)
{
rem=(10*k+nxt)%13;
dp[i+1][rem]+=dp[i][k];
dp[i+1][rem]%=m;
}
if(s[i]!='?')
break;
}
}
cout<<dp[n][5];
return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)

long long int dp[51][51][2501]={0};
int N,A;
int X[51];

void solve(){
    dp[0][0][0] = 1;
    int i,j,k;
    FOR(i,1,N+1){
        REP(j,N+1){
            REP(k,50*N+1){
                if (k>=X[i-1] && j){
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]];
                }else if (k<X[i-1]){
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }
    long  long int ans = 0;
    FOR(j,1,N+1){
        ans += dp[N][j][j*A];
    }
    printf("%lld\n",ans);
}

int main(void){
    scanf("%d %d",&N,&A);
    int i;REP(i,N)scanf("%d",&X[i]);
    solve();
    return 0;
}


Measured memory_bytes: 49280
import java.util.Scanner;

public class Main{
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 String S=sc.next();
	 int A=0;
	 int B=0;
	 char[] c=S.toCharArray();
	 for(int i=0;i<S.length();i++) {
		 if(c[i]=='1') {
			 A++;
		 }else {
			 B++;
		 }
	 }
	 
	 System.out.println(2*Math.min(A,B));
 }
	


}

Measured memory_bytes: 27476
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

void A_149()
{
  string S, T;
  cin >> S >> T;

  cout << T << S << endl;
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  A_149();
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

ll dp[100001][2];

int main(){
    string l;
    cin >>l;
    int n=l.size();
    dp[0][0]=1;
    rep(i,n){
        //まさかの２回に分けて分かりやすくする！！！！！！！！
        //a+b=0  dp[0]はギリ　dp[1]は余裕あり
        if(l[i]=='0'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
        }else{
            dp[i+1][1]=(dp[i][0]+dp[i][1])%mod;
        }
        //a+b=1
        if(l[i]=='0'){
            dp[i+1][1]+=2*dp[i][1]%mod;
        }else{
            dp[i+1][0]+=2*dp[i][0]%mod;
            dp[i+1][1]+=2*dp[i][1]%mod;
        }
    }
    ll ans=(dp[n][0]+dp[n][1])%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int n,k;
  cin >> n >> k;
  vi data(n);
  rep(i,n) cin >> data[i];
  int ans = 0;
  rep(i,n) {
    if(data[i] >= k) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
#define pri 100000000007
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;

         
   



int main()
{    
 

   #ifdef APNA_IO
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
   #endif
          ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

   ll n,k;
   cin>>n>>k;

   ll a=2*k+1;
   if(n%a==0)
    cout<<n/a<<endl;
  else
    cout<<n/a+1<<endl;



}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define ll      long long

void solve() {
        int n;
        cin >> n;
        vector<int> cnt(101010, 0);
        for (int i = 0; i < n; i ++) {
                int a;
                cin >> a;
                if (a > 0) cnt[a - 1] ++;
                cnt[a] ++;
                cnt[a + 1] ++;
        }
        int ans = -1;
        for (int i = 0; i < 101010; i ++) {
                ans = max(ans, cnt[i]);
        }
        cout << ans << endl;
        return;
}

int main() {
        //freopen("a.in", "r", stdin);
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int T = 1;
        //cin >> T;
        while (T --) solve();
        return 0;
}



Measured memory_bytes: 640
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vl a(n);
	loop(i,n)
	cin>>a[i];
	ll res=1;
	ll m=a[0];
	l00p(i,1,n)
	{
		if(m>a[i]){
			m=a[i];
			res++;
		}
	} 
	cout<<res<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343#include<stdio.h>

Measured memory_bytes: 4752
#include <stdio.h>
#define N 8
#define NOT_FREE 0
#define FREE 1
int ro[N],co[N],dp[15],dn[15],A[N][N];
int i,j,n,r,c;

void printBoard()
{
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(A[i][j]&&ro[i]!=j)return;
        }
    }
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(ro[i]==j) printf("Q");
            else{printf(".");}
        }
        printf("\n");
    }
}


void putQueen(int i)
{
    int j;
    if(i==N)
    {
        printBoard();
        return;
    }
    
    for(j=0;j<N;j++)
    {
        if(co[j]==NOT_FREE||dp[i+j]==NOT_FREE||dn[i-j+N-1]==NOT_FREE) continue;
        ro[i]=j;
        co[j]=dp[i+j]=dn[i-j+N-1]=NOT_FREE;
        putQueen(i+1);
        co[j]=dp[i+j]=dn[i-j+N-1]=FREE;
    }
}



int main ()
{
    scanf("%d",&n);
    
    for(i=0;i<15;i++)
    {
        dp[i]=dn[i]=FREE;
    }
    
    for(i=0;i<N;i++)
    {
        co[i]=ro[i]=FREE;
        for(j=0;j<N;j++)
        {
            A[i][j]=0;
        }
    }
    
    
    
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&r,&c);
        A[r][c]=90;
    }
    putQueen(0);
    return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b,a % b);
}
int combination(int n, int k){
    int spaceOptimize[k+1];
    memset(spaceOptimize, 0, sizeof(spaceOptimize));
    spaceOptimize[0] = 1;
    for(int i=1;i<=n; i++){
        for(int j= min(i,k);j>0;j--){
            spaceOptimize[j] = spaceOptimize[j] + spaceOptimize[j-1];
        }
    }
    return spaceOptimize[k];
}
signed main(){
#ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
#endif
    fastIO

    int n,k;
    cin >> n >> k;
    if(n*500 >= k) cout<< "Yes";
    else cout << "No";

    return 0;
}


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

using namespace std;

int main(){
    int x,y;
    cin>>x>>y;
    
    if(y%2!=0){
        cout<<"No"<<endl;
        goto Exit;
    }
    
    if(y/4.0<=x && y/2.0>=x){
        cout<<"Yes"<<endl;
        goto Exit;
    }
    
    cout<<"No"<<endl;
    
    Exit:
        ;
}

Measured memory_bytes: 3624
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    switch_pattern = bin(i)[2:].zfill(N)
    for j in range(M):
        switch_on = 0
        for k in ks[j][1:]:
            if switch_pattern[k-1] == "1":
                switch_on += 1
        if switch_on%2 != p[j]:
            break
    else:
        ans += 1
print (ans)

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

class Main{
	public static void main(String[] args) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		String moji="";
		int yoko,tate;
		String[] hata;

		try {
			str=bfr.readLine();
			if(str==null) {
				System.exit(0);
			}
			else {
				stk=new StringTokenizer(str," ");
				yoko=Integer.parseInt(stk.nextToken());
				tate=Integer.parseInt(stk.nextToken());
				moji=stk.nextToken();
				hata=new String[tate];

				for(int i=0; i<tate; i++) {
					hata[i]="";
				}


				for(int i=0; i<yoko; i++) {
					if(i==0 || i==yoko-1) {		// hata no +
						hata[0]=hata[0]+"+";
						hata[tate-1]=hata[tate-1]+"+";
						for(int j=1; j<tate-1; j++) {
							hata[j]=hata[j]+"|";
						}
					}
					else {
						hata[0]=hata[0]+"-";
						hata[tate-1]=hata[tate-1]+"-";

						for(int j=1; j<tate-1; j++) {
							if(j!=(tate-1)/2) {
								hata[j]=hata[j]+".";
							}
							else {
								if(i==(yoko-1)/2) {
									hata[j]=hata[j]+moji;
								}
								else {
									hata[j]=hata[j]+".";
								}
							}
						}
					}
				}
				for(int l=0; l<tate; l++) {
					System.out.println(hata[l]);
				}

			}
		}catch(IOException e){}
	}
}


Measured memory_bytes: 24280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;


class Main {
	public static void main(String[] args){
		Integer[] input = new Integer[10];
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		for(int i=0; i<10; i++){
			try {
				input[i] = Integer.parseInt(br.readLine());
			} catch (NumberFormatException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
		Arrays.sort(input, Collections.reverseOrder());
		
		for(int i=0; i<3; i++){
			System.out.println(input[i]);
		}
	}
}

Measured memory_bytes: 16928
#include<iostream>
int main(){
  int i,j,h,w;
  while(1){
    std::cin >> h >> w;
    if(h == 0 && w == 0) return 0;
    for(i=0; i<h; i++){
      for(j=0; j<w; j++) std::cout << ((i + j) % 2 ? "." : "#");
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b==7 && c==5){
        cout<<"YES"<<endl;
    }else if(a==7 && b==5 && c==5){
        cout<<"YES"<<endl;
    }else if(a==5 && b==5 && c==7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(i=a;i<b;i++)
using namespace std;
int  main()
{
   long long int n,k,i,sum=0;
    cin>>n>>k;
    f(i,0,k)
    {
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>=n)
    cout<<"Yes";
    else
    cout<<"No";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N, A; cin >> N >> A;
    vei x(N); rep(i,N) cin >> x[i];
    ll dp[52][52][2505];
    ll sum = acc(all(x), 0LL);
    memset(dp, 0, sizeof(dp));
    dp[0][1][x[0]] = 1; dp[0][0][0] = 1;

    rep(i,N) rep(j,N+1) rep(k,sum+1){
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][ j + 1 ][ k + x[ i + 1 ] ] += dp[i][j][k];
    }
    ll ans = 0;
    rep1(j, N + 1){
        int aim = j * A;
        if(aim <= sum) ans += dp[N - 1][j][aim];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53120
import math

def cul(a,b,d):
    num = 0
    for i in range(d):
        num += (a[i] - b[i]) ** 2
    return math.sqrt(num)

N,D = map(int,input().split())
X = []
count = 0
d = 0
for i in range(N):
        X.append(list(map(int,input().split())))
for i in range(N):
    for j in range(i+1,N):
        if(i != j):
            d = cul(X[i],X[j],D)
        if (d - int(d)) == 0.0:
            count += 1

print(count)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))

if N == 1:
    print(1)
    exit()

buff = [0 for i in range(9)]
for i in range(N):
    if a[i] < 3200:
        buff[a[i] // 400] += 1
    else:
        buff[8] += 1

zero_c = 0
noz_c = 0

for i in range(8):
    if buff[i] == 0:
        zero_c += 1
    else:
        noz_c += 1

# 最小値
ans_m = 0
if noz_c > 0:
    ans_m = noz_c
elif buff[8] > 0:
    ans_m = 1

ans_mx = 0
ans_mx = noz_c + buff[8]
# # 最大値
# if noz_c > 0:
#     ans_mx = noz_c
#     amari = 9 - ans_mx
#     if amari <= buff[8]:
#         ans_mx += amari
#     elif amari > buff[8]:
#         ans_mx += buff[8]
# else:
#     if 9 <= buff[8]:
#         ans_mx = 9
#     else:
#         ans_mx = buff[8]

print(ans_m, ans_mx)

Measured memory_bytes: 38256
input=__import__('sys').stdin.readline
def getdist(a,b):return abs(a[0]-b[0])+abs(a[1]-b[1])
n=int(input())
s=[]
for _ in range(n):s.append([*map(int,input().split())])
ans=0
def ff1(x):return x[0]+x[1]
def ff2(x):return x[0]-x[1]
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
print(ans)

Measured memory_bytes: 58088
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    int ans = 0;
    if(s=="SUN") ans=7;
    if(s=="MON") ans=6;
    if(s=="TUE") ans=5;
    if(s=="WED") ans=4;
    if(s=="THU") ans=3;
    if(s=="FRI") ans=2;
    if(s=="SAT") ans=1;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextLine();
            out.println(s.charAt(0) + "" + (s.length() - 2) + s.charAt(s.length() - 1));
        }

    }

    static class InputReader {
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String nextLine() {
            String str = null;
            try {
                str = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }

    }
}
 

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#include <unistd.h>
#define inf 1000000007LL
#define INF 1000000000000000007LL
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define st first
#define nd second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector< pair<int,int> >
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define LOG(x) (63-__builtin_clzll(x))
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i, n) for(int i=1; i<=(n); ++i)
#define endr cerr<<'\n'
#define endl '\n'
#ifdef DEBUG
#define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__)
#define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';}
#define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';}
#define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';}
#define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';}
#define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';}
#else
#define cerr if(0)cout
#define pv(...) if(0)endr
#define ps(x) if(0)endr
#define pa(x, xs) if(0)endr
#define pal(x, xs) if(0)endr
#define ppii(x, xs) if(0)endr
#define pm(x, xn, xm) if(0)endr
#endif
using namespace std;
template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);}
template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;}
const int N = 1000007;
#define int long long

int n, waysB[N];
vi A, B, C;


void solve()
{
  cin>>n;
  A.resize(n+1);
  B.resize(n+1);
  C.resize(n+1);
  rep1(i, n) cin>>C[i];
  rep1(i, n) cin>>B[i];
  rep1(i, n) cin>>A[i];

  sort(all(A));
  sort(all(B));
  sort(all(C));

  /*A.erase(unique(all(A)), A.end());
  B.erase(unique(all(B)), B.end());
  C.erase(unique(all(C)), C.end());*/

  ps(A);
  ps(B);
  ps(C);

  int rst = 0;

  int ic = 0;
  for (int i=1; i<=n; ++i)
  {
    while (ic<n && C[ic+1]<B[i]) ++ic;
    waysB[i] = ic;
  }

  pal(waysB, n);

  int pref = 0;
  int ib = 0;
  for (int i=1; i<=n; ++i)
  {
    while (ib<n && B[ib+1]<A[i])
    {
      ++ib;
      pref += waysB[ib];
    }

    pv(i, pref, ib);
    rst += pref;
  }

  cout<<rst;
}

int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL);
cout<<fixed<<setprecision(10);

  solve();

return 0;
}


Measured memory_bytes: 3456
n=int(input())
data=[0]*(n+1)
for i in range(2,n+1):
    while i%2==0:
        i//=2
        data[2]+=1
    j=3
    while i>1:
        if i%j==0:
            i//=j
            data[j]+=1
        else:
            j+=2
ans=1
mod=10**9+7
for i in range(n+1):
    if data[i]!=0:
        ans=ans*(data[i]+1)%mod
print(ans)

Measured memory_bytes: 3064