akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n, q;
  scanf("%d %d", &n, &q);

  char s[MAX];
  scanf("%s", s);

  int dp[MAX]; //　dp[i]: 先頭からi文字目までのAC数
  dp[0] = 0;
  rep(i, 1, n) {
    if ( s[i - 1] == 'A' && s[i] == 'C' ) {
      dp[i] += dp[i - 1] + 1;
    } else {
      dp[i] = dp[i - 1];
    }
  }

  int l, r;
  rep(i, 0, q) {
    scanf("%d %d", &l, &r);
    int ans = dp[r - 1] - dp[l - 1];
    printf("%d\n", ans); 
  }
  return 0;
}


Measured memory_bytes: 1280
// https://atcoder.jp/contests/abc153/tasks/abc153_a
//
#![allow(unused_imports)]
use std::io::*;
use std::io::Write;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

    ($iter:expr, switch) => {
        {
            let ty = read_value!($iter, i32);
            if ty == 1 {
                vec![ty, read_value!($iter, i32), read_value!($iter, i32)]
            } else if ty == 2 {
                vec![ty, read_value!($iter, i32)]
            } else {
                vec![ty, read_value!($iter, i32)]
            }
        }
    };

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

// ===

fn main() {
    input! {
        h: i32, a: i32
    };
    println!("{}", (h+a-1)/a);
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

/*
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
*/

int gcd(int a, int b)
{
    rep1r(i, a) {
        if (a % i == 0 && b % i == 0) return i;
    }
    return 1;
}

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


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

ll solve() {
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    ll left = n;
    ll res = 0;
    rrep(i, n) {
        ll from = i - a[i];
        if (from < 0) return -1;
        if (from > left) return -1;
        if (from < left) {
            res += a[i];
            left = from;
        }
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << solve() << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define ERR 0.00000001
typedef long long ll;
double gaiseki(double x1, double y1, double x2, double y2)
{
	return x1*y2 - x2*y1;
}

double naiseki(double x1, double y1, double x2, double y2)
{
	return x1*x2 + y1*y2;
}

double vector_size(double x, double y)
{
	return pow(x*x + y*y, 0.5);
}

int main(void)
{
	double a, b, c, d, e, f, p0p1_x, p0p1_y, p0p2_x, p0p2_y,
	nai, gai, p0p1_size, p0p2_size, judge;
	cin >> a >> b >> c >> d;
  p0p1_x = c - a;
  p0p1_y = d - b;
  	p0p1_size = vector_size(p0p1_x, p0p1_y);
	int q;
	cin >> q;
	rep(i, q)
	{
		cin >> e >> f;
    p0p2_x = e - a;
    p0p2_y = f - b;
		gai = gaiseki(p0p1_x, p0p1_y, p0p2_x, p0p2_y);
		if(gai<0) cout << "CLOCKWISE";
		else if(gai>0) cout << "COUNTER_CLOCKWISE";
		else
		{
			nai = naiseki(p0p1_x, p0p1_y, p0p2_x, p0p2_y);
			p0p2_size = vector_size(p0p2_x, p0p2_y);
			judge = nai/(p0p1_size*p0p2_size);
			if(judge<0) cout << "ONLINE_BACK";
			else
			{
				if(p0p1_size<p0p2_size) cout << "ONLINE_FRONT";
				else cout << "ON_SEGMENT";
			}
		}
		cout << endl;
		//cout << gai <<" "<< nai<< " "<< p0p1_size <<" "<< p0p2_size << " " <<judge<< endl;
	}
	return 0;
}



Measured memory_bytes: 3380
friends=input()
friends=friends.split()
friends_all=friends[0]
friends_cakes=friends[1]
person=int(friends_all)+1
cakes=input()
cakes_amount=0
for a in cakes.split():
        cakes_amount+=int(a)
one_person=cakes_amount//person

if cakes_amount%person!=0:
        one_person+=1
else:
        pass
print(one_person)


Measured memory_bytes: 5592
class BinaryTree
	attr_accessor :parent, :left, :right
	def format(id)
		puts "node #{id}: parent = #{self.parent}, sibling = #{self.get_sibling(id)}, degree = #{self.get_degree}, depth = #{self.get_depth}, height = #{self.get_height(id)}, #{self.get_type}"
	end
	
	def initialize(parent = -1, left = -1, right = -1)
		@parent = parent
		@left = left
		@right = right
	end
	
	def get_sibling(id)
		parent_node = $nodes[self.parent]
		result = parent_node.left == id ? parent_node.right : parent_node.left
		return result
	end
	
	def get_degree
		cnt = 0
		cnt += 1 if self.left != -1
		cnt += 1 if self.right != -1
		return cnt
	end
	
	def get_type
		if self.parent == -1
			return "root"
		else
			if self.left == -1 && self.right == -1
				return "leaf"
			else
				return "internal node"
			end
		end
	end
	

	def get_height(id,h=0)
		return h if $nodes[id].left == -1 && $nodes[id].right == -1
		h1 = $nodes[id].left != -1 ? get_height($nodes[id].left, h+1) : 0
		h2 = $nodes[id].right != -1 ? get_height($nodes[id].right, h+1) : 0
		return [h1, h2].max
	end
	
	def get_depth
		depth = 0
		i = self.parent
		while true
			return depth if i == -1
			i = $nodes[i].parent
			depth += 1
		end
	end
end


n = gets.chomp.to_i
$nodes = []
n.times do |i|
	$nodes[i] = BinaryTree.new
end

n.times do
	id, left, right = gets.chomp.split(" ").map{|i|i.to_i}
	if left != -1
		$nodes[id].left = left
		$nodes[left].parent = id
	end
	if right != -1
		$nodes[id].right = right if right != -1
		$nodes[right].parent = id
	end
end

$nodes.each_with_index do |node,ix|
	node.format(ix)
end


Measured memory_bytes: 6884
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, M, a, ways[100001] = {};
bool broken[100001] = {};

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a;
		broken[a] = true;
	}
	ways[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (broken[i])continue;
		ways[i] += ways[i - 1];
		ways[i] %= 1000000007;
		if (i > 1) {
			ways[i] += ways[i - 2];
			ways[i] %= 1000000007;
		}
	}
	cout << ways[N] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

struct node
{
    int x,y;
}p[90005];

int h,w,d,num;
int dp[90005];
int main()
{
    cin >> h >> w >> d;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin >> num;
            p[num].x = i;
            p[num].y = j;
        }
    }
    for(int i=1+d;i<=h*w;i++)
    {
        dp[i] = dp[i-d]+abs(p[i].x-p[i-d].x)+abs(p[i].y-p[i-d].y);
    }
    int q;	q = read();
    for(int i=0;i<q;i++)
    {
        int l,r;	l = read();	r = read();
        printf("%d",abs(dp[l]-dp[r]));
        if(i != q-1)    printf("\n");
    }
	return 0;
}


Measured memory_bytes: 2176
#CADDi2018 C
'''
問題
N個の自然数の積がPであるとき,それらの最大公約数としてありうるものの最大値を求めよ
ただしNとPはともに1以上10**12以下

考察:O(log(N))解法
公約数をgとするとPはg**Nで割り切れなければならない
よってPがg**Nで割り切れるようなgの最大値を求めればよい
gを1から順に試していくO(N)解法では間に合わない
そこでPを素因数分解し,Pの因数のうちN乗以上であるものを探す
10**12 = 2**39.8... なのでPの因数はたかだか39乗である
10**12 = 3**25.1...
10**12 = 4**19.9...
10**12 = 5**17.1...
10**12 = 6**15.4...
10**12 = 7**14.1...
10**12 = 8**13.2...
10**12 = 9**12.5...
N=1のときはg=P
N=2のときはg<=10**6
N=3のときはg<=10**4
N=4のときはg<=1000
N=5のときはg<=251
N=6のときはg<=100
N=7のときはg<=51
N=8のときはg<=31
N=9のときはg<=21
N=10のときはg<=15
N=11のときはg<=12
N>=12のときはg=1,2,3,4,5,6,7,8,9,10のいずれか
N>=13のときはg=1,2,3,4,5,6,7,8のいずれか
N>=14のときはg=1,2,3,4,5,6,7のいずれか
N>=15のときはg=1,2,3,4,5,6のいずれか
N>=16のときはg=1,2,3,4,5のいずれか
N>=18のときはg=1,2,3,4のいずれか
N>=20のときはg=1,2,3のいずれか
N>=26のときはg=1,2のいずれか
N>=40のときはg=1
'''
N,P=map(int,input().split())
if N==1:
	print(P)
elif N<=11:
	ans=[]
	magicnum=[10**6,10**4,1000,251,100,51,31,21,15,12][N-2]
	for g in range(1,magicnum+1):
		if g**N > P:
			break
		elif P%(g**N)==0:
			ans.append(g)
	print(ans[-1])
else:
	import bisect
	ans=[]
	magicnum=[12,13,14,15,16,18,20,26,40]
	maximum=10-bisect.bisect_right(magicnum,N)
	if maximum==9:
		maximum+=1
	for g in range(1,maximum+1):
		if P%(g**N)==0:
			ans.append(g)
	print(ans[-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000*5000+10;
long long f[maxn];
int n,g1,g2,s1,s2,b1,b2;
void add(int w,int c)
{
	if(c<=0) return;
	for(int i=0;i<=5000*5000-w;i++)
	{
		f[i+w]=max(f[i+w],f[i]+c);
	}
}
int main()
{
	cin>>n>>g1>>s1>>b1>>g2>>s2>>b2;
	memset(f,0,sizeof(f));
	add(g1,g2-g1);
	add(s1,s2-s1);
	add(b1,b2-b1);
	n=n+f[n];
	memset(f,0,sizeof(f));
	add(g2,g1-g2);
	add(s2,s1-s2);
	add(b2,b1-b2);
	cout<<n+f[n]<<endl;
	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int flag = 0;
    for (int i = 1;i < 4;i++){
        if (S[i] == S[i - 1]) flag = 1;
    }
    if (flag == 0) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b == c)
    cout << "Yes" << endl;
  else if(a+c == b)
    cout << "Yes" << endl;
  else if(c+b == a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func sumOfDigits(n int) (sum int) {
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	N := scanInt()
	A := scanInt()
	B := scanInt()

	total := 0
	for i := 1; i <= N; i++ {
		sum := sumOfDigits(i)
		if sum >= A && sum <= B {
			total += i
		}
	}
	fmt.Println(total)

}


Measured memory_bytes: 1772
import sys
from collections import deque
readline = sys.stdin.readline
n = int(readline())
li = list(map(int, readline().split()))
def square(P):
    G = []
    L = deque()
    for i, v in enumerate(P):
        if not L:
            L.append((i, v))
            continue
        if v > L[-1][1]:
            L.append((i, v))
        elif v < L[-1][1]:
            k = i - 1
            while L and v < L[-1][1]:
                a = L.pop()
                G.append((k - a[0] + 1) * a[1])
            L.append((a[0], v))
    while L:
        a = L.pop()
        G.append((n - a[0]) * a[1])
    return max(G)
print(square(li))

Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;

inline LL max3(LL a, LL b, LL c) {
    return max(a, max(b, c));
}

inline LL min3(LL a, LL b, LL c) {
    return min(a, min(b, c));
}

LL H, W, res;

void solve1() {
    
    for(int i = 1; i < H; i++) {
        LL  part1 = W * i,
            part2 = (H - i) * floor(W / 2.0),
            part3 = (H - i) * ceil(W / 2.0);
        res = min(res, max3(part1, part2, part3) - min3(part1, part2, part3));

        part2 = W * ceil((H - i) / 2.0);
        part3 = W * floor((H - i) / 2.0);
        res = min(res, max3(part1, part2, part3) - min3(part1, part2, part3));
    }
}


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

    cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    
    res = H * W;

    solve1();
    
    swap(H, W);

    solve1();

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


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2003,INF=10000;

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

int main(){
    
    int T;cin>>T;
    for(int i=0;i<T;i++){
        ll A,B,C,D;cin>>A>>B>>C>>D;
        bool flag=true;
        if(A<B) flag=false;
        else if(A%B>C) flag=false;
        else if(B>D) flag=false;
        else if(B<C) flag=true;
        else{
            if(D%B==0){
                flag=true;
            }else{
                ll E=gcd(B,D);
                ll X=A%B;
                ll M=(B-X-1)/E;
                
                if(X+M*E>C) flag=false;
                else flag=true;
            }
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k,l,r,cnt,a[110];
    while(cin >> n,n!=0){
        for(int i=0;i<n;i++) cin >> a[i];
        cin >> k;
        l = 0;
        r = n-1;
        cnt = 0;
        while(l <= r){
            cnt++;
            int mid = (l+r)/2;
            if(k == a[mid]) break;
            if(k < a[mid]) r = mid-1;
            if(a[mid] < k) l = mid+1;
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 2996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5+10;
long long l=1,r=2000000000;
int n,k,a[MAXN];
int check(long long x){
    long long num=0;
    for(int i=1;i<=n;i++){
        if(a[i]%x==0) num+=a[i]/x-1;
        else num+=a[i]/x;
    }
    if(num<=k) return true;
    else return false;
}
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    while(r-l>1){
        long long mid=(l+r)>>1;
        if(check(mid)==1) r=mid;
        else l=mid;
    }
    if(check(l)) cout<<l;
    else cout<<r;
}


Measured memory_bytes: 4316
#include<stdio.h>

int main(){
        int i;
        int j;
        int seki;
        for(i=1;i<10;i++){
                for(j=1 ;j<10;j++){
                seki = i*j;
                printf("%dx%d=%d\n",i,j,seki);
                }
        }
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cmath>
#include<iomanip>

int main(void) {
	double x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;

	auto calc_dist = [&]() {
		return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	};
	std::cout << std::fixed << std::setprecision(15) << calc_dist() << '\n';
	return 0;
}



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

typedef long long ll;
const ll MAXN = 3e6 + 5;
const long long MOD = 1e9 + 9;
const long double eps = 1e-6;

#define mp make_pair
#define pb push_back
#define all(temp) temp.begin(), temp.end()
#define REP(i,n) for(int i = 0; i < n; ++i)

int main()
{
	//freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

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

	int n,x; cin >> n >> x;
	vector<int> m(n);
	int mn = 2000;
	for(int i = 0; i < n; ++i){
		cin >> m[i];
		x -= m[i];
		mn = min(mn, m[i]);
	}
	int ans = n + x / mn;
	cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc060/tasks/abc060_b

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

    for (int i = 1; i <= A*B; i++) if (A*i%B==C){
            cout << "YES" << "\n";
            return 0;
    }

    cout << "NO" << "\n";
    return 0;
}


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

#define ll long long

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

	ll sum =0 ;

	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			for(ll k=1;k<=n;k++)
			{
				ll g= __gcd(i,j);
				g = __gcd(g,k);

				sum+=g;
			}
		}
	}

	cout << sum << endl;

	return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll f(ll b, ll n){
	if(n < b){
		return n;
	}else{
		return f(b, n/b) + (n % b);
	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll n, s;
	cin >> n >> s;

	if(s > n){
		puts("-1");
		return 0;
	}else if(s == n){
		cout << n + 1 <<  endl;
		return 0;
	}
	
	for(ll i=2; i*i<=n; i++){
		if(f(i, n) == s){
			cout << i << endl;
			return 0;
		}
	}

	ll mi = INF;
	for(ll i=1; i*i<n && i <= s; i++){
		ll b;
		if((n-s) % i == 0){
			b = (n-s)/i + 1;
			if(f(b, n) == s){
				mi = min(mi, b);
			}
		}
	}
	if(mi != INF){
		cout << mi << endl;
		return 0;
	}

	puts("-1");

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

	string S;
	cin >> S;
	ll N = S.size();

	vector<ll> res(N, 0);
	vector<ll> saisyo(N, 0);

	ll tmp;
	REP(i, N){
		if(S[i] == 'R') tmp = i;
		if(S[i] == 'L') saisyo[i] = tmp;
	} 
	REP(i, N){
		ll j = N-1-i;
		if(S[j] == 'L') tmp = j;
		if(S[j] == 'R') saisyo[j] = tmp;
	} 

	REP(i, N){
		if(S[i] == 'R'){
			ll dif = saisyo[i] - i;
			if(dif%2 == 0) res[saisyo[i]]++;
			else res[saisyo[i]-1]++;
		}
		if(S[i] == 'L'){
			ll dif = i - saisyo[i];
			if(dif%2 == 0) res[saisyo[i]]++;
			else res[saisyo[i]+1]++;
		}
	}
	REP(i, N) cout << res[i] << " ";
	cout << endl;
    return 0;
}

Measured memory_bytes: 2256
n=int(input())
p=input().split()
for i in range(n):
    p[i]=int(p[i])

a=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        a+=1
    elif p[i]>p[i+1] and p[i+1]>p[i+2]:
        a+=1
    else:
        continue

print(a)


Measured memory_bytes: 3060
/*
ID: aspatel1
TASK: gift1
LANG: C++
*/
#include <bits/stdc++.h>


#define ff first
#define ss second

using namespace std;

typedef pair<int,int> pii;
int main (){
  
    int n;cin >> n;
    vector<pair<string,pii>> input(n);
    for(int i=0;i<n;i++){
        cin >> input[i].ff;
        cin >> input[i].ss.ff;
        input[i].ss.ss = i;
    }
    sort(input.begin(),input.end(),[](const auto &x,const auto &y){

            if(x.ff == y.ff) return x.ss.ff > y.ss.ff;
            return x.ff < y.ff;
    });

    vector<int> ans(n);
    for(int i=0;i<n;i++){

        ans[i] = input[i].ss.ss;
    }
    for(int x:ans) cout << x+1 << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

bool solve1()
{
    int n, max = 0;
    cin >> n;

    map<string, int> s;

    rep(i, 0, n, 1)
    {
        string name;
        cin >> name;
        s[name]++;
        max = std::max(max, s[name]);
    }

    //cout << "----------------" << endl;

    for (auto &m : s)
    {
        if (m.second == max)
        {
            cout << m.first << endl;
        }
    }

    return true;
}

int main(void)
{
    solve1();
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << double(w * h) / 2 << endl;
    if (x * 2 == w && y * 2 == h)
    {
        cout << "1" << endl;
    }
    else
    {
        cout << "0" << endl;
    }
}

Measured memory_bytes: 256
from collections import deque
import sys

N, u, v = map(int, input().split())
u -= 1; v -= 1
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    A, B = map(lambda x: int(x) - 1, s.split())
    edge[A].append(B)
    edge[B].append(A)

INF = float('inf')

# Aoki
pathV = [INF] * N
pathV[v] = 0
q = deque()
q.append((v, 0))
while q:
    p, d = q.popleft()
    nd = d + 1
    for np in edge[p]:
        if pathV[np] > nd:
            pathV[np] = nd
            q.append((np, nd))

# Takahashi
ans = 0
pathU = [INF] * N
pathU[u] = 0
q = deque()
q.append((u, 0))
while q:
    p, d = q.popleft()
    nd = d + 1
    if len(edge[p]) == 1:
        ans = max(ans, pathV[p] - 1)
    for np in edge[p]:
        if pathU[np] > nd and pathV[np] > nd:
            pathU[np] = nd
            q.append((np, nd))

print(ans)


Measured memory_bytes: 78528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

ll grid[3050][3050];
ll dp[3050][3050][4];

int main()
{
    int r, c, k;
    cin >> r >> c >> k;
    memset(grid, 0, sizeof(grid));
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < k; i++)
    {
        int rr, cc;
        ll v;
        cin >> rr >> cc >> v;
        --rr;
        --cc;
        grid[rr][cc] = v;
    }
    dp[0][0][1] = grid[0][0];
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (i == 0 && j == 0) // 最初のマスはスキップ
            {
                continue;
            }

            if (i == 0) // 最下段の処理
            {
                dp[i][j][0] = dp[i][j - 1][0];
                dp[i][j][1] = max(dp[i][j - 1][0] + grid[i][j], dp[i][j - 1][1]);
                dp[i][j][2] = max(dp[i][j - 1][1] + grid[i][j], dp[i][j - 1][2]);
                dp[i][j][3] = max(dp[i][j - 1][2] + grid[i][j], dp[i][j - 1][3]);
            }
            else // ２段目以降の処理
            {
                ll from_top = max(max(dp[i - 1][j][0], dp[i - 1][j][1]), max(dp[i - 1][j][2], dp[i - 1][j][3]));
                if (j == 0)
                {
                    dp[i][j][0] = from_top;
                    dp[i][j][1] = from_top + grid[i][j];
                }
                else
                {
                    dp[i][j][0] = max(dp[i][j - 1][0], from_top);
                    dp[i][j][1] = max(from_top + grid[i][j], max(dp[i][j - 1][0] + grid[i][j], dp[i][j - 1][1]));
                    dp[i][j][2] = max(dp[i][j - 1][1] + grid[i][j], dp[i][j - 1][2]);
                    dp[i][j][3] = max(dp[i][j - 1][2] + grid[i][j], dp[i][j - 1][3]);
                }
            }
        }
    }
    // for (int i = 0; i < r; i++)
    // {
    //     for (int j = 0; j < c; j++)
    //     {
    //         cout << grid[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    // for (int k = 0; k < 4; k++)
    // {
    //     cout << "===========" << endl;
    //     for (int i = 0; i < r; i++)
    //     {
    //         for (int j = 0; j < c; j++)
    //         {
    //             cout << dp[i][j][0] << ' ';
    //         }
    //         cout << endl;
    //     }
    // }
    ll ans = 0;
    for (int l = 0; l < 4; l++)
    {
        ans = max(ans, dp[r - 1][c - 1][l]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 366984
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char letter;
    cin >> letter;
    if (int(letter) >= 65 && int(letter) <= 90)
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    
    
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

	long long int n,k,bot=0, mid, top,aux,au,z=0;
	
	cin >> n >> k;
	vector<long long int>a(n);
	vector<long long int>c(n);

	for(int i=0;i<n;i++) cin >> a[i];	
	for(int i=0;i<n;i++) cin >> c[i];	

	sort(a.begin(),a.end());
	sort(c.begin(),c.end());

	top = a[n-1]*c[n-1];

	while(top>bot){
		mid = (bot + top)/2;
		
		aux=0;

		for(int i=0;i<n;i++){
			au = min(mid/c[i], a[n-i-1]);
			aux+= a[n-1-i]-au;
			if(aux>k) break;
		}

		if(aux>k) bot=mid+1;
		else top=mid;

	
	}

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

Measured memory_bytes: 3456
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
ll n, m, k, a[N], b[N],res;
int solve()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        ll x;
        in1(x);
        a[i]=a[i-1]+x;
    }
    for(int i=1;i<=m;i++)
    {
        ll x;
        in1(x);
        b[i]=b[i-1]+x;
    }
    for(int i=0;i<=n;i++)
    {
        ll p = k-a[i];
        if(p>=0)
        {
            ll high = m, low=0, mid, ans=0;
            while(high>=low)
            {
                mid=(high+low)/2;
                if(b[mid]<=p)
                {
                    low=mid+1;
                    ans=mid;
                }
                else high=mid-1;
            }
            res=max(i+ans, res);
        }
    }
    cout<<res<<endl;

    return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int ret = solve();
    return 0;
}
/*

*/


Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
int main(){
 ll n ,cont=0;
 cin >> n ;
 int a[n]  ;
 for(int i=0 ; i<n ; i++)
 {
     cin >> a[i] ;
 }
 for(int i=1 ; i<n-1 ; i++)
 {
   if(a[i]<a[i-1]&&a[i]>a[i+1]||a[i]>a[i-1]&&a[i]<a[i+1]) {cont++ ;}
 }
cout << cont <<endl;
 return 0  ;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/agc023/tasks/agc023_a
# 累積和とってからcounterすれば終わりでは？


N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate
from collections import Counter

A_acc_cnt = Counter(accumulate(A))
ans = 0
for a, c in A_acc_cnt.items():
    if a == 0:
        c += 1
    if c == 1:
        continue
    ans += c * (c - 1) // 2

print(ans)


Measured memory_bytes: 39060
s=input()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
print('AMBIGUOUS' if 1<=a<=12 and 1<=b<=12 else 'YYMM' if (a==0 or a>12) and 1<=b<=12 else 'MMYY' if 1<=a<=12 and (b==0 or b>12) else 'NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数
 //double 少数（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  int n,c,d=0;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  c=a[0];
  for(int i=0;i<n;i++)
    c+=b[i];
  d=c;
  for(int i=1;i<n;i++){
    c=c+a[i]-b[i-1];
    d=max(d,c);
  }
  cout<<d;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,c;
  cin>>n>>c;
  vecll a(n), b(n);
  for(auto&&e:a)cin>>e;
  for(auto&&e:b)cin>>e;
  vector<vecll> powm(401, vecll(401, 0));
  FOR(x,1,401) {
    ll p = 1;
    REP(i,401) {
      powm[i][x] = p;
      p *= x;
      p %= MOD;
    }
  }
  vector<vecll> pspm(401, vecll(402, 0));
  REP(i,401) {
    partial_sum(ALL(powm[i]), begin(pspm[i])+1);
    REP(x,402) pspm[i][x] %= MOD;
  }
  vector<vecll> dp(n+1, vecll(c+1, 0));
  dp[0][0] = 1;
  REP(i,n) {
    REP(j,c+1) {
      REP(k,j+1) {
        int rem = j - k;
        dp[i+1][j] += dp[i][rem] * (pspm[k][b[i]+1] + MOD - pspm[k][a[i]]) % MOD;
        dp[i+1][j] %= MOD;
      }
    }
  }
  cout<<dp[n][c]<<endl;
  return 0;
}


Measured memory_bytes: 4096
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

// x coordinate mod 2 = 0
int dx1[] = {0, 1, 1, 0, -1, -1};
int dy1[] = {1, 0, -1, -1, -1, 0};

// mod 2 = 1
int dx2[] = {0, 1, 1, 0, -1, -1};
int dy2[] = {1, 1, 0, -1, 0, 1};

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// ??§?¨? (x, y), ?????? z (mod 6) ????????????????°????
int rec[210][210][6];
int sx, sy, gx, gy;
int N, X[1010], Y[1010];
bool exist[210][210];
int lx, ly;

struct Elem {
    int x, y, t;
};

signed main() {
    rep(i,0,210) rep(j,0,210) rep(k,0,6) rec[i][j][k] = INF;
    cin >> sx >> sy >> gx >> gy;
    cin >> N;
    rep(i,0,N) cin >> X[i] >> Y[i];
    cin >> lx >> ly;

    sx += lx, sy += ly, gx += lx, gy += ly;
    rep(i,0,N) {
        exist[ X[i]+lx ][ Y[i]+ly ] = true;
    }

    rec[sx][sy][0] = 0;
    queue<Elem> q;
    q.push(Elem{sx, sy, 0});
    while(!q.empty()) {
        Elem cur = q.front(); q.pop();

        // move
        int ax = abs(cur.x - lx), ay = abs(cur.y - ly);
        int dir = (ax * ay * (cur.t)) % 6;
        rep(i,0,6) {
            int nx, ny;
            if(ax % 2) nx = cur.x + dx2[i], ny = cur.y + dy2[i];
            else       nx = cur.x + dx1[i], ny = cur.y + dy1[i];
            if(nx < 0 || nx > 2*lx || ny < 0 || ny > 2*ly) continue;
            if(exist[nx][ny]) continue;
            if(rec[nx][ny][(cur.t+1)%6] > rec[cur.x][cur.y][cur.t] + (dir != i)) {
                rec[nx][ny][(cur.t+1)%6] = rec[cur.x][cur.y][cur.t] + (dir != i);
                /*
                if(nx-lx >= 0 && ny-ly >= 0)
                    printf("(%lld, %lld) -> (%lld, %lld), time = %lld, cost = %lld\n",
                    cur.x-lx, cur.y-ly, nx-lx, ny-ly, cur.t+1, rec[nx][ny][(cur.t+1)%6]);
                */
                q.push(Elem{nx, ny, (cur.t+1)%6});
            }
        }

        // stay
        if(rec[cur.x][cur.y][(cur.t+1)%6] > rec[cur.x][cur.y][cur.t] + 1) {
            rec[cur.x][cur.y][(cur.t+1)%6] = rec[cur.x][cur.y][cur.t] + 1;
            q.push(Elem{cur.x, cur.y, (cur.t+1)%6});
        }
    }

    int ans = INF;
    rep(i,0,6) chmin(ans, rec[gx][gy][i]);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int d, e, f;
  d = a*10 + b +c;
  e = b*10 + a +c;
  f = c*10 + a +b;
  
  int answer;
  answer = max({d, e, f});
  
  cout << answer << endl;
  
}

Measured memory_bytes: 384
X = []
Y = []
while True:
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    else:
        if x < y:
            X.append(x)
            Y.append(y)
        else:
            X.append(y)
            Y.append(x)
for i in range(len(X)):
    print(X[i], Y[i])


Measured memory_bytes: 6124
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

//#include<bits/stdc++.h>

// #include "beginner_138/beginner_138.h"
// Still dunno how to put linker 

using namespace std; 



void b_sol01(){
    int n ;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n-1);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0; i < n; i++)cin >> B[i];
    for(int i = 0; i < n-1; i++)cin >> C[i];

    int ans = 0;
    int prev = n;
    // Misunderstanding! i and i+1 means the dishes whose orders are adjacent to each other.
    for(int i = 0; i < n; i++){
        if(prev == A[i]-1)ans += C[prev];
        ans += B[A[i]]; // Actually B[i] is also fine
        prev = A[i];
        // if(A[i-1] < C.size()){
        //     ans += C[A[i-1]];
        // }
        // else cout << "c is at last element.";
    }

    cout << ans;
}

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

    b_sol01();
    
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S;
	int cnt[26] = {};
	
	while (cin >> S) {
		for (int i = 0; i < S.size(); i++) {
			if (!isalpha(S[i])) continue;
			if (isupper(S[i])) S[i] = tolower(S[i]);
			cnt[S[i] - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		cout << char(i + 'a') << " : " << cnt[i] << endl;
	}

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int num = stoi(a + b);
  for (int i = 0; i <= 10000; ++i) {
    if (i * i == num) {
      printf("Yes\n");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (a > b)
		cout << "a > b" << endl;
	else if (a == b)
		cout << "a == b" << endl;
	else
		cout << "a < b" << endl;
	
	return 0;
}



Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

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

	    String S= gs();
	    
	    int ckz= 0;
	    int cgz=0;
        for (int i=0; i<S.length(); i++) {
        	char c=S.charAt(i);
        	if (c=='0' && i%2==0) {
                ckz++;
        	} else if (c=='1' && i%2==1) {
        		ckz++;
        	}
        	
        	if (c=='0' && i%2==1) {
                cgz++;
        	} else if (c=='1' && i%2==0) {
        		cgz++;
        	}
        }


        System.out.print(Math.min(cgz, ckz));
	}

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

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

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

Measured memory_bytes: 39204
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
	int a,b;
	cin>>a>>b;
	cout<<a/b+(bool)(a%b)<<endl;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
     
    int main()
    {
    	std::string str;
    	std::getline(std::cin, str);
    	
    	long long int n = str.length();
    	
    	long long int ans = (n * (n - 1)) / 2 + 1, counter[27] = { 0 };
    	
    	for (int i = 0; i < n; ++i)
    		++counter[str[i] - 'a'];
    	
    	for (int i = 0; i < 26; ++i)
    	{
    		ans -= (counter[i] * (counter[i] - 1)) / 2;
    	}
    	
    	std::cout << ans;
    }

Measured memory_bytes: 640