akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv;
import std.algorithm, std.array, std.container, std.range, std.string;

import core.bitop;

void main()
{
    auto nab = reads!uint;
    immutable n = nab[0], a = nab[1], b = nab[2];
    if (cast(uint)(a ^ b).popcnt & 1)
        "YES\n%(%d %)".writefln((new size_t[1<<n]).solve(
                n, (1 << n) - 1, a, b));
    else
        "NO".writefln;
}

/// fill arr with sequence 0...d
size_t[] solve(
        size_t[] arr, in size_t n,
        in size_t change,
        in size_t start, in size_t end)
{
    debug stderr.writefln("solve(len=%d, n=%d, %d..%d)", arr.length, n, start, end);
    assert (arr.length == 1 << n);
    assert (change);
    if (arr.length == 2)
    {
        arr[0] = start;
        arr[1] = end;
        return arr;
    }

    size_t
        diff = start ^ end,
        changeHere = 1 << (diff.bsr),
        otherChange = 1 << (change - changeHere).bsr;
    arr[0..$/2].solve(n-1, change ^ changeHere, start, start ^ otherChange);
    arr[$/2..$].solve(n-1, change ^ changeHere, start ^ changeHere ^ otherChange, end);
    debug foreach (elem; arr)
        stderr.writef("%0*b ", n, elem);
    debug stderr.writeln;
    return arr;
}

auto read(T)()
{
    return readln.chomp.to!T;
}
auto reads(T)()
{
    return readln.chomp.split.to!(T[]);
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define SIZE 100009
#define INF 1e9
using namespace std;
struct edge{int from,to,cost;};
int n,m,s,d[SIZE],a,b,c,i,j,update;
edge e;
vector<edge>v;

void bellman_ford(){
  fill(d,d+SIZE,INF);d[s]=0;
  for(i=0;i<n;i++){
      update=0;
      for(j=0;j<m;j++){
        e=v[j];
        if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
            d[e.to]=d[e.from]+e.cost;
            update=1;
            if(i==n-1){
              cout<<"NEGATIVE CYCLE"<<endl;
              return;
            }
        }
    }
    if(!update)break;
  }
  for(i=0;i<n;i++){
    if(d[i]==INF)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
}
int main(){
  cin>>n>>m>>s;
  for(i=0;i<m;i++){
    cin>>a>>b>>c;
    v.push_back({a,b,c});
  }
  bellman_ford();
}



Measured memory_bytes: 3600
ALEN, BLEN, M = map(int, input().split())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

price = float('inf')

for i in range(M):
	ai, bi, c = map(int, input().split())
	waribiki = A[ai-1] + B[bi-1] - c
	if waribiki < price:
		price = waribiki

nowaribiki = min(A) + min(B)

if nowaribiki < price:
	price = nowaribiki

print(price)


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

    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
    }

    rep(posX, 101){
        rep(posY, 101){
            int H = -1;
            bool ok = true;
            rep(i, n){
                if(h[i] > 0){
                    int tmp = h[i] + abs(x[i]-posX) + abs(y[i]-posY);
                    if(H == -1){
                        H = tmp;
                    }
                    else{
                        if(H != tmp){
                            ok = false;
                            break;
                        }
                    }
                }
            }
            rep(i, n){
                if(h[i] == 0){
                    int tmp = abs(x[i]-posX) + abs(y[i]-posY);
                    if(H - tmp > 0){
                        ok = false;
                    }
                }
            }
            if(ok){
                cout << posX << " " << posY << " " << H << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main()
{
    int a, b, n;
    cin >> n;
    vector<int> x(n + 1, 0);
    FOR(i, 1, n + 1)
    {
        int rest = i;
        FOR(j, 2, n + 1)
        {
            while(rest % j == 0)
            {
                rest /= j;
                x[j]++;
            }
        }
    }

    ll out = 1;
    FOR(i, 1, n + 1)
    {
        if(x[i] != 0)
        {
            out *= (x[i] + 1);
            out %= MOD;
        }
    }
    cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a, b, c;
int main() {
	cin >> n;
	for (int i = 1;i <= n;i++) {
		int x;
		scanf("%d", &x);
		if (x % 4 == 0) c++;
		else if (x % 2 == 0) b++;
		else a++;
	}
	if (c >= a) {
		puts("Yes");
	} else {
		if (b == 0 && c == a-1) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int[] array=new int[x];
        for(int i=0;i<x;i++){
            array[i]=sc.nextInt();
        }
        int count=0;
        for(int i=1;i<x-1;i++){
            if((array[i-1]>array[i] && array[i]>array[i+1]) || (array[i+1]>array[i] && array[i]>array[i-1]))
                count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35628
from math import atan2, sqrt
N = int(input())
E = []
for _ in range(N):
    x, y = map(int, input().split())
    d = atan2(y, x)
    E.append((d, x, y))

E.sort()

dp = [[(0, 0)] * N for _ in range(N)]

ans = 0
for i in range(N):
    _, xi, yi = E[i]
    dist = xi ** 2 + yi ** 2
    ans = max(ans, dist)
    dp[i][i] = (xi, yi)
    for j in range(i+1,i+N):
        j %= N
        _, xj, yj = E[j]
        dp[i][j] = (dp[i][j-1][0] + xj, dp[i][j-1][1] + yj)
        dist = dp[i][j][0] ** 2 + dp[i][j][1] ** 2
        ans = max(ans, dist)

print(sqrt(ans))


Measured memory_bytes: 40560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

void insert_sort(int *buff, int low, int high) {
  for (int i = low + 1; i <= high; i++) {
    int j;
    double temp = buff[i];
    for (j = i - 1; j >= low && temp < buff[j]; j--) {
      buff[j + 1] = buff[j];
    }
    buff[j + 1] = temp;
  }
}

#define LIMIT 2

void msort(int *a, int *b, int low, int high)
{
  if (high - low <= LIMIT) {
    insert_sort(b, low, high);
  } else {
    int mid = low + (high - low) / 2;
    msort(b, a, low, mid);
    msort(b, a, mid + 1, high);
    int i = low;
    int j = mid + 1;
    int k = low;
    while (i <= mid && j <= high) {
      if (a[i] <= a[j])
	b[k++] = a[i++];
      else
	b[k++] = a[j++];
    }
    while (i <= mid) b[k++] = a[i++];
    while (j <= high) b[k++] = a[j++];
  }
}

void merge_sort(int *work, int *buff, int size) {
  for (int i = 0; i < size; i++) work[i] = buff[i];
  msort(work, buff, 0, size - 1);
}


int main() {
    int N = 0, K = 0;
    scanf("%d %d", &N, &K);
    int h[N];
    int htmp;
    for (int n = 0; n < N; n++) {
        htmp = 0;
        scanf("%d", &htmp);
        h[n] = htmp;
    }
    int work[N];
    merge_sort(work, h, N);
    
    int diff = INT_MAX;
    int difftmp;
    for (int n = 0; n + K - 1 < N; n++) {
        difftmp = h[n + K - 1] - h[n];
        if (diff > difftmp) {
            diff = difftmp;
        }
        if (diff == 0) {
            printf("%d", diff);
            return 0;
        }
    }
    
    printf("%d", diff);
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

import scala.annotation.tailrec
import scala.io.StdIn._

object Main extends App {

  val Array(a,b,c,d) = readLine().split(" ").map(_.toInt)

  def solve() = {
    var tLife = a
    val tAtk = b
    var aLife = c
    val aAtk = d

    var tTurn = true
    while(tLife > 0 && aLife > 0) {
      if(tTurn) aLife -= tAtk
      else tLife -= aAtk
      tTurn = !tTurn
    }
    if(tLife <= 0) "No" else "Yes"
  }

  println(solve())

}



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

using i64 = int64_t;

int main(){
    int n, k;
    cin >> n >> k;
    vector<double> v;
    for(int i=0;i<n;++i){
        int p;
        cin >> p;
        v.push_back((p+1)/2.);
    }
    vector<double> cumsum(n+1);
    for(int i=1;i<=n;++i){
        cumsum[i] = cumsum[i-1] + v[i-1];
    }

    double ans = 0;
    for(int i=k;i<=n;++i){
        //cerr << i << " " << cumsum[i] << " " << cumsum[i-k] << " " << v[i-1] << endl;
        ans = max(ans, cumsum[i] - cumsum[i-k]);
    }

    printf("%.10lf\n", ans);

    return 0;
}

Measured memory_bytes: 3952
N = int(input())
a = list(map(int, input().split()))
b = [0] * N
for i in range(N):
    n = 0
    while True:
        if a[i] % 2**(n + 1) == 0:
            n += 1
        else:
            break
    b[i] = n
print(sum(b))

Measured memory_bytes: 4148
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        t: usize,
        foods:[(usize,usize);n]
    }

    let cap = t - 1;
    let mut foods = foods;
    foods.sort();
    foods.reverse();

    // dp[x][y] = 前からx個までの料理をy時間使って食べた場合の最大の満足度,諦めた最大の料理の満足度
    let mut dp = vec![vec![(0, 0); cap + 1]; n + 1];

    for i in 1..n + 1 {
        let target = i - 1;
        for j in 0..cap + 1 {
            if foods[target].0 > j {
                dp[i][j].0 = dp[i - 1][j].0;
                dp[i][j].1 = cmp::max(dp[i - 1][j].1, foods[target].1);
            } else {
                if (dp[i - 1][j - foods[target].0].0 + foods[target].1) + dp[i - 1][j].1
                    > dp[i - 1][j].0 + cmp::max(foods[target].1, dp[i - 1][j].1)
                {
                    // iを採用した方がよい
                    dp[i][j].0 = dp[i - 1][j - foods[target].0].0 + foods[target].1;
                    dp[i][j].1 = dp[i - 1][j - foods[target].0].1;
                } else {
                    dp[i][j].0 = dp[i - 1][j].0;
                    dp[i][j].1 = cmp::max(dp[i - 1][j].1, foods[target].1);
                }
            }
        }
    }

    //println!("{:?}", dp);

    let mut ans = dp[n][cap].0 + dp[n][cap].1;
    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 141784
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

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

            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a4 = 0;
            int a2 = 0;
            for(var i = 0; i < N; i++)
            {
                if (a[i] % 4 == 0)
                {
                    a4++;

                }
                else if (a[i] % 2 == 0)
                {
                    a2++;
                }
            }
            string ans = "No";
            if (a4 * 2 + 1 >= a.Length || (a4 * 2 + a2 >= a.Length && a2 > 0)) 
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);



            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 19680
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long p=Math.Abs(a[0]-s[1]);
		for(int i=1;i<s[0];i++){
			p=gcd(p,Math.Abs(a[i]-s[1]));
		}
		Console.WriteLine("{0}",p);
	}
	static long gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}

Measured memory_bytes: 20576
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>
#include <random>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(auto i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(auto i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define CAST static_cast

template<typename T>
constexpr bool in_range(T const &l, T const &a, T const &u){ return l < a && a < u; };
constexpr double inf {std::numeric_limits<double>::infinity()};

#define FAST_TYPE
#ifdef FAST_TYPE
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
#else
using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
#endif

using imx = std::intmax_t;
using umx = std::uintmax_t;

using namespace std;

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

  i32 N, M;
  cin >> N >> M;

  vector<i32> dp(N+1);
  dp[0] = 1;
  dp[1] = 1;

  REP (i, M) {
    i32 a;
    cin >> a;

    dp[a] = a < 2 ? 0 : -1;
  }

  FOR (i, 2, dp.size()) {
    if (dp[i] == -1)
      dp[i] = 0;
    else
      dp[i] = (dp[i-1] + dp[i-2]) % 1'000'000'007;
  }

  cout << dp[N] << endl;

  return 0;
}

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

int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for(int i=1; i<N-1; i++){
    map<char, int> mp;    
    for(int j=0; j<=i; j++) mp[S[j]]++;
    int tmpans = 0;
    for(int j=i+1; j<N; j++){
      if(mp[S[j]] >= 1) {
        tmpans++;
        mp[S[j]] = 0;
      }
    }
    ans = max(ans, tmpans);
  }
  cout << ans << endl;
  return 0;
}

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

void solve(std::string S)
{
    for (size_t i = 0; i < S.length(); i++)
    {
        cout << "x";
    }
    cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <cmath>
using namespace std;

int lislength(vector<int> &a){
    vector<int> lis;
    for(int i=0; i<a.size(); i++){
        auto itr = lower_bound(lis.begin(), lis.end(), a[i]);
        if(itr == lis.end())
            lis.push_back(a[i]);
        else
            *itr = a[i];
    }
    return lis.size();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2, N;
    cin >> x1 >> y1 >> x2 >> y2 >> N;
    vector<pair<int, int>> XY(N);
    for(int i=0; i<N; i++)
        cin >> XY[i].first >> XY[i].second;

    x2 -= x1;
    y2 -= y1;
    for(int i=0; i<N; i++){
        XY[i].first -= x1;
        XY[i].second -= y1;
    }
    if(x2 < 0){
        x2 = -x2;
        for(int i=0; i<N; i++)
            XY[i].first = -XY[i].first;
    }
    if(y2 < 0){
        y2 = -y2;
        for(int i=0; i<N; i++)
            XY[i].second = -XY[i].second;
    }
    double ans = 100.0 * (x2 + y2);
    const double diff = 5.0 * M_PI - 20.0;
    sort(XY.begin(), XY.end());

    vector<int> a;
    for(auto xy : XY){
        if(0 <= xy.first && xy.first <= x2 && 0 <= xy.second && xy.second <= y2)
            a.push_back(xy.second);
    }

    const double diff2 = 10.0 * M_PI - 20.0;

    int ll = lislength(a);
    if(ll != min(x2, y2) + 1)
        ans += diff * ll;
    else
        ans += diff * (ll - 1) + diff2;
    cout << fixed << setprecision(32) << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int k; cin >> k;
    bool rem[k]; memset(rem, false, sizeof(rem));
    int n = 7;
    int cnt = 0;
    while(1){
        cnt++;
        if(n % k == 0){
            cout << cnt << '\n';
            return;
        }
        if(rem[n % k]){
            cout << -1 << '\n';
            return;
        }
        rem[n % k] = true;
        n = (n * 10 + 7) % k;
    }

}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;
const ll MAX = 302;

// dp[i][j][k] = # of ways to get length j sequence with max element at most i,
// and all elements equal to i are inserted with at most k smaller predecessors
ll dp[MAX][MAX][MAX];

void Solve(ll) {
  ll n, m, mod;
  if (not(cin >> n >> m >> mod))
    return;
  const auto add = [&](ll& a, ll b) {
    a = (a + b) % mod;
  };
  memset(dp, 0, sizeof(dp));
  dp[1][0][0] = 1;
  VEVE(i, 1, m + 1) VEVE(j, 0, n + 1) DYDY(k, j, -1) {
        // insert element with value i with predecessor one of the first k or parent id = 0
        add(dp[i][j + 1][k], (k + 1) * dp[i][j][k]);
        if (k > 0)
          // accumulate to k-1 predecessors if possible
          add(dp[i][j][k - 1], dp[i][j][k]);
        else
          // otherwise accumulate to next larger element
          add(dp[i + 1][j][j], dp[i][j][k]);
      }
  const auto res = dp[m][n][0];
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

int calc (int x) {
	int y = 0;
	while (x) {
		y += x % 10;
		x /= 10;
	}
	re y;
}

int main () {
	scanf ("%d", &n);
	int ans = 1e9;
	for (int i = 1; i < n; i++)
		ans = min (ans, calc (i) + calc (n - i));
	printf ("%d\n", ans);	
	return 0;
}

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

using namespace std;

long long int N, M, L, R, D, x[100001] = {}, cur;
queue<pair<long long int,long long int>> q[100001];
queue<long long int>q2;
bool visited[100001] = {}, flag = true, appearL[100001] = {}, appearR[100001] = {}, ans = true, flag2 = true;

void solve(long long int num) {
	while (q[num].size()) {
		pair<long long int, long long int>box = q[num].front();
		q[num].pop();
		if (x[box.first] != -1 && x[box.first] != x[num] + box.second)flag = false;
		x[box.first] = x[num] + box.second;
		solve(box.first);
	}
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> L >> R >> D;
		q[L].push(make_pair(R, D));
		appearL[L] = true;
		appearR[R] = true;
	}
	for (int i = 1; i <= N; i++) {
		x[i] = -1;
		if (!appearR[i] && appearL[i])q2.push(i);
	}
	if (M == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (!q2.size()) {
		cout << "No" << endl;
		return 0;
	}
	while (q2.size()) {
		cur = q2.front();
		q2.pop();
		x[cur] = 0;
		solve(cur);
		if (!flag) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 73088
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//  cout <<  s.at(1)-'0'-49  <<endl;
int main() {
  int n;
  int d,x;
  cin >> n >> d >> x;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  int sum=0;
  rep(i,n){
    if(d%a.at(i) ==0 )    sum += d / a.at(i) ;
    else sum += d / a.at(i) +1;
  }

  cout << sum + x <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] n = scanner.next().split("");
        long sum = 0;
        for (String str : n) {
            sum += Integer.parseInt(str);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }


    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









Measured memory_bytes: 65388
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    var(string, s);

    string t = s.substr(0, s.length() / 2);
    if (t + t == s) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


Measured memory_bytes: 256
//use rand::Rng;
use std::collections::{BTreeMap, BTreeSet};

fn main() {
    //    let mut rng = rand::thread_rng();
    //    loop {
    //        let n = 5;
    //        let a: Vec<u64> = (0..n).map(|_| rng.gen::<u64>() % (n as u64) + 1).collect();
    //
    //        let ans1 = solve(&a, n);
    //        let ans2 = naive(&a, 0, n);
    //        assert_eq!(ans1, ans2, "a={:?} naive={:?} solve={:?}", a, ans2, ans1);
    //    }

    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let k: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);

    let ans = solve(&a, k * n);
    for (i, a) in ans.into_iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", a);
    }
    println!();
}

fn solve(a: &Vec<u64>, l: usize) -> Vec<u64> {
    let n = a.len();
    let mut prev = BTreeMap::new();
    let mut jump = vec![vec![0; n]; 50];

    for i in 0..n {
        if prev.contains_key(&a[i]) {
            let x = prev[&a[i]];
            jump[0][x] = i - x;
            prev.insert(a[i], i);
        } else {
            prev.insert(a[i], i);
        }
    }

    for i in 0..n {
        if let Some(x) = prev.remove(&a[i]) {
            jump[0][x] = n + i - x;
        }
    }

    for t in 1..50 {
        for i in 0..n {
            let jump1 = jump[t - 1][i];
            let next = (i + jump1 + 1) % n;
            let jump2 = jump[t - 1][next];
            jump[t][i] = jump1 + 1 + jump2;
        }
    }

    let mut pos = 0;
    for t in (0..50).rev() {
        loop {
            let next = jump[t][pos % n] + pos + 1;
            if next < l {
                pos = next;
            } else {
                break;
            }
        }
    }
    assert!(pos < l);

    naive(&a, pos, l)
}

fn naive(a: &Vec<u64>, pos: usize, l: usize) -> Vec<u64> {
    let n = a.len();
    let mut set = BTreeSet::new();
    let mut ans = vec![];
    for i in pos..l {
        let d = i % n;
        let a = a[d];
        if set.contains(&a) {
            while let Some(p) = ans.pop() {
                set.remove(&p);
                if p == a {
                    break;
                }
            }
            set.remove(&a);
        } else {
            set.insert(a);
            ans.push(a);
        }
    }
    ans
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 110844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int d, c;
    cin >> d >> c;
    cout << d * c << "\n";
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim().Split(' ');
            var N = Int32.Parse(line[0]);
            var H = Int32.Parse(line[1]);
            var W = Int32.Parse(line[2]);

            var cnt = 0;
            for(var i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Trim().Split(' ');
                if(Int32.Parse(input[0]) >= H && Int32.Parse(input[1]) >= W) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    int ans = 1000;
    int val = 1000;
    for (int i = -100; i <= 200; i++) {
        if (find(p.begin(), p.end(), i) != p.end()) {
            continue;
        }
        if (abs(x - i) < val) {
            val = abs(x - i);
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int k = scan.nextInt();
		int have[] = new int[n];
 		
		for(int i=0;i<k;i++) {
			int d = scan.nextInt();
			for(int j=0;j<d;j++) {
				int take = scan.nextInt();
				have[take-1] = 1;
			}
		}
		
		int ans = 0;
		for(int i=0;i<n;i++) {
			if(have[i] == 0) {
				ans += 1;
			}
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 45832
a[999];main(){
	int n,m,c,d;
	for(scanf("%d%d",&n,&m);m--;)for(scanf("%d%d",&c,&d);c<d;c++)a[c]=1;
	for(c=d=0;c<n;c++)d+=a[c]*2;
	*a=!printf("%d\n",d+n+1);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int N;
    cin >> N;
    res = 2;
    if (N == 1)
    {
        cout << "1" << endl;
        return 0;
    }
    while (res <= N)
    {
        res *= 2;
    }

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

Measured memory_bytes: 256
from collections import deque

N,u,v = map(int,input().split())
u-=1
v-=1
points = [set() for x in range(N)]
for i in range(N-1):
    A,B = map(int,input().split())
    A-=1
    B-=1
    points[A].add(B)
    points[B].add(A)

def distance_array(x):
    arr = [-1] * N
    scanned = set()
    q = deque()
    q.append((x,-1))
    for i in range(N):
        po,root_d = q.pop()
        scanned.add(po)
        this_d = root_d + 1
        arr[po] = this_d
        for ii in points[po]:
            if ii in scanned:
                continue
            q.append((ii,this_d))
    return arr

leaves = filter(lambda x: len(points[x])==1,range(N))
du = distance_array(u)
dv = distance_array(v)
# 目指す点までの距離 du, dv
# まず2duターンかかって 0, (dv-du)になる

# (dv-du) + 1 = 2n
# (dv-du)     = 2n

# 4n  ターン目に高橋が動いて1, (dv-du)-2n+2
# # 成立していたら終了 求める答えは 2du + 2n
# 4n+1ターン目に青木が動いて1, (dv-du)-2n+1
# # 成立していたら終了 求める答えは 2du + 2n + 1
# 4n+2ターン目に高橋が動いて0, (dv-du)-2n+1
# # 成立していたら終了 求める答えは 2du + 2n + 1
# 4n+3ターン目に青木が動いて0, (dv-du)-2n
# # 成立していたら終了 求める答えは 2du + 2n + 2

b = filter(lambda x: dv[x]-du[x] > 0,leaves)
c = max(b,key=lambda x: dv[x])

def aa():
    s = 0
    ddu = du[c]
    ddv = dv[c]
    while True:
        if ddu == ddv:
            return s
        ddu = abs(ddu - 1)
        if ddu == ddv:
            return s
        ddv -= 1
        s += 1

print(aa())



Measured memory_bytes: 47616
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int n;
    cin >> n;

    int cnt[n][26];
    fill(cnt[0], cnt[n], 0);

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (char c : s) cnt[i][c - 'a']++;
    }

    string ret = "";
    for (int i = 0; i < 26; i++) {
        int mn = 50;
        for (int j = 0; j < n; j++) {
            mn = min(mn, cnt[j][i]);
        }

        for (int j = 0; j < mn; j++) {
            ret += 'a' + i;
        }
    }

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

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<class T> void read(T &x)
{
	x = 0; int f = 1, ch = getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
	x *= f;
}

template<class T> inline void Cmax(T &a, T b) {if(a < b) a = b;}

const int maxn = 5000 + 5;
const int maxm = maxn << 1;
int n, m, k;
char s[maxm];
char an[maxn];

char a;
void full()
{
	for(int i = 1; i <= n; ++i) an[i] = a;
}
void sol()
{
	int L = 0, cnt = 0;
	a = *min_element(s + 1, s + m + 1);
	for(int i = 1; i <= m; ++i)
	{
		if(s[i] == a) ++cnt;
		else
		{
			Cmax(L, cnt);
			cnt = 0;
		}
	}
	Cmax(L, cnt);
	int M = L;
	if(M >= n)
	{
		full();
		return;
	}
	for(int i = 1; i < k; ++i)
	{
		M <<= 1;
		if(M >= n)
		{
			full();
			return;
		}
 	}
 	cnt = 0;
 	bool flag = true;
 	for(int i = 1; i <= m; ++i)
 	{
 		if(s[i] == a) ++cnt;
 		else cnt = 0;
 		if(cnt == L && i >= n)
 		{
 			static char t[maxn];
 			for(int j = 1; j <= M; ++j) t[j] = a;
			for(int j = M + 1, h = i - L; j <= n; ++j, --h)
			{
				t[j] = s[h];
			}
			if(flag) 
			{
				copy(t + 1, t + n + 1, an + 1);
				flag = false;
			}
			else
			{
				bool ok = false;
				for(int j = 1; j <= n; ++j) if(an[j] != t[j])
				{
					if(an[j] > t[j])
					{
						ok = true;
						break;
					}
					else break;
				}
				if(ok) copy(t + 1, t + n + 1, an + 1);
			}
		}
	}
}

int main()
{
	read(n), read(k);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; ++i)
	{
		s[i + n] = s[n - i + 1];
	}
	m = n << 1;
	sol();
	puts(an + 1);
	return 0;
}

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

int main(){
    int a, b,x;
    cin>>a>>b>>x;
    if(x<a){
        cout<<"NO";
        cout<<endl;
        return 0;
    }

    if(a+b<x){
        cout<<"NO";
        cout<<endl;
        return 0;
    }

    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll N, Y;
    cin >> N >> Y;

    for (ll x = 0; x <= Y / 10000; x++)
    { //1万円の枚数
        for (ll y = 0; y <= Y / 5000; y++)
        { //5千円の枚数
            if ((Y - 10000 * x - 5000 * y) >= 0 && (Y - 10000 * x - 5000 * y) % 1000 == 0)
            {
                if (N == x + y + (Y - 10000 * x - 5000 * y) / 1000)
                {
                    cout << x << " " << y << " " << (Y - 10000 * x - 5000 * y) / 1000 << endl;
                    return 0;
                }
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3548
# ABC133-B

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,d=LI()
  l=[LI() for _ in range(n)]

  c=0
  for i in range(n):
    for j in range(i+1,n):
      x=l[i]
      y=l[j]

      sm=0
      for k in range(d):
        sm+=(x[k]-y[k])*(x[k]-y[k])

      # print(sm)

      a=math.sqrt(sm)
      if a==int(a) and a*a==sm:
        c+=1

  return c

print(main())


Measured memory_bytes: 6216
#include <iostream>
using namespace std;
int main(void){
    int N, T, cost, times, minm = 10000;
    cin >> N >> T;
    for(int i=0; i < N; i++) {
        cin >> cost >> times;
        if(times <= T) {
            minm = min(minm, cost);
        }
    }
    if(minm == 10000) cout << "TLE" << endl;
    else cout << minm << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, mxid(0), ans(0); cin >> N;
    REP(i, N){
        int A, B; cin >> A >> B;
        if(chmax(mxid, A)) ans = A + B;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if ((a == b)&&(b == c)) {
		printf("1\n");
	}
	else if (a == b || b == c || c == a) {
		printf("2\n");
	}
	else printf("3\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
int N,s,i;
char c[300000];
int main()
{
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		s+=i;
		if(s>=N)break;
	}
	int len=i*2;
	for(int i=1;i<=len/2;i++)
		c[i]=')',c[len/2+i]='(';
	if(s==N){
		for(int i=1;i<=len;i++)printf("%c",c[i]);
		printf("\n");
		return 0;
		}
	int p=s-N;
	for(int i=len/2;i>=2;i--)
	{
		swap(c[i],c[i+1]);
		p--;
		if(p==0){
			for(int i=1;i<=len;i++)printf("%c",c[i]);
			printf("\n");
			return 0;
		}
	}
	for(int i=len/2+1;i<=len-1;i++)
	{
		swap(c[i],c[i+1]);
		p--;
		if(p==0){
			for(int i=1;i<=len;i++)printf("%c",c[i]);
			printf("\n");
			return 0;
		}
	}

}

Measured memory_bytes: 3228
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int w = sc.nextInt();

        for(int i=0; i<S.length(); i+=w){
        System.out.print(S.charAt(i));
        }
    } 
}


Measured memory_bytes: 36232
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string.h>
using namespace std;
int a[3];
int main()
{
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[2]*10+a[1]+a[0]<<endl;
    return 0;
}


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

int main() {
    ll n; cin >> n;
    vector<pair<ll, ll>> xl;
    rep(i, n){
        ll x, l;
        cin >> x >> l;
        xl.push_back(make_pair(x, l));
    }

    sort(xl.begin(), xl.end());
    ll tmp = xl.at(0).first + xl.at(0).second;
    ll cnt = 1;
    for(ll i=0; i<n; i++){
        if(tmp <= xl.at(i).first-xl.at(i).second){
            tmp = xl.at(i).first + xl.at(i).second;
            cnt++;
        }
        else if(tmp>=xl.at(i).first+xl.at(i).second){
            tmp = xl.at(i).first + xl.at(i).second;
        }
    }

    cout << cnt << endl;
}


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

int n , x,y,t;

int main(){

scanf("%d",&n);
while( n-- ){
    int a,b,c;
    scanf("%d %d %d",&c,&a,&b);
    int dx = abs(a-x);
    int dy = abs(b-y);
    int dt = abs(c-t);
    dt-=dx;
    dt-=dy;
    if( dt <0 || dt%2 ){
        printf("No\n");
        return 0;
    }
    t=c;
    x=a;
    y=b;
}

printf("Yes\n");
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
ll K;

pair<int, int>p[112345];



int main(){
  
  int i;
  int ans;
  
  cin>>N>>K;
  
  for( i = 0; i < N; i++ ){
    scanf("%d %d", &p[i].fi, &p[i].se);
  }
  
  sort( p, p+N );
  
  i = 0;
  
  while( K > 0 ){
    K -= (ll)p[i].se;
    ans = p[i].fi;
    i++;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let n = read_i64() as usize;
    let xs = {
        let mut xs = vec![];
        for _ in 0..n {
            let x = read_i64();
            xs.push(x-1);
        }
        xs
    };
    let ys = {
        let mut ys = vec![0; n];
        for i in 0..n {
            ys[xs[i] as usize] = i;
        }
        ys
    };
    let mut x = 0;
    let mut count = 1;
    let mut max_count = 1;
    while x+1 < n {
        if ys[x] < ys[x+1] {
            count += 1;
            x += 1;
        }
        else {
            count = 1;
            x += 1;
        }
        max_count = max(max_count, count);
    }
    let res = n - max_count;
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 8444