akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ll C[51][51];

void comb_table(int N) {
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= i; j++) {
            if(j == 0 || j == i) {
                C[i][j] = 1LL;
            } else {
                C[i][j] = (C[i-1][j-1] + C[i-1][j]);
            }
        }
    }
}

int main() {

    int N, A, B;
    cin >> N >> A >> B;
    const int NMAX = 50;
    ll v[NMAX];

    for(int i = 0;i < N; i++) {
        cin >> v[i];
    }

    comb_table(N);
    sort(v, v+N);
    reverse(v, v+N);

    double max_ave = 0.0;
    for(int i = 0; i < A; i++) {
        max_ave += v[i];
    }
    max_ave /= A;

    int ath_val_num = 0, ath_val_pos = 0;
    for(int i = 0; i < N; i++) {
        if(v[i] == v[A - 1]){
            ath_val_num++;
            if(i < A) {
                ath_val_pos++;
            }
        }
    }

    ll cnt=0LL;
    if(ath_val_pos==A) {
        for(ath_val_pos = A; ath_val_pos <= B; ath_val_pos++) {
            cnt += C[ath_val_num][ath_val_pos];
        }
    } else {
        cnt += C[ath_val_num][ath_val_pos];
    }

    cout.precision(20);
    cout << fixed << max_ave << endl;
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

long long a,b,k;

int main()
{
    cin>>a>>b>>k;
    if (k>=a)
    {
        k-=a;
        a=0;
    }
    else
    {
        a-=k;
        k=0;
    }
    if (k>=b)
    {
        k-=b;
        b=0;
    }
    else b-=k;
    cout<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

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

public class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] c = Console.ReadLine().ToCharArray();
        int t = 0;
        int max = 0;
        for (int i = 0; i < c.Length; i++)
        {
            if (c[i] == 'I') { t += 1; }
            else if (c[i] == 'D') { t -= 1; }
            if (t > max) max = t;
        }
        Console.WriteLine(max);
    }

}


Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。

count = 0
height = 0

for i in range(1,n):
    height = a[i-1]-a[i]
    if height >= 0:
        count += height
        a[i] += height

print(count)


Measured memory_bytes: 32180
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    int b[n-1],a[n];
    for(int i=0;i<n-1;i++) cin>>b[i];
    a[0] = b[0],a[1] = b[0];
    for(int i=1;i<n-1;i++)
    {
      if(a[i] > b[i]) a[i] = b[i];
      a[i+1] = b[i];
    }
    int ans = 0;
    //for(int i=0;i<n;i++) cout<<a[i]<<' ';
    for(int i=0;i<n;i++)
      ans += a[i];
      cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if( a <= c && c <= b){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key === arr[mid]) return 1;
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    //else return 1;
  }
  return 0;
}


(function() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    ll cnt = 0;
    map<string, ll> mp;
    rep(i, n) {
      string s;  cin >> s;
      sort(s.begin(), s.end());
      mp[s]++;
    }
    for (auto const& entry: mp) {
      for (ll i = entry.second - 1; i >= 0; --i) {
        cnt += i;
      }
    }
    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 11264
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: usize = read!();
    let mut sum: usize = 0;
    let b: Vec<usize> = a.to_string().chars().map(|a|a.to_digit(10).unwrap() as usize).collect_vec();
    for i in 0..b.len() {
        sum+=b[i];
    }
    println!("{}",if a%sum==0 {"Yes"}else{"No"})
}

Measured memory_bytes: 2104
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, q, c, s, t, x;
  scanf("%lld%lld", &n, &q);
  ll f = 1, seg[4 * n];
  while(f < n) f *= 2;
  for(i = f; i < f * 2; ++i) seg[i] = 0;
  for(i = 0; i < f; ++i) seg[i] = 0;
  for(i = 1; i <= q; ++i) {
    scanf("%lld", &c);
    if(!c) {
      scanf("%lld%lld%lld", &s, &t, &x);
      s--, t--;
      ll r = s + f;
      while(1) {
        ll las, ra = 1;
        while(!(r % 2)) r /= 2;
        while(ra <= r) ra *= 2;
        ra /= 2;
        las = f / ra * (r + 1 - ra) - 1;
        while(las > t) {
          r *= 2;
          ra *= 2;
          las = f / ra * (r + 1 - ra) - 1;
        }
        seg[r] += x;
        //printf("r%lld ra%lld las%lld\n", t, ra, las);
        if(las == t) break;
        r++;
      }
    } else {
      scanf("%d", &s);
      s--;
      int now = s + f, ans = 0;
      while(now) {
         ans += seg[now];
         now /= 2;
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,c;
  int p;
  float b,d;
  cin>>a;
  cin>>b;
  d=b*100 + 0.01;
  p=(int)d;
  c=a*p;
  c/=100;
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3688
N, Y = map(int, input().split())

def find() :
    for yukichi in range(N+1) :
        if yukichi * 10000 > Y :
            break
        for higuchi in range(N+1-yukichi) :
            noguchi = N - yukichi - higuchi
            money = yukichi * 10000 + higuchi * 5000 + noguchi * 1000
            if money == Y :
                return (yukichi, higuchi, noguchi)
            if money > Y :
                break
    return (-1, -1, -1)

ans = find()

print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] A1 = new int[N];
        int[] A2 = new int[N];
        int[] a1 = new int[N + 1];
        int[] a2 = new int[N + 1];
        Integer[] result = new Integer[N + 1];

        for (int i = 0; i < N; i++) {
            A1[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N; i++) {
            A2[i] = Integer.parseInt(sc.next());
        }

        a1[0] = 0;
        a2[0] = 0;
        for (int i = 0; i < N; i++) {
            a1[i + 1] = a1[i] + A1[i];
            a2[i + 1] = a2[i] + A2[i];
        }

        result[0] = 0;
        for (int i = 1; i <= N; i++) {
            result[i] = a1[i] + a2[N] - a2[i - 1];
        }

        Arrays.sort(result, Collections.reverseOrder());

        PrintWriter out = new PrintWriter(System.out);
        out.println(result[0]);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35968
import * as fs from 'fs'

const lines = (fs.readFileSync("/dev/stdin", "utf8")).split("\n")

const limit = lines[0]
const num = Number(lines[1])

const arr = Array.from(limit).map(Number)

const createArr = (num: number) => new Array(num).fill(0)

const combination = (all: number, pick: number): number => {
  return createArr(pick).reduce((r1, n1, i1) => r1 * (all - i1) / (i1 + 1), 1) * 9 ** pick
}

const res = arr.reduce((r1, n1, i1) => {
  if (n1 === 0 || r1.remaining === 0) return r1
  const latter = arr.length - i1
  const first = combination(latter - 1, r1.remaining)
  const second = (n1 - 1) * combination(latter - 1, r1.remaining - 1)
  const remaining = r1.remaining - 1
  const third = remaining ? 0 : 1
  const sum = r1.sum + first + second + third
  return {sum, remaining}
}, {sum: 0, remaining: num})

console.log(res.sum)


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

int main()
{
    int a, b;
    cin >> a >> b;
    int n = max(a, b);
    for(int i = 1; i <= n; i++)
    {
        if(abs(a-i) == abs(b-i))
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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


def euclid(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return euclid(y, x % y)


lcm = n * m // euclid(n, m)
nn = lcm // n
mm = lcm // m
ss = s[0::mm]
tt = t[0::nn]

if ss == tt:
    print(lcm)
else:
    print(-1)


Measured memory_bytes: 3316
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		sc.close();

		int i = n/15;

		if(i==0){
 			System.out.print(800*n);
		}else if(i>0){
			System.out.print(800*n-(i*200));
		}
	}
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r_mod(x:int, n:int, mod=10**9+7)->int:
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

def  mod_pow(a:int, b:int, mod:int)->int:
    if b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r_mod(2, m)-1-mca-mcb) % P)
#print((mod_pow(2, m, P)-1-mca-mcb) % P)

Measured memory_bytes: 53104
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let x: usize = it.next().unwrap().parse().unwrap();
    let y: usize = it.next().unwrap().parse().unwrap();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let _c: usize = it.next().unwrap().parse().unwrap();
    let mut p: Vec<i64> = it.map(|s| s.parse().unwrap()).collect();
    let (p, q) = p.split_at_mut(a);
    let (q, r) = q.split_at_mut(b);
    r.sort();
    let mut h = std::collections::BinaryHeap::new();
    let mut sum = 0;
    for &p in p.iter() {
        h.push(-p);
        sum += p;
        while h.len() > x {
            sum += h.pop().unwrap();
        }
    }
    let mut score = vec![sum];
    for &r in r.iter() {
        h.push(-r);
        sum += r;
        sum += h.pop().unwrap();
        score.push(sum);
    }
    let p_res = score;
    let mut h = std::collections::BinaryHeap::new();
    let mut sum = 0;
    for &p in q.iter() {
        h.push(-p);
        sum += p;
        while h.len() > y {
            sum += h.pop().unwrap();
        }
    }
    let mut score = vec![sum];
    for &r in r.iter().rev() {
        h.push(-r);
        sum += r;
        sum += h.pop().unwrap();
        score.push(sum);
    }
    let mut ans = 0;
    for (a, b) in p_res.iter().zip(score.iter().rev()) {
        ans = std::cmp::max(ans, *a + *b);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 18276
#include<stdio.h>
#include<string.h>
char x_x,s[15],ans[15];
int len,len_a;
int main(){
	scanf("%s",s);
	len=strlen(s);

	for(int i=0;i<len;i++){
		x_x=s[i];

		if(x_x=='B'){
			if(len_a>0){
			len_a--;
			ans[len_a]='\0';
			}
		}
		else{
			ans[len_a]=x_x;
			len_a++;
		}
	
	}

	printf("%s",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9+7;
int N, M;
int dp[303][303][303];
vector<pair<int, int> > lx[303];
int main()
{
  scanf("%d%d", &N, &M);
  for(int i=1; i<=N; ++i) lx[i].clear();
  for(int i=0; i<M; ++i)
  {
    int l, r, x; scanf("%d%d%d", &l, &r, &x);
    lx[r].emplace_back(l, x);
  }
  int ans = 0;
  memset(dp, 0, sizeof dp);
  dp[0][0][0] = 1;
  for(int i=0; i<=N; ++i)
    for(int j=0; j<=N; ++j)
      for(int k=0; k<=N; ++k)
      {
        //if(dp[i][j][k] == 0) continue;
        int V = max(i, max(j, k));
        for(auto t: lx[V])
        {
          int l, x; tie(l, x) = t;
          if(l <= i && i <= V) --x;
          if(l <= j && j <= V) --x;
          if(l <= k && k <= V) --x;
          if(x != 0){ dp[i][j][k] = 0; break;}
        }
        if(V==N)
        {
          ans += dp[i][j][k]; ans %= MOD;
        }
        else
        {
          dp[V+1][j][k] += dp[i][j][k]; dp[V+1][j][k] %= MOD;
          dp[i][V+1][k] += dp[i][j][k]; dp[i][V+1][k] %= MOD;
          dp[i][j][V+1] += dp[i][j][k]; dp[i][j][V+1] %= MOD;
        }
      }
  printf("%d\n", ans);
}

Measured memory_bytes: 108928
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
using namespace std;

int main() {
    int a[3], ans = 0;
    rep(i, 3) cin >> a[i];
    sort(a, a+3);
    ans = a[1] - a[0] + a[2] - a[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// ABC 066 D
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF 1e9

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

int main(){

    int N,init,prev_type,j; cin >> N;
    string a,b; cin >> a >> b;
    long long ans;
    if(a[0] == b[0]){
        // tate
        j = 1;
        ans = 3;
        prev_type = 1;
    } else {
        // yoko
        j = 2;
        ans = 6;
        prev_type = 0;
    }

    for(int i=j; i<N; i++){
        if(a[i] == b[i]){
            // tate
            if(prev_type == 1){
                // tate tate
                ans = mod_mul(ans,2);
            } prev_type=1;
        } else {
            // yoko
            if(prev_type == 1){
                //tate yoko
                ans = mod_mul(ans, 2);
            } else {
                // yoko yoko
                ans = mod_mul(ans, 3);
            } prev_type=0; i++;
        }
    }

    cout << ans << endl;

}


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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

#define pb push_back

#define fst first
#define snd second
#define mp make_pair

#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define frl(i,n) for(long long i=0;i<n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << "\n"
#define displayvec(vec) cout<<#vec<<": "; for(auto vd : vec) cout<<vd<<" "; cout<<"\n"

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) os << v[i] << " ";
  os << endl;
  return os;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, W;
    cin>>n>>W;

    vector< ll > w(n), v(n);
    for(ll i = 0; i < n; ++i) cin>>w[i]>>v[i];

    vector< ll > dp(100001, LLONG_MAX);
    dp[0] = 0;

    for(ll i = 0; i < n; ++i){
            vector< pll > values;
        for(ll val = v[i]; val <= 100000; ++val){
            if(dp[val - v[i]] != LLONG_MAX){
                values.push_back({val, min(dp[val - v[i]] + w[i], dp[val])});
            }
        }
        for(auto value : values){
            dp[value.first] = value.second;
        }
    }
    ll val = 100000;
    for(; val > 0 && dp[val] > W; --val);
    cout<<val<<"\n";
    return 0;
}


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

int main () {
  int n, ans = 0;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);
  rep(i,n-2) {
    if(p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2))
      ans++;
    else if(p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2))
      ans++;
  }
  cout << ans;
}


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

#define max 100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

int main()
{
    int n, i, cnt=0, flag=0;
    long int h[max];
    
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%ld", &h[i]);
    }
    
    for (i=n-1; i>0; i--) {
        if (h[i]-h[i-1]==-1) {
            h[i-1]--;
        } else if(h[i]-h[i-1]<-1){
            printf("No");
            return 0;
        }
    }
    
    printf("Yes");
    
    return 0;
}



Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
const int siz = 5*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}




signed main()
{
 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		int ans[k+1];
		memset(ans,0,sizeof(ans));
		int sum = 0;

		for(int i = k ; i >= 1 ; i--)
		{
			int div = k/i;
			if(div == 0)
			{
				div = 1;
			}
			//cout<<div<<" ";
			ans[i] = be(div,n,mod);

			int sub = 0;

			for(int j = 2*i ; j <= k ; j+= i)
			{
				sub = (sub + ans[j])%mod;
			}

			//cout<<ans[i]<<"\n";

			ans[i] = (ans[i] - sub + mod)%mod;
		}

		for(int i = 1 ; i <= k ; i++)
		{
			int p = i;
			p = (p*ans[i])%mod;
			sum = (sum + p)%mod;
		}

		cout<<sum<<"\n";
	}
}

Measured memory_bytes: 4420
N = 0;
i = 0;
tmp = 0;
ans = 0;

N = int(input());

for i in range(1,10,1):
    if N%i!=0:
        continue;
    tmp = N/i;
    
    if tmp<=9 and tmp>=1:
        ans+=1;

if ans>0:
    print('Yes');
    
else:
    print('No');



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

double solve(int n){
    double res = 1;
    for(int i = 0; i < n; i++){
        res *= i+1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;    
    vector<double> x(n),y(n);
    vector<pair<double,double>> pos(n);
    double dum = 0;

    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        pos[i] = {y[i],x[i]};
    }
    for(int i = 0; i < solve(n); i++){
        for(int j = 0; j < n-1; j++){
            dum += sqrt((pos[j].second-pos[j+1].second)*(pos[j].second-pos[j+1].second)+(pos[j].first-pos[j+1].first)*(pos[j].first-pos[j+1].first));
        }
        next_permutation(pos.begin(),pos.end());
    }
    dum /= solve(n);
    cout << fixed << setprecision(10) << dum << endl;
}

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

bool IsNine(int n) {
  if (n % 10 == 9) return true;
  return n / 10 == 9;
}

int main() {
  int n;
  cin >> n;
  cout << (IsNine(n) ? "Yes\n" : "No\n");
  return 0;
}


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

ll dp[51][51][10000];

int main(void){
    int n,a;
    cin >> n >> a;
    int x[n];
    for(int i = 0;i < n;i++)cin >> x[i];
    
    rep(i,n+1)dp[i][0][0] = 1;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int l = 0;l <= n*50;l++){
                dp[i+1][j+1][l] = max(dp[i+1][j+1][l],dp[i][j+1][l]);
                if(l + x[i] <= n*50)dp[i+1][j+1][l+x[i]] += dp[i][j+1][l+x[i]] + dp[i][j][l];
            }
        }
    }
    
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        ans += dp[n][i][i*a];
    }
    cout << ans << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 109, INF = 2000007;
int h, w;
string s[N];
int dp[N][N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(i != 0 || j != 0) {
                dp[i][j] = INF;
            }
            if(i > 0) {
                bool free = s[i][j] == '.' || s[i-1][j] != '.';
                if(free) dp[i][j] = min(dp[i][j], dp[i-1][j]);
                else dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
            }
            if(j > 0) {
                bool free = s[i][j] == '.' || s[i][j-1] != '.';
                if(free) dp[i][j] = min(dp[i][j], dp[i][j-1]);
                else dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                
            }
        }
    }

    cout << dp[h-1][w-1] << '\n';
    
    return 0;
}


Measured memory_bytes: 384
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;

int p[200010];
const double pi = 3.14159265358979323846;

int main(void){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans = (double)a*a+b*b;
    double theta2 = (double)6*m;
    double theta1 = (double)30*h+0.5*m;
    double theta = theta1-theta2;
    if(theta<0)theta*=-1;
    if(theta>180)theta = 360-theta;
    theta = (double)theta/180.0;
    theta = (double)theta*pi;
    ans = (double)ans-2*a*b*cos((double)theta);
    printf("%.11lf\n",sqrt((double)ans));
    return 0;
}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    ll h,w,n;
    cin>>h>>w>>n;
    ll cnt[10]={(h-2)*(w-2)};
    map<PL,int> c;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        --a;--b;
        REP(x,max(1,a-1),min(h-1,(ll)a+2)){
            REP(y,max(1,b-1),min(w-1,(ll)b+2)){
                int&q=c[{x,y}];
                dprint('+',x,y,':',q);
                --cnt[q];
                ++cnt[++q];
            }
        }
    }
    REP(i,10)cout<<cnt[i]<<endl;
}


Measured memory_bytes: 56576
#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>;

int main() {
  string t;
  cin >> t;
  rep(i, t.size()) {
    if (t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
int a,b,c,d;
ll f(ll n)
{
    if(n==0)return 0;
    if(n==1)return d;
    if(mp.find(n)!=mp.end())return mp[n];
    ll res=2e18;
    if(!(n%2))res=f(n>>1)+a;
    else res=min(f(n>>1)+a+d,f((n+1)>>1)+a+d);
    int t=n%3;
    res=min(res,f(n/3)+b+1ll*d*t);
    if(t)res=min(res,f((n+2)/3)+b+1ll*d*(3-t));
    t=n%5;
    res=min(res,f(n/5)+c+1ll*d*t);
    if(t)res=min(res,f((n+4)/5)+c+1ll*d*(5-t));
    if(1.0*n*d<=1e18)res=min(res,n*d);
    mp[n]=res;
    return res;
}
int main()
{
    int _;
    scanf("%d",&_);
    while(_--)
    {
        ll n;
        scanf("%lld%d%d%d%d",&n,&a,&b,&c,&d);
        mp.clear();
        printf("%lld\n",f(n));
    }
    return 0;
}

Measured memory_bytes: 4548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long N = sc.nextLong();

        long x = Math.min(N, B - 1);

        System.out.println(A * x / B + A * (x / B));
        sc.close();

    }
}


Measured memory_bytes: 35720
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int l,r;
    scanf("%d%d", &l,&r);

    int a = l/2019;
    int b = r/2019;
    if(a!=b) {
        printf("0\n"); return 0;
    }
    l = l%2019;
    r = r%2019;
    assert(l<r);
    if(l==0) {
        printf("0\n"); return 0;
    }

    int ans=INF;
    int i,j;
    for(i=l; i<=r; i++) {
        for(j=i+1; j<=r; j++) {
            int val = i*j %2019;
            ans=MIN(ans,val);
        }
    }
    printf("%d\n", ans);


    return 0;
}


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

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

    vector<int> subordinates(N);

    for (int i = 0; i < N - 1; ++i) {
        int senior;
        cin >> senior;
        ++subordinates[senior - 1];
    }

    for (int i = 0; i < N; ++i) {
        cout << subordinates[i] << endl;
    }
}

Measured memory_bytes: 4048
import sys

input = sys.stdin.readline

def main():
    w,h,x,y,r = map(int, input().split())
    
    if x-r < 0 or x + r >w or y - r < 0 or y + r >h:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()


Measured memory_bytes: 5604
import java.util.*;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        int max = 1;
        for (int i = 2; i <= a; i++) {
            if (a % i == 0 && b % i == 0) {
                max = i;
            }
        }
		DecimalFormat decimalFormat = new DecimalFormat("###");
      	Double result=new Double(a)*new Double(b);
        System.out.println(decimalFormat.format(result/max));
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;

int n,l,t;
int rk,i,j;
int a[100005],w[100005],b[100005];
int main(){
	cin>>n>>l>>t;
	for(i=0;i<n;i++){
		cin>>a[i]>>w[i];
		if(w[i]==1) b[i]=(a[i]+t)%l; else b[i]=((a[i]-t)%l+l)%l;
		if(w[i]==1) rk=(rk+1ll*(a[i]+t)/l)%n; else rk=(rk-1ll*(t-a[i]+l-1)/l)%n;
	}
	if(rk<0) rk+=n;
	sort(b,b+n);
	for(i=rk;i<n;i++) cout<<b[i]<<endl;
	for(i=0;i<rk;i++) cout<<b[i]<<endl;
	return 0;
}

Measured memory_bytes: 2432
/**
 *      ABC 56 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-06 02:18:28
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int W, a, b; cin >> W >> a >> b;

    if (abs(a - b) <= W){
        cout << 0 << endl;
    }
    else {
        cout << min(abs(a + W - b), abs(b + W - a)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll K;
  string S; cin>>K>>S;
  if(S.size()<=K) cout<<S<<endl;
  else cout<<S.substr(0,K)<<"..."<<endl;
}

Measured memory_bytes: 3632
s = gets.chomp

t1 = ""
t2 = ""
s.length.times do |i|
  if i % 2 == 0 then
    t1 += "1"
    t2 += "0"
  else
    t1 += "0"
    t2 += "1"
  end
end

xor1 = (t1.to_i(2) ^ s.to_i(2))
xor2 = (t2.to_i(2) ^ s.to_i(2))
puts [xor1.to_s(2).count("1"), xor2.to_s(2).count("1")].min




Measured memory_bytes: 102596
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   
void solve(){
    int n;
    cin >> n;
    int ans = 0;
    FOR(i,1,n+1){
        ans += i*(n-i+1);
    }
    FOR(i,1,n){
        int u,v;
        cin >> u >> v;
        if(u > v)swap(u,v);
        ans -= u*(n-v+1);
    }
    cout << ans << "\n";
}

signed main()
{
    showoff;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 3668
'''
5
29384293847243 454353412 332423423 934923490 1
'''
import sys
import heapq
from collections import defaultdict
read = sys.stdin.buffer.read

N, *r = map(int, read().split())
r=iter(r)
Querys=zip(r,r,r,r,r)

cost=defaultdict(lambda :10**27)
que=0
ans=0
def push(n,c):
    global ans
    if n not in cost:
        heapq.heappush(que,(c,n))
    cost[n]=min(cost[n],c)
    ans=min(ans,c+n*d)
    
for n,a,b,c,d in Querys:
    cost.clear()
    cost[n]=0
    ans=n*d
    que=[(0,n)]#number

    #1になるのに最小のものを見つける
    while que:
        C,n=heapq.heappop(que)
        C=cost[n]
        if n==1 or cost[n]<C:
            continue
        # 2で割る
        if n%2==0:
            push(n//2,C+a)
        else:
            push(n//2,C+a+d)
            push(n//2+1,C+a+d)
        # 3
        if n<3:
            continue
        if n%3==0:
            push(n//3,C+b)
        if n%3==1:
            push(n//3,C+b+d)
        if n%3==2:
            push(n//3+1,C+b+d)
        # 5
        if n<5:
            continue
        if n%5==0:
            push(n//5,C+c)
        if n%5==1:
            push(n//5,C+c+d)
        if n%5==2:
            push(n//5,C+c+2*d)
        if n%5==3:
            push(n//5+1,C+c+2*d)
        if n%5==4:
            push(n//5+1,C+c+d)
    print(ans)





Measured memory_bytes: 122908
#include <iostream>
#include <vector>
#include <array>
#include <iterator>
#include <algorithm>

int main(){
	int num;

	while(std::cin >> num){
		//input
		std::vector<int> factor;
		for(int i = 0; i < num; ++i){
			int buf;
			std::cin >> buf;
			factor.push_back(buf);
		}

		std::array<long int, 21> count = {0}; //0~20 of ways
	
		for(auto fct_itr = factor.begin(); fct_itr != factor.end(); ++fct_itr){
			std::array<long int, 21> tmp_count = {0};
			int cnt_number = 0;
			if(fct_itr == factor.begin()){
				tmp_count[*fct_itr] = 1;
			}else{
				for(auto cnt_itr = count.begin(); cnt_itr != count.end(); ++cnt_itr){
					//substruction
					if(cnt_number >= *fct_itr){
						tmp_count[cnt_number - *fct_itr] += *cnt_itr;
					}
					//addition
					if(cnt_number + *fct_itr <= 20){
						tmp_count[cnt_number + *fct_itr] += *cnt_itr;
					}
					cnt_number++;
				}
			}
		std::copy(tmp_count.begin(), tmp_count.end(), count.begin());

		}
		
		std::cout << count.front() << std::endl;
		std::vector<int>().swap(factor);
	}

	return 0;
}

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

int main(){
		int n;
		double D1 = 0,D2 = 0,D3 = 0,Dinf = 0;
		cin >> n;
		int x[n];
		int y[n];
		for(int i = 0;i < n;i++){
				cin >> x[i];
		}
		for( int i = 0;i < n;i++){
				cin >> y[i];
		}
		for( int i = 0;i < n;i++){
				D1 += abs(x[i] - y[i]);
				D2 += pow(x[i] - y[i],2);
				D3 += pow(abs(x[i] - y[i]),3);
		}
		D2 = sqrt(D2);
		D3 = pow(D3,1.0 /3.0);
		for( int i = 0;i < n;i++){
				if(Dinf < abs(x[i] -y[i])){
						Dinf = abs(x[i] - y[i]);
				}
		}
		printf("%f\n%f\n%f\n%f\n",D1,D2,D3,Dinf);
		return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
ll n,K,fac[10101],inv[10101],_inv[10101];
inline ll getC(ll n,ll m){
    if (n<m) return 0;
    return fac[n]*_inv[m]%ljc*_inv[n-m]%ljc;
}
ll F[4020],pw[10101];
inline void add(ll &a,ll b){a=(a+b)%ljc;}
inline ll fast_pow(ll a,ll b,ll p){
	ll t=1;
	while (b){
		if (b&1ll) t=t*a%p;
		b>>=1ll;a=a*a%ljc;
	}
	return t;
}
signed main(){
	K=read(),n=read();
    fac[0]=inv[0]=inv[1]=_inv[0]=1;
    for (ll i=1;i<=10000;i++) fac[i]=fac[i-1]*i%ljc;
    for (ll i=2;i<=10000;i++) inv[i]=(ljc-inv[ljc%i]*(ljc/i)%ljc)%ljc;
    for (ll i=1;i<=10000;i++) _inv[i]=_inv[i-1]*inv[i]%ljc;
//	for (int i=0;i<=10000;i++) pw[i]=fast_pow(i,n,ljc);
//    for (ll i=0;i<=2*K;i++){
//    	for (int j=0;j<=i;j++){
//    		add(F[i],(((i-j)&1)?ljc-1:1)%ljc*pw[K-i+j]%ljc*getC(i,j)%ljc);
//		}
//	}
	for (ll i=2;i<=K+1;i++){
		ll _=0;
		for (ll j=0;j<=i/2;j++){
			_=(_+((j&1)?ljc-1:1)*getC(i/2,j)%ljc*getC(n-2*j+K-1,K-1)%ljc)%ljc;
		}
		printf("%lld\n",_);
	}
	for (ll i=K;i>=2;i--){
		ll _=0;
		for (ll j=0;j<=i/2;j++){
			_=(_+((j&1)?ljc-1:1)*getC(i/2,j)%ljc*getC(n-2*j+K-1,K-1)%ljc)%ljc;
		}
		printf("%lld\n",_);
	}
}



Measured memory_bytes: 4016
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  cout<<n*n<<endl;
  return 0;
}

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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

comb_l = [int(n*(n-1)/2)]
comb = comb_l[0]
uf = UnionFind(n)
for a,b in [list(map(int,input().split())) for _ in range(m)][::-1]:
    if not uf.same(a-1, b-1):
        temp = uf.size(uf.find(a-1)) * uf.size(uf.find(b-1))
        
    
    else:
        temp = 0
    
    comb -= temp
    comb = max(0,comb)
    comb_l.append(comb)
    
    uf.union(a-1,b-1)
    

for i in comb_l[:-1][::-1]:
    print(i)
    

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int &x:A) cin>>x;
  vector<int> num(N);
  for(int i=0;i<N;i++)
    num[A[i]-1]++;
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int sum=0;
  for(int i=0;i<K&&num[i]!=0;i++) sum+=num[i];
  cout<<N-sum<<endl;
}
  
    
    

Measured memory_bytes: 1792
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
s_dic = {}
for _ in range(N):
    s_list = list(input())
    s_list.sort()
    s = ''.join(s_list)

    if s in s_dic:
        s_dic[s] += 1
    else:
        s_dic[s] = 1

ans = 0
for v in s_dic.values():
    if v >= 2:
        ans += v*(v-1)
print(ans//2)


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

vector<vector<int>> G;
int G2[100][100];

void input_graph(int n) {
    int u, k, v;
    rep(i, n) {
        vector<int> vec;
        cin >> u >> k;
        u--;
        rep(j, k) {
            cin >> v;
            v--;
            vec.push_back(v);
        }
        G.push_back(vec);
    }
}

void input_graph2(int n) {
    int u, k, v;
    rep(i, n) {
        cin >> u >>k;
        u--;
        rep(j,k){
            cin >> v;
            v--;
            G2[u][v]=1;
        }
    }
}

void print_graph2(int n){
    rep(i,n){
        rep(j,n){
            cout<<G2[i][j];
            if(j<n-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}

void print_graph() {
    rep(i, G.size()) {
        rep(j, G[i].size()) {
            printf("%d", G[i][j]);
            if(j < G[i].size() - 1)
                printf(" ");
        }
        printf("\n");
    }
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    input_graph2(n);
    print_graph2(n);
}


Measured memory_bytes: 3124
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
                                                  
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;   
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)2e5 + 5;
const int INF = (int)1e9;

vector<int> adj[MAXN], adj2[MAXN];

bool used[MAXN];

int col[MAXN];

int ans[MAXN];

int arr[MAXN];

pii e[MAXN];

int n, m;

void dfs(int v) {
    used[v] = 1;

    for (int to : adj2[v]) {
        if (!used[to]) {
            col[to] = 1 - col[v];
            dfs(to);
        }
    }
}

void solve() {
    scanf("%d %d", &n, &m);

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

    for (int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        e[i] = mp(u, v);
        adj[u].pb(i);
        adj[v].pb(i);
        ans[i] = INF;
    }

    for (int i = 1; i <= n; ++i) {
        pii best = mp(-1, -1);

        for (int c : adj[i]) {
            int j = e[c].fi + e[c].se - i;
                
            if (best.fi == -1 || mp(arr[j], j) < mp(arr[best.fi], best.fi)) {
                best = mp(j, c);
            }
        }

        if (best.fi == -1) {
            continue;
        }

        if (arr[best.fi] > arr[i]) {
            printf("-1\n");
            return;
        }

        adj2[i].pb(best.fi);
        adj2[best.fi].pb(i);
        ans[best.se] = arr[i];
    }

    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            col[i] = 0;
            dfs(i);
        }
    }             

    for (int i = 1; i <= n; ++i) {
        printf("%c", col[i] ? 'W' : 'B');
    }

    printf("\n");

    for (int i = 1; i <= m; ++i) {
        printf("%d\n", ans[i]);
    }
}

int main() {
    int tt = 1;

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

    return 0;
}


Measured memory_bytes: 22784