akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		int W = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

//		if (b - (a+W) > 0) {
//			System.out.println(b - (a+W));
//		}else if (a-(b+W) > 0) {
//			System.out.println(a-(b+W));
//		}else {
//			System.out.println(0);
//		}

		System.out.println(Math.max(Math.abs(a-b)-W, 0));
	}
}

Measured memory_bytes: 20692
import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    p = abs(p) if abs(p) < 10e-5 else p
    q = abs(q) if abs(q) < 10e-5 else q
    print("{:.3f} {:.3f} {:.3f}".format(p, q, r))


Measured memory_bytes: 5692
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N,K = map(int, sys.stdin.readline().split())
list_num = list(map(int, sys.stdin.readline().split()))
list_tmp = [0] * N
# print(list_tmp)

for num in list_num:
    # print(num)
    list_tmp[num-1] += 1

# print(list_tmp)
# print([i for i in list_tmp if i > 0])
list_tmp2 = [i for i in list_tmp if i > 0]

if(len(list_tmp2) <= K):
    print(0)
else:
    list_tmp2.sort()
    # print(list_tmp2)
    cnt = 0
    for i in range(len(list_tmp2) - K):
        cnt += list_tmp2[i]
    print(cnt)



Measured memory_bytes: 27192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOrdinaryNumber solver = new BOrdinaryNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOrdinaryNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
                p[i] = in.nextInt();

            int answer = 0;
            for (int i = 1; i + 1 < n; i++) {
                int[] x = {p[i - 1],
                           p[i],
                           p[i + 1]};
                Arrays.sort(x);
                if (p[i] == x[1])
                    answer++;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
#include<stdio.h>

int main(){
  long  x,y,cnt,tmp;
  scanf("%ld %ld",&x,&y);
  cnt=1;
  tmp=x;
  while(1){
    tmp *=2;
    if(tmp>y){
      break;
    }else{
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)



//--------------入力受け取る場所----------------------------------------------------
intl n,m;
intl a,b,c,d;
string s,t;

void input_var(){
    cin >> s >> t;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl ma = 0;
    intl tlen = t.length();
    intl slen = s.length();
    rep(i, slen - tlen + 1){
        intl cnt = 0;
        rep(j, tlen){
            if(s[i + j] == t[j])cnt++;
        }
        ma = max(ma, cnt);
    }
    cout << tlen - ma << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
   int a[]=new int[n];
    for(int i=0;i<n;i++){
a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    int res=0;
    for(int i=0;i<k;i++){
		res+=a[i];
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 38892
let rec seq a b = if a >= b then [] else a :: seq (a+1) b
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let h = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.sort (-) h;
  seq 0 (n+1-k) |> List.map (fun i -> h.(i+k-1) - h.(i))
  |> List.fold_left min h.(n-1)
  |> Printf.printf "%d\n"
    


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<vector<int>> ans(n);
    int maxx=0;
    while((1<<maxx)<n)maxx++;
    rep(i,0,n-1){
        ans[i].resize(n-i);
        rep(j,i,n-1){
            int b=-1;
            rep(k,0,maxx)if(((i>>k)&1)!=(((j+1)>>k)&1))b=k;
            ans[i][j-i]=b;
        }
    }
    rep(i,0,n-1){
        rep(j,0,n-i-1)printf("%d ",ans[i][j]+1);
        printf("\n");
    }
    return 0;
}


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

#define PI 3.141592653589793238

int main(void)
{
	int a, b, c;
	double s, l, h;

	scanf("%d%d%d", &a, &b, &c);

	s = sin(c * PI / 180.0) * a * b / 2;
	l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * PI / 180.0));
	h = s / a * 2;

	printf("%lf %lf %lf\n", s, l, h);

	return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 310

ll A[SIZE][SIZE], B[SIZE][SIZE], C[SIZE][SIZE];

int main() {
   int n;
   scanf("%d", &n);
   for (int i = 1 ; i <= n ; ++i) {
      for (int j = 1 ; j <= n ; ++j) {
         if (i != j) B[i][j] = INF;
         else B[i][j] = 0;
         C[i][j] = 0;
         scanf("%lld", &A[i][j]);
      }
   } 

   for (int i = 1 ; i <= n ; ++i) {
      for (int j = 1 ; j <= n ; ++j) {
         if (A[i][j] != A[j][i]) {
            printf("-1\n");
            return 0;
         }
      }
   }

   for (int i = 1 ; i <= n ; ++i) {
      for (int j = 1 ; j <= n ; ++j) {
         if (j == i) continue;
         ll mn = 1e15;
         for (int k = 1 ; k <= n ; ++k) {
            if (i == k || j == k) continue;
            mn = min (A[i][k] + A[k][j], mn);
         }
         if (mn < A[i][j]) {
            printf("-1\n");
            return 0;
         }
         if (mn > A[i][j]) C[i][j] = B[i][j] = A[i][j];
      }
   }

   for (int k = 1 ; k <= n ; ++k) {
      for (int i = 1 ; i <= n ; ++i) {
         for (int j = 1 ; j <= n ; ++j) {
            B[i][j] = min (B[i][j], B[i][k] + B[k][j]);
         }
      }
   }

   ll sum = 0;
   for (int i = 1 ; i <= n ; ++i) {
      for (int j = 1 ; j <= n ; ++j) {
         if (B[i][j] != INF && A[i][j] != B[i][j]) {
            printf("-1\n");
            return 0;
         }
         sum += C[i][j];
      }
   }
   printf ("%lld\n", sum / 2);

   return 0;
}


Measured memory_bytes: 2432
#!/usr/bin/env run-cargo-script

#![allow(unused_imports, unused_macros)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(x: u32, t: u32) -> u32 {
    if x < t { 0 } else { x - t }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void) {

  int n;
  int k;
  int arr[10000];
  int i;
  int t;
  int t_n;
  int count = 0;
  
  scanf("%d %d", &n, &k);

  for (i = 0; i < n; i++) {
    scanf("%d",&t);
    arr[i] = t;
  }
  
  t_n = n;
  t_n -= k;
  count++;

  count += (t_n / (k-1));
  if (t_n % (k-1) != 0) {
    count++;
  }

  printf("%d\n",count);
  
  return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,q;
  cin >> n >> q;
  int s[n],t[n],x[n];

  vector<PII> dist;
  rep(i,n){
    cin >> s[i] >> t[i] >> x[i];
    dist.push_back({x[i],i});
  }
  sort(all(dist));
  int tmp;
  set<pair<int,int>> dd;
  rep(i,q){
    cin >> tmp;
    dd.insert({tmp,i});
  }

  VI ans(q);

  rep(i,n){
    int d = dist[i].first;
    int idx = dist[i].second;
    int ss = s[idx] - d;
    int tt = t[idx] - d;
    auto itr = dd.lower_bound({ss,-1});
    while(itr != dd.end() && itr->first < tt ){
      //cout << "ans " << itr->second << " is " << d << ", " << itr->first << "is rm" << endl;
      ans[itr->second] = d;
      dd.erase(itr++);
    }
  }
  for(PII p: dd){
    ans[p.second] = -1;
  }

  rep(i,q){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 16368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if (s.size()%2) cout << "No" << endl;
  else {
    bool flag = 1;
    rep(i, s.size()/2) {
      if (s.at(2*i)=='h' && s.at(2*i+1)=='i') continue;
      flag = 0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      City[] city = new City[m];
      City[] city2 = new City[m];
      int[] p = new int[n+1];

      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city[i] = new City(i, x, y);
        city2[i] = city[i];
      }

      Arrays.parallelSort(city2, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      for(int i=0; i<m; i++) {
        city2[i].no = ++p[city2[i].p];
      }

      // String no;
      StringBuilder buf1 = new StringBuilder();
      StringBuilder buf2 = new StringBuilder();
      String[] pre0 = {"000000","00000","0000","000","00","0",""};
      for(int i=0; i<m; i++) {
        // no = String.format("%06d%06d", city[i].p,city[i].no);
        buf1.append(city[i].p);
        // for(int j=buf1.length(); j<6; j++)
        //   buf2.append("0");
        buf2.append(pre0[buf1.length()])
            .append(buf1);
        buf1.setLength(0);
        
        buf1.append(city[i].no);
        // for(int j=buf1.length(); j<6; j++)
        //   buf2.append("0");
        buf2.append(pre0[buf1.length()])
            .append(buf1).append('\n');
        buf1.setLength(0);
        // out.println(no);
      }
      // out.flush();
      System.out.print(buf2);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int s, int p, int y) {
      this.s = s;
      this.p = p;
      this.y = y;
    }
  }
}

Measured memory_bytes: 54260
#include <iostream>
#include <complex>
 
using namespace std;
 
int main()
{
	int x;
 
	cin >> x;
 
	int max = sqrt(x);
 
	int a = 1;
 
	for (int i = 2; i <= max; i++)
	{
		int n = i;
		while (1)
		{
			if (n*i <= x) n = n*i;
			else break;
		}
 
		if (a < n)a = n;
	}
 
	cout << a;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18L + 5;
int main(int argc, const char** argv) {
    int N,W,i,j;
    int total_value=0;

    cin>>N>>W;
    vector<int> weight(N),value(N);

    for(i=0;i<N;i++)
        cin>>weight[i]>>value[i];

    for(int k:value)
        total_value += k;

    vector<ll> dp(total_value+1, INF);         //dp[i] is minimum total weight of items with total values exactly i
    dp[0] = 0;

    for(i=0;i<N;++i){
        for(j = total_value - value[i];j>=0;--j)
            dp[j+value[i]] = min(dp[j+value[i]],dp[j]+weight[i]);
    }

    ll ans= 0;
    for(i=0;i<=total_value;++i)
        if(dp[i]<=W)
            ans = max(ans,(ll)i);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()

    if (n == 0) {
        println(0)
        return
    }


    var result = ""
    while (n != 0) {
        var r = (n % -2)
        if (r == 0) {
            result = '0' + result
        } else {
            result = '1' + result
        }
        if (r < 0) {
            n += r
        }

        n /= -2

    }
    println(result)

}

Measured memory_bytes: 29912
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

from decimal import *

getcontext().prec = 28      # デフォルト28桁のところを20桁にする


A, B, C = input_int()

A = Decimal(A).sqrt()
B = Decimal(B).sqrt()
C = Decimal(C).sqrt()



if (A+B) < C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61548
import sys
input = sys.stdin.readline

import numpy as np

mod = 10**9+7

n = int(input())
*a, = map(int, input().split())
a = np.array(a)

ans = 0
for i in range(60):
    bits = np.count_nonzero(a&1)
    ans += 2**i*bits*(n-bits)
    a >>= 1
    
print(ans%mod)



Measured memory_bytes: 48816
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> b;
	for (int i = 2; i <= b; i++)
	{
		n = i;
		a = 2;
		//10進数の桁数を取得
		while (n >= a * a) {
			// a で割り切れたら、a は素因数
			// そして、割られる数を a で割る
			// a で割り切れなかったら、 a を 1 増加させる
			if (n % a == 0) {
				//printf("%d * ", a);
				x[a]++;
				n /= a;
			}
			else {
				a++;
			}
		}
		x[n]++;
	}
	ans = 1;
	for (int i = 0; i <= b; i++)
	{
		ans *= x[i] + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

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

    vector<pair<int, int>> p(n, pair<int, int>());
    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i).first >> p.at(i).second;
        x.at(i) = p.at(i).first;
        y.at(i) = p.at(i).second;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int64_t res = INT64_MAX;
    for (int il = 0; il < n; il++)
    {
        int64_t xl = x.at(il);
        for (int ir = il + 1; ir < n; ir++)
        {
            int64_t xr = x.at(ir);
            for (int ib = 0; ib < n; ib++)
            {
                int64_t yb = y.at(ib);
                for (int it = ib + 1; it < n; it++)
                {
                    int64_t yt = y.at(it);

                    int cnt = 0;
                    for (int i = 0; i < n; i++)
                    {
                        int64_t xi = p.at(i).first, yi = p.at(i).second;
                        if (xi < xl || xr < xi)
                            continue;
                        if (yi < yb || yt < yi)
                            continue;
                        cnt++;
                    }

                    if (cnt >= k)
                    {
                        int64_t w = xr - xl, h = yt - yb;
                        int64_t s = w * h;
                        if (s < res)
                            res = s;
                    }
                }
            }
        }
    }

    cout << res << endl;
}

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

int main() {
  long long a, sum = 0; cin >> a;
  for(long long i = 1; i <= a; i++)
  if(i%3 != 0 && i%5 != 0) sum += i;
  cout << sum;

  return 0;
}

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

import heapq

def ans() :
    n, m  = map(int, input().split())
    aa = map(int, input().split())
    a = []
    for i in aa:
        heapq.heappush(a, int(i) * (-1))

    for i in range(m):
        head = heapq.heappop(a)
        head = (-1) * (-head // 2)
        heapq.heappush(a, head)

    print(-sum(a))

if __name__ == '__main__':
    ans()

Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;
static const ll MAX = 100001;
vector <ll> G[MAX];
int NIL = -1;

struct prob{
    ll num, diss = NIL, disf = NIL;
};

prob lis[MAX];

void bfsf(ll u){
    queue <ll> Q;
    Q.push(u);
    lis[u].disf = 0;
    while(!Q.empty()){
        ll v = Q.front();
        Q.pop();
        for (ll i = 0;i<G[v].size();i++){
            if(lis[G[v][i]].disf == NIL){
                lis[G[v][i]].disf = lis[v].disf + 1;
                Q.push(G[v][i]);
            }
        }
    }
}

void bfss(ll u){
    queue <ll> Q;
    Q.push(u);
    lis[u].diss = 0;
    while(!Q.empty()){
        ll v = Q.front();
        Q.pop();
        for (ll i = 0;i<G[v].size();i++){
            if(lis[G[v][i]].diss == NIL){
                lis[G[v][i]].diss = lis[v].diss + 1;
                Q.push(G[v][i]);
            }
        }
    }
}

int main() {
    
    ll n;
    cin >> n;
    for (ll i = 1;i<n;i++){
        ll a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (ll i=1;i<=n;i++){
        prob p;
        p.num = i;
        lis[i] = p;
    }
    bfsf(1);
    bfss(n);
    ll numf = 0;
    ll nums = 0;
    for (ll i=1;i<=n;i++){
        if(lis[i].disf <= lis[i].diss){
            numf += 1;
        }else{
            nums += 1;
        }
    }
    if(numf > nums){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }

}

Measured memory_bytes: 8876
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n;
    cin >> n;
    vi num(4);
    rep(i,4)
    {
        num[i]=n%10;
        n/=10;
    }
    if((num[0]==num[2]&&num[0]==num[1])||(num[1]==num[3]&&num[1]==num[2]))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import Counter

s = input()
t = input()

s_cnt = Counter(s).most_common()
t_cnt = Counter(t).most_common()

for i in range(min(len(s_cnt), len(t_cnt))):
    if s_cnt[i][1] != t_cnt[i][1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=1e6+6;
int w[N],v[N];
ll dp[N];
int main()
{

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

	int n,we; cin>>n>>we;
	memset(dp,0x3f,sizeof dp);
	for(int i=1; i<=n; i++) {
		cin>>w[i]>>v[i];
	}
	dp[0]=0;
	for(int i=1; i <=n; i++)
		for(int j=1000000-v[i]; j>=0; j--)
			dp[j+v[i]] = min(dp[j+v[i]], w[i] + dp[j]);


	ll ans=-1;
	for(int i=1000000; i>=0; i--) {
		if(dp[i]<=we) {
			cout<<i<<endl; return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 10496
#include "bits/stdc++.h"
using namespace std;

vector<int> g[2][101010];
vector<int> gg[202020];
vector<int> ans;
int used[101010];

int dfs(int v, int k, vector<vector<int>> &zero) {
        vector<int> matching;
        if (!zero[k][v]) matching.push_back(v);
        for (int u : g[k][v]) {
                int get = dfs(u, k, zero);
                if (get == -1) continue;
                matching.push_back(get);
        }
        if (g[k][v].size() == 0) return (zero[k][v] ? -1 : v);
        while (matching.size() >= 2) {
                int s1 = matching.back();
                matching.pop_back();
                int s2 = matching.back();
                matching.pop_back();
                gg[s1].push_back(s2);
                gg[s2].push_back(s1);
        }
        if (matching.size() == 1) return matching[0];
        else return -1;
}

void coloring(int v, int w) {
        used[v] = true;
        ans[v] = w;
        for (int u : gg[v]) if (!used[u]) {
                coloring(u, -w);
        }
}

int main() {
        int n, a;
        cin >> n;
        vector<int> root(2);
        for (int k = 0; k < 2; k ++) {
                for (int i = 0; i < n; i ++) {
                        cin >> a;
                        if (a == -1) { 
                                root[k] = i;
                        } else { 
                                a --;
                                g[k][a].push_back(i);
                        }
                }
        }
        vector<vector<int>> zero(2, vector<int> (n, false));
        for (int k = 0; k < 2; k ++) {
                for (int i = 0; i < n; i ++) {
                        if (g[k][i].size() & 1) zero[k][i] = true;
                }
        }
        bool ok = true;
        for (int i = 0; i < n; i ++) ok &= zero[0][i] == zero[1][i];
        if (!ok) {
                cout << "IMPOSSIBLE" << endl;
                return 0;
        }
        for (int k = 0; k < 2; k ++) dfs(root[k], k, zero);
        ans.resize(n, 0);
        for (int i = 0; i < n; i ++) {
                if (!zero[0][i] && !used[i]) { 
                        coloring(i, 1);
                }
        }
        cout << "POSSIBLE" << endl;
        for (int i = 0; i < n; i ++) cout << ans[i] << (i == n - 1 ? '\n' : ' ');
        return 0;
}


Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))
 
constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;
double A, B, H, M;
 
int main(){
  cin >> A >> B >> H >> M;
  double Htheta = (360/12)*H + 360/12/(double)60*M, Mtheta = (360/60)*M;
  double theta = max(Htheta, Mtheta) - min(Htheta, Mtheta);
  theta = min(theta, 360-theta);
  // theta = Htheta - Mtheta;
  double pi = acos(-1);
  double ans = A*A+B*B-2*A*B*cos(2*pi*theta/(double)360);
  printf("%.9f\n", sqrt(ans));
  return 0;
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
bool isPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return n!=1;
}
vi divisor(int n){
    vi res;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            res.pb(i);
            if(i!=n/i)res.pb(n/i);
        }
    }
    return res;
}
map<int,int> primeFactor(int n){
    map<int,int> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1){
        res[n]=1;
        return res;
    }
}
const int MAX_N=100000;
int prime[MAX_N];
bool is_prime[MAX_N+1];
int sieve(int n){
    int p=0;
    REP(i,n+1){
        is_prime[i]=true;
    }
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}
int main(){
    sieve(MAX_N+1);
    vi ans(MAX_N+1);
    REP(i,MAX_N+1){
        if(i%2){
            if(is_prime[i]&&is_prime[(i+1)/2]){
                ans[i]++;
            }
        }
    }
    FOR(i,1,MAX_N+1){
        ans[i]+=ans[i-1];
    }
    int q;
    cin>>q;
    REP(i,q){
        int a,b;
        cin>>a>>b;
        cout<<ans[b]-ans[a-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int i,n,l[4],s[4];

  scanf("%d",&n);

  while(n != 0){
    int cnt=0;
    int a=n;

    for(i=3;i>=0;i--){
      int aa=a%10;
      l[i]=aa;
      a /= 10;
    }

    if(n == 6174){
      printf("0\n");
    }else if(l[0] == l[1] && l[0] == l[2] && l[0] == l[3]){
      printf("NA\n");
    }else{
     
      while(n != 6174){
	int len1,len2;
	for(len1=0;len1<3;len1++){
	  for(len2=0;len2<3-len1;len2++){
	    if(l[len2] < l[len2+1]){
	      int temp = l[len2];
	      l[len2] = l[len2+1];
	      l[len2+1] = temp;
	    }
	  }
	}   
	
	int j=0;
	for(i=3;i>=0;i--){
	  s[j]=l[i];
	  j++;
	}
	int ll=0,ss=0,ba=1000;
	for(i=0;i<4;i++){
	  ll += l[i]*ba;
	  ss += s[i]*ba;
	  ba /= 10;
	}
	n = ll - ss;
	cnt++;
	a=n;
	for(i=3;i>=0;i--){
	  int aa=a%10;
	  l[i]=aa;
	  a /= 10;
	}
      }
      printf("%d\n",cnt);
    }
    scanf("%d",&n);
  }
  return 0;
}



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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    ll K;
    cin >> K;
    int N = s.size();
    for(int i = 0; i < N; i++) {
        if (s[i] == 'a') continue;
        int req = 'z' - s[i] + 1;
        if (K >= req) {
            K -= req;
            s[i] = 'a';
        }
    }
    K %= 26;
    for(int i = 0; i < K; i++) {
        if (s[N - 1] < 'z') s[N - 1]++;
        else s[N - 1] = 'a';
    }
    cout << s << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
typedef pair<int,bool> P;

const int MAX_N=1e5;

set<P> G[MAX_N];

typedef pair<int,int> edge;

int main(){
	stack<edge> st;
	int N;
	scanf("%d",&N);
	REP(i,N-1){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;
		b--;
		G[a].insert(P(b,false));
		G[b].insert(P(a,false));
	}
	REP(i,N-1){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;
		b--;
		G[a].insert(P(b,true));
		G[b].insert(P(a,true));
		st.push(edge(a,b));
	}
	int c=0;
	while(!st.empty()){
		edge e=st.top();
		st.pop();
		int from=e.first,to=e.second;
		auto ite=G[from].find(P(to,false));
		if (ite!=G[from].end()){
			auto ite2=ite;
			ite2++;
			if (ite2!=G[from].end() && ite2->first==to){
				if (G[from].size()<G[to].size()){
					swap(from,to);
				}
				c++;
				G[from].erase(P(to,false));
				G[from].erase(P(to,true));
				G[to].erase(P(from,false));
				G[to].erase(P(from,true));
				for(auto ite3=G[to].begin();ite3!=G[to].end();){
					st.push(edge(from,ite3->first));
					G[ite3->first].erase(P(to,ite3->second));
					G[ite3->first].insert(P(from,ite3->second));
					G[from].insert(*ite3);
					ite3=G[to].erase(ite3);
				}
			}
		}
	}
	if (c==N-1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 24448
#include<cstdio>
#include<vector>
#include<map>

using namespace std;

char col[200000];
vector<pair<int,int> > G[200000];

void dfs(int cur, int pre, char c) {
    col[cur] = c;
    for(auto v: G[cur]) {
        if(v.first == pre) continue;

        dfs(v.first, cur, (c + v.second)%2);
    }
}

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n-1; i++) {
        int u,v,w;
        scanf("%d%d%d", &u, &v, &w);
        w %= 2;
        u--, v--;
        G[u].push_back(pair<int,int>(v, w));
        G[v].push_back(pair<int,int>(u, w));
    }

    dfs(0, -1, 0);

    for(int i=0; i<n; i++) {
        printf("%d\n", col[i]);
    }
}

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


int dp[30][20][300];


int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
  dp[0][0][0] = 1;
  for (int i = 0; i < 20; ++i) {
    for (int j = 0; j <= 10; ++j) {
      for (int k = 0; k < 159; ++k) {
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][j + 1][k + (i + 1)] += dp[i][j][k];
      }
    }
  }
  int n, k, s; 
  while (cin >> n >> k >> s and n) {
    cout << dp[n][k][s] << '\n';
  }
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

class UnionFind{
  public:
  vector<int> par;
  UnionFind(int n) : par(n,-1) {}
  bool unite(int x,int y){
    x = root(x),y = root(y);
    if(x == y)return false;
    if(par[x] > par[y])swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool find(int x,int y){
    return root(x) == root(y);
  }
  int root(int x){
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
};

int main(){

  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int x,y,z;cin >> x >> y >> z;
    x--,y--;
    uf.unite(x,y);
  }
  int res = 0;
  rep(i,n)if(uf.root(i) == i)res++;
  cout << res << endl;
  



  return 0;
}

Measured memory_bytes: 640
function Main(input) {
	input = input.trim();
  var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  if(A > B + 1){
     console.log(A + (A - 1));
  }else if(B > A + 1){
     console.log(B + (B - 1));
  }else{
     console.log(Math.max(A,B) + Math.min(A,B));
  }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main(){
    int L;
    cin >> L;
    double a = L/3.0;
    cout << fixed << setprecision(12) << a*a*a << endl;

}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int oo=1e18;

void smain() {
    int n;
    cin>>n;
    vpi kek(n);
    for(int i=0;i<n;i++){
        int x,l;
        cin>>x>>l;
        kek[i]={x+l-1,x-l+1};
    }
    sort(ALL(kek));
    int lst=-oo,ans=0;
    for(int i=0;i<n;i++) {
        if(lst>=kek[i].second)
            continue;
        ans++;
        lst=kek[i].first+1;
    }
    cout<<ans;
}

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

using namespace std;


int main()
{
    int a,b,m,mna=1000000,mnb=1000000,ara[100005],arb[100005],c,x,y,p;
    cin>>a>>b>>m;
    for(int i=1;i<=a;i++)
    {
        cin>>ara[i];
        mna=min(mna,ara[i]);
    }
    for(int i=1;i<=b;i++)
    {
        cin>>arb[i];
        mnb=min(mnb,arb[i]);
    }
    int mn=mna+mnb;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>c;
        p=ara[x]+arb[y]-c;
        mn=min(mn,p);
    }
    cout<<mn<<endl;




    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<pr, null_type,less<pr>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,int>
#define ll long long int
#define ld long double
const ll mod=998244353;


//const ll mod=1e9+7;
ll f(ll x,ll n){
    ll r=1;
    while(n){
        if(n%2==1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return r;

}
void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3624
n, k = map(int,input().split())

flag = "No"
if k == 1:
  n = 0
else:
  n = n % k

for i in range(1, 1000000000000000000):
  if abs(n - k) > n:
    print(n)
    flag = "Yes"
    break
  else:
    n = abs(n - k)
if flag == "No":
  print(n)

Measured memory_bytes: 38612
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string u;
        cin >> u;
        S.insert(u);
    }
    int M;
    cin >> M;
    bool open = false;
    while (M--) {
        string t;
        cin >> t;
        if (S.find(t) != S.end()) {
            if (!open) cout << "Opened by " << t << endl;
            else cout << "Closed by " << t << endl;
            open = !open;
        } else cout << "Unknown " << t << endl;
    }
    return 0;
}

Measured memory_bytes: 3256
#include <stdio.h>

int main(void)
{
	int N;
	int array[3];
	int i;
	int j;
	int k;
	int swap;
	
	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%d %d %d", &array[0], &array[1], &array[2]);
		for (j = 0; j < 2; j++){
			for (k = 0; k < 2; k++){
				if (array[k] > array[k + 1]){
					swap = array[k];
					array[k] = array[k + 1];
					array[k + 1] = swap;
				}
			}
		}
		if ((array[0] * array[0]) + (array[1] * array[1]) == array[2] * array[2]){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<stdlib.h>
long minf(long a,long b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}
  
int main(){
  long n = 0;
  long h[100000] = {};
  long dp[100000] = {};
  long k = 0;
  long i = 0;
  long j = 0;
  long min = -1;
  
  scanf("%ld %ld",&n,&k);
  for(i=0;i<n;i++){
    scanf("%ld",&h[i]);
  }
  dp[0] = 0;
  for(i=1;i<n;i++){
    min = -1;
    for(j=1;j<=k;j++){
      if(i-j >= 0){
        if(min == -1){
          min = dp[i-j] + labs(h[i]-h[i-j]);
        }else{
          min = minf(min,dp[i-j]+labs(h[i]-h[i-j]));
        }
      }
    }
    dp[i] = min;
    //printf("%ld,",dp[i]);
  }
  printf("%ld",dp[n-1]);
  return 0;
}
    

Measured memory_bytes: 1664
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

Tuple!(N, N)[] prime_division(N)(N n)
{
    Tuple!(N, N)[] res;
    foreach (N i; 2..10^^3+1) {
        if (n%i == 0) {
            N cnt;
            while (n%i == 0) {
                ++cnt;
                n /= i;
            }
            res ~= tuple(i, cnt);
        }
    }
    if (n != cast(N)1) res ~= tuple(n, cast(N)1);
    return res;
}

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    long[long] memo;
    long[long][] aps;
    foreach (a; AS) {
        auto ps = prime_division(a);
        foreach (p; ps) {
            if (p[0] in memo) {
                memo[p[0]] = max(memo[p[0]], p[1]);
            } else {
                memo[p[0]] = p[1];
            }
        }
    }
    long x = 1;
    foreach (n, k; memo) (x *= pow(n, k)) %= P;
    long r;
    foreach (a; AS) (r += x * inv(a) % P) %= P;
    writeln(r);
}

Measured memory_bytes: 3580