akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll x;
    cin >> x;
    if(x >= 2300){
        cout << 1 << endl;
        return 0;
    }

    rep(i,0,x/100+1){
        rep(j,0,x/101+1){
            rep(k,0,x/102+1){
                rep(l,0,x/103+1){
                    rep(m,0,x/104+1){
                        if(i*100+j*101+k*102+l*103+m*104 > x) break;
                        if((x-(i*100+j*101+k*102+l*103+m*104)) % 105 == 0){
                            cout << 1 << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

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

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main()
{
	char a;
	int rank, b1[14] = {}, b2[14] = {}, b3[14] = {}, b4[14] = {}, i, m;
	cin >> m;
	 while (m--)
	{
		cin >> a >> rank;
		if (a == 'S')b1[rank]++;
		if (a == 'H')b2[rank]++;
		if (a == 'C')b3[rank]++;
		if (a == 'D')b4[rank]++;
	}
	for (i = 1; i <= 13; i++)
		if (b1[i] == 0)cout<<'S' <<" "<<i << endl;
	for (i = 1; i <= 13; i++)
		if (b2[i] == 0)cout<<'H' <<" "<<i << endl;
	for (i = 1; i <= 13; i++)
		if (b3[i] == 0)cout<< 'C'<<" "<<i << endl;
	for (i = 1; i <= 13; i++)
	{
		if (b4[i] == 0)cout << 'D' << " " << i << endl;
		
	}
	
	return 0;	
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

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

    vector<vector<long long int> > AB(100001);
    for(int n=0; n<N; n++) {
        int a;
        long long int b;
        cin >> a >> b;
        AB[a].push_back(b);
    }
    
    priority_queue<long long int> que;
    long long int ans=0;
    for(int m=1; m<M+1; m++)  {
        for(int i=0; i<AB[m].size(); i++) {
            que.push(AB[m][i]);
        }
        
        if(que.empty()) {
            continue;
        }
        ans += que.top();
        que.pop();
    }

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

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <cmath>

auto main()
 -> int{

	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);

	int n, out = 0, base = 0, point = 0;
	std::string cmd;

	std::cin>> n;
	for(int i=0;i < n;i++ ){
		out = 0;
		base = 0;
		point = 0;
		while(out < 3){
			std::cin>> cmd;
			if(cmd == "HIT"){
				base <<= 1;
				base += 1;
				if(base > 8){
					base -= 8;
					point++;
				}
			}else if(cmd == "OUT"){
				out++;
			}else{
				for(int i = 2;i >= 0 ;i--){
					if(base - pow(2,i) >= 0){
						base -= pow(2,i);
						point++;
					}
				}
				point++;
			}
		}
		std::cout<< point <<"\n";
	}

	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
void insertionSort(int *a,int n,int g);
int count = 0;

int main(){
  int a[1100000],g[110]={};
  int n,m=1;
  int i,j,x;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  x=n;
  while(x/2!=0){
    x/=2;
    m++;
  }
  g[0]=n;
  for(i=1;i<m;i++){
    if(g[i-1]/2!=0)  g[i]=g[i-1]/2;
    else g[i]=1;
  }
  for(i=0;i<m;i++) insertionSort(a,n,g[i]);
  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",g[i]);
    if(i!=m-1) printf(" ");
    else printf("\n");
  }
  printf("%d\n",count);
  for(i=0;i<n;i++) printf("%d\n",a[i]);
  
    return 0;
}

void insertionSort(int *a,int n,int g){
  int v;
  int i,j;
  
  for(i=g;i<n;i++){
    v=a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g] = a[j];
      j = j-g;
      count++;
    }
    a[j+g] = v;
  }
}



Measured memory_bytes: 5636
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    auto t = cast(ubyte[]) s.dup;
    bool b = t.sort().uniq().array().length == s.length;
    writeln(b ? "yes" : "no");
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	length := len(S)
	for i := 1; i <= length; i++ {
		S = S[:len(S)-1]
		if strings.Repeat(S[:len(S)/2], 2) == S {
			fmt.Println(len(S))
			break
		}
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename V>
V compress(V v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}
template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}
map<char, Int> dict(const string &v){
  return dict(vector<char>(v.begin(),v.end()));
}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  Int n;
  cin>>n;
  vector<Int> xs(n),ys(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  if(x1>x2) swap(x1,x2),swap(y1,y2);
  const Int MAX = 1e8;
  if(y1>y2){
    for(Int &y:ys) y=MAX-y;
    y1=MAX-y1;
    y2=MAX-y2;
  }
  assert(x1<=x2 && y1<=y2);

  vector<Int> vx(xs),vy(ys);
  vx.emplace_back(x1);
  vx.emplace_back(x2);
  vy.emplace_back(y1);
  vy.emplace_back(y2);

  vx=compress(vx);
  vy=compress(vy);
  auto dx=dict(vx);
  auto dy=dict(vy);

  Int m=dx.size();
  vector<Int> fs(m,-1);
  for(Int i=0;i<n;i++){
    if(xs[i]<x1) continue;
    if(x2<xs[i]) continue;
    if(ys[i]<y1) continue;
    if(y2<ys[i]) continue;
    fs[dx[xs[i]]]=dy[ys[i]];
  }

  using D = long double;
  const D PI = asinl(1) * 2;
  if(x1==x2) drop((y2-y1)*100+(~fs[dx[x1]]?PI*10-20:0));

  Int len=0;
  vector<Int> dp(m,MAX);
  for(Int i=0;i<m;i++){
    if(fs[i]<0) continue;
    Int k=lower_bound(dp.begin(),dp.end(),fs[i])-dp.begin();
    dp[k]=fs[i];
    chmax(len,k+1);
  }

  D ans=(x2-x1)*100+(y2-y1)*100+len*(5*PI-20);
  if(len==min(x2-x1,y2-y1)+1)
    ans+=-(5*PI-20)+(PI*10-20);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 34692
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=4000+10;
const int mod=1e9+7;

inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}
int fac[N],ifac[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
}
inline int C(int n,int m) { return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod; }

int main() { int n=read(),k=read(); init(n+k);
    printf("%lld\n",1ll*(C(n+k-2,k-1)-C(n+k-2,k-2)+mod)*qpow(2,max(0,n-k-1))%mod);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H1 =sc.nextInt();
    int M1 =sc.nextInt();
    int H2 =sc.nextInt();
    int M2 =sc.nextInt();
    int K =sc.nextInt();
    int l =K/60;
    int m =K%60;
    H2=H2-l;
    M2=M2-m;
    if(M2<0){M2=M2+60;H2=H2-1;}
    int H3 =H2-H1;
    int M3 =M2-M1;
    int ans =H3*60+M3;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35712
#include<iostream>
using namespace std;
int main() {
	char ctc[256];
	ctc['A'] = 'T';
	ctc['T'] = 'A';
	ctc['C'] = 'G';
	ctc['G'] = 'C';
	char a;
	cin >> a;
	cout << ctc[a] << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe

binaryAllSearch :: Int -> [[Int]]
binaryAllSearch n
 | n < 0    = [[]]
 | otherwise = [n:binaryElem | binaryElem <- binaryAllSearch (n - 1)] ++ binaryAllSearch (n - 1)

getSkillInfo :: IO [Int]
getSkillInfo = map read . words <$> getLine

getCosts ::  [[Int]] -> [Int] -> Int -> [Int] -> Maybe Int
getCosts a b x total
 | b == []   = if and (map (\n -> n >= x) (tail total)) then return (head total) else Nothing
 | otherwise = getCosts a (tail b) x (zipWith (+) (a !! (head b)) total) 

getAllCosts :: [[Int]] -> [[Int]] -> Int -> Int -> [Maybe Int] -> Int
getAllCosts a b m x ans
 | b == []   = if null tmp then -1 else minimum tmp
 | otherwise = getAllCosts a (tail b) m x ((getCosts a (head b) x (replicate (m + 1) 0)):ans)
  where tmp = map fromJust $ filter (\x -> x /= Nothing) ans

main = do
 [n,m,x] <- map read . words <$> getLine :: IO[Int]
 a <- replicateM n getSkillInfo
 print $ getAllCosts a (binaryAllSearch (n - 1)) m x []
 


Measured memory_bytes: 5804
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

S=input()
N=len(S)
T=input()
M=len(T)

# dp[i][j] := T[0..j]をS[0..i]にするのにかかる最小操作数
dp = [[INF] * (M+1) for i in range(N+1)]
# 初期化(Sが0文字でTも0文字なら何もしなくていい)
dp[0][0] = 0
for i in range(N+1):
    for j in range(M+1):
        # 挿入
        if i < N:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1)
        # 削除
        if j < M:
            dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1)
        # 置換
        if i < N and j < M:
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+1)
            if S[i] == T[j]:
                # 今回増やす文字が一致するなら、ノーコストで遷移できる
                dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j])
# SがN文字、TがM文字で終わる場合の最小回数
print(dp[N][M])



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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

vector<vector<int> > dp, G;
int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m, s, t;
  cin >> n >> m;
  G.resize(n);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    G[u].emplace_back(v);
  }
  cin >> s >> t;
  --s;
  --t;

  dp.resize(n, vector<int>(3, inf));
  dp[s][0] = 0;
  queue<pair<int, int> > Q;
  Q.push(make_pair(s, 0));

  while(! Q.empty()) {
    int cur = Q.front().first, cost = Q.front().second;
    Q.pop();
    rep(i, (int)G[cur].size()) {
      if (dp[G[cur][i]][(cost + 1) % 3] > dp[cur][cost] + 1) {
        dp[G[cur][i]][(cost + 1) % 3] = dp[cur][cost] + 1;
        Q.push(make_pair(G[cur][i], (cost + 1) % 3));
      }
    }
  }

  if (dp[t][0] == inf) cout << -1 << endl;
  else cout << dp[t][0] / 3 << endl;


  return 0;
}

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

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  ll hoge,cnt=0;
  map<ll,bool> map;
  rep(i,n){
    cin>>hoge;
	  auto itr = map.find(hoge);
	  if( itr != map.end() ) {
      map.erase(hoge);
      cnt--;
	  } else {
      map[hoge]=true;
      cnt++;
	  }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 6528
N = int(input())
t = []
for _ in range(N):
  a, b = map(int, input().split())
  t.append((a, b))
  
t.sort(key = lambda t: t[0] + t[1])
s = 0
while t:
  s += t.pop()[0]
  if t:
    s -= t.pop()[1]
    
print(s)

Measured memory_bytes: 57176
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;
for($bit = 0, $NN = (1<<$N); $bit < $NN; ++$bit){
    $con = 0;
    for ($i = 0; $i < $N; ++$i) if ($bit & (1<<$i)) ++$con;
    $ords = [];
    $iter = $con;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = $iter++;
    for($s = 0; $s <= 50; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $p0 => $p1){
            $ns = ($p0-$con) & 1 ? $B[$p0] : $A[$p0];
            if($ns >= $s){
                $dp[$bit | (1<<$p0)][$ns] = min($dp[$bit|(1<<$p0)][$ns], $dp[$bit][$s] + abs($p1 - $con));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}

Measured memory_bytes: 682488
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<i32>();
    v.sort();
    println!("{}", (v[n-1]-v[0]).abs());
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    int memo =n;
    int N = n/4;
    int m = n/7;
    rep(i,N){
        n-=4;
        if(n%7==0){
            cout << "Yes" << endl;
            return 0;
        }

    }
    rep(i,m){
        memo-=7;
        if(memo%4==0){
            cout << "Yes" << endl;
            return 0;
        }

    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> heap;
  rep(i, n) {
    int a;
    cin >> a;
    heap.push(a);
  }
  rep(i, m) {
    int m = heap.top();
    heap.pop();
    m = m >> 1;
    heap.push(m);
  }
  llong ans = 0;
  rep(i, n) {
    ans += heap.top();
    heap.pop();
  }
  cout << ans << endl;
  return 0;
}

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

int SumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
   
    
int main() {
  int N, A, B;
  cin >> N >> A >> B;
 
  int sum;
  for (int i = 1; i <= N; i++) {
    int sdi = SumOfDigits(i);
    if (sdi >= A && sdi <= B) sum += i;
  }
  cout << sum << endl;
}    
    


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>


using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()


int main(){
    string s; cin >> s;
    int ans = 0;
    int left=0,right=s.length()-1;
    
    while(left <= right){
      if(s[left]==s[right]){
        left++; right--; continue;
      } else if(s[left]=='x' && s[right]!='x'){
        ans++; left++; continue;
      } else if(s[left]!='x' && s[right]=='x'){
        ans++; right--; continue;
      } else if(s[left]!=s[right]){
        ans=-1; break;
      } 
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    cout << accumulate(a.begin(), a.end(), 0, [](int x, int y) { return __gcd(x, y); }) << endl;
    return 0;
}


Measured memory_bytes: 640
//by shubham_bitsg

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

//#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int b, a, h, m;
    cin>>b>>a>>h>>m;
    double x = sqrt(a*a + b*b - (double)2*a*b*cos((double)(abs(30*(h+(m/60.0))-6*m))*PI/180.0));
    cout<<setprecision(20)<<x<<"\n";
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n, m, k;

int main() {

	FAST;

	cin >> n >> m >> k;
	vector <int> prefx(n + 2), prefy(m + 2);
	vector <int> x(k + 1), y(k + 1);
	for (int i = 1; i <= k; i ++) {
		cin >> x[i] >> y[i];
		prefx[x[i]] ++;
		prefx[x[i] + 1] --;
		prefy[y[i]] ++;
		prefy[y[i] + 1] --;
	}
	for (int i = 1; i <= n; i ++) {
		prefx[i] += prefx[i - 1];
	}
	for (int i = 1; i <= m; i ++) {
		prefy[i] += prefy[i - 1];
	}
	int maxx = -1;
	for (int i = 1; i <= n; i ++) {
		maxx = max(maxx, prefx[i]);
	}
	int maxy = -1;
	for (int i = 1; i <= m; i ++) {
		maxy = max(maxy, prefy[i]);
	}
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= n; i ++) {
		if (prefx[i] == maxx) cnt1 ++;
	}
	for (int i = 1; i <= m; i ++) {
		if (prefy[i] == maxy) cnt2 ++;
	}
	int tmp = 0;
	for (int i = 1; i <= k; i ++) {
		if (prefx[x[i]] + prefy[y[i]] == maxx + maxy) tmp ++;
	}
	if (1LL * tmp == 1LL * cnt1 * cnt2) {
		cout << maxx + maxy - 1 << '\n';
	}
	else {
		cout << maxx + maxy << '\n';
	}
	return 0;
}

Measured memory_bytes: 7924
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    if(s[i] == 'R') a[i] = 0;
    if(s[i] == 'G') a[i] = 1;
    if(s[i] == 'B') a[i] = 2;
  }
  vector<long long> cnt(3);
  for(int i = 0; i < n; i++) cnt[a[i]]++;
  long long ans = 1;
  for(int i = 0; i < 3; i++) ans *= cnt[i];
  for(int j = 0; j < n; j++) {
    for(int i = 0; i < j; i++) {
      int k = j + (j-i);
      if(k < n) {
        if(a[i] == a[j]) continue;
        if(a[i] == a[k]) continue;
        if(a[k] == a[j]) continue;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
    int ururu, i, j, k, t=0, N, C[1000], S[1000], F[1000];

    scanf("%d", &N);
    for (i = 0; i < N-1; i++){
        scanf("%d %d %d", &C[i], &S[i], &F[i]);
    }

    for (i = 0; i < N-1; i++){
        t = 0;

        for (j = i; j < N-1; j++){

            ururu = 0;
            if (j == i){
                t = S[j];
            } else {
                if(t < S[j]){
                    t = S[j];
                } else {
                    while(ururu < t){
                        ururu += F[j];
                    }
                    t = ururu;
                }
            }

            //printf("i=%d, j=%d, t=%d, ", i, j, t);
            t += C[j];
            //printf("t+C[%d]=%d\n", j, t);
        }

        printf("%d\n", t);
    }

    printf("0\n");

    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}
// B
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int mini = INT_MAX;
  rep(i,n) {
    if( i + 2 >= n ) continue;
    int a = s[i]-'0';
      int b = s[i+1]-'0';
	int c = s[i+2]-'0';
	mini = min(mini,abs(753-(a*100+b*10+c)));
  }
  cout << mini << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,m,i,sum=0;
  int cost[10000];
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0; i<m; i++){
    scanf("%d",&cost[i]);
    sum += cost[i];
  }
  if(n>=sum)
    printf("%d",n-sum);
  else
    printf("-1");
  return 0;
}

Measured memory_bytes: 1768
#include <stdio.h>

int main(void)
{
	int x,y,z,tmp;
	scanf("%d %d %d",&x,&y,&z);
	if(x > y) tmp = x,x = y,y = tmp;
	if(y > z) tmp=y,y=z,z=tmp;
	if(x > y) tmp=x,x=y,y=tmp;
	printf("%d %d %d\n",x,y,z);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0); }

int main() {
  ull n, m;
  vector<ull> l;
  vector<ull> r;
  cin >> n >> m;

  each(i, m) {
    ull t1, t2;
    cin >> t1 >> t2;
    l.push(t1);
    r.push(t2);
  }

  ull minl = 0;
  ull minr = n;
  bool fail = false;
  each(i, m) {
    minl = max({minl, l[i]});
    minr = min({minr, r[i]});
    if (minl > minr) {
      fail = true;
      break;
    }
    // cout << minl << " : " << minr << endl;
  }

  if (fail) {
    cout << 0 << endl;
  } else {
    cout << minr - minl + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define PER(i, a, b) for(int i = a; i >= b; i--)
#define LL long long
#define lowbit(x) x &(-x)

inline int read() {
    int x = 0, flag = 1;char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-') flag = - 1;
        ch = getchar();
    }
    while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * flag;
}

int main() {   
    unsigned long long n, a, b;
    scanf("%llu%llu%llu", &n, &a, &b);
    if((b - a) & 1) {
        unsigned long long c, d;
        unsigned long long a0 = a, b0 = b;
        c = a; b = b - a;
        c = c + (b - 1) / 2;
        a = a0; b = b0;
        d = n - b + 1; a = a + n - b + 1;
        d = d + (n - a) / 2;
        printf("%llu", min(c, d));
    } else {
        unsigned long long x = (b - a) >> 1; 
        printf("%llu", x);
    }
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c) = readIntegerList()
    val set = setOf(a, b, c)
    if (set.size == 2) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 36008
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;cin >> S;
    int N[S.length()];
    for(int i = 0;i < S.length();i++){
        N[i] = S[i] - '0';
    }
    int ans = 1000;
    for(int i = 0;i < S.length() - 2;i++){
        int t = abs(753 -  (N[i] * 100 + N[i + 1] * 10 + N[i + 2]));
        ans = min(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exit {cout << "No\n"; return 0;}

using namespace std;

const int Nmax = 1e5 + 5;
int i, j, n, a[Nmax], A[5][Nmax], b[Nmax];

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=3; ++i)
        for(j=1; j<=n; ++j)
            cin >> A[i][j];

    int ans0 = 0, ans1 = 0;
    for(i=1; i<=n; ++i)
    {
        if(A[2][i] % 3 != 2) exit;
        if(A[1][i] == A[2][i] - 1 && A[3][i] == A[2][i]+1) a[i] = A[2][i] / 3 + 1, b[i] = 0;
            else if(A[1][i] == A[2][i] + 1 && A[3][i] == A[2][i] - 1) a[i] = A[2][i] / 3 + 1, b[i] = 1;
                else exit;
        if(i&1) ans1 ^= b[i];
            else ans0 ^= b[i];
    }

    for(i=1; i<=n; ++i) if( (a[i]&1) != (i&1) ) exit;

    for(i=1; i<=n; ++i)
        while(a[i] != i)
        {
            swap(a[i], a[a[i]]);
            if(i&1) ans0 ^= 1;
                else ans1 ^= 1;
        }

    if(ans0 || ans1) exit;
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
   int k,n;
   cin >> k >> n;
   std::vector<int> a;
   for(int i=0; i<n; i++){
   		int x;
   		cin >> x;
   		a.push_back(x);
   }
   sort(a.begin(),a.end());
   int ans = k;
   for(int i=0; i<n; i++){
   		int tmp;
   		if(i != n-1){
   			tmp=k-(a[i+1]-a[i]);
   		}else{
   			tmp = a[i]-a[0];
   		}
   		ans = min(ans,tmp);
   }
   cout << ans << "\n";
   return 0;
}

	





Measured memory_bytes: 4252
#include <cstdio>

int main(int argc, const char * argv[]) {
    
    int n,d,x;
    
    scanf("%d %d %d",&n,&d,&x);
    int ans = 0;
    for(int i=0,tmp;i<n;i++){
        scanf("%d",&tmp);
        int t = 1;
        
        while(t<=d){
            ans++;
            t+=tmp;
        }
    }
    
    printf("%d\n",ans+x);

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys
import math
import itertools

input = sys.stdin.readline


def main():
    N = int(input())
    t = [[int(i) for i in input().split()] for _ in range(N)]

    div = math.factorial(N)
    ans = 0
    l = [i for i in range(N)]
    for ary in itertools.permutations(l):
        s = 0
        for i in range(len(ary)-1):
            a = ary[i]
            b = ary[i+1]
            s += math.sqrt((t[a][0]-t[b][0])**2+(t[a][1]-t[b][1])**2)
        ans += s
    print(ans/div)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void){
    int S;
    cin >> S;
    int x, y;
    x = S / 100;
    y = S % 100;
    if(1 <= x && x <= 12){
        if(1 <= y && y <= 12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }else{
        if(1 <= y && y <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    ll a, b;
    cin >> a >> b;
    if(a <= 0 and 0 <= b){
        puts("Zero");
    }else if(a > 0 and b > 0){
        puts("Positive");
    }else{
        if(abs(b - a) % 2 == 0) puts("Negative");
        else puts("Positive");
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            string tmp = "";
            for(int i = 0; i < S.Length; i++)
            {
                if (tmp == "")
                {
                    tmp = S.Substring(S.Length - 1, 1) + S.Substring(0, S.Length - 1);
                }
                else
                {
                    tmp = tmp.Substring(tmp.Length - 1, 1) + tmp.Substring(0, tmp.Length - 1);
                }
                if (tmp == T)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 25772
from itertools import combinations
import numpy as np
import math
X = int(input())
if X == 0:
    print(1, 1)
    exit()

def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def judge(a, b):
    right = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4
    if (a - b) * right == X:
        return True
    else:
        return False

prime = prime_factorize(X)
cand = []
if len(prime) == 1:
    cand = prime
else:
    for r in range(1, len(prime)):
        for i in list(combinations(prime, r)):
            tmp = np.prod(np.array(list(i)))
            if tmp * tmp <= X:
                cand.append(tmp)
    cand = set(cand)

for c in cand:
    for a in range(0, int(math.sqrt(X)) + 1)[::-1]:
        b = a - c
        if judge(a, b):
            print(a, b)
            exit()

Measured memory_bytes: 27192
#include<bits/stdc++.h>
using namespace std;
int f[4][4];
int main()
{
	int a;
    cin>>f[1][1]>>f[1][2]>>f[2][2];
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
       	int k=1; 
		for(int j=1;j<=3;j++)
        {
            if(k)k=0;
            else cout<<" ";
			cout<<f[i][j];
        }
        cout<<endl;
    }
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    string temp = s;
    int len = s.length();

    reverse(s.begin(), s.end());

    int count = 0;
    for(int i = 0; i < len; i++) {
        if(s[i] != temp[i]) count++;
    }

    cout << count / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b = map(int, input().split())
    for i in range(1, 1001):
        if int(i*0.08) == a and int(i*0.1) == b:
            print(i)
            return
        if i == 1000:
            print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
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(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    vector<int> tmp = {1, 2, 3};
    for(int i = 0; i < 3; i++) {
        if(tmp[i] != a && tmp[i] != b) {
            cout << tmp[i] << endl;
            return 0;
        }
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i=0;i<N;i++) cin >> W.at(i);
    
    int S_all=0;
    for(int i=0;i<N;i++) S_all += W.at(i);
    int S1 = 0;
    int T1 = 0;
    for(int i=0;i<N;i++){
        S1 += W.at(i);
        if(S1 + W.at(i+1) > S_all/2) {
            T1 = S1 + W.at(i+1);
            break;
        }
    }
    int S2 = S_all-S1;
    int T2 = S_all-T1;
    cout << min(S2-S1,T1-T2) << endl;
}

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

int main() {
  int N;
  cin >> N;
  string color;
  for (int i = 0; i < N; i++){
    cin >> color;
    if (color == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1){
      cout << "Three" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
count=0
AC_count=[0]
for i in range(1,N+2):
  if S[i-1:i+1]=="AC":
    count+=1
  AC_count.append(count)
k=0
for j in range(Q):
  k=AC_count[r_list[j]-1]-AC_count[l_list[j]-1]
  print(k)

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

int main() {
  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < 4; i++) ans+= s[i];
  ans += " ";
  for (int i = 4; i < s.size(); i++) ans += s[i];

  cout << ans << endl;
}

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

using namespace std;
int n,t,y,ans=0,px[1010],py[1010];
void fy(int a){
    ans+=(py[a]>=py[a-1])?py[a]-py[a-1]:py[a-1]-py[a];
}
void fx(int b){
    ans+=(px[b]>=px[b-1])?px[b]-px[b-1]:px[b-1]-px[b];
}
int main(){
    cin >> y >> t >> n;
    for(int i=0;i<n;i++){
        cin >> px[i] >> py[i];
    }
    for(int j=1;j<n;j++){
        if(px[j]==px[j-1])
        fy(j);
            //ans+=(py[j]>=py[j-1])?py[j]-py[j-1]:py[j-1]-py[j];
        else if(py[j]==py[j-1])
        fx(j);
//ans+=(px[j]>=px[j-1])?px[j]-px[j-1]:px[j-1]-px[j];
        else if(py[j]>py[j-1]&&px[j]>px[j-1]){
            fy(j);
            fx(j);
            int r=(py[j]>=py[j-1])?py[j]-py[j-1]:py[j-1]-py[j];
            int k=(px[j]>=px[j-1])?px[j]-px[j-1]:px[j-1]-px[j];
            ans-=(r>k)?k:r;
        }else if(py[j]<py[j-1]&&px[j]<px[j-1]){
            fy(j);
            fx(j);
            int r=(py[j]>=py[j-1])?py[j]-py[j-1]:py[j-1]-py[j];
            int k=(px[j]>=px[j-1])?px[j]-px[j-1]:px[j-1]-px[j];
            ans-=(r>k)?k:r;
        }else {
        fy(j);
        fx(j);
    }
    }
    cout << ans <<endl;
return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) if (i*108/100==n) kill(i)
	kill(":(")
	
	
	return 0;
}


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

#define MAX_N 200005

int n;
int a[MAX_N];
int ntz[MAX_N];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d",&a[i]);
        ntz[i] = (a[i] ? i : -1);
    }

    ntz[n] = n;
    for(int i=n-1; ~i; i--){
        ntz[i] = (~ntz[i] ? ntz[i] : ntz[i+1]);
    }

    long long ans = 0;
    for(int i=0; i<n; i++){
        int aa = 0;
        for(int j=i; j<n; j=ntz[j+1]){
            if(a[j]&aa)
                break;
            ans += ntz[j+1]-j;
            aa |= a[j];
        }
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
import bisect
import collections
import functools
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


# pattern of x で割れる
@functools.lru_cache(maxsize=None)
def f(x):
    return K//x
    a = 0
    for i in range(1, K + 1):
        if i % x == 0:
            a += 1
    return a % ACMOD


@functools.lru_cache(maxsize=None)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return frozenset(divisors)


@functools.lru_cache(maxsize=None)
def get_diff(x):
    """
    xで割れるときにいくら増加するか
    2 -> 1 でカウント済みなので1
    """
    if x == 1:
        return 1
    ans = x
    for v in make_divisors(x):
        if v != x:
            ans -= get_diff(v)
    return ans % ACMOD


@functools.lru_cache(maxsize=None)
def pow(base_val, pow_val):
    if pow_val == 1:
        return base_val
    if pow_val == 0:
        return 1
    t = pow(base_val, pow_val // 2) % ACMOD
    return (t * t % ACMOD * (base_val if pow_val % 2 else 1)) % ACMOD


# for i in range(1, 100000):
#     get_diff(i)
#
# print("ok")
N, K = lmi()

ans = 0
for i in range(1, K + 1):
    ans += (pow(f(i), N) % ACMOD) * get_diff(i) % ACMOD
    # print(i,f(i), get_diff(i))

print(ans % ACMOD)


Measured memory_bytes: 161456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int n, m, c;
int b[30];
int a[30][30];

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int score = c;
    for (int j = 0; j < m; j++) {
      score += a[i][j] * b[j];
    }
    if (score > 0) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
LL P(LL x) { return x * x * x * x * x; }

VEC<pair<int, LL>> Z;
map<LL, pair<int, int>> K;
pair<int, int> solve(LL X) {
  REP(i, 0, Z.size()) {
    REP(j, i + 1, Z.size()) {
      LL A = Z[i].second;
      LL B = Z[j].second;
      K[A - B] = {Z[i].first, Z[j].first};
      K[B - A] = {Z[j].first, Z[i].first};
      if (A - B == X) {
        return make_pair(Z[i].first, Z[j].first);
      } else if (B - A == X) {
        return make_pair(Z[j].first, Z[i].first);
      }
    }
  }
  return make_pair(0, 0);
}

int main() {
  LL X;
  cin >> X;

  map<int, LL> Y;
  int mi = -1000;
  LL i = mi;
  while (i <= abs(mi)) {
    // cout << i << " " << j << endl;
    i++;
    Y[i] = P(i);
  }

  // DUMP("HI");
  Z = VEC<pair<int, LL>>(Y.size());
  int k = 0;
  for (auto x : Y) {
    Z[k] = x;
    k++;
  }

  auto ans = solve(X);
  cout << ans.first << " " << ans.second<<endl;

  // for (auto v : K) {
  //   auto i = v.first;
  //   auto a = v.second;
  //   DUMP(i, a.first, a.second, P(a.first) - P(a.second));
  // }

  return 0;
}


Measured memory_bytes: 128832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n,ans=0;
  cin >> n;
  rep(i,3){
    ans=ans+n%10;
  n=n/10;
  }
  cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(r<=x&&r<=y&&x<=W-r&&y<=H-r) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	while (A > 0 && C > 0) {
		C -= B;
		if (C <= 0) {
			cout << "Yes\n";
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No\n";
		}
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1777777777;
using PIC = pair<int32, char>;

int main(void){
	int32 N;
	vector<PLL> v;
	cin >> N;
	int64 maxi = 0, mini = INF_LL;
	REP(i, N){
		int64 a, b;
		cin >> a >> b;
		if(a > b) swap(a, b);
		chmax(maxi, b);
		chmin(mini, a);
		v.push_back({a, b});
	}
	sort(all(v));
	int64 mini2 = INF_LL, maxi2 = 0;
	using tup = tuple<int64, int64, int64>;
	priority_queue<tup, vector<tup>, greater<tup>> pq;
	REP(i, v.size()){
		chmax(maxi2, v[i].fs);
		chmin(mini2, v[i].sc);
		pq.push(tup(v[i].fs, i, 0));
	}
	int64 res = (maxi-mini2)*(maxi2-mini);
	maxi2 = 0;
	REP(i, v.size()) chmax(maxi2, v[i].fs);
	chmin(res, (maxi-mini)*(maxi2-get<0>(pq.top())));
	while(get<2>(pq.top()) == 0){
		int64 val, in, id;
		tie(val, in, id) = pq.top(); pq.pop();
		chmax(maxi2, v[in].sc);
		pq.push(tup(v[in].sc, in, 1));
		chmin(res, (maxi-mini)*(maxi2-get<0>(pq.top())));
	}
	cout << res << endl;
}

Measured memory_bytes: 15596