akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	//変数の宣言
	int n;
	char s[110];
	int i,j,k;
	int l,r;
	char dummy;
	
	//データの読み込み
	scanf("%d",&n);
	scanf("%c",&dummy);
	
	for(i=0;i<n;i++){
		scanf("%c",&s[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	l=0;
	r=0;
	
	for(i=0;i<n;i++){
		if(s[i]-')'==0){
			if(r==0){
				l++;
//				printf("l=%d,r=%d\n",l,r);
			}else{
				r--;
//				printf("l=%d,r=%d\n",l,r);
			}
		}else{
			r++;
//			printf("l=%d,r=%d\n",l,r);
		}
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	for(i=0;i<l;i++){
		printf("(");
	}
	
	for(i=0;i<n;i++){
		printf("%c",s[i]);
	}
	
	for(i=0;i<r;i++){
		printf(")");
	}
	
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
from heapq import heapify,heappop,heappush

def solve(A,N,K):
    ans_max,ans_min = max(A),1

    while True:
        if cutable(A,N,K,(ans_max+ans_min)//2):
            if ans_max > (ans_max+ans_min)//2:
                ans_max = (ans_max+ans_min)//2
            else:
                return ans_max
        else:
            if ans_min < (ans_max+ans_min)//2:
                ans_min = (ans_max+ans_min)//2
            else:
                return ans_max

def cutable(A,N,K,div):
    #K回までの切断で全部を長さdiv以下にできるかどうか
    cnt = 0
    for i in range(N):
        cnt += A[i]//div
        if A[i] % div == 0:
            cnt -= 1
        if cnt > K:
            return False

    return True

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    ans = solve(A,N,K)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31104
from collections import defaultdict,Counter

def nck(n, k):
    ret = 1
    for i in range(min(n - k, k)):
        ret *= (n - i)
        ret /= (i + 1)
    return ret


def main():
    n, a, b = map(int, input().split())
    v = list(map(int, input().split()))

    v = sorted(v, reverse=True)
    d = Counter(v)
    value = 0
    t = 0
    for i in range(a):
        value += v[i]
        if i == a - 1:
            t = v[i]
    print(value / a)

    c = 0
    for i in range(n):
        if v[i] == t:
            break
        c += d[v[i]]

    ans = 0
    if d[v[0]] > a:
        for i in range(a, min(b,d[v[0]])+1):
            ans += nck(d[v[0]], i)
        print(int(ans))
    else:
        print(int(nck(d[t], a - c)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b = input().split()
c = a + b
c = int(c)
for i in range(1,c+1):
    if i**2 == c:
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 12492
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n,k;
 	cin>>n>>k;
 	int cnt=0;
 	while(n>=k){
 		cnt++;
		 n/=k;	
	}
	cout<<cnt+1;
return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    X = 2**N
    dp = [float("inf")] * X
    dp[0] = 0
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        bit = 0
        for item in c:
            bit |= 2**(item-1)
        for j in range(X):
            dp[j | bit] = min(dp[j | bit], dp[j] + a)
    if dp[X-1] == float("inf"):
        print(-1)
    else:
        print(dp[X-1])


if __name__ == "__main__":
    main()


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

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>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,k;
    cin>>n>>k;
    ll ct=0;
    fr(i,1,n+1)
    {
        ll x=n/i;
        //ll rem=i-1;
        if(i>=k)
            ct+=x*(i-k);
        ll rem=n%i;
        if(rem>=k)
        {
            ct+=(rem+1-k);
        }
    }
    if(k==0)
        ct-=n;
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	A := sc.NextInt()
	P := sc.NextInt()
	P += A * 3
	fmt.Println(P / 2)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func gcd(x, y int) int {
	if y > 0 {
		return gcd(y, x%y)
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func max64(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func min64(x, y float64) float64 {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt64() int64 {
	i, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
N,M = map(int,input().split())
ans = []
if N%2:
    for i in range(N//2):
        ans.append((i+1, N-1-i))
else:
    m = N//2
    for i in range(m//2):
        ans.append((i+1, m-i))
    for i in range((m-1)//2):
        ans.append((m+i+1, N-1-i))
for a,b in ans[:M]:
    print(a,b)

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

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


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

    int f = 0;
    while(n>0){
        f += n%10;
        n /= 10;
    }
    cout << (N%f==0? "Yes": "No") << endl;
    return 0;
}

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

using vi = vector<int>;
using ii = pair<int, long long>;
#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)

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

  int n;
  cin >> n;
  vi h(n), a(n);
  trav(i, h) cin >> i;
  trav(i, a) cin >> i;
  set<ii> best; // maintain (h_i, v_i) s.t. i < j => h_i < h_j and v_i < v_j
                // since if h_i < h_j and v_i > v_j, element j is redundant
  best.insert({0, 0});
  rep(i, 0, n) {
    auto pval = (--best.upper_bound({h[i], 0})) -> second;
    auto it = best.insert({h[i], pval + a[i]}).first;
    if (it != begin(best) and prev(it) -> second >= it -> second)
      best.erase(it); // i-th element is redundant
    else {
      while (next(it) != end(best) and it -> second >= next(it) -> second)
	best.erase(next(it)); // i-th element makes something bigger redundant
    }
  }
  auto res = 0LL;
  trav(elem, best)
    res = max(res, elem.second);
  cout << res << '\n';
}


Measured memory_bytes: 14336
open System

let (h, w) = Console.ReadLine().Split() |> (fun x -> int x.[0], int x.[1])
for i in [0..h-1] do
    let ss= Console.ReadLine().Split()
    for j in [0..w-1] do
        if ss.[j] = "snuke" then printfn "%c%d" (char ((int 'A') + j)) (i+1) else ()
    done
done


Measured memory_bytes: 14160
N = int(input())
plist = list(map(float, input().split()))
dp = [[0 for i in range(N+1)] for j in range(N)]
dp[0][0], dp[0][1] = plist[0], 1-plist[0]
for i in range(1, N):
    p = plist[i]
    for j in range(i+1):
        dp[i][j] += dp[i-1][j]*p
        dp[i][j+1] += dp[i-1][j]*(1-p)
print(sum(dp[-1][0:(N+1)//2]))

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

int main(){
	int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin>>m>>d,m+d){
		int sum=d;
		for(int i=0;i<m-1;i++){
			sum+=month[i];
		}	
		switch(sum%7){
			case 1:cout<<"Thursday";break;
			case 2:cout<<"Friday";break;
			case 3:cout<<"Saturday";break;
			case 4:cout<<"Sunday";break;
			case 5:cout<<"Monday";break;
			case 6:cout<<"Tuesday";break;			
			case 0:cout<<"Wednesday";break;
		}
		cout<<endl;
		
	}
}

Measured memory_bytes: 1156
class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]
 
    def __init__(self, mod  = 10**9+7, max_n = 10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append
 
        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)
 
        inv_append(pow(fac[-1], mod-2, mod))
 
        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)
 
        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
 
    def get_combination(self, n, r):
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod
 
    def get_permutation(self, n, r):
        return self.factorial[n] * self.inverse[n-r] % self.mod
 
 
import math
Big = BigCombination()
mod=10**9+7
h,w,a,b=map(int,input().split())
ans=0
for i in range(b,w):
    ans=(ans+ Big.get_combination(h-a-1+i,i)* Big.get_combination(a-1+w-i-1,w-i-1))%mod
print(ans)


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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let mut h: Vec<i32> = (0..n).map(|_|  iter.next().unwrap().parse().unwrap()).collect();
    h.sort();
    let mut ans = std::i32::MAX;
    for i in 0..n-k+1 {
        ans = std::cmp::min(ans, (h[i] - h[i+k-1]).abs());
    }
    println!("{}",ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

typedef tuple< ll, ll > road;
typedef tuple< ll, ll > node;

ll fact(ll n)
{
  ll ans = 1;
  for (ll i = 2; i <= n; ++i) ans *= i;
  return ans;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n, m, r;
  cin >> n >> m >> r;
  ll goal[r];
  for (ll i = 0; i < r; ++i) {
    cin >> goal[i];
    goal[i]--;
  }
  vector< vector< road > > ro(n);
  for (ll i = 0; i < m; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    ro[a].push_back(make_tuple(b, c));
    ro[b].push_back(make_tuple(a, c));
  }
  ll cost[n][n];
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < n; ++j) cost[i][j] = -1;
    cost[i][i] = 0;
    priority_queue< node, vector< node >, greater<node> > q;
    q.push(make_tuple(0, i));
    while (!q.empty()) {
      auto t = q.top();
      q.pop();
      ll ncost = get<0>(t), idx = get<1>(t);
      for (auto w : ro[idx]) {
        ll to = get<0>(w), rc = get<1>(w);
        if (cost[i][to] == -1 || cost[i][to] > ncost + rc) {
          cost[i][to] = ncost + rc;
          q.push(make_tuple(ncost + rc, to));
        }
      }
    }
  }
  ll s_max = fact(r);
  ll ans = -1;
  for (ll seed = 0; seed < s_max; ++seed) {
    ll nseed = seed;
    ll p[r];
    bool visited[r];
    for (ll i = 0; i < r; ++i) visited[i] = false;
    for (ll i = 0; i < r; ++i) {
      ll j = nseed % (r-i);
      nseed /= (r-i);
      ll nov = 0;
      for (ll k = 0; k < r; ++k) {
        if (visited[k]) continue;
        if (nov == j) {visited[k] = true; p[i] = k; break;}
        nov++;
      }
    }
    ll nans = 0;
    for (ll i = 1; i < r; ++i) nans += cost[goal[p[i-1]]][goal[p[i]]];
    if (ans == -1) ans = nans;
    else ans = min(ans, nans);
  }
  cout << ans << endl;
  return 0;
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

ll gcd(ll a,ll b){
  if(a < b){
    ll temp = a+b;
    a = temp - a;
    b = temp - b;
  }
  ll c = 1;
  if(b == 0)return a;
  while(c != 0){
    c = a%b;
    if(c == 0)return b;
    a = b;
    b = c;
  }
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = a*b;
    ans /= gcd(a,b);
    cout << ans << endl;
    //cin >> a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define test ll t;cin >> t; while(t--)
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

    
int main()
{
   std::ios::sync_with_stdio(false);
   ll n;
   cin>>n;
   ll a[n];
   rep(i,n)cin>>a[i];
   ll dp[n+1]={0};
   dp[0]=0;
   dp[1]=abs(a[0]-a[1]);
   f(i,2,n)
   {
       dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
   }
   
   
   cout<<dp[n-1];
}







Measured memory_bytes: 1792
fun main(args: Array<String>) {
   val list: List<Int> = readLine()!!.split(" ").map { it.toInt() }
   val W = list[0]
   val H = list[1]
   val x = list[2]
   val y = list[3]
   val r = list[4]
   if (x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0) {
       println("Yes")
   } else {
       println("No")
   }
}


Measured memory_bytes: 33860
#include<stdio.h>
#include<string.h>
int main(void)
{
    long long int s = 0,t = 0,i = 0,j = 0,count = 0,kekka = 1000000;
    char S[1001],T[1001];
    scanf("%s %s",S,T);
    s = strlen(S);
    t = strlen(T);
    for(i = 0 ; i <= s - t  ; i++)
    {
        count = 0;
        for(j = 0 ; j < t ; j++)
        {
            if(S[i + j] != T[j])
            {
                count++;
            }
        }
        
        if(count <= kekka)
        {
            kekka = count;
        }
    }
    printf("%lld\n",kekka);
    
    return 0;
}

Measured memory_bytes: 1716
from collections import deque
s = input()
q = int(input())
former = deque()
latter = deque()

flg = False
for i in range(q):
    p = list(map(str, input().split()))
    if p[0] == "1":
        flg = True if flg == False else False
        continue
    else:
        if (p[1] == "1" and not flg) or (p[1] == "2" and flg):
            former.appendleft(p[2])
        else:
            latter.append(p[2])

ans = list(former) + list(s) + list(latter)
ans = "".join(ans)
print(ans if not flg else ans[::-1])

Measured memory_bytes: 78808
#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.1415926535
#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
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int has[siz];
int ifact[siz];
int bit[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

bool ispalin(string s)
{
	string k = s;
	reverse(k.begin(),k.end());
	if(k == s)
	{
		return true;
	}

	return false;
}


signed main()
{
   
	speedrap
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		int n,x,y;
		cin>>n>>x>>y;
		map<int,int> mp;

		for(int i = 1 ; i <= n ; i ++)
		{
			for(int j = i+1 ; j <= n ; j++)
			{
				if(i <x and j < x)
				{
					mp[j-i]++;
					continue;
				}

				if(i < x and j == x)
				{
					mp[j-i]++;
				}
				if(i < x and j > x)
				{
					int d1 = j-i;
					int dis = x-i+1;
					dis += abs(y-j);
					mp[min(dis,d1)]++;
					continue;
				}

				if(i>=x and i < y)
				{
					int d1 = abs(j-i);
					int dis = abs(j-y);
					dis += 1 + abs(x-i);
					mp[min(d1,dis)]++;
					continue;
				}

				if(i >=y)
				{
					mp[j-i]++;
				}
			}
		}

		for(int i = 1 ; i < n; i++ )
		{
			cout<<mp[i]<<"\n";
		}
	}
}

Measured memory_bytes: 384
import math
 
class Vector(object):
    def __init__(self, arr):
        self.arr = arr
 
    def sub(self, vec):
        return Vector([self.arr[i] - vec.arr[i] for i in range(len(self.arr))])
     
    def p_norm(self, p):
        return sum([abs(e) ** p for e in self.arr]) ** (1 / p)
     
    def inf_norm(self):
        return max([abs(e) for e in self.arr])
 
 
n = int(input())
x = Vector([int(e) for e in input().split()])
y = Vector([int(e) for e in input().split()])
z = x.sub(y)
 
print(z.p_norm(1))
print(z.p_norm(2))
print(z.p_norm(3))
print(z.inf_norm())


Measured memory_bytes: 5700
#include<cstdio>
#include<cstring>
using namespace std;
const int w=20003;
char s[10005];
int x,y,_x,len,p,sum,q,now=1;
bool ws[2][2][40009];
int main(void){
    register int i;
    scanf("%s%d%d",s+1,&x,&y),len=strlen(s+1),x+=w,y+=w;
    while(now<=len&&s[now]=='F')++now,++_x;
    ws[0][0][w+_x]=1,ws[1][0][w]=1;
    while(now<=len){
        ++now,sum=0,p^=1,q^=p;
        while(now<=len&&s[now]=='F')++sum,++now;
        for(int i=w-len;i<=w+len;++i)
            ws[p][q][i]=ws[p][q^1][i+sum]|ws[p][q^1][i-sum];
    }
    if(p==1&&ws[0][q^1][x]&&ws[1][q][y]||p==0&&ws[0][q][x]&&ws[1][q][y])puts("Yes");
    else puts("No"); 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var n = Int32.Parse(Console.ReadLine());
            Console.WriteLine(Enumerable.Range(1, n).Sum());

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 2776
import itertools

s = [int(input()) for _ in range(5)]

res = 1 << 28
for ss in itertools.permutations(s):
    tmp = 0
    tmp += (ss[0] + 9) // 10 * 10
    tmp += (ss[1] + 9) // 10 * 10
    tmp += (ss[2] + 9) // 10 * 10
    tmp += (ss[3] + 9) // 10 * 10
    tmp += ss[4]
    res = min(res, tmp)

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
/*{{ x | (1 << k) sets the kth bit of x to one
x & ~(1 << k) sets the kth bit of x to zero
x ^ (1 << k) inverts the kth bit of x.
x & (x-1) sets the last one bit of x to zero
x & -x sets all the one bits to zero, except for the last one bit. 
x | (x-1) inverts all the bits after the last one bit.}} SOME BIT MANIPULATION*/
//__builtin_clz(x): the number of zeros at the beginning of the number
//__builtin_ctz(x): the number of zeros at the end of the number
//__builtin_popcount(x): the number of ones in the number
//__builtin_parity(x): the parity (even or odd) of the number of ones 
struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const 
	{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/*//DSU 
int parent[200005];
int rankr[200005];
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rankr[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rankr[a] < rankr[b])
            swap(a, b);
        parent[b] = a;
        if (rankr[a] == rankr[b])
            rankr[a]++;
    }
} */

int main()
{  
	fast; 
	ll n; cin>>n; ll arr[n]; for(ll i = 0; i < n; i++) cin>>arr[i];
	ll money = 1000; ll stocks = 0;
	ll i = 0; ll ans = 1000;
	while(i < n)
	{
		while(i < n-1 && arr[i] >= arr[i+1])
			i++;
		if(i == n-1) break;
		if(money != 0) stocks += (money/arr[i]);
		if(money != 0 ) money -= (money/arr[i])*arr[i];
	//	cout << arr[i] << " " << money << " " << stocks << endl;
		ans = max(ans,money);
		i++;
		while(i < n-1 && arr[i] <= arr[i+1])
			i++;
		money += arr[i]*stocks;
		stocks = 0;
	//	cout << arr[i] << " " << money << " " << stocks << endl;
		ans = max(ans,money);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int gcd(int x, int y)
{
    int r;

    // 引数チェック
    if (x == 0 || y == 0)
    {
        return 0;
    }

    // ユーグリッドの互除法
    // yで割り切れるまでループ
    while ((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

int main(int argc, const char *argv[])
{
    int k;
    cin >> k;

    int sum = 0, x;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                x = gcd(a, b);
                x = gcd(c, x);
                sum += x;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#define ll long long
#define INF 1000000000
#define MOD 1
#define SIZE 100001
using namespace std;

int n;vector<int>v;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin>>n;v.resize(n);
  for (int i=0; i<n; i++){cin>>v[i];}
  int tracker=1,ans=0;
  for (int i=0; i<n; i++){
	  if(v[i]!=tracker){
		  ans++;
	  }
	  else{tracker++;}
  }
  ans==n?cout<<-1:cout<<ans;
}


Measured memory_bytes: 1024
def mkstring(s):
  if len(s)<10:
    return '0'*(10-len(s))+s
  else:
    return s

n=int(input())
arr1=[''.join(map(str,input().split())) for _ in range(n)]
arr2=[list(map(int,input().split())) for _ in range(n)]
ans=-10**10
for i in range(1,2**10+1):
  s=mkstring(format(i,'b'))
  tmp=0
  for j in range(n):
    cnt=0
    for k in range(10):
      if s[k]=='1' and arr1[j][k]=='1':
        cnt+=1
    tmp+=arr2[j][cnt]
  if ans<tmp:
    ans=tmp
print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
static const int MAX=100000;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
int d[MAX];
vector<pair<int,int>> adj[MAX];

void dik(int s)
{
	priority_queue<PII> PQ;
	int col[MAX];
	REP(i,n)
	{
		d[i]=INF;
		col[i]=WHITE;
	}
	
	d[s]=0;
	PQ.push(MP(0,s));
	col[s]=GRAY;
	
	while(!PQ.empty())
	{
		PII f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=BLACK;
		
		if(d[u]<f.first*(-1))continue;
		
		REP(j,adj[u].size())
		{
			int v=adj[u][j].first;
			if(col[v]==BLACK)continue;
			if(d[v]>d[u]+adj[u][j].second)
			{
				d[v]=d[u]+adj[u][j].second;
				PQ.push(MP(d[v]*(-1),v));
				col[v]=GRAY;
			}
		}
	}
}

int main()
{
	cin>>n;
	FOR(i,1,n)
	{
		int s,t,w;
		cin>>s>>t>>w;
		adj[s].PB(MP(t,w));
		adj[t].PB(MP(s,w));
	}
	dik(0);
	int maxcost=-1;
	int u=0;
	REP(i,n)
	{
		if(d[i]>maxcost&&d[i]!=INF)
		{
			maxcost=d[i];
			u=i;
		}
	}
	dik(u);
	maxcost=-1;
	REP(i,n)
	{
		if(d[i]>maxcost&&d[i]!=INF)
		{
			maxcost=d[i];
		}
	}
	cout<<maxcost<<endl;
	return 0;
}

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

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

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

		if (!n) break;

		string s; cin >> s;

		int p = 0, ba = 0;
		vi num(n);
		rep(i, 100) {
			if (s[i] == 'M') {
				num[p]++;
			}
			else if (s[i] == 'S') {
				ba += num[p] + 1;
				num[p] = 0;
			}
			else {
				num[p] += ba + 1;
				ba = 0;
			}

			p++;
			if (p == n) p = 0;
		}

		sort(ASC(num));
		rep(i, n) cout << num[i] << " ";
		cout << ba << endl;
	}
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

#define int ll

int a, b, c, d;

void read() {
    cin >> a >> b >> c >> d;
}

vector<int> get(int l, int r) {
    vector<int> ans;
    ans.push_back(l);
    ans.push_back(r);
    if (l <= 0 && r >= 0) {
        ans.push_back(0);
    }
    if (l <= 1 && r >= 1) {
        ans.push_back(1);
    }
    if (l <= -1 && r >= -1) {
        ans.push_back(-1);
    }
    return ans;
}

int ans;

void run() {
    auto L = get(a, b);
    auto R = get(c, d);
    ans = L[0] * R[0];
    for (auto i : L) {
        for (auto j : R) {
            chkmax(ans, i * j);
        }
    }
}

void write() {
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    read();
    run();
    write();
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
char s[105];
int a[30][2];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++)
	{
		int x=s[i]-'a'+1;
		if(!a[x][0]) a[x][0]=i+1;
		a[x][1]=i+1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=1;j<=26;j++)
		if(a[j][0]<i&&a[j][1]>=i) sum++;
		if(sum>ans) ans=sum;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class A
{
    static void Main()
    {
        string C = Console.ReadLine().Trim();

        string[] abc = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };

        var list = new List<string>();
        list.AddRange(abc);

        Console.WriteLine(list[list.IndexOf(C) + 1]) ;
    }

}


Measured memory_bytes: 13152
import sys
from collections import deque
 
input = sys.stdin.readline
 
N,D,A = map(int,input().split())
XH = []
for i in range(N):
	x,h = map(int, input().split())
	XH.append([x,h])
 
XH.sort(key=lambda xh: xh[0])
que = deque()
D = 2*D
 
H = XH[0][1]
if(0==H%A): a = H//A
else: a = H//A+1
que.append([XH[0][0]+D,a*A])
tot = a * A
ans = a
for i in range(1,N):
	while XH[i][0] > que[0][0] :
		tot -= que[0][1]
		que.popleft()
		if(len(que)==0): break
	if(tot < XH[i][1]):
		H = XH[i][1]-tot
		if(0==H%A): a = H//A
		else: a = H//A+1
		ans += a
		que.append([XH[i][0]+D,a*A])
		tot += a*A
print(ans)

Measured memory_bytes: 53972
#include <iostream>


int main() {
    int n;
    int a[20];
    int count = 0;
    std::cin >> n;
    for (int i=0; i<n; ++i) std::cin >> a[i];
    for (int i=1; i<n-1; ++i) {
        if ((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1])) ++count;
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: i64 = read();
    let mut a = (x / 11) * 2;

    if x % 11 == 0 {
    } else if x % 11 <= 6 {
        a += 1;
    } else {
        a += 2;
    }
    println!("{}", a);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main()
{
    ll x;
    cin >> x;
    int y = 0;
    ll m = 100;
    while(m<x){
        m*=1.01;
        y++;
    }
    cout << y << endl;

}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        ArrayList<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; i++) A.add(scan.nextInt());

        Collections.sort(A);
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                for (int k = j + 1; k < N; k++) {
                    if (A.get(i).equals(A.get(j)) || A.get(j).equals(A.get(k))) continue;
                    if (Math.abs(A.get(i) - A.get(j)) < A.get(k) && A.get(k) < A.get(i) + A.get(j)) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 37572
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l
int main(){
    int n, y; cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            int k = n - i - j;
            if (y == 10000 * i + 5000 * j + 1000 * k) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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 Would
#define you
#define please

int P[100001];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N, M;
	N = getint();
	M = getint();

	int A[100000], B[100000];
	rep(i, M) {
		A[i] = getint();
		B[i] = getint();
	}

	ll sum = (ll)N * (N - 1) / 2;
	ll kotae[100001];
	kotae[M] = sum;

	rep1(i, N) P[i] = -1;

	for (int i = M - 1; i > 0; i--) {
		int ap = Find(A[i]);
		int bp = Find(B[i]);
		if (ap != bp) {
			sum -= (ll)P[ap] * P[bp];
			if (P[ap] > P[bp]) swap(ap, bp);
			P[ap] += P[bp];
			P[bp] = ap;
		}
		kotae[i] = sum;
	}

	rep1(i, M) putint(kotae[i]);
	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
int main() {

    int K, A, B;
    int sum=0;
    
    scanf("%d", &K);
    scanf("%d %d", &A, &B);
	
	for(int i=A;i<=B;i++) {
		if(i % K == 0) {
			sum++;
		}
	}
		if(sum !=0) {
			printf("OK");
		}else{
			printf("NG");
		}
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <utility>
#include <cmath>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(3);
    double a1, b1, c1, a2, b2, c2;
    while(cin>>a1>>b1>>c1>>a2>>b2>>c2){
        double m = a1*b2-a2*b1;
        double x=(c1*b2-c2*b1)/m, y=(a1*c2-a2*c1)/m;
        if(fabs(x)<1e-9) x=0;
        if(fabs(y)<1e-9) y=0;
        cout<<x<<' '<<y<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3232
# include <bits/stdc++.h>
# define x first
# define y second
# define ll long long
# define pii pair < int, int > 
using namespace std;
const int N = 2e5 + 100, mod = 1e9 + 7;
ll ways[N], fac[N], inv[N], h, w, n; 
pii a[N];
int C(int n, int m){
    return fac[m] * inv[n] % mod * inv[m - n] % mod;
}
int fun(pii from, pii to){
    int n = to.x - from.x;
    int m = to.y - from.y;
    assert(C(n, n + m) == C(m, n + m));
    return C(n, n + m); 
}
int binary_power(ll value, ll power){
    ll answer = 1;
    while(power){
        if(power & 1){
            answer = answer * value % mod;
        }
        value = value * value % mod;
        power >>= 1; 
    }
    return answer;
}
int inverse(int value, int modulo){
    return binary_power(value, modulo - 2);
}
int main(){
    cin >> h >> w >> n;
    fac[0] = inv[0] = 1;
    for(int i = 1; i <= h + w + 2; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = inverse(fac[i], mod);
    } 
    for(int i = 0; i < n; i++){
        cin >> a[i].x >> a[i].y; 
    }
    sort(a, a + n);
    a[n] = {h, w};
    for(int i = 0; i <= n; i++){
        ways[i] = fun({1, 1}, a[i]);
        for(int j = 0; j < i; j++){
            if(a[j].x <= a[i].x && a[j].y <= a[i].y){
                ways[i] = (ways[i] - ways[j] * fun(a[j], a[i]) % mod + mod) % mod;
            }
        }
    }
    cout << ways[n] << endl;
}

Measured memory_bytes: 4864
using System;

namespace _0615
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] cakes = new long[n];
			for (int i = 0; i < n; i++) cakes[i] = long.Parse(Console.ReadLine());
			long[,] dp = new long[n, n];//長さ　始点
			for (int i = 0; i < n; i++) dp[0, i] = cakes[i];
			for (int i = 1; i < n; i++)//長さ
			{
				for (int j = 0; j < n; j++)//始点
				{
					if (i % 2 == 0)
					{
						dp[i, j] = Math.Max(dp[i - 1, j] + cakes[(j + i) % n], cakes[j] + dp[i - 1, (j + 1) % n]);
					}
					else
					{
						if (cakes[j] > cakes[(j + i + 1) % n])
							dp[i, j] = Math.Max(dp[i, j], dp[i - 1, (j + 1) % n]);
						if (cakes[(i + j) % n] > cakes[(j - 1 + n) % n])
							dp[i, j] = Math.Max(dp[i, j], dp[i - 1, j]);
					}
				}
			}
			long ret = 0;
			for (int i = 0; i < n; i++)
			{
				ret = Math.Max(ret, dp[n - 1, i]);
				ret = Math.Max(ret, dp[n - 2, i]);
			}
			Console.WriteLine(ret);
		}
	}
}


Measured memory_bytes: 46668
def main():
  f_0 = []
  f_1 = []
  n = int(input())
  for i in range(n):
    x, y = map(int, input().split())
    f_0.append(x-y)
    f_1.append(x+y)
  print(max(max(f_0)-min(f_0),max(f_1)-min(f_1)))
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 24956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    ll h;
    cin >> h;
    ll count = 0;
    while(h!=1){
        h=h/2;
        count++;
    }
    ll sum = 0;
    for (int i = 0; i < count + 1; i++){
        sum += pow(2, i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 2019;
int INF = (int)2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        ans[i] = p[i];
    }
    sort(ans.begin(), ans.end());
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (p[i] != ans[i]) ++count;
    }
    if (count == 0 || count == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(void) {
	int W, a, b, ans;

	cin >> W >> a >> b;
	if (a + W < b)
		ans = b - (a + W);
	else if (a > b + W)
		ans = a - (b + W);
	else
		ans = 0;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int n, s, d;
	cin >> n >> d;
	s = d * 2 + 1;
	if (n % s == 0)cout << n / s << endl;
	else cout << (n / s) + 1 << endl;
}

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


int main(){
  int N, X;
  cin >> N >> X;
  int ans = 1;
  int sum = 0;
  for(int ii=0; ii<N; ii++){
      int l;
      cin >> l;
      sum += l;
      if(sum > X)break;
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
enum = enumerate

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N = int(input())
	vA = linput()
	vA.sort()
	vA.reverse()
	
	res = 0
	res = sum(vA[1:2*N+1:2])
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 113856
n = gets.to_i
a = gets.split(" ").map(&:to_i)
z = []
a.length.times{ |i|
  z[a[i]] ||= 0
  z[a[i]] += 1
}
sum = a.sum
q = gets.to_i
q.times{
  b, c = gets.split(" ").map(&:to_i)
  if z[b] != nil && z[b] > 0
    sum += (c -b) * z[b]
    z[c] ||= 0
    z[c] += z[b]
    z[b] = 0
  end
  p sum
}

Measured memory_bytes: 25416
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   int arr[105]={0};
   int n;
   while(cin>>n)
   {
     int temp;
     for(int i=0;i<n;i++) 
     {
       cin>>temp;
       arr[temp]++;  
     }  
     int cnt=0;
     for(int i=1;i<=100;i++) if(arr[i]) cnt++;
     cout<<cnt<<endl;
   }
   
   return 0;
 }
 


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i%2 == 0){
                    if(j%2 == 0) cout << '#';
                    else cout << '.';
                }else{
                    if(j%2 == 0) cout << '.';
                    else cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
sx,sy,tx,ty=map(int,input().split())
print("R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy)+"L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U")


Measured memory_bytes: 3060