akhauriyash/Code-Regression huggingface dataset:
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk
# import networkx as nx
# G = Graph()

# slist = "abcdefghijklmnopqrstuvwxyz"
X,N = map(int,input().split())
lisP = list(map(int,input().split()))

tmp = 1000
ans = 1000
for p in range(-120,121):
    if p in lisP:
        continue
    num = abs(X-p)
    if num == tmp:
        ans = min(ans,p)
    elif num < tmp:
        tmp = num
        ans = p

print(ans)
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9184
#include<stdio.h>
#include<stdlib.h>
int M[12][12],i,r;

void dfs(int h,int w)
{
	int i,nh,nw,mv[]={0,1,0,-1,0};
	M[h][w]=0;
	for(i=0;i<4;i++)
	{
		nh=h+mv[i];nw=w+mv[i+1];
		if(0<=nh&&0<=nw&&nh<12&&nw<12&&M[nh][nw])
			dfs(nh,nw);
	}
}

int main()
{
	for(;;){
	for(i=0;i<144;i++)if(!~scanf("%1d",&M[i/12][i%12]))return 0;
	for(i=r=0;i<144;i++)if(M[i/12][i%12]){r++;dfs(i/12,i%12);}
	printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 604
S = input()
lst_S = list(S)

if lst_S == lst_S[::-1] and\
lst_S[0:int((len(S)-1)/2)] == lst_S[0:int((len(S)-1)/2)][::-1] and\
lst_S[int((len(S)+3)/2-1):len(S)] == lst_S[int((len(S)+3)/2-1):len(S)][::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

use std::ops::Bound::{Included, Excluded};

#[fastout]
fn main() {
    input! {
        h: usize, w: usize,
        ab: [(Usize1, Usize1); h],
    }

    let mut range = BTreeSet::new();
    let mut dists = BTreeMap::new();
    for i in 0..w {
        range.insert((i, i)); // (end, start)
    }
    dists.insert(0, w);

    for k in 0..h {
        let (a, b) = ab[k];
        let mut to_be_removed = Vec::new();
        let mut to_be_add = None;
        for &(end, start) in range.range((Included(&(a, 0)), Excluded(&(b + 1, 0)))).rev() {
            to_be_removed.push((end, start));
            if to_be_add.is_none() {
                let end = if b == w - 1 { 1<<60 } else { b + 1 };
                to_be_add = Some((end, start));
            }
        }

        for (end, start) in to_be_removed {
            range.remove(&(end, start));
            let entry = dists.get_mut(&(end - start)).unwrap();
            if *entry == 1 {
                dists.remove(&(end - start));
            } else {
                *entry -= 1;
            }
        }
        if let Some((end, start)) = to_be_add {
            range.insert((end, start));
            *dists.entry(end - start).or_insert(0) += 1;
        }

        let res = *dists.iter().next().unwrap_or((&(1<<60), &0)).0;
        if res >= w {
            println!("-1");
        } else {
            println!("{}", res + k + 1);
        }
    }
}


Measured memory_bytes: 15024
def f(a, b)
  k = Math::log2(b - a).to_i
  mask = -(1 << k)

  c = b & mask
  if b == c
    a, b = -b, -a 
    c = b & mask
  end
  b == c ? 1 : f(a, c) + f(c, b)
end

n = STDIN.gets.to_i
n.times do
  s, d = STDIN.gets.split.map(&:to_i)
  puts f(s, d)
end

Measured memory_bytes: 8704
import fractions

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

if n == 1:
    print(1)
else:
    lcm = 1
    sum_b = 0
    for i in range(n):
        gcd = fractions.gcd(a[i], lcm)
        sum_b *= (a[i] // gcd)
        sum_b %= mod
        lcm = lcm * a[i] // gcd
        sum_b += (lcm // a[i])
        sum_b %= mod
    print(sum_b)

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

long long n;

int dfs(long long i){
    if(i > n){
        return 0;
    }

    int tmp = i;
    int t2[10] = {};

    while(tmp > 0){
        t2[tmp % 10]++;
        tmp /= 10;
    }

    int ans = 0;
    if(t2[3] > 0 && t2[5] > 0 && t2[7] > 0){
        ans = 1;
    }

    return ans + dfs(i*10+3) + dfs(i*10+5) + dfs(i*10+7);
}

int main(){
    cin >> n;

    cout << dfs(0) << endl;
    return 0;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >>N;
  ll A[N];
  rep(i,N) cin >> A[i];
  ll B2[N];
  B2[0] =0;
  ll pm=1LL;
  for(ll i=N-1; i>=0; i--){
    B2[0]+=A[i]*pm;
    pm *= -1*1LL;
  }
  rep1(i,N-1){
    B2[i] = (A[i-1] -B2[i-1]/(2*1LL))*2*1LL;
  }
  rep(i,N) cout << B2[i] << " ";
   
  return 0;
    

}


Measured memory_bytes: 2944
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val xy = (1..n).map { Pair(sc.nextInt(), sc.nextInt()) }

  val dlist = mutableListOf<Int>()
  for (i in 0 until n) {
    for (j in i + 1 until n) {
      val x = xy[i].first - xy[j].first
      val y = xy[i].second - xy[j].second
      val tmp = x * x + y * y
      dlist.add(tmp)
    }
  }

  val dsum = dlist.map { Math.sqrt(it.toDouble()) }.sum()

  println(dsum * 2.0 / n.toDouble())
}


Measured memory_bytes: 31400
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	unsigned short sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+(unsigned short)((pr[i] && pr[(i+1)/2])?1:0 );
	}
};

int main()
{
	io_speedup();
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	int q=read<int>();
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		print(s.sum[r+1]-s.sum[l]);
	}
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d %d", &a, &b);

    
    if(a>b){
    printf("a > b\n");
    }
    else if(a<b){
    printf("a < b\n");
    }
    else{
    printf("a == b\n");
    }

    return 0;
}


Measured memory_bytes: 2084
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 累積和の算出
A_sum, B_sum = [0], [0]
for i, a in enumerate(A):
    A_sum.append(A_sum[i] + a)
for i, b in enumerate(B):
    B_sum.append(B_sum[i] + b)

ans = 0
j = M

# 机Aの本を読む所要時間:A_sum[i] … iの値を0から増やしていく
# 机Bの本を読む所要時間:B_sum[j] … iの値を固定し、Mから減らしていく
# A_sum[i]+B_sum[j]がKに収まるiとjの値を見つけ出し、i+jの値を出す
# iの値を増やしながら上記を繰り返し、i+jの最大値が解となる
for i in range(N+1):
    if A_sum[i] > K:
        break
    while B_sum[j] > K - A_sum[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)


Measured memory_bytes: 48824
#include<stdio.h>
int main(void)
{
	int a,b,c,d,n,i,p[100]={0};
	for(i=0;i<4;i++){
		scanf("%d %d",&a,&b);
		if(a==1)
		p[i]=6000*b;
		else if(a==2)
		p[i]=4000*b;
		else if(a==3)
		p[i]=3000*b;
		else if(a==4)
		p[i]=2000*b;
	}
	for(i=0;i<4;i++)
	printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
using namespace std ;
int main () {
  float i,n,s = 0.0,x;
  string u;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> x >> u;
   if(u == "JPY"){s += x;}
    if(u == "BTC"){x = x*380000; s += x;} 
    
  }
    cout << s << endl;
  return 0;
}

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

node_list = [[False]*n for i in range(n)]
graph = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    graph[i] = [a, b]
    node_list[a-1][b-1] = True
    node_list[b-1][a-1] = True

ans = m
for i in range(m):
    p, q = graph[i][0], graph[i][1]
    node_list[p-1][q-1] = False
    node_list[q-1][p-1] = False
    already = [False]*n
    not_yet = []
    already[0] = True
    for j in range(n):
        if node_list[0][j]:
            not_yet.append(j)
    while not_yet:
        k = not_yet[-1]
        not_yet.pop()
        already[k] = True
        for j in range(n):
            key = node_list[k][j]
            if key:
                if not already[j]:
                    not_yet.append(j)
    node_list[p-1][q-1] = True
    node_list[q-1][p-1] = True
    if all(already):
        ans -= 1
  
print(ans)

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    S a,b,c;
    cin >> a >> b >> c;
    vc A,B,C;
    rp(i,a.size()){
        A.pb(a.at(i));
    }
    rp(i,b.size()){
        B.pb(b.at(i));
    }
    rp(i,c.size()){
        C.pb(c.at(i));
    }
    vi turn={1,0,0};
    while(true){
        if(turn.at(0)){
            if(A.size()==0){
                cout << 'A' << endl;
                return 0;
            }else{
                if(A.at(0)=='a'){
                    turn={1,0,0};
                }else if(A.at(0)=='b'){
                    turn={0,1,0};
                }else if(A.at(0)=='c'){
                    turn={0,0,1};
                }
                A.erase(A.begin());
            }
        }else if(turn.at(1)){
            if(B.size()==0){
                cout << 'B' << endl;
                return 0;
            }else{
                if(B.at(0)=='a'){
                    turn={1,0,0};
                }else if(B.at(0)=='b'){
                    turn={0,1,0};
                }else if(B.at(0)=='c'){
                    turn={0,0,1};
                }
                B.erase(B.begin());
            }
        }else if(turn.at(2)){
            if(C.size()==0){
                cout << 'C' << endl;
                return 0;
            }else{
                if(C.at(0)=='a'){
                    turn={1,0,0};
                }else if(C.at(0)=='b'){
                    turn={0,1,0};
                }else if(C.at(0)=='c'){
                    turn={0,0,1};
                }
                C.erase(C.begin());
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
h,w,k = map(int, input().split())
mod = 10 ** 9 + 7
dp = [[0] * w for i in range(h+1)]
dp[0][0] = 1
b0,b1 = 1,0
c = [1]
for i in range(w-1):
  b0, b1 = b0+b1, b0
  c.append(b0+b1)
if w == 1:
  print(1)
  exit()
for i,v_i in enumerate(dp[:h]):
  for j,now in enumerate(v_i):
    if j == 0:
      dp[i+1][j] += (now * (c[max(0,w-2)])) % mod
      dp[i+1][j+1] += (now * (c[max(0,w-3)])) % mod
    elif j == w-1:
      dp[i+1][j] += (now * (c[max(0,w-2)])) % mod
      dp[i+1][j-1] += (now * (c[max(0,w-3)])) % mod
    else:
      dp[i+1][j-1] += (now * c[max(0,j-2)]*c[max(0,w-j-2)]) % mod
      dp[i+1][j] += (now * c[max(0,j-1)]*c[max(0,w-j-2)]) % mod
      dp[i+1][j+1] += (now * c[max(0,j-1)]*c[max(0,w-j-3)]) % mod
ans = dp[h][k-1] % mod
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N, M;
  cin>>N>>M;
  vector<ll> A(M), B(M);
  vector<pair<ll, ll>> P(M);
  rep(i, M){
    cin>>A[i]>>B[i];
    A[i]--;B[i]--;
    P[i]=make_pair(B[i], A[i]);
  } 
  sort(ALL(P));
  ll x=-1;
  ll Cou=0;
  rep(i, M){
    if(P[i].second>x){
      Cou++;
      x=P[i].first-1;
    }
  }
  cout<<Cou<<endl;


} 

Measured memory_bytes: 6408
# -*- coding: utf-8 -*-
# 標準入力を取得
N, M = list(map(int, input().split()))
k, s = [], []
for m in range(M):
    l = list(map(int, input().split()))
    k_m, s_m = l[0], l[1:]
    k.append(k_m)
    s.append(s_m)
p = list(map(int, input().split()))


def lights_on(switches: int) -> bool:
    result = True
    for m in range(M):
        on_count = 0
        for s_m_km in s[m]:
            if switches & (1 << (s_m_km - 1)):
                on_count += 1
        if on_count % 2 != p[m]:
            result = False

    return result


# 求解処理
ans = 0
for switches in range(1 << N):
    if lights_on(switches):
        ans += 1

# 結果出力
print(ans)


Measured memory_bytes: 9044
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<' '<<x<<' '<<y;
	return 0;
}

Measured memory_bytes: 256
import heapq


def main():
    nvertices, nedges, s = map(int, input().split())
    adj = [[] for i in range(nvertices)]
    for i in range(nedges):
        u, v, w = map(int, input().split())
        adj[u].append((v, w))

    INF = float('inf')
    costs = [INF] * nvertices
    que = [(0, s)]
    for i in range(1, nvertices):
        que.append((INF, 1))
    while que:
        cost, u = heapq.heappop(que)
        if cost > costs[u]:
            continue
        costs[u] = cost
        for v, w in adj[u]:
            if costs[v] > costs[u] + w:
                costs[v] = costs[u] + w
                heapq.heappush(que, (costs[v], v))

    for i in range(nvertices):
        print(costs[i] if costs[i] < INF else "INF")


main()

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;

            var word = Console.ReadLine().Split(' ');
            int x = int.Parse(word[0]);
            int y = int.Parse(word[1]);
            a = x + y;
            b = x - y;
            c = x * y;
            if (a >= b && a >= c)
                x = a;
            if (b >= a && b >= c)
                x = b;
            if (c >= a && c >= b)
                x = c;
            Console.WriteLine(x);
            Console.ReadKey();



        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y;
    cin >> x >> y;
    if (x <= 2*y && y <= 2*x && (x+y) % 3 == 0) {
        int n = (x + y) / 3;
        int k = x - n;
        combination c(n);
        cout << c(n, k) << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 10624
#include<cstdio>
int main(){
	char a;
	bool f=false;
	while(scanf("%c",&a)!=EOF){
		if(a=='A')
			f=true;
		if(a=='C'&&f){
			printf("Yes\n");
			return 0;
		}
		if(a!='A'&&a!='C')f=false;
	}
	printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,m;

void dkstr(vector<vector<P>>& e,ll s,vector<ll>& result){
  result.resize(0);result.resize(n+1);
  priority_queue<P,vector<P>,greater<P>> pq;
  vector<bool> vis(n+1);
  pq.push(mp(0,s));
  while(!pq.empty()){
    ll i=pq.top().second,c=pq.top().first;pq.pop();
    if(vis[i]) continue;
    vis[i]=1;result[i]=c;
    fr(j,e[i].size()) if(!vis[e[i][j].first]) pq.push(mp(c+e[i][j].second,e[i][j].first));
  }
}

int main(){
  ll s,t,u,v,a,b,mn[100010];
  vector<ll> ra,rb;
  cin>>n>>m>>s>>t;
  vector<vector<P>> ea(n+1),eb(n+1);
  fr(i,m){
    cin>>u>>v>>a>>b;
    ea[u].pb(mp(v,a));
    ea[v].pb(mp(u,a));
    eb[u].pb(mp(v,b));
    eb[v].pb(mp(u,b));
  }
  dkstr(ea,s,ra);dkstr(eb,t,rb);
  mn[n+1]=1e15;
  iFr(i,n) mn[i]=min(ra[i]+rb[i],mn[i+1]);
  Fr(i,n) cout<<1000000000000000-mn[i]<<endl;
}

Measured memory_bytes: 19048
length = int(input())
num_li = list(map(int, input().split()))
count = 0
loop = True
while True:
    for i in range(length):
        if num_li[i]%2 == 1:
            loop = False
            break
        else:
            num_li[i] /= 2
    if loop == False:
        break
    else:
        count += 1
print(count)

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int mod = 1000000007;

int n, m;
int d[310][310][310];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n >> m;
	d[0][1][1] = 1;
	for (int i = 0; i < m; i++)for (int j = 1; j <= n; j++)for (int k = 1; k <= j; k++) {
		d[i + 1][j][k] = (d[i + 1][j][k] + (ll)d[i][j][k] * (j - k)) % mod;
		d[i + 1][j][j] = (d[i + 1][j][j] + (ll)d[i][j][k] * k) % mod;
		d[i + 1][j + 1][k] = (d[i + 1][j + 1][k] + d[i][j][k]) % mod;
	}
	for (int i = 1; i < n; i++)d[m][n][n] = (ll)d[m][n][n] * i%mod;
	cout << d[m][n][n] << endl;
}

Measured memory_bytes: 113960
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

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

    vector<int> x(n), y(n);
    vector<int> xary, yary;

    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(begin(xary), end(xary));
    sort(begin(yary), end(yary));

    ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

    for (int xi = 0; xi < n; ++xi) {
        for (int xj = xi + 1; xj < n; ++xj) {
            for (int yi = 0; yi < n; ++yi) {
                for (int yj = yi + 1; yj < n; ++yj) {

                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];

                    for (int i = 0; i < n; ++i) {
                        if (lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= k) ans = min(ans, 1LL*(rx - lx) * (uy - by));
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    while (cin >> s)
    {
        if (s == "#")
            break;
        int a, b, c, d;
        int i = 0, j = 0;
        cin >> a >> b >> c >> d;
        char t[20][20];
        for (int i = 0; i < 20; i++)
        {
            for (int j = 0; j < 20; j++)
            {
                t[i][j] = ' ';
            }
        }
        for (char c : s)
        {
            if (c == '/')
            {
                i++;
                j = 0;
            }
            else if (c == 'b')
            {
                t[i][j] = 'b';
                j++;
            }
            else
            {
                for (int k = 0; k < c - '0'; k++)
                {
                    t[i][j] = '.';
                    j++;
                }
            }
        }
        string ans;
        int cnt = 0;
        swap(t[a - 1][b - 1], t[c - 1][d - 1]);
        for (i = 0; i < 20; i++)
        {
            for (j = 0; j < 20; j++)
            {
                if (t[i][j] == '.')
                {
                    cnt++;
                }
                else if (t[i][j] == 'b')
                {
                    if (cnt != 0)
                    {
                        ans += to_string(cnt);
                    }
                    ans.push_back('b');
                    cnt = 0;
                }
            }
            if(cnt!=0){
                ans+=to_string(cnt);
                cnt=0;
            }
            if (t[i + 1][0] == ' ')
            {
                break;
            }
            else
            {
                ans.push_back('/');
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3200
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B, C;
  cin >> A >> B >> C;
  C -= A - B;
  C = max(0l, C);
  cout << C << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int r, s, p;
int d[1 << 20];
int main() {
	cin >> r >> s >> p;
	rep(i,p){
		int x, y; cin >> x >> y; x--; y--;
		int dis = 0; dis += r - x;
		if (y < s) {
			dis += s - y;
		}
		else {
			dis += y - s + 1;
		}
		d[dis]++;
		//cout << dis << endl;
	}
	rep(i, (1 << 20)) {
		if (d[i]>1) {
			d[i + 1] += d[i] - 1; d[i] = 1;
		}
	}
	int out = 0;
	rep(i, 1 << 20) {
		if (d[i])out = i;
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+4;
vector<bool> visited(N,0);
vector<ll> adj[N];
vector<ll> order;
void dfs(ll u){
 visited[u]=1;
 for(ll v:adj[u]){
  if(!visited[v]) dfs(v);
 }
 order.push_back(u);
}
int main(){
 ll n;
 cin>>n;
 ll m;
 cin>>m;
 while(m--){
  ll u,v;
  cin>>u>>v;
  adj[u].push_back(v);
 }
 for(ll i=1;i<=n;i++) if(!visited[i]) dfs(i);
 reverse(order.begin(),order.end());
 unordered_map<ll,ll> ma;
 for(ll i=0;i<n;i++){
  ma[order[i]]=i;
 }
 ll dp[n];
 dp[n-1]=0;
 //for(ll i=0;i<n;i++) cerr<<order[i]<<" ";
 //cerr<<endl;
 for(ll i=n-2;i>=0;i--){
  ll u=order[i];
  ll ans=0;
  for(ll v:adj[u]){
   //cerr<<u<<" "<<v<<endl;
   ans=max(ans,1+dp[ma[v]]);
  }
  //cerr<<i<<" "<<ans<<endl;
  dp[i]=ans;
 }
 cout<<*max_element(dp,dp+n)<<endl;
 return 0;
}

Measured memory_bytes: 12660
#include <iostream>
#include <string>
#include <cstdio>
 
#define rep(i,a,b) for(int i=(a);i<(b);i++)
 
using namespace std;
 
int n, m;
int c[310], v[310], d[310], l[310];
int dp[310][310];
 
int main(){
  while(cin >> n >> m){
    //cout <<"AAA" <<n <<" " << m << endl;
	char str[80];
	
    rep(i,0,n){
     gets(str);
      gets(str);
	  //cout << str << endl;
      //cin.getline(str,800);
      //cout << "akira"<<endl;
      //cout << c << endl;
      //cout << "bakatin"<<endl;
      cin >> c[i] >> v[i] >> d[i] >> l[i]; 
      //cout <<  c[i] << v[i]<< d[i]<<l[i]; 
    }
    rep(i, 0, n+1){
      rep(j, 0, m+1){
    dp[i][j] = 0;
      }
    }
    rep(i, 0, n){
      rep(j, 0, m+1){
    dp[i+1][j] = dp[i][j];
    for(int k = 0; j - k*c[i]>= 0; k++)
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-k*c[i]] + k*v[i]);
      }
    }
    int mv = dp[n][m];
 
    rep(i, 0, n+1){
      rep(j, 0, m){
    dp[i][j] = 0;
      }
    }
    rep(i, 0, n){
      rep(j, 0, m+1){
    dp[i+1][j] = dp[i][j];
    for(int k = 0; j - k*c[i]>= 0 ; k++)
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-k*c[i]] + k*d[i]);
      }
    }
    int md = dp[n][m];
    //cout << md << endl;
 
    rep(i, 0, n+1){
      rep(j, 0, m){
    dp[i][j] = 0;
      }
    }
    rep(i, 0, n){
      rep(j, 0, m+1){
    dp[i+1][j] = dp[i][j];
    for(int k = 0; j - k*c[i]>= 0 ; k++)
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-k*c[i]] + k*l[i]);
      }
    }
    int ml = dp[n][m];
    int ans = 0;
    ans = max(mv, md);
    ans = max(ans, ml);
     
    cout << ans <<endl;
 
  }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int main(){
    string s;
    cin>>s;
    if(s[0]=='a'){
       cout<<"vowel"<<endl;
       return 0;
    }
    if(s[0]=='i'){
       cout<<"vowel"<<endl;
       return 0;
    }
    if(s[0]=='e'){
       cout<<"vowel"<<endl;
       return 0;
    }
    if(s[0]=='u'){
       cout<<"vowel"<<endl;
       return 0;
    }
    if(s[0]=='o'){
       cout<<"vowel"<<endl;
       return 0;
    }
    cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
s = input()
n = int(input())

s = list(s)

for i in range(n):
  arv = [a for a in input().split()]

  if (arv[0] == "reverse"):
    reverse_s = s[int(arv[1]) : int(arv[2])+1]
    reverse_s.reverse()
    s[int(arv[1]) : int(arv[2])+1]= reverse_s
  
  if (arv[0] == "replace"):
    s[int(arv[1]) : int(arv[2])+1] = list(arv[3])
        
  if (arv[0] == "print"):
    print("".join(s[int(arv[1]):int(arv[2])+1]))


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    long double ans=0;
    rep(i,n){
        long double x;
        string y;
        cin>>x>>y;
        if(y=="JPY") ans+=x;
        else ans+=380000.0*x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3772
import bisect

n = int(input())
num_list = []
for i in range(n):
    num_list.append(int(input()) * -1) 

dp = [1] * n 

for i in num_list:
    indx = bisect.bisect_right(dp, i)
    dp[indx] = min(dp[indx], i)

ans = sum(x < 1 for x in dp)

print(ans)

Measured memory_bytes: 7852
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long res = 0;
            for (int i = 1; i <= n; i++)
            {
                if (!(i % 3 == 0) && !(i % 5 == 0))
                {
                    res += i;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
    string s;
    cin >> s;
    rep(i, s.size() - 1)
    {
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    rep(i, s.size() - 2)
    {
        if (s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 500000
#define INFTY 1000000000

int L[N],R[N];
int count=0;

void merge(int [],int,int,int);
void mergeSort(int [],int,int);

int main(){
  int A[N], n, i;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    if (A[i] >= INFTY ){
      return 1;
    }
  }
  mergeSort(A, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i >= 1 ) printf(" ");
    printf("%d", A[i]);
    }
  printf("\n");

  printf("%d\n", count);

  return 0;
}
void merge(int A[],int left,int mid,int right){
  
  int i,j,k,n1,n2;
  
  n1 = mid - left;
  n2 = right - mid;
  for( i = 0; i <= n1-1; i++ ){
    L[i] = A[left + i];
  }
  for( i = 0; i <= n2-1; i++ ){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for( k = left; k <= right-1; k++ ){
    count++;
    if( L[i] <= R[j] ){
      A[k] = L[i];
	i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int A[],int left,int right){

  int mid;
  
  if( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4512
use std::io::{self, Read, Write};

#[rustfmt::skip] #[macro_use] #[allow(unused_macros)]
mod rwc {
    macro_rules! rd { ($buf:ident, $t:ty)       => { $buf.next().unwrap().parse::<$t>().ok().unwrap() }; }
    macro_rules! wt { ($out:ident, $($arg:tt)*) => { write!($out, $($arg)*).ok()                      }; }
    macro_rules! cv { ($n:expr, $fn:expr)       => { (0..$n).map($fn).collect::<Vec<_>>()             }; }
}

fn main() {
    let (mut _buf, mut _out) = (String::new(), io::stdout());
    let (mut _buf, mut _out) = {
        io::stdin().read_to_string(&mut _buf).ok();
        (_buf.split_whitespace(), io::BufWriter::new(_out.lock()))
    };

    let n = rd!(_buf, usize);
    let v = rd!(_buf, String).chars().collect::<Vec<_>>();

    let mut vr = vec![0; n];
    let mut vg = vec![0; n];
    let mut vb = vec![0; n];

    if &v[0] == &'R' {
        vr[0] = 1;
    }
    if &v[0] == &'G' {
        vg[0] = 1;
    }
    if &v[0] == &'B' {
        vb[0] = 1;
    }

    for i in 1..n {
        vr[i] = if &v[i] == &'R' {
            vr[i - 1] + 1
        } else {
            vr[i - 1]
        };
        vg[i] = if &v[i] == &'G' {
            vg[i - 1] + 1
        } else {
            vg[i - 1]
        };
        vb[i] = if &v[i] == &'B' {
            vb[i - 1] + 1
        } else {
            vb[i - 1]
        };
    }

    let mut ans = 0u64;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            let x = &v[i];
            let y = &v[j];
            if x == y {
                continue;
            }

            let d = j - i;
            let k = j + d;
            if x != &'R' && y != &'R' {
                ans += vr[n - 1] - vr[j];
                if k < n && &v[k] == &'R' {
                    ans -= 1;
                }
            } else if x != &'G' && y != &'G' {
                ans += vg[n - 1] - vg[j];
                if k < n && &v[k] == &'G' {
                    ans -= 1;
                }
            } else {
                ans += vb[n - 1] - vb[j];
                if k < n && &v[k] == &'B' {
                    ans -= 1;
                }
            };
        }
    }

    wt!(_out, "{}\n", ans);
}


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

int main(){


    //エラトステネスの篩
    vector<bool> prime(1000000, true);     //1000000までで、素数ならtrue
    prime[0] = prime[1] = false;
    for(int i = 2; i < 1000000; i++){
        if(prime[i] == true){
            for(int j = 2*i; j < 1000000; j += i){
                prime[j] = false;
            }
        }
    }

    while(1){
        int n; cin >> n;
        if(!n) break;
        int ans = 0;
        for(int i = n + 1; i <= 2*n; i++){
            ans += prime[i];
        }
    
        cout << ans << endl;
    }

    

    return 0;
}


Measured memory_bytes: 3184
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
ad = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ad[y].append(x)

dp = [-1]*N

def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in ad[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return dp[v]

for v in range(N):
    rec(v)

ans = max(dp)
print(ans)

Measured memory_bytes: 103936
import java.util.*;

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

    int N = scan.nextInt();
    String A = scan.next();
    String B = scan.next();
    String C = scan.next();
    String choiceOfA = "0";
    String choiceOfB = "0";
    String choiceOfC = "0";
    int ans = 0;
    for (int i = 0;i<N ;i++ ) {
      choiceOfA = A.substring(i,i+1);
      choiceOfB = B.substring(i,i+1);
      choiceOfC = C.substring(i,i+1);
      if (!choiceOfA.equals(choiceOfB) && !choiceOfB.equals(choiceOfC) && !choiceOfC.equals(choiceOfA)) {
        ans+=2;
      }else if((choiceOfA.equals(choiceOfB) && !choiceOfB.equals(choiceOfC) || (choiceOfB.equals(choiceOfC) && !choiceOfC.equals(choiceOfA)) || (choiceOfC.equals(choiceOfA) && !choiceOfA.equals(choiceOfB)))) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    char c;
    cin >> c;

    cout << char(c+1) << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
 
int main(void){
	int in[6] = {};
  	int i,j;
  	bool flag = true;
  	
  	for(i=0;i<6;i++){
    	scanf("%d\n",&in[i]);
    }
  	for(i=0;i<4;i++){
      	for(j=i+1;j<5;j++){
    		if(in[j] - in[i] > in[5]){
        		flag = false;
        	}
    	}
    }
  	if(flag) printf("Yay!\n");
  	if(!flag) printf(":(\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a,b,c;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    if(a == b)
        printf("%d\n",c);
    else
        if(a == c)
            printf("%d\n",b);
    else
        printf("%d\n",a);
    return 0;
}

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

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;

    int ret = 1;
    for (int i = 1; i * i <= m; i++) {
        if ((n - 1) * i < m) {
            int last = m - (n - 1) * i;
            ret = max(ret, __gcd(i, last));
        }
        if ((n - 1) * (m / i) < m) {
            int last = m - (n - 1) * (m / i);
            ret = max(ret, __gcd((int) m / i, last));
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  int N_min = 1000000000;
  int N_max = 1;
  
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if( N_min > A.at(i) ){
      N_min = A.at(i);
    }
    if( N_max < A.at(i) ){
      N_max = A.at(i);
    }
  }
//  cout << N_min << " : " << N_max << endl;
  cout << N_max-N_min << endl;
}

Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

// solution 
use std::collections::HashMap;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut dic = HashMap::new();

    for &ai in a.iter() {
        let mut entry = dic.entry(ai).or_insert(false);
        *entry = !*entry;
    }

    let mut sum = 0;
    for v in dic.values().into_iter() {
        if *v {
            sum += 1;
        }
    }
    println!("{}",sum);
}



Measured memory_bytes: 12540
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    string fie[8];
    cin>>N;
    for(int i=0;i<N;i++){
        getchar();getchar();
        for(int j=0;j<8;j++)cin>>fie[j];
        int X,Y;
        cin>>X>>Y;
        queue<int> QX,QY;
        QX.push(X);QY.push(Y);
        while(!QX.empty()){
            Y=QY.front(),X=QX.front();
            QY.pop();QX.pop();
            if(Y<=0||9<=Y||X<=0||9<=X)continue;
            if(fie[Y-1][X-1]=='1'){
                fie[Y-1][X-1]='0';
                for(int j=-3;j<=3;j++){
                    for(int k=-3;k<=3;k++){
                        if((j==0||k==0)&&(!(j==0&&k==0))){
                            QY.push(Y+j);QX.push(X+k);
                        }
                    }
                }
            }
        }
        printf("Data %d:\n",i+1);
        for(int j=0;j<8;j++)cout<<fie[j]<<endl;;
    }
    return 0;
}

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


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int N;
    int x[20][20];
    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 20; j++){
            x[i][j] = -1;
        }
    }
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;  cin >> a;
        for(int j = 0; j < a; j++){
            int xx, yy;
            cin >> xx >> yy;
            xx--;
            x[i][xx] = yy;
        }
    }

    int res = 0;
    for(int i = 0; i < (2 << N); i++){
        bool ok = true;
        for(int j = 0; j < N; j++){
            if((i >> j) % 2 == 1){
                for(int k = 0; k < N; k++){
                    if(x[j][k] == 1 && ((i >> k) % 2 == 0)){
                        ok = false;
                        break;
                    }
                    if(x[j][k] == 0 && ((i >> k) % 2 == 1)){
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok){
            int tmp = 0;
            for(int j = 0; j < N; j++){
                tmp += (i >> j) % 2;
            }
            res = max(res, tmp);
        }
    }

    cout << res << endl;


    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  V<int> b;

  cin >> n;
  b.resize(n - 1);

  rep(i, n - 1) {
    cin >> b[i];
  }

  int ans = 0;
  rep(i, n) {
    int cand_a = INT32_MAX;

    if(i >= 0 && i < n - 1) {
      cand_a = min(cand_a, b[i]);
    }
    if(i - 1 >= 0 && i - 1 < n - 1) {
      cand_a = min(cand_a, b[i - 1]);
    }
    ans += cand_a;
  }

  cout << ans << endl;
}

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

int main() {
int n,c=0;
map<int,int> m;
cin>>n;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    m[a]++;
}

for(auto x=m.begin();x!=m.end();x++){
    //cout<<x->first<<","<<x->second<<endl;
    if(x->second%2==0)c++;
}
cout<<m.size()-c%2<<endl;
	return 0;
}

Measured memory_bytes: 4992
n = int(input())
l_list = [2, 1]
if n < 2 :
    print(l_list[n])
else :
    for i in range(2,n+1) :
        new = l_list[i-1] + l_list[i-2]
        l_list.append(new)
    print(l_list[n])


Measured memory_bytes: 9084