akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination
 * usage:repc(bit,k,n)
 * */
int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

/* uniq
 * usage:uniq(vec)
 * */
void uniq(vector<int> &vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return;
}

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  int n;cin>>n;
  vector<vector<int> >rob;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    rob.push_back({a+b,a-b});
  }
  sort(rob.begin(), rob.end());
  int ans = 0;
  queue<vector<int> >robos;
  rep(i,n)robos.push(rob[i]);
  while(!robos.empty()){
    ans++;
    int limit = robos.front()[0];
    robos.pop();
    if(robos.size()>0){
      while(!robos.empty()){
        if(robos.front()[1]<limit) robos.pop();
        else break;
      }
    }
  }
  cout << ans<<'\n';

        return 0;
}

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

# 小さい数から配っていくと子供の人数を最大化できる
a = sorted(a)

leftCandy = x
childrenCnt = 0
for i in range(len(a)):
  leftCandy -= a[i]
  if leftCandy >= 0:
    childrenCnt += 1

if leftCandy > 0:
  childrenCnt -= 1

print(childrenCnt)





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

#define FOR(i, j, k) for(ll i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}
ll dp[5000 * 5000 + 1];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    vll wa(3), wb(3);
    cin >> wa[0] >> wa[1] >> wa[2];
    cin >> wb[0] >> wb[1] >> wb[2];
    // ll ga, sa, ba, gb, sb, bb;
    // cin >> ga >> sa >> ba >> gb >> sb >> bb;

    memset(dp, 0, sizeof(dp));
    REP(i, 3) for(ll w = 0; w <= n; w++) {
        if(w >= wa[i])
            dp[w] = max(dp[w], dp[w - wa[i]] + wb[i]);
        else
            dp[w] = dp[w];
        // cout << i << " " << w << " : " << dp[w] << endl;
    }
    ll max_donguri1 = 0;
    REP(i, n + 1) max_donguri1 = max(max_donguri1, n - i + dp[i]);

    memset(dp, 0, sizeof(dp));
    REP(i, 3) for(ll w = 0; w <= max_donguri1; w++) {
        if(w >= wb[i])
            dp[w] = max(dp[w], dp[w - wb[i]] + wa[i]);
        else
            dp[w] = dp[w];
        // cout << i << " " << w << " : " << dp[w] << endl;
    }
    ll max_donguri2 = 0;
    REP(i, max_donguri1 + 1)
    max_donguri2 = max(max_donguri2, max_donguri1 - i + dp[i]);

    cout << max_donguri2 << endl;

    return 0;
}


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

V = [0]*10000

for j in range (1, 100):
    for k in range (1, 100):
        for l in range (1, 100):
            if j**2+k**2+l**2+j*k+k*l+j*l < 10001:
                V[j**2+k**2+l**2+j*k+k*l+j*l-1]+=1

for i in range (0, N):
    print(V[i])

Measured memory_bytes: 9248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> arr(n);
    for (int z=0;z<n;z++){
        cin >> arr[z];
    }
    sort(arr.begin(),arr.end());
    ld c = (arr[0]+arr[1])/ld(2);
    for (int z=2;z<n;z++){
        c = (c+arr[z])/ld(2);
    }
    cout << setprecision(60) << c << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();

    sc.close();

    String[] S = s.split("");
    
    Deque<String> deque = new ArrayDeque<>();

    for (int i = 0; i < S.length; i++) {
      if (S[i].equals("0")) {
        deque.addLast("0");
      }
      if (S[i].equals("1")) {
        deque.addLast("1");
      }
      if (S[i].equals("B")) {
        if (0 < deque.size()) {
          deque.pollLast();
        }
      }
    }

    int l = deque.size();

    for (int i = 0; i < l; i++) {
      System.out.print(deque.pollFirst());
    }

    System.out.println("");

  }

}

Measured memory_bytes: 21844
#include<iostream>
using namespace std ;
int main()
{
	int a=0 , b=0 , N=0 , s=0 , f=0 , A=0 ;
	cin >> a >> b >> N ;
	for(int i=0;i<N;i++)
	{
		cin >> s >> f ;
		if(a<s&&s<b) A=1 ;

		if(s<=a&&a<=f&&s<=b&&b<=f) A=1 ;

		if(a<f&&f<b) A=1 ;
	}
	cout << A << endl ;
	return 0 ;
}




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

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    let ans = std::cmp::max(std::cmp::max(a+b, a-b), a*b);
    println!("{}", ans);
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(abc.Skip(1).All(x => abc.First() == x) ? "Yes" : "No");
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<vector>
#include<algorithm>
 
#define ll long long
ll MAX = 1000000000+7;
 
using namespace std;
 
ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}
 
int main() {
        ll n, k, i, a, po=0, ni=0, ans=1;
        vector<ll> vcp, vcn;
        cin >> n >> k;
        for (i=0;i<n;i++) {
            cin >> a;
            if (a<0) {
                a=-a;
                ni++; vcn.push_back(a);
            }
            else {
                po++; vcp.push_back(a);
            }
        }
        if (po>0) sort(vcp.begin(),vcp.end());
        if (ni>0) sort(vcn.begin(),vcn.end());
 
        if (po==0) {
            if (k%2==0) {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[ni-1]);
                    ans = modF(ans);
                    ni--;
                }
            }
            else {
                for (i=0;i<k;i++) {
                    ans = ans * (-vcn[i]);
                    ans = modF(ans);
                }
            }
        }
        else if (ni==0) {
            for (i=0;i<k;i++) {
                ans = ans * vcp[po-1];
                ans = modF(ans);
                po--;
            }
        }
        else {
            if (k%2==1) {
                ans = vcp[po-1];
                po--; k--;
            }
            while (k>1 && (po>=2 || ni>=2)) {
                ll propo = 0;
                if (po>=2) propo = vcp[po-1]*vcp[po-2];
                ll proni = 0;
                if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];
 
                if (propo>proni) {
                    propo = modF(propo);
                    ans = ans*propo;
                    ans = modF(ans);
                    po = po-2;
                }
                else {
                    proni = modF(proni);
                    ans = ans*proni;
                    ans = modF(ans);
                    ni = ni-2;
                }
                k=k-2;
            }
            while (k>0) {
                if (po>0) {
                    ans = ans*vcp[po-1];
                    ans = modF(ans);
                    po--; k--;
                }
                else if (ni>0) {
                    ans = ans*(-vcn[ni-1]);
                    ans = modF(ans);
                    ni--; k--;
                }
            }
        }
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5528
#include <iostream>
#include <set>
#include <map>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    string S, g;
    cin >> S;
    set<string> St;
    for(int i = 0; i < S.size(); ++i){
      if(S[i] == ':') g = "";
      else if(S[i] == ',' || S[i] == '.'){
	St.insert(g);
	g = "";
      }else{
	g += S[i];
      }
    }
    map<string, string> M;
    string S_[n];
    for(int i = 1; i < n; ++i){
      cin >> S_[i];
    }
    for(int k = 0; k < n; ++k){
      for(int i = 1; i < n; ++i){
	S = S_[i];
	  g = "";
	for(int j = 0; j < S.length(); ++j){
	  if(S[j] == ':'){
	    if(St.find(g) == St.end()) break;
	    else{
	      St.erase(g);
	    }
	    g = "";
	  }else if(S[j] == ',' || S[j] == '.'){
	    St.insert(g);
	    g = "";
	  }else{
	    g += S[j];
	  }
	}
      }
    }
    cout << St.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 3144
// Alapan
// IIITH

#include<bits/stdc++.h>
using namespace std;

// data types
#define ll long long int
#define ld long double

//funtion macros


// stl
#define lp(var,start,end) for (ll var = start; var <=end ; ++var)
#define ilp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))

#define mod 1000000007

// utility functions
ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

ll min(ll a, ll b){
	if(a<b)return a;
    return b;
}

ll power(ll x, ll y, ll m=mod){
	if(y<0){
		x = power(x,m-2);
		y = -y;
	}
	ll ans=1;
	x = x % m;
	while(y){
		if(y&1) ans = (ans*x)%m;
		y=y/2;
		x=(x*x)%m;
	}
	return ans;
}

ll factorial(ll n, ll m=mod){
    ll ans = 1;
	ll i = 1;
    while(i<=n){
        ans = (ans*i)%m;
        i++;
    }
    return ans;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll x[n];
    ll y[n];
    for(ll i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    ll maxs=0;
    ll maxindex=0;
    ll mins = LLONG_MAX;
    ll minindex=0;
    for(ll i=0;i<n;i++){
        if(x[i]+y[i]>maxs){
            maxs=x[i]+y[i];
            maxindex=i;
        }
        if(x[i]+y[i]<mins){
            mins=x[i]+y[i];
            minindex=i;
        }
    }
    maxs=0;
    mins=LLONG_MAX;

    ll ans = abs(x[maxindex]-x[minindex])+abs(y[maxindex]-y[minindex]);
    for(ll i=0;i<n;i++){
        if(x[i]-y[i]>maxs){
            maxs=x[i]-y[i];
            maxindex=i;
        }
        if(x[i]-y[i]<mins){
            mins=x[i]-y[i];
            minindex=i;
        }
    }
    ans = max(ans, abs(x[maxindex]-x[minindex])+abs(y[maxindex]-y[minindex]));
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 6736
// AOJ 2104: Country Road
// 2017.9.30 bal4u@uu
// 2017.11.7 retry

#include <stdio.h>
#include <string.h>

int d[100002], d2[100002]; int n;

// for data input
char buf[800000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

// for sorting
#define VMAX 1000000
int f[VMAX+1], vmax, vmin;
void distsort()
{
	int i, x;

	memset(f, 0, sizeof(f));
	for (i = 0; i < n; i++) f[d[i]]++;
	for (i = vmin+1; i <= vmax; i++) f[i] += f[i-1];
	for (i = n-1; i >= 0; i--) x = d[i], d2[--f[x]] = d[i];
}

int main()
{
	int t, k, i, x, x0, dx, ans;

	fgets(p=buf, 10, stdin), t = getint();
	while (t--) {
		fgets(p=buf, 20, stdin), n = getint(), p++, k = getint();
		fgets(p=buf, sizeof(buf), stdin);
		if (k >= n) { puts("0"); continue; }
		vmin = 1000000, vmax = 0;
		for (n--, x0 = getint(), i = 0; i < n; i++, x0 = x) {
			p++, x = getint();
			d[i] = dx = x - x0;
			if (dx < vmin) vmin = dx;
			if (dx > vmax) vmax = dx;
		}
		distsort();
		for (ans = 0, i = 0; i <= n-k; i++) ans += d2[i];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 7048
A,B,K = map(int, input().split())
if B-A > 2 * K:
  [print(i) for i in range(A,A+K)]
  [print(i) for i in range(B+1-K,B+1)]
else:
  [print(i) for i in range(A,B+1) if i - K < A or i + K > B]

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);


	    int N=gi();
	    char[][] cs=new char[N][26];
        for (int i=0; i<N; i++) {
            String s=gs();
            for (int j=0; j<s.length(); j++) {
            	char c= s.charAt(j);
            	cs[i][c-97]++;
            }
        }
        
        StringBuilder sb=new StringBuilder();
        for (int i=0; i<26; i++) {
        	int min=Integer.MAX_VALUE;
        	for (int j=0; j<N; j++) {
                if(min>cs[j][i]) {
                	min=cs[j][i];
                }
            }
        	char c=(char)(97+i);
        	sb.append(String.join("", Collections.nCopies(min, String.valueOf(c))));
        }

        System.out.println(sb.toString());

//        if(ans==0) {
//
//		    System.out.println("Yes");
//        } else {
//        	System.out.println("No");
//
//        }
	}

	public static List<Integer> insuB(int n) {
		List<Integer> l=new ArrayList<Integer>();
		int i=2;
		while(n!=1) {
			if (n%i==0) {
				l.add(i);
				n/=i;
			} else {
				i++;
			}
		}
		return l;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 ll dp[101][100001]={0};
struct help{
 ll we,val;
};
ll maxValue(help arr[],ll n,ll tw){
 if(tw==0 || n==0){
    return 0;
 }
 if(dp[n][tw]!=0){
     return dp[n][tw];
 }
 ll maxm = INT_MIN;
    if(tw-arr[n].we>=0)
    maxm = max(maxm,arr[n].val +maxValue(arr,n-1,tw-arr[n].we));
    maxm = max(maxm,maxValue(arr,n-1,tw));
return dp[n][tw] = maxm;
}
int main(){
 ll n,tw;
 cin>>n>>tw;
 help arr[n+1];
 for(ll i=1;i<=n;i++){
    ll w,v;
    cin>>w>>v;
    arr[i].we = w;
    arr[i].val = v;
 }
 cout<<maxValue(arr,n,tw);
}


Measured memory_bytes: 77312
import sys
sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline
 
N, Q = list(map(int, input().split()))
 
M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)
 
ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x
 
def setAnswer(parent, number):
    ans[number] += ans[parent]
 
    for i in M[number]:
        if i != parent:
            setAnswer(number, i)
 
for i in M[0]:
    setAnswer(0, i)
 
print(' '.join(map(str, ans)))


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

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

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans += A[i] * A[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, cnt=0;
  bool odd_flag;
  cin >> N;
  int s[N];
  for (int i = 0; i < N; i++) { cin >> s[i]; }
  while(true)
  {
    odd_flag = false;
    for (int i = 0; i < N; i++)
  	{
  		if (s[i] % 2 != 0) { odd_flag = true; }
  	}
    if (odd_flag) { break; }
    
    for (int i = 0; i < N; i++) { s[i] /= 2; }
    cnt++;
  }
  cout << cnt << endl;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

template<int N=255>
class UnionFindTree {
public:
  const LL len = N;
  A<LL, N> uftq{};
  A<LL, N> s{};
  UnionFindTree(LL &n) {
    FOR(i,0,n) {
        uftq[i] = i;
        s[i] = 1;
    }
  }
  LL find(LL& x) {
      LL xParent = uftq[x];
      V<LL> v;
      while(xParent != uftq[xParent]) {
          v.push_back(xParent);
          xParent = uftq[xParent];
      }
      REP(i, v.size()) {
          uftq[v[i]] = xParent;
      }
      return xParent;
  }
  LL size(LL& idx) {
      return s[find(idx)];
  }
  bool unite(LL& x, LL& y) {
      LL xRoot = find(x);
      LL yRoot = find(y);
      if(xRoot == yRoot) return false;
      s[yRoot] = s[xRoot] + s[yRoot];
      s[xRoot] = 0;
      uftq[xRoot] = yRoot;
      return true;
  }
};


LL n, m;
V<LL> ai;
V<LL> bi;
V<LL> ans;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> n; cin >> m;
    UnionFindTree<100001> uft{n};
    REP(i, m) {
        LL a, b;
        cin >> a; cin >> b;
        ai.push_back(a-1);
        bi.push_back(b-1);
    }

    LL f = (n * (n - 1)) / 2;
    ans.push_back(f);
    for(int i = m-1; i >= 0; i--) {
        LL x = uft.size(ai[i]);
        LL y = uft.size(bi[i]);
        if(uft.unite(ai[i], bi[i]) && (f - (x*y) >= 0)) f -= (x*y);
        ans.push_back(f);
    }
    for(int i=m-1; i >= 0; i--) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 5356
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin>> N;//入力
    
    vector<int> Oct(N,0);
    for(int k=0;k<N; k++){
           cin>>Oct[k];
        }

    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=0;j<N-i-1;j++){
           ans+=Oct[i]*Oct[i+1+j];
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[305][305],t[305];
int main (){
	int i,j,k,n,m;
	scanf ("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{for (j=1;j<=m;j++)
	{scanf ("%d",&a[i][j]);}
	}
	int ans=123456;
	for (i=1;i<=m;i++)
	{int b=0,pos;
	memset (t,0,sizeof(t));
	for (j=1;j<=n;j++)
	{for (k=1;k<=m;k++)
	{if (a[j][k]!=0) 
	{t[a[j][k]]++;break;}
	}
	}
	for (j=1;j<=m;j++)
	{if (t[j]>b) {b=t[j];pos=j;}
	}
	if (b<ans) {ans=b;}
	for (j=1;j<=n;j++)
	{for (k=1;k<=m;k++)
	{if (a[j][k]==pos)
	{a[j][k]=0;break;}
	}
	}
	}
	printf ("%d",ans);
	return 0;
}
	
	

Measured memory_bytes: 640
using System;

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

            var d = new int[n];
            for(var i = 0; i < n; i++){
                d[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(d);

            var count = 1;
            var val = d[0];
            for(var i = 1; i < n; i++){
                if(val < d[i]){
                    val = d[i];
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main() {
  ll N; cin >> N;
  map<ll, ll> pos;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i]; pos[a[i]] = i+1;
  }
  set<ll> s;
  ll res = 0;
  ll m = INF; ll M = -1; 
  for (ll i = 1; i <= N; i++) {
    ll l, r;
    if (M > pos[i]) {r = *(s.lower_bound(pos[i]));}
    else {r = N+1;}
    if (m < pos[i]) {l = *(prev(s.lower_bound(pos[i])));}
    else {l = 0;}
    M = max(M, pos[i]); m = min(m, pos[i]);
    s.insert(pos[i]);
    //cout << r-l-1 << endl;
    res += i*(r-pos[i])*(pos[i]-l);
  }
  cout << res << endl;
}

Measured memory_bytes: 23680
#include <strings.h>
#include <stdio.h>
#include <ctype.h>

char str[101];
int tindex=0;
int map[255];
int token;

int addminus();

void getToken(void) {
    int r = 0;
    if (isdigit(str[tindex])) {
	while (isdigit(str[tindex])) {
	    r = r*10+(str[tindex++]-'0');
	}
	token = r;
    } else {
	token = map[(int)str[tindex++]];
    }
}

int terminal() {
    int result = 0;
    if (token == -5) {
	getToken();
	result = addminus();
	getToken();
    } else if (token >= 0) {
	result = token;
	getToken();
    }
    return result;
}

int multidiv() {
    int result = terminal();
    while (token == -3 || token == -4) {
	if (token == -3) {
	    getToken();
	    result *= terminal();
	} else {
	    getToken();
	    result /= terminal();
	}
    }
    return result;
}
 
int addminus() {
    int result = multidiv();
    while (token == -1 || token == -2) {
	if (token == -1) {
	    getToken();
	    result += multidiv();
	} else {
	    getToken();
	    result -= multidiv();
	}
    }
    return result;
}
 
int main(void) {
    int i, n, total;

    map['+'] = -1;
    map['-'] = -2;
    map['*'] = -3;
    map['/'] = -4;
    map['('] = -5;
    map[')'] = -6;
    map['='] = -7;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
	tindex=0;
	scanf("%s", str);
	getToken();
	total=addminus();
	printf("%d\n", total);
    }
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n;
vector< int > a, ans;
vector< vector< int > > edg;

vector<int> dp;

void f(int v, int mx = 0){
    int ok = 0, ng = n+1;
    while(ok + 1 < ng){
        int mid = (ng+ok)/2;
        if(dp[mid] < a[v]) ok = mid;
        else ng = mid;
    }
    int xm = mx;
    ans[v] = mx = max(mx, ok+1);
    int mem = dp[ok+1];
    dp[ok+1] = min(dp[ok+1], a[v]);

    for(int w: edg[v]){
        if(ans[w] == -1) f(w, mx);
    }

    mx = xm;
    dp[ok+1] = mem;
}
int main(void){
    cin >> n;
    a.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    edg.assign(n, vector<int>());
    for(int i=0;i<n-1;i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }

    ans.assign(n, -1);
    dp.assign(n+1, 1e9+1);
    dp[0] = 0;
    f(0);

    for(int v: ans) cout << v << endl;


}


Measured memory_bytes: 24648
#include <iostream>

using namespace std;

const int MAX_P = 100;

int main(int argc, char const *argv[]) {
  char C[MAX_P][MAX_P];
  char ans[MAX_P*2][MAX_P];
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> C[i][j];
  }
  for (int i = 0; i < 2*h; i+=2) {
    for (int j = 0; j < w; j++) {
      ans[i][j] = C[(i+1)/2][j];
      ans[i+1][j] = C[(i+1)/2][j];
    }
  }

  for (int i = 0; i < 2*h; i++) {
    for (int j = 0; j < w; j++) cout << ans[i][j];
    cout << endl;
  }

  return 0;
}


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

// r -> p, s -> r, p -> s
int main() {
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  auto score = [&](int i) {
    if (t[i] == 'r')
      return p;
    else if (t[i] == 's')
      return r;
    else
      return s;
  };

  ll res = 0;
  rep(i, k) {
    bool last = false;
    for (int j = i; j < n; j += k) {
      if (j >= k && t[j - k] == t[j] && last)
        last = false;
      else
        res += score(j), last = true;
    }
  }
  cout << res << endl;
}

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

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

  int *table;
  table = (int*)malloc(sizeof(int)*(n+7));
  for(int i=0; i<n+7; i++)  table[i] = 0;


  long ans = 0;
  for(int i=1; i<=n; i++){
    for(int j=1; i*j<=n; j++)
      table[i*j]++;
    ans = ans + ((long)table[i]*(long)i);
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 40764
n,k=map(int, input().split()) 
s=list(input())
s=list('R')+s+list('L')
count1=0
count2=0

for i in range(1,n+2):
    if s[i-1]=='R' and s[i]=='L':
        if i==1 or i==n+1:
            count1+=1
        else:
            count2+=1
            
ans=n-(count1+count2*2)

if k<=count2:
    print(ans+k*2)
else:
    print(n-1)
    
    




            
             


Measured memory_bytes: 51952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{       
    static int GetParent(int index, int[] parents)
    {
        if(parents[index] == index)
            return index;
        else
        {
            int parent = GetParent(parents[index], parents);
            parents[index] = parent;
            return parent;
        }

    }
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        int[] parents = Enumerable.Range(0, n).ToArray();
        var bridges = 
            Enumerable.Range(0, m)
            .Select(x =>
                Console.ReadLine().Split())
            .Select(x => new {A = int.Parse(x[0]) - 1, B = int.Parse(x[1]) - 1})
            .ToArray();
        List<long> result = new List<long>();
        result.Add((long)n * (n - 1) / 2);
        int[] pCount = new int[n].Select(x => 1).ToArray();
        foreach(var bridge in bridges.Reverse().Take(m - 1))
        {
            int aParent = GetParent(bridge.A, parents);
            int bParent = GetParent(bridge.B, parents);
            if(aParent != bParent)
            {
                //System.Console.WriteLine($"{parents.Count(x => x == aParent)} {parents.Count(x => x == bParent)}");
                //System.Console.WriteLine(string.Join(",", parents));
                long count = (long)pCount[aParent] * pCount[bParent];
                result.Add(result.Last() - count);
                parents[aParent] = bParent;
                pCount[bParent] += pCount[aParent];
            }
            else
                result.Add(result.Last());
        }
        result.Reverse();
        System.Console.WriteLine(string.Join("\n", result));
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 37828
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll mod){
	ll res = 1;
	while(y){
		if(y & 1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
ll C(ll n, ll m,ll p)
{
    if(m > n) return 0;
    ll ans = 1;
    for(int i=1; i<=m; i++)
    {
        ll a = (n + i - m) % p;
        ll b = i % p;
        ans = ans * (a * poww(b,p-2,p) % p) % p;
    }
    return ans;
}
ll Lucas(ll n, ll m,ll p)
{
    if(m == 0) return 1;
    return C(n % p, m % p,p) * Lucas(n / p, m / p,p) % p;
}
ll n,a,b;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	cin >> n >> a >> b;
	ll ans = (poww(2,n,mod) - 1 + mod) % mod;
	ans = (ans - Lucas(n,a,mod) + mod) % mod;
	ans = (ans - Lucas(n,b,mod) + mod) % mod;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define vll vector< ll >
#define rep(a,b)  for(ll i=a;i<=b;i++)
#define vpll vector<pair<ll,ll>>
#define SZ(x) ((int)x.size())
#define FIO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define mp make_pair
#define pb push_back
#define pf push_fron

using namespace std;
const int inf=1e9+7;
int main()
{
	ll T=1;//cin>>T;
	while(T--)
	{
        ll n,k;cin>>n>>k;
        ll a[n];
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll dp[n];
        dp[0]=0;
        for(ll i=1;i<n;i++)
            dp[i]=inf;
        for(ll i=0;i<n;i++)
        {
            for(ll j=i+1;j<=i+k && j<n;j++)
            {
                dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
            }
        }
        cout<<dp[n-1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 5204
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
k = I()
ans = 1
for i in range(n):
    ans = min(ans+k, ans*2)
print(ans)

Measured memory_bytes: 74176
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long int
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl vector<long long>v(n);
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
ll power(ll a,ll b){ ll res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}



 int main()
 {
       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       ll tst;
       tst=1;
       //cin>>tst;
    
       while(tst--)
       {
        ull n;
        cin>>n;bool flag=true;bool t=true;
        vector<ull>v(n);ull ans=1;
        for(ull i=0;i<n;i++)
        {
                  cin>>v[i];
                  if(v[i]==0)
                  t=false;
        }
        if(t==false)
        ans=0;
        else
        {
        for(ull i=0;i<n;i++)
        {
                  if(v[i]<=1000000000000000000/ans)
                  ans=ans*v[i];
                  else
                  {
                            flag=false;
                            cout<<-1<<endl;break;
                  }
        }
        }
        if(flag)
        cout<<ans<<endl;
       }
 
 }

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> w(n,0),e(n,0);
  if(s[0]=='W'){
    w[0]++;
  }else{
    e[0]++;
  }
  for(int i=1;i<n;i++){
    if(s[i]=='W'){
      w[i]=w[i-1]+1;
      e[i]=e[i-1];
    }else{
      e[i]=e[i-1]+1;
      w[i]=w[i-1];
    }
  }
  int ans=e[n-1]-e[0];
  for(int i=1;i<n;i++){
    ans=min(ans,w[i-1]+e[n-1]-e[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
use proconio::*;
use proconio::marker::Chars;

fn salsa(x: usize) -> usize {
    assert!(x < 3);
    if x == 0 {
        0
    } else {
        x ^ 3
    }
}

fn test() {
    input! {
        n: usize,
        s: Chars,
    }
    let mut sum = vec![0; s.len() + 1];
    let mut rumba = vec![];
    for (i, (s, c)) in sum.iter_mut().zip(s.iter()).enumerate() {
        if *c == 'S' {
            *s = 1;
        } else {
            rumba.push(i);
        }
    }
    for i in (0..s.len()).rev() {
        sum[i] += sum[i + 1];
    }
    let mut dp = vec![(rumba, 0)];
    for i in 0..n {
        let len = 3usize.pow(i as u32);
        let mut next: Vec<_> = vec![(vec![], 0); 3 * len];
        for (i, (rumba, pos)) in dp.into_iter().enumerate() {
            let mut prev = 0;
            let mut a = vec![0, 1, 2];
            for x in rumba {
                if (sum[prev] - sum[x]) % 2 == 1 {
                    for y in a.iter_mut() {
                        *y = salsa(*y);
                    }
                }
                for (j, y) in a.iter_mut().enumerate() {
                    if *y == 2 {
                        *y = 0;
                        next[j * len + i].0.push(x);
                    } else {
                        *y += 1;
                    }
                }
                prev = x;
            }
            if sum[prev] % 2 == 1 {
                for y in a.iter_mut() {
                    *y = salsa(*y);
                }
            }
            for (j, &y) in a.iter().enumerate() {
                next[j * len + i].1 = y * len + pos;
            }
        }
        dp = next;
    }
    let mut s = String::new();
    for dp in dp {
        s.push_str(&format!("{} ", dp.1));
    }
    s.pop();
    println!("{}", s);
}

fn main() {
    test();
}


Measured memory_bytes: 34136
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N;
string S;
int mod = 1e9 + 7;

int main() {
    cin >> S;
    bool flag = S <= "2019/04/30";
    cout << (flag? "Heisei": "TBD") << endl;
}

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

int main()
{
    std::string str;
    std::getline(std::cin, str);

    auto has_bus = false;
    for (size_t i = 1; i < str.size(); i += 1) {
        if (str[i] != str[0]) {
            has_bus = true;
            break;
        }
    }

    std::cout << (has_bus ? "Yes" : "No") << "\n";
    return 0;
}


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

if m != 0:
    sc = [map(int, input().split()) for _ in range (m)]
    s,c = [list(i) for i in zip(*sc)]
else:
    pass

start = 0 if n == 1 else 10**(n-1)
for j in range(start,10**n+1):
    judge = 0
    for k in range(m):
        if str(j)[s[k]-1] == str(c[k]):
            judge += 1
        else:
            pass

    if judge == m:
        print(j)
        break
    elif j == 10**n:
        print(-1)
        #print(judge) #test
    else:
        pass

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i )
typedef std::pair<int,int> pint;

using namespace std;
typedef long long ll;

int main(){
    int X; cin >> X;
    if (X >= 30){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c > a+b)
    if(4*a*b < (c-(a+b))*(c-(a+b)))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  else
    cout << "No" << endl;
}


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


int main(){
	int N;
	cin>>N;
	N*=2;
	vector<int> L(N);
	for(int i=0;i<N;i++)cin>>L[i];
	sort(L.begin(),L.end(),greater<int>());
	int ans = 0;
	for(int i=1;i<N;i+=2){
		ans+=L[i];
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    set<char> atc = {'A','C','G','T'};
    string s;
    int cnt=0, maxs=0;
    cin >> s;
    rep(i, s.size()) {
        if (atc.count(s[i]))cnt++;
        else {
            maxs = max(maxs, cnt);
            cnt = 0;
        }
    }
    cout << max(cnt,maxs) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    lst = sorted([int(i) for i in input().split()], reverse=True)
    ans = lst[0]

    n, m = divmod(N - 2, 2)
    ans += sum(lst[1:n + 1]) * 2
    if m:
        ans += lst[n + 1]

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31756
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
    int n, d;
    cin >> n >> d;
    
    int64_t x, y, count = 0;
    double_t num;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        num = sqrt(x * x + y * y);
        if(num <= d){
            count++;
        }
    }
    
    cout << count << endl;
}

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


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

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;
int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

int H, W;
char A[1010][1010];
queue<P>que;
int ans = 0;
void BFS(queue<P> que) {
	queue<P>que2;
	bool found = 0;
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		int x = p.first, y = p.second;
		
		REP(i, 4) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx >= 0 && nx < H&&ny >= 0 && ny < W) {
				if (A[nx][ny] == '.') {
					found = true;
					que2.push({ nx,ny });
					A[nx][ny] = '#';
				}
			}
		}
		
	}
	if (found)ans++;
	else return;
	BFS(que2);
}
void solve() {
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
			if (A[i][j] == '#') {
				que.push({ i,j });
			}
		}
	}
	BFS(que);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 33972
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    ll n, p;   cin >> n >> p;

    vector<P> fact_p = prime_factorize(p);
    ll res = 1;
    for(P x: fact_p){
        ll ex = x.sc;
        for(int i = 0; i < ex / n; i++){
            res *= x.fs;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 6e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n ;
    cin >> n ;
    multiset<ll> s ;
    for (int i = 0 ; i < 3 * n ; i ++) {
    	ll x ;
    	cin >> x ;
    	s.insert(x) ;
	}
	ll ans = 0 ;
	while (s.size()) {
		ll v = *s.rbegin() ;
		s.erase(s.find(v)) ;
		ll u = *s.rbegin() ;
		s.erase(s.find(u)) ;
		ll x = *s.begin() ;
		s.erase(s.find(x)) ;
		ans += u ;
	}
	cout<< ans ;
    
    return (0) ;
}

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

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

  int answer = 0;
  if( s == '+') {
   answer = a + b;
  } else {
   answer =  a - b;
  }
  cout << answer << endl;


}


Measured memory_bytes: 256
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,P = map(int,input().split())
A = list(map(int,input().split()))
H = [i%2 for i in A]
B = collections.Counter(H)[1]

ans = 0
for i in range(1,B//2+1):
    ans += combinations_count(B, 2*i)
C = (ans+1) * (2**(len(A)-B))
print(C if P == 0 else 2**N - C)

Measured memory_bytes: 9412
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

	int N, K;
	cin >> N >> K;

	int snuke[101] = {};
	rep(i, K) {
		int d;
		cin >> d;

		rep(i, d) {
			int A;
			cin >> A;
			snuke[A]++;
		}
	}

	int kotae = 0;
	rep1(i, N) if (snuke[i] == 0) kotae++;

	co(kotae);



	Would you please return 0;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
  ll X, K, D;
  cin >> X >> K >> D;
  if (X<0) X*=-1;

  ll q = X/D, r = X%D;

  if (q>K) ans = X-K*D;
  else {
    K -= q;
    if (K%2==0) ans = r;
    else ans = abs(r-D);
  }

    
  cout << ans << endl;
  return 0;
}





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

int main() {
  int N,M,a,b;
  cin >> N >> M;
  vector<int>cnt(N);
  for(int i=0;i<M;i++){
    cin >> a >> b;
    cnt.at(a-1)++;
    cnt.at(b-1)++;
  }
  for(int i=0;i<N;i++){
    cout << cnt.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
const int N_MAX=100000;
ll dp[101000];

int main() {
    int N;
    int h[N_MAX];
    cin>>N;
    rep(i,N)    cin>>h[i];

    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=0; i<N-2; ++i) {
        dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
    }

    cout<<dp[N-1]<<endl;

 return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
  int N,Y,a,b,c;
  scanf("%d %d",&N,&Y);
  for(a=0;(10000*a<=Y) && (a<=N);a++){
    for(b=0;(10000*a+5000*b<=Y) && (a+b<=N);b++){
      c=Y/1000-10*a-5*b;
      if(a+b+c==N){
        printf("%d %d %d\n",a,b,c);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin >>W >>H >>x >> y >>r ;
    if (r <=x && x<=W-r && r<=y && y<=H-r){
        cout << "Yes"  << endl;
    }else{
        cout << "No"  << endl;
    }
}


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

int h,n,p,m,k,a,b;
double ans[501][101][101];
bool check[501];
bool amida[501][100];
double prob;
int use[501];

int main(){
  cin >> h >> n >> p >> m >> k;

  for(int i=1;i<=h;i++){
    check[i] = false;
    for(int j=1;j<n;j++)amida[i][j] = false;
  }

  for(int i=0;i<m;i++){
    cin >> a >> b;
    check[a] = true;
    amida[a][b] = true;
  }

  int tmp = 0;
  for(int i=1;i<=h;i++){
    if(!check[i])tmp++;
    use[i] = tmp;
  }

  for(int i=0;i<=h;i++){
    for(int j=1;j<=n;j++){
      for(int l=0;l<=k;l++)ans[i][j][l] = 0.0;
    }
  }

  ans[h][p][k] = 1.0;

  for(int i=h;i>0;i--){
    for(int j=1;j<=n;j++){
      int up = min(use[i],k);
      for(int l=0;l<=up;l++){
	if(check[i]){
	  if(j<n && amida[i][j])ans[i-1][j][l] = ans[i][j+1][l];
	  else if(j>1 && amida[i][j-1])ans[i-1][j][l] = ans[i][j-1][l];
	  else ans[i-1][j][l] = ans[i][j][l];
	}else{
	  if(j<n && l>0)ans[i-1][j][l-1] += ( (double)l/use[i] ) * ans[i][j+1][l] / (n-1);
	  if(j>1 && l>0)ans[i-1][j][l-1] += ( (double)l/use[i] ) * ans[i][j-1][l] / (n-1);
	  ans[i-1][j][l-1] += ( (double)(n-3)/(n-1) ) * ( (double)l/use[i] ) * ans[i][j][l];
	  if(j==1 || j==n)ans[i-1][j][l-1] += (1.0/(n-1) ) * ( (double)l/use[i] ) * ans[i][j][l];
	  ans[i-1][j][l] += ( (double)(use[i]-l)/use[i] ) * ans[i][j][l];
	}
      }
    }
  }

  double res = 0.0;

  for(int i=1;i<=n;i++)res = max(res,ans[0][i][0]);
  
  printf("%.8lf\n",res);
}

Measured memory_bytes: 39000