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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int n;
vec<int> cand;
int dp[111111];

int rec(int sum) {
	if (sum >= n) {
		if (sum == n) {
			return 0;
		}
		return 1e18;
	}

	if (dp[sum] != 1e18) {
		return dp[sum];
	}

	int ret = 1e18;
	for (int six = 1; six <= n; six*=6) {
		chmin(ret, rec(sum + six) + 1);
	}
	for (int six = 1; six <= n; six*=9) {
		chmin(ret, rec(sum + six) + 1);
	}

	return dp[sum] = ret;
}

signed main() {
	cin >> n;

	rep (i, 111111) {
		dp[i] = 1e18;
	}

	int ans = rec(0);

	// print1(dp, dp+n);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        v: [i64; n]
    }

    let v = v.into_iter().collect::<VecDeque<_>>();
    let mut ans = 0;

    for a in 0..=k {
        for b in 0..=min(n - a, k - a) {
            let mut c = v.clone();
            let mut h = BinaryHeap::new();
            for _ in 0..a {
                if c.is_empty() {
                    break;
                }
                h.push(Reverse(c.pop_front().unwrap()));
            }
            for _ in 0..b {
                if c.is_empty() {
                    break;
                }
                h.push(Reverse(c.pop_back().unwrap()));
            }

            for _ in 0..(k - a - b) {
                if h.peek().unwrap_or(&Reverse(0)).0 >= 0 {
                    break;
                }
                h.pop();
            }

            ans = max(ans, h.iter().map(|x| x.0).sum::<i64>());
            // dbg!(a, b);
            // dbg!(h.iter().map(|x| x.0).sum::<i64>());
            // println!();
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2120
#include<stdio.h>
#include<math.h>

int main(void)
{
  int n,i,ans;
  int odd,even;
  int count_odd[100001]={0};
  int count_even[100001]={0};
  int  max_odd=0,  max_odd_num=1;
  int max_even=0, max_even_num=1;
  int  scnd_odd=0,  scnd_odd_num=1;
  int scnd_even=0, scnd_even_num=1;

  scanf("%d",&n);
  for(i=0;i<n/2;i++){
    scanf("%d %d",&odd,&even);
    count_odd[odd]++;
    count_even[even]++;

    if(max_odd<count_odd[odd]){
      max_odd = count_odd[odd];
      max_odd_num = odd;
      if(odd != max_odd_num){
        scnd_odd = max_odd;
        scnd_odd_num = max_odd_num;
      }
    }else if(scnd_odd<count_odd[odd]){
      scnd_odd = count_odd[odd];
      scnd_odd_num = odd;
    }

    if(max_even<count_even[even]){
      max_even = count_even[even];
      max_even_num = even;
      if(even != max_even_num){
        scnd_even = max_even;
        scnd_even_num = max_even_num;
      }
    }else if(scnd_even<count_even[even]){
      scnd_even = count_even[even];
      scnd_even_num = even;
    }
  }

  if(max_odd_num != max_even_num){
    ans = n - max_odd - max_even;
  }else{
    if(max_odd+scnd_even < max_even+scnd_odd){
      ans = n - max_even - scnd_odd;
    }else{
      ans = n - max_odd - scnd_even;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){


int N;
cin>>N;
int K;
cin>>K;


vector<long long >plus;
vector<long long >minus;
rep(i,N)
{
    long long x;
    cin>>x;
    if(x<0){
    minus.push_back(-x);
    }
    else{
    plus.push_back(x);
    }
}

int p=plus.size();
int m=minus.size();
if(m>0)sort(minus.begin(),minus.end());

long long ans=INF;
if(m>0 && p>0){
    for(int i=1;i<min(K,m+1);i++){
        if(K-i<=p)ans=min(minus[i-1]*2+plus[(K-i)-1],ans);
    }
    for(int i=1;i<min(K,p+1);i++){
        if(K-i<=m)
    ans=min(plus[i-1]*2+minus[(K-i)-1],ans);
    }
}

if(K<=plus.size()){
ans=min(ans,plus[K-1]);
}

if(K<=minus.size()){
ans=min(ans,minus[K-1]);
}

cout<<ans<<endl;

 return 0;
}
/*

5 3
-30 -10 10 20 50

40

3 2
10 20 30

20

1 1
0

0

8 5
-9 -7 -4 -3 1 2 3 4

10
*/


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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N;
    cin >> N;

    vi A(N);
    cin >> A;

    int cnt = 0;
    int mini = INT_MAX;

    ll ans = 0;
    REP(i, N) {
        if(A[i] < 0)
            cnt++;
        mini = min(mini, abs(A[i]));

        ans += abs(A[i]);
    }

    // cout << cnt << " " << (cnt % 2) << " " << mini << " " << ans << endl;
    if(cnt % 2 > 0)
        ans -= mini * 2;

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


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int A = K;
    int R = 1;

    
    while((N - A) >= 0){
      A =  A * K;
      R++;
    }   

    System.out.println(R);
  }
}



Measured memory_bytes: 22100
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

def factorial(n)
  arr = [*1..n]
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

n = gets_i
puts factorial(n) % (10**9 + 7)

Measured memory_bytes: 21980
#include <cstdio>

int main(void) {
    char s[101];
    scanf("%s", s);
    for(int i=0 ; s[i]!=0 ; i++) {
        if(s[i]=='C') {
            for(int j=i+1 ; s[j]!=0 ; j++) {
                if(s[j]=='F') {
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()

N = int(input())

rows = []
cols = []
weights = []

for _ in range(N-1):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, a)
    g.add_edge(v-1, u-1, a)

Q, K = [int(i) for i in input().split()]
d = Dijkstra(g, K-1)

#print(g)
#print(d.dist)
for i in range(Q):
    x, y = [int(i) for i in input().split()]
    print(d.dist[x-1]+d.dist[y-1])

Measured memory_bytes: 73756
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int MXN = 1000010;

int N, A[202020];
int cnt[MXN];
int prima[MXN];
i64 invs[MXN];

i64 modpow(i64 a, int p)
{
	if (p == 0) return 1;
	i64 ret = modpow(a, p / 2);
	ret = ret * ret % MOD;
	if (p % 2 == 1) ret = ret * a % MOD;
	return ret;
}

vector<int> factor(int p)
{
	vector<int> ret;
	while (p != 1 && prima[p] != -1) {
		int q = prima[p];
		while (p % q == 0) p /= q;
		ret.push_back(q);
	}
	if (p != 1) ret.push_back(p);
	return ret;
}
vector<int> divs[MXN];

i64 kk[MXN];
int ps[MXN];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);
	for (int i = 0; i < N; ++i) ++cnt[A[i]];
	for (int i = 1; i < MXN; ++i) invs[i] = modpow(i, MOD - 2);

	fill(prima, prima + MXN, -1);
	for (int i = 2; i < MXN; ++i) {
		if (prima[i] == -1) {
			if (i > 2000) continue;
			for (int j = i * i; j < MXN; j += i) {
				if (prima[j] == -1) prima[j] = i;
			}
		}
	}
	i64 ret = 0;

	for (int i = 1; i < MXN; ++i) {
		if (i > 2000) continue;
		for (int j = i * i + i; j < MXN; j += i) divs[j].push_back(i);
	}
	for (int i = 1; i <= 1000; ++i) ps[i * i] = i;

	for (int p = 1; p < MXN; ++p) {
		i64 gg = 0;
		for (int i = p; i < MXN; i += p) gg += cnt[i] * (i64)i;
		gg %= MOD;

		i64 fakt = invs[p];
		for (int q : divs[p]) {
			fakt += MOD - kk[q];
			fakt += MOD - kk[p / q];
		}
		if (ps[p] != 0) fakt += MOD - kk[ps[p]];
		fakt %= MOD;
		ADD(ret, gg * gg % MOD * fakt % MOD);

		kk[p] = fakt;
	}
	for (int i = 0; i < N; ++i) ADD(ret, MOD - A[i]);
	ret = ret * invs[2] % MOD;

	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 112384
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

struct UnionFind {
private:
	vector<int> uf;
	size_t sz;

public:
	UnionFind(size_t Size) {
		uf.assign(Size, -1);
		sz = Size;
	}

	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return sz; }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) { return; }
		--sz;

		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	UnionFind uf(N);
	vector<int> ans;
	for (int i = 0; i < Q; ++i) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t) { ans.emplace_back(uf.same(u, v)); }
		else { uf.unite(u, v); }
	}

	for (auto v : ans) { cout << v << "\n"; }

	return 0;
}


Measured memory_bytes: 4428
N = int(input())

ac = 0
wa = 0
tle = 0
re = 0

idx = 0

while idx < N:
    idx += 1
    AAA = input()
    if AAA == "AC":
        ac += 1
    elif AAA == "WA":
        wa += 1
    elif AAA == "TLE":
        tle += 1
    elif AAA == "RE":
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))


Measured memory_bytes: 9212
#include <iostream>

using namespace std;

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

int main(){
  int w, h, n, dx = 0, dy = 0;
  cin >> w >> h >> n;

  int x, y, a;
  rep(i, n) {
    cin >> x >> y >> a;
    if (a == 1) dx = max(dx, x);
    if (a == 2) w = min(w, x);
    if (a == 3) dy = max(dy, y);
    if (a == 4) h = min(h, y);
  }
  if (w <= dx || h <= dy) {
    cout << 0 << endl;
  } else {
    cout << abs(dx - w) * abs(dy - h) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> read_vec(int n){
    vector<int> ret(n);
    for (int i = 0; i < n; i++){
        cin >> ret[i];
    }
    return ret;
}

int main() {
    long long n, s, ans = 0, a, b, m;
    cin >> n >> m;
    vector<pair<long long, long long>> as;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        as.push_back({a, b});
    }
    sort (as.begin(), as.end());
    for (int i = 0; i < n; i++){
        m -= as[i].second;
        ans += (as[i].first) * (as[i].second);
        if (m < 0){
            s = i;
            break;
        }
    }
    cout << ans - ((0 - m) * as[s].first) << endl;
}

Measured memory_bytes: 2420
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))

    retval = float("inf")
    for i in range(0, N - (K - 1)):
        left = x[i]
        right = x[i + K - 1]
        time = max(abs(left), abs(right))
        if abs(left + right) != abs(left) + abs(right):
            time += min(abs(left), abs(right)) * 2
        retval = min(retval, time)
    print(retval)


if __name__ == "__main__":
    main()


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

int main() {
	int n, l;
	cin >> n >> l;
	int L = n + l - 1;
	
	if (l >= 0)cout << (n * (2 * l + n - 1) / 2 - l) << endl;
	else if (L <= 0)cout << (n * (2 * l + n - 1) / 2 - L) << endl;
	else cout << (n * (2 * l + n - 1) / 2) << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int cnt[26];
string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	FOR(i, s.size()) cnt[s[i]-'a']++;
	FOR(i, 26) {
		if (cnt[i] == 0) {
			cout << (char)('a'+i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;
 
int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    repeat(i, n) cin >> a[i];
    vector<pair<int, int>> ans;
    
    auto minit = min_element(a.begin(), a.end());
    int minval = *minit;
    int minpos = distance(a.begin(), minit);
    
    auto maxit = max_element(a.begin(), a.end());
    int maxval = *maxit;
    int maxpos = distance(a.begin(), maxit);
    
    if (minval >= 0) {
        repeat(i, n - 1) ans.emplace_back( make_pair(i + 1, i + 2) );
    }
    else if (maxval <= 0 ) {
        repeat(i, n - 1) ans.emplace_back( make_pair(n - i, n - i - 1) );
    }
    else if (minval < 0 && maxval + minval >= 0) {
        repeat(i, n) ans.emplace_back( make_pair(maxpos + 1, i + 1) );
        repeat(i, n - 1) ans.emplace_back( make_pair(i + 1, i + 2) );
    }
    else if (minval < 0 && maxval + minval < 0) {
        repeat(i, n) ans.emplace_back( make_pair(minpos + 1, i + 1) );
        repeat(i, n - 1) ans.emplace_back( make_pair(n - i, n - i - 1) );
    }
    cout << ans.size() << endl;
    repeat(i, ans.size()) {
        cout << ans[i].fst << " " << ans[i].snd << endl;
    }   
}

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

using namespace std;

typedef long long ll;

map <pair<string, string>, ll> M;

ll n, ans;
char str[44];

int main()
{
	ll i, j;
	
	scanf("%lld%s", &n, str);
	
	for(i=0;i<(1<<n);i++){
		string s1, s2;
		for(j=0;j<n;j++){
			if(i & (1<<j)) s1.push_back(str[j]);
			else s2.push_back(str[j]);
		}
		M[make_pair(s1, s2)] ++;
	}
	
	for(i=0;i<(1<<n);i++){
		string s1, s2;
		for(j=0;j<n;j++){
			if(i & (1<<j)) s1.push_back(str[n+n-1-j]);
			else s2.push_back(str[n+n-1-j]);
		}
		ans += M[make_pair(s1, s2)];
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 91904
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int g=(__gcd(i,j));
                g=(__gcd(g,k));
                ans+=g;
            }
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15524
#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
int main()
{
	
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

//FILE *fin = fopen("test.in", "r");
//FILE *fout = fopen("test.out", "w");

int main() {
    int rez = 0;
    for (int i = 1; i <= 6; i++) {
        char ch = fgetc(stdin);
        if (ch == '1')
            rez++;
    }
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  double t,a,x;
  cin>>t>>a;
  vector<pair<double ,int>> v;
  rep(i,0,n){
    cin>>x;
    x=t-x*0.006;
    x=abs(a-x);
    v.pb({x,i});
  }
  sort(all(v));
  cout<<v[0].s+1<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3828
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL n,m,a[1010],b[1010];
LL fac[1000010],inv[1000010];
void pre()
{
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(LL i=2;i<=1000000;i++) fac[i]=fac[i-1]*i%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    for(LL i=2;i<=1000000;i++) inv[i]=inv[i-1]*inv[i]%mod;
}
LL C(LL m,LL n)
{
	if(m<n) return 0;
	return fac[m]*inv[m-n]%mod*inv[n]%mod;
}
int main()
{
	pre();
	scanf("%lld %lld",&n,&m);
	for(LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(LL i=1;i<=m;i++) scanf("%lld",&b[i]);
	sort(a+1,a+n+1);sort(b+1,b+m+1);
	for(LL i=2;i<=n;i++) if(a[i]==a[i-1]) return puts("0"),0;
	for(LL i=2;i<=m;i++) if(b[i]==b[i-1]) return puts("0"),0;
	LL t1=1,t2=1;
	LL num=0,ans=1;
	while(t1<=n&&t2<=m)
	{
		if(a[t1]==b[t2])
		{
			LL k=(n-t1+1)+(m-t2+1)-1;
			//printf("k1:%lld\n",k);
			(ans*=C(a[t1]-num-1,k-1)*fac[k-1]%mod)%=mod;
			//printf("%lld %lld %lld\n",C(a[t1]-num-1,k-1),fac[k-1],a[t1]-num-1);
			num+=k;t1++;t2++;
		}
		else if((t1<n&&a[t1]<b[t2])||t2>m)
		{
			LL k=(m-t2+1);
			//printf("k2:%lld\n",k);
			(ans*=C(a[t1]-num-1,k-1)*fac[k]%mod)%=mod;
			num+=k;t1++;
		}
		else if((t2<m&&a[t1]>b[t2])||t1>n)
		{
			LL k=(n-t1+1);
			//printf("k3:%lld\n",k);
			(ans*=C(b[t2]-num-1,k-1)*fac[k]%mod)%=mod;
			num+=k;t2++;
		}
		//printf("ans:%lld %lld\n",ans,num);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 15872
while True:
    m, f, r = map(int, input().split())
    score = m + f

    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        ans = 'F'
    elif score >= 80:
        ans = 'A'
    elif 65 <= score < 80:
        ans = 'B'
    elif 50 <= score < 65:
        ans = 'C'
    elif 30 <= score < 50:
        if r >= 50:
            ans = 'C'
        else:
            ans = 'D'
    else:
        ans = 'F'
    print(ans)


Measured memory_bytes: 5592
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif (m == -1 or f == -1) or (m + f < 30):
        print('F')
    elif 80 <= m + f:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if 50 <= r:
            print('C')
        else:
            print('D')


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

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

    if(s.size() <= K) cout << s;
    else{
        for(int i=0; i<K; i++){
            cout<<s[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<P> A(N),B(N);
    rep(i,0,N){
        int a,b;
        cin >> a >> b;
        A[i] = P(a,b);
    }
    rep(i,0,N){
        int a,b;
        cin >> a >> b;
        B[i] = P(a,b);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int cnt = 0;
    rep(i,0,N){
        int idx = -1, maxb = -1;
        rep(j,0,N){
            if(A[j].first > B[i].first)break;
            if(A[j].second > maxb && A[j].second < B[i].second){
                maxb = A[j].second;
                idx = j;
            }
        }
        if(idx == -1)continue;
        cnt++;
        A[idx].second = INF;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }
template<typename T>
void fin(std::vector<T>const& t, char delim=' '){
  if(t.size() > 0) {
    for(int i = 0; i < t.size() -1; ++i) std::cout << t[i] << delim;
    std::cout << t.back();
  }
  std::cout << std::endl; 
  exit(0);
}

int const MAXN = 2e5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; int64_t K; std::cin >> N >> K;
  std::vector<int> A(N+N);
  for(int i = 0; i < N; ++i) { std::cin >> A[i]; A[N+i] = A[i]; }
  std::vector<int> prev(MAXN+1, -1);
  std::vector<int> sk(N);
  for(int i = 0; i < N+N; ++i) {
    int p = prev[A[i]];
    if(0 <= p && p < N) sk[p] = i-p+1;
    prev[A[i]] = i;
  }
  std::vector<int64_t> sum({0});
  std::fill_n(prev.begin(), N, -1);
  prev[0] = 0;
  int b;
  for(;;) {
    int64_t nx = sum.back();
    nx += sk[nx%N];
    if(prev[nx%N] >= 0) {
      b = prev[nx%N];
      sum.push_back(nx);
      break;
    }
    prev[nx%N] = sum.size();
    sum.push_back(nx);
  }
  int64_t l = K*N;
  if(l >= sum[b]) {
    l -= sum[b];
    int64_t p = sum.back() - sum[b];
    l %= p;
    auto it = std::upper_bound(sum.begin(), sum.end(), l+sum[b]);
    if(it != sum.begin()) l -= *(it-1) - sum[b];
  } else {
    l -= *(std::upper_bound(sum.begin(), sum.end(), l)-1);
  }
  std::vector<int> ans;
  std::fill_n(prev.begin(), MAXN+1, -1);
  for(int i = N-l; i < N; ++i) {
    if(prev[A[i]] < 0) {
      prev[A[i]] = ans.size();
      ans.push_back(A[i]);
    } else {
      int nsz = prev[A[i]];
      while(ans.size() > nsz) {
        prev[ans.back()] = -1;
        ans.pop_back();
      }
    }
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 500005;
int n;
string s;
int res;
int dp[N];
int main() {
    std :: ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
//    freopen("input.inp", "r", stdin);
    //-------------------------------------------------------------------------------------------------------
    cin >> n >> s;
    s = '0' + s + '0';
    n = s.size() - 1;
    for (int i = 1; i < n; i++) {
        dp[i + 1] = max(dp[i + 1], dp[i]);
        if (s[i - 1] == '1' && s[i] == '0' && s[i + 1] == '1') {
            for (int pre = i - 1; s[pre] == '1'; pre--)
                dp[i + 1] = max(dp[i + 1], dp[pre - 1] + i - pre);
            for (int nx = i + 1; s[nx] == '1'; nx++)
                dp[nx] = max(dp[nx], dp[i - 2] + nx - i);
        }
    }
    cout << dp[n];
    //-------------------------------------------------------------------------------------------------------
    return 0;
}


Measured memory_bytes: 2864
#include <bits/stdc++.h>
using namespace std;
int main(){
  set<int> U;
  int n;
  cin >> n;
  set<int> A;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    A.insert(a);
    U.insert(a);
  }
  int m;
  cin >> m;
  set<int> B;
  for (int i = 0; i < m; i++){
    int b;
    cin >> b;
    B.insert(b);
    U.insert(b);
  }
  for (auto itr = U.begin(); itr != U.end(); itr++){
    if (!A.count(*itr) || !B.count(*itr)){
      cout << *itr << endl;
    }
  }
}


Measured memory_bytes: 40608
a1,a2,a3 = map(int, input().split())
a4,a5,a6 = map(int, input().split())
a7,a8,a9 = map(int, input().split())
A = [a1,a2,a3,a4,a5,a6,a7,a8,a9]

n = int(input())
for _ in range(n):
    b = int(input())
    if b in A:
        i = A.index(b)
        A[i] = 0

if A[0]+A[1]+A[2]==0 or A[3]+A[4]+A[5]==0 or A[6]+A[7]+A[8]==0:
    print("Yes")
elif A[0]+A[3]+A[6]==0 or A[1]+A[4]+A[7]==0 or A[2]+A[5]+A[8]==0:
    print("Yes")
elif A[0]+A[4]+A[8]==0 or A[2]+A[4]+A[6]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/*B - 105*/
#include <iostream>
#include <cmath>
using namespace std;

int main() 
{
  int n,counter=0;
  cin >> n;
  int num[5]={3,5,7,11,13};

  for(int i=0; i<=2;  i++)
  {
    for(int j=i+1; j<=3;  j++)
    {
      for(int k=j+1; k<=4;  k++)
      {
        int pro = num[i] * num[j] * num[k];
//        cout <<  pro << endl;
        if( pro <= n )
          counter++;
      }
    }
  }

  for(int i=0; i<=3;  i++)
  {
    for(int j=i+1; j<=4;  j++)
    {
        int pro = pow(num[i],3) * num[j];
        if( pro <= n )
        {
//          cout << num[i] << " "; 
//          cout << num[j] << " ";
//          cout << pro << endl;
          counter++;
        }
    }
  }

  cout << counter << endl;

  return 0;
}


Measured memory_bytes: 384
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		int cnt = 0;
		for (char j = 'a'; j <= 'z'; ++j) {
			if (s.substr(0, i).find(j) != string::npos && s.substr(i).find(j) != string::npos) {
				++cnt;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  a = u == s ? a-1 : a;
  b = u == t ? b-1 : b;
  cout << a << " " << b << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=101;
int a[N];
int n;
int main(){
	while(cin>>n){
		bool flag=true;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n;i++){
			if(a[i]%2==0){
				if(a[i]%3!=0&&a[i]%5!=0){
					flag=false;
					break;
				}
			} 
		}		
		if(flag==true){
			cout<<"APPROVED"<<endl;
		}else{
			cout<<"DENIED"<<endl;
		}		
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

ll n;
vvll g;
vll color;
bool ok;

bool dfs(ll t, ll c, pll& p) {
    color[t] = c;
    if(c == 0) ++p.first;
    else ++p.second;
    for(int i = 0; i < n; ++i) {
        if(!g[t][i]) continue;
        if(color[i] == 1 - c) continue;
        if(color[i] == c) return false;
        if(!dfs(i, 1 - c, p)) return false;
    }
    return true;
}

void solve() {
    ll m;
    cin >> n >> m;
    g.assign(n, vll(n, 1));
    rep(i, n) g[i][i] = 0;
    while(m--) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        g[a][b] = g[b][a] = 0;
    }
    color.assign(n, -1);
    vpll vp;
    ok = true;
    rep(i, n) {
        if(color[i] != -1) continue;
        pll p;
        if(!dfs(i, 0, p)) {
            cout << -1 << endl;
            return;
        };
        vp.push_back(p);
    }
    vb dp(n + 1, false);
    dp[0] = true;
    for(auto p : vp) {
        vb _dp(n + 1, false);
        rep(j, n + 1) {
            if(!dp[j]) continue;
            _dp[j + p.first] = true;
            _dp[j + p.second] = true;
        }
        dp = _dp;
    }
    ll ans = INFL;
    rep(i, n + 1) {
        if(!dp[i]) continue;
        ll _ans = i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2;
        chmin(ans, _ans);
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 7516
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    a = input()

    if a == 'Sunny':
        print('Cloudy')
    if a == 'Cloudy':
        print('Rainy')
    if a == 'Rainy':
        print('Sunny')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

ll N;
mint ans;

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

  ans = mint(10).pow(N);

  ans -= mint(9).pow(N);
  ans -= mint(9).pow(N);

  ans += mint(8).pow(N);

  std::cout << ans.x << endl; 

  return 0;
}

Measured memory_bytes: 3632
m[100],a[100],b[100],i,j,M,B;main(n){for(;scanf("%d",&n)*n;puts(B?"NG":"OK")){for(i=n;i--;B=0)scanf("%d%d%d",m+i,a+i,b+i);for(i=n;i--;B|=M>150)for(M=0,j=n;j--;)M+=a[i]>=a[j]&&a[i]<b[j]?m[j]:0;}}
m[100],a[100],b[100],i,j,M,B;

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	LL n;
	cin>>n;
	n=sqrt(n);
	cout<<n*n<<endl;
	return 0;
}


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


int main(){
	char str1[300000],str2[300000];
	int beda = 0;
		
	scanf("%s",str1);
	scanf("%s",str2);
	int len = strlen(str1);
	int i=0;
	while(len--){
		if(str1[i]!=str2[i]){
			beda +=1;
		}
		i++;
	}
	printf("%d",beda);
	
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, K;
  cin >> N >> K;
  vi32 h(N);
  cin >> h;
  vi32 dp(N, 2e9);
  dp[0] = 0;
  reps(i, N - 1) {
    int mi = 2e9;
    reps(j, K) {
      if (i - j < 0) break;
      amin(mi, dp[i - j] + abs(h[i] - h[i - j]));
    }
    dp[i] = mi;
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
# https://beta.atcoder.jp/contests/arc079/tasks/arc079_a


def solve():
    from_start = set()
    to_end = set()
    n, m = map(int, input().split())

    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            from_start.add(b)
        elif b == n:
            to_end.add(a)

    if len(from_start & to_end) == 1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 19024
import sys

def solve():
    file_input = sys.stdin
    N, W = map(int, file_input.readline().split())
    C = [0] * (W + 1)
    for line in file_input:
        item_v, item_w = map(int, line.split())
        for i, vals in enumerate(zip(C[item_w:], C)):
            v1, v2 = vals
            C[i] = max(v1 + item_v, v2)
    print(C[0])

solve()

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int n, m; cin >> n >> m;
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        q.push(a);
    }

    for (int i = 0; i < m; i++) {
        int x = q.top(); q.pop();
        x >>= 1;
        q.push(x);
    }

    ll ans = 0;
    while (!q.empty()) {
        int x = q.top(); q.pop();
        ans += x;
    }

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

Measured memory_bytes: 892
#include <cstdlib>
#include <iostream>
#include <memory>

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

  int N;
  cin >> N;

  int *V = nullptr;
  int *C = nullptr;
  V = new int[N];
  C = new int[N];
  for (int index = 0; index < N; index++)
  {
    cin >> V[index];
  }
  for (int index = 0; index < N; index++)
  {
    cin >> C[index];
  }

  int sum = 0;

  for (int index = 0; index < N; index++)
  {
    if (V[index] > C[index])
    {
      sum += V[index] - C[index];
    }
  }

  cout << sum << endl;

  return EXIT_SUCCESS;
}


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

int main()
{

    while(true){
        int n;
        cin>>n;
        if(n==0)
            break;
        int h[101];
        for(int i=0; i<n+1; i++){
            cin>>h[i];
        }
        
        for(int i=0; i<n+1; i++){
            int tmp[100];
            for(int j=0; j<i; j++){
                tmp[j] = h[j];
            }
            for(int j=i+1; j<n+1; j++){
                tmp[j-1] = h[j];
            }
            
            bool flg = true;
            
            int d = tmp[1]-tmp[0];
            for(int j=1; j<n-1; j++){
                if(tmp[j+1]-tmp[j]!=d){
                    flg = false;
                    break;
                }
            }
            
            if(flg){
                cout<<h[i]<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
  string n,s;
  cin>>n>>s;
  int cnt =0;
  for(int i =0;i<s.size();i++)
  {
 		if(n[i]!=s[i])
        {
          cnt++;
         }
    
  }
  cout<<cnt<<endl;
  
}

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

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

using namespace std;


vector<int> pp;
void preparePrime(int maxp)
{
	int i;
	vector<int> a(maxp + 1);
	for (i = 2; i <= maxp; i++) {
		int k = i + i;
		while (k <= maxp) {
			a[k] = 1;
			k += i;
		}
	}
	for (i = 2; i <= maxp; i++) {
		if (a[i] == 0) pp.push_back(i);
	}
	return;
}

void solve()
{
	preparePrime(100000);
	int n = 100005;
	vector<int> a(n+1);
	int i;
	for (i = 0; i<(int)pp.size(); i++) {
		a[pp[i]] = 1;
	}
	vector<int> b(n + 1);
	for (i = 1; i <= n; i++) {
		if (i % 2 == 1 && a[i] && a[(i + 1) / 2]) {
			b[i] = 1;
		}
	}

	for (i = 1; i <= n; i++) {
		b[i] = b[i - 1] + b[i];
	}

	int Q;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		int ans = b[r] - b[l - 1];
		printf("%d\n", ans);
	}
	

	return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 1528