akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

int H, W;

int main(void) {
  cin >> H >> W;
  REP(i, H) REP(j, W) {
    string s;
    cin >> s;
    if (s == "snuke") cout << (char)('A' + j) << (i + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

type Queue struct {
	name string
	time int
}
type Queues [MAX]Queue

var q Queues
var head, tail int

const MAX = 100000

func main() {
	var c, n, t, extime int
	initialize()
	fmt.Scan(&n, &t)
	for i := 1; i <= n; i++ {
		fmt.Scan(&q[i].name, &q[i].time)
	}
	head = 1
	tail = n + 1

	for {
		if head == tail {
			break
		}
		x := dequeue()
		c = comp(t, x.time)
		x.time -= c
		extime += c
		if x.time > 0 {
			enqueue(x)
		} else {
			fmt.Printf("%s %d\n", x.name, extime)
		}
	}
}
func comp(t, u int) int {
	if t <= u {
		return t
	}
	return u
}
func initialize() {
	head = 0
	tail = 0
}
func dequeue() Queue {
	if err := isEmpty(); err != nil {
		fmt.Println(err)
	}
	x := q[head]
	if head+1 == MAX {
		head = 0
	} else {
		head++
	}
	return x
}
func enqueue(x Queue) {
	if err := isFull(); err != nil {
		fmt.Println(err)
	}
	q[tail] = x
	if tail+1 == MAX {
		tail = 0
	} else {
		tail++
	}
}
func isFull() error {
	if head == (tail+1)%MAX {
		return fmt.Errorf("overflow")
	}
	return nil
}
func isEmpty() error {
	if head == tail {
		return fmt.Errorf("underflow")
	}
	return nil
}



Measured memory_bytes: 7812
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum)%MOD;
        sum = (sum * sum) % MOD;
        b >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> line(n);
    REP(i, n){
        cin >> line[i];
    }
    vector<int> sum(n+1, 0);
    REPA(i, n+1){
        sum[i] = sum[i-1] + line[i-1];
    }
    int ans = INF;
    REP(i, n){
        ans = min(ans, abs(sum.back() - sum[i]*2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    char a; cin >> a;
    if ('A' <= a && a <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
#define EPS 0.00000001
using namespace std;

double eq(double x,double y){
  double z=abs(x-y);
  return z<EPS;
}
double di(double x1,double y1,double x2,double y2){
  return sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
}


int n;
double xa,ya,ra,xb,yb,rb;

int main(){
  cin>>n;
  while(n--){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    if     (di(xa,ya,xb,yb)+rb<ra)cout<<"2"<<endl;
    else if(di(xa,ya,xb,yb)+ra<rb)cout<<"-2"<<endl;
    else if(di(xa,ya,xb,yb)<=ra+rb)cout<<"1"<<endl;
    else cout<<"0"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    string hitachi = "";
    rep(i, 5) {
        hitachi += "hi";
        if (hitachi == S) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans[30];
	int temp[30]={0};
	memset(ans,0x3f,sizeof(ans));
    string s;
    for(int i=0;i<n;i++){
    	cin>>s;
    	for(int j=0;j<s.size();j++){
    		temp[s[j]-'a']++;
		}
		for(int j=0;j<26;j++){
			ans[j]=min(ans[j], temp[j]);
		}
		memset(temp,0,sizeof(temp));
	}
	for(int i=0;i<26;i++){
		for(int j=0;j<ans[i];j++){
			char c='a'+i;
			cout<<c;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
vector<int>v;
int ans;
void solve(int n){
for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(n/i !=i)ans++;
			ans++;
		}	
	}
}
int solve2(int n,int k){
	// trace(n,k);
	if(n<=1 || n<k)return n;
	else{
		if(n%k==0){
			return solve2(n/k,k);
		}
		else{
			return solve2(n%k,k);
		}
	}
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		for(int i=1;i*i<=n;i++){
			if(n%i==0){		
				if(n/i !=i)v.pb(n/i);
					v.pb(i);
				}	
		}	
		solve(n-1);	
		for(auto i : v){
			if(i==1)continue;
			if(solve2(n,i)==1)ans++;
		}
		ans--;
		cout<<ans;
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N,M; cin>>N>>M;
    vector<int>left(M);
    vector<int>right(M);
    rep(i,M)cin>>left[i]>>right[i];
    sort(left.begin(),left.end());
    reverse(left.begin(),left.end());
    sort(right.begin(),right.end());
    int ans =right[0]-left[0]+1;
    if(ans>0){
    cout<<ans<<endl;
    }
    else cout<<0<<endl;


}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Sentou
            var line = ReadLine().ToList();
            int n = (int)line[0];    //スイッチの押された回数
            int t = line[1];    //お湯の出続ける秒数

            long totalTime = CalcTotalTimeOfHotWater(n, t);
            Console.WriteLine(totalTime);
        }

        static long CalcTotalTimeOfHotWater(int n, int t)
        {
            var people = ReadLine().ToList();

            int startTime = 0;
            int endTime = t;
            long sum = 0;

            for(int i = 1; i < n; i++)
            {
                int nextStartTime = people[i];

                if (nextStartTime < endTime)
                {
                    int diff = nextStartTime - startTime;
                    sum += diff;
                }
                else
                {
                    sum += t;
                }

                startTime = nextStartTime;
                endTime = startTime + t;
            }

            return sum + t;
        }

        static IEnumerable<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');

            foreach (var s in array)
            {
                yield return int.Parse(s);
            }
        }
    }
}

Measured memory_bytes: 28640
import java.util.Scanner;

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

        if (n > k) {
            n = n % k;
        }

        System.out.println(Math.min(k - n, n));
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 998244353;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

ll d[100005];

set<ll> st;
int main() {
    cin >> n;
    REP(i, 50) {
        st.insert(pow(9, i));
        st.insert(pow(6, i));
    }
    d[0] = 0;
    d[1] = 1;
    FOR(i, 2, n + 1) {
        if (st.count(i) != 0) {
            d[i] = 1;
        } else if (i > 6 && i < 9) {
            d[i] = min({ d[i - 1] + 1, d[i - 6] + 1 });
        } else if (i > 9) {
            d[i] = min({ d[i - 1] + 1, d[i - 6] + 1,d[i - 9] + 1 });
            FOR(j, 2, n) {
                cnt = pow(6, j);
                if (i > cnt) {
                    chmin(d[i], d[i - cnt] + 1);
                } else {
                    break;
                }
            }
            FOR(j, 2, n) {
                cnt = pow(9, j);
                if (i > cnt) {
                    chmin(d[i], d[i - cnt] + 1);
                } else {
                    break;
                }
            }
        } else {
            d[i] = d[i - 1] + 1;
        }
    }
    cout << d[n] << endl;
}

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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using ld = long double;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

// no change 
const ll MOD = 1e9+7;  
int n;
void Titan(){
	cin >> n;
	cout<< ((1000 - n%1000) == 1000 ? 0 : (1000 - n%1000));



}

int main() {
	FASTER;
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T)Titan();
}
		

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


def main():
    n = int(input())
    a = sorted([int(input()) for _ in range(n)], reverse=True)
    ans = 0
    center = n // 2

    # See:
    # http://drken1215.hatenablog.com/entry/2018/10/28/222800
    # KeyInsight
    # a > b < c > d < e ...
    # a < b > c < d > e ...の形で決め打ちしてよい
    # それぞれの係数に着目する
    if n % 2 == 0:
        ans += sum(a[:center - 1]) * 2
        ans += a[center - 1]
        ans -= a[center]
        ans -= sum(a[center + 1:]) * 2
    else:
        ans1 = 0
        ans1 += sum(a[:center - 1]) * 2
        ans1 += a[center - 1]
        ans1 += a[center]
        ans1 -= sum(a[center + 1:]) * 2

        ans2 = 0
        ans2 += sum(a[:center]) * 2
        ans2 -= a[center]
        ans2 -= a[center + 1]
        ans2 -= sum(a[center + 2:]) * 2
        ans = max(ans1, ans2)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int H, A;
    std::cin >> H >> A;

    if (H % A == 0) {
        std::cout << H / A << std::endl;
    } else {
        std::cout << (H / A) + 1 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K, Q) = read!(usize, i64, usize);
    let A = read![usize; Q];

    let mut S = vec![K - Q as i64; N];
    for q in 0..Q {
        let a = A[q] - 1;
        S[a] += 1;
    }

    for i in 0..N {
        println!("{}", if S[i] > 0 { "Yes" } else { "No" });
    }
}


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

#define INF 1<<21
#define BLACK 0
#define GRAY 1
#define WHITE 2

int prim(int n, int **A, int *d, int *p) {
  int *color = new int[n];

  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INF;
  }

  d[0] = 0;
  p[0] = -1;

  while (true) {
    int mincost = INF;
    int u;
    for (int i = 0; i < n; i++) {
      if ((color[i] != BLACK) && (d[i] < mincost)) {
        mincost = d[i];
        u = i;
      }
    }

    if (mincost == INF) {
      break;
    }

    color[u] = BLACK;

    for (int v = 0; v < n; v++) {
      if ((color[v] != BLACK) && (A[u][v] != INF)) {
        if (A[u][v] < d[v]) {
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }

  }

  delete color;

  return 0;
}

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

  int **A = new int*[n];
  for (int i = 0; i < n; i++) {
    A[i] = new int[n];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int w;
      cin >> w;
      if (w == -1) {
        A[i][j] = INF;
      }
      else {
        A[i][j] = w;
      }
    }
  }

  int *d = new int[n];
  int *p = new int[n];
  prim(n, A, d, p);

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += d[i];
  }

  cout << sum << endl;

  for (int i = 0; i < n; i++) {
    delete[] A[i];
  }
  delete[] A;

  delete d;
  delete p;

  return 0;
}


Measured memory_bytes: 3180
#include <math.h>
main(){
    int i,n,s[1000];
    double t,u;
    for(;scanf("%d",&n),n;){
        for(i=t=0;i<n;t+=s[i++])
            scanf("%d",&s[i]);
        for(t/=i,i=u=0;i<n;i++)
            u+=(s[i]-t)*(s[i]-t);
        printf("%.8f\n",sqrt((double)u/n));
    }
}

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

int main() {
  string s;
  cin >> s;
  
  int n;
  n = s.size();
  
  long acc;
  long ans;
  
  ans = 0;
  for(int bit=0; bit<(1<<(n-1)); bit++){
    acc = 0;
  	for(int i=0; i<n; i++){
      acc *= 10;
      acc += s.at(i) - '0';
      if((bit & (1<<i)) == 0){
        ans += acc;
        acc = 0;
      }
    }
    ans += acc;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int sum = 0;
	int min = 1;
	for(int i=0;i<n;i++) {
		if(a[i]==min) min++;
		sum+=(a[i]-1)/min;
		if(min==1) min++;
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> sw(n+1), sb(n+1);
    rep(i, n) {
        if (s[i]=='.') {
            sw[i+1] = sw[i] + 1;
            sb[i+1] = sb[i];
        }
        else {
            sb[i+1] = sb[i] + 1;
            sw[i+1] = sw[i];
        }
    }
    int ans = n+5;
    rep(i, n+1) {
        int x = sb[i];
        int y = sw[n] - sw[i];
        chmin(ans, x+y);
    }
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int D[114514];
    cin >> N;
    REP(i,N){
        cin >> D[i];
    }
    sort(D,D+N);
    int M=N/2;
    cout << D[M]-D[M-1] << endl;
    return 0;
}



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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

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

    int size = s.size();
    cout << s.at(0) << size - 2 << s.at(size - 1) << endl;
}

Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef long double Double;

const int N = 4e5 + 5;

bool valid(int median, const vector<pair<int, int>>& v, bool lowest) {
  int tmp = 0;
  for (auto& x : v) {
    if (lowest) {
      tmp += x.first <= median;
    } else {
      tmp += x.second >= median;
    }
  }
  return median >= v.size() / 2;
}

int bs(const vector<pair<int, int>>& v, bool lowest) {
  int low = 0, high = 1e9 + 1, ans = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (valid(mid, v, lowest)) {
      ans = mid;
      if (lowest) {
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    } else {
      if (lowest) {
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;

  vector<pair<int, int>> v(n);
  for (auto& x : v) {
    cin >> x.first >> x.second;
  }

  auto v_a = v;
  sort(all(v_a));
  auto v_b = v;
  sort(all(v_b),
       [](const auto& a, const auto& b) { return a.second < b.second; });

  if (v.size() % 2 == 0) {
    int l1 = v_a[(n - 1) / 2].first;
    int r1 = v_b[(n - 1) / 2].second;
    int l2 = v_a[n / 2].first;
    int r2 = v_b[n / 2].second;
    cout << r2 + r1 - l2 - l1 + 1 << endl;
  } else {
    int lowest = v_a[n / 2].first;
    int highest = v_b[n / 2].second;
    cout << highest - lowest + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 7960
n=int(input())
a=list(map(int,input().split()))
p4=p2=p1=0
for i in a:
    if i%4==0:
        p4 += 1
    elif i%2==0:
        p2 += 1
    else:
        p1 += 1

if p2==0 and p1<= p4+1:
    print('Yes')

elif p2==0 and p1> p4+1:
    print('No')

elif p1 <= p4:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	vi co(26,inf);
	int n;
	cin>>n;
	rep(i,n){
		vi c(26);
		string s;
		cin>>s;
		rep(j,s.size())c[s[j]-'a']++;
		rep(j,26)co[j]=min(co[j],c[j]);
	}
	rep(i,26)if(co[i]!=inf){
		rep(j,co[i])cout<<(char)('a'+i);
	}
	cout<<endl;	
}








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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<"\n";
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX 50004
int dp[MAX], d[MAX];

int main(){
	int n, m = 0;
	static bool c[MAX]={true, true};
	for(ll i = 2;i < MAX;i++){
		if(!c[i]){
			for(ll j = 2;i*j < MAX;j++)c[i*j] = true;
			d[m++] = i;
		}
	}
	
	for(int i = 0;i < 3000;i++)
		for(int j = i;d[i]+d[j] < MAX-3;j++)
			dp[d[i] + d[j]]++;
	while(cin >> n, n)cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3252
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        while(true){
            int a=sc.nextInt();
            int b=sc.nextInt();
            int way =0 ;
            if(a==0&&b==0){
                break;
            }
            for(int i=1;i<=a-2;i++){
                for(int j=i+1;j<=a-1;j++){
                    for(int k=j+1;k<=a;k++){
                        if(i+j+k==b){
                            way++;
                        }
                    }
                }
            }
            System.out.println(way);
        }
        sc.close(); 
    }
}


Measured memory_bytes: 26696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

template <typename T> vector<T> divisor(T a) {
    vector<T> res;
    for (T i = 1; i*i <= a; i++) {
        if(a%i == 0){
            res.push_back(i);
            if(i != a/i) res.push_back(a/i);
        }
    }
    return res;
}


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

    int N;
    cin >> N;
    vi A(N);
    in(N,A);
    set<int> B;
    sort(all(A));
    int ans = 0;
    map<int,int> M;
    rep(i,N) M[A[i]]++;
    
    rep(i,N){
        M[A[i]]--;
        if(M[A[i]] == 0){
            if(B.count(A[i])) continue;
            ve<int> C;
            C = divisor(A[i]);
            int aa = 0;
            rep(i,int(C.size())) if(B.count(C[i])){ aa++; break;}
            if(aa == 0) ans++;
        }
        
        
        B.insert(A[i]);
        
    }
    
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 22752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll cnt[3];
int col[MAXn];
vector<int> e[MAXn];
bool fg;
ll sq(ll x){
    return x * x;
}
void dfs(int x,int c){
    col[x] = c;
    for (auto i:e[x]) {
        if (col[i] != -1) {
            if ((col[i] ^ col[x]) == 0) fg = false;
        }
        else dfs(i,c^1);
    }
}
int main(){
    IOS();
    int n,m;
    cin >> n >> m;
    REP (i,m) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        e[u].eb(v);
        e[v].eb(u);
    }
    REP (i,n) if (SZ(e[i]) == 0) cnt[0]++;
    RST(col,-1);
    REP (i,n) {
        if (SZ(e[i]) != 0) {
            if (col[i] == -1) {
                fg = true;
                dfs(i,0);
                if (fg) cnt[1]++;
                else cnt[2]++;
            }
        }
    }
    ll ans = 2 * cnt[0] * n - sq(cnt[0]) + 2 * sq(cnt[1]) + 2 * cnt[1] * cnt[2] + sq(cnt[2]);
    cout << ans << endl;
}


Measured memory_bytes: 13368
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int pas[n+1];
  for(int i=0;i<=n;i++) pas[i] = 0;
  int d,c;
  for(int i=0;i<m;i++){
    cin >> d >> c;
    pas[d] = c;
  }
  int pd[2][3]={0,0};
  int mem[2][3]={0,0};
  if(pas[1]==0) pd[0][0]=pd[0][1]=pd[0][2]=1;
  else pd[0][pas[1]-1]=1;
  for(int i=2;i<=n;i++){
    if(pas[i]==0||pas[i]==1){
      mem[0][0] = pd[0][1]+pd[1][1]+pd[0][2]+pd[1][2];
      mem[1][0] = pd[0][0];
    }
    if(pas[i]==0||pas[i]==2){
      mem[0][1] = pd[0][0]+pd[1][0]+pd[0][2]+pd[1][2];
      mem[1][1] = pd[0][1];
    }
    if(pas[i]==0||pas[i]==3){
      mem[0][2] = pd[0][0]+pd[1][0]+pd[0][1]+pd[1][1];
      mem[1][2] = pd[0][2];
    }
    for(int i=0;i<2;i++){
      for(int j=0;j<3;j++){
	pd[i][j] = mem[i][j]%10000;
	mem[i][j] = 0;
      }
    }
  }
  int ans = 0;
  for(int i=0;i<2;i++){
    for(int j=0;j<3;j++) ans += pd[i][j];
  }
  ans %= 10000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<vector<pair<int, int>>> Tree;
vector<int> colBranches;

void paint(int v, int parent, int numBranch, int color){
    if(numBranch >= 0)colBranches[numBranch] = color;
    int bufColor = 1;
    for(auto child: Tree[v]){
        if(child.second == parent)continue;
        if(color == bufColor)bufColor++;
        paint(child.second, v, child.first, bufColor);
        bufColor++;
    }
}

int main(void){

    int N;
    int abuf, bbuf;
    cin >> N;
    Tree.assign(N, vector<pair<int, int>>());
    colBranches.assign(N-1, 0);

    for(int i=0; i<N-1; i++){
        cin >> abuf >> bbuf;
        abuf--;
        bbuf--;
        Tree[abuf].push_back(pair<int, int>(i, bbuf));
        Tree[bbuf].push_back(pair<int, int>(i, abuf));
    }

    paint(0, -1, -1, -1);

    int size = 0;
    for(auto Branches: Tree){
        size = max(size, (int)Branches.size());
    }

    cout << size << endl;

    for(int i: colBranches)cout << i << endl;

    return 0;
}

Measured memory_bytes: 8320
function Main(input) {
  input = input.trim().split("\n");
  const NK = input[0].split(" ");
  const N = parseInt(NK[0], 10);
  const K = parseInt(NK[1], 10);
  var d = [];
  var A = [];
for(var i=1;i<=2*K;i+=2){
    d = d.concat(parseInt(input[i],10));
    var Ai = input[i+1].split(" ").map(n=>parseInt(n,10))
    A = A.concat(Ai)
}

  var newA = A.filter((v,i)=>{
      return A.indexOf(v) == i
  })
  console.log(N - newA.length)

}

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


Measured memory_bytes: 31760
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int g = 0;
    int ap = 0;
    int bp = 0;
    while (scanner.hasNext()) {
      String line = scanner.nextLine();
      if (line.equals("0")) {
        if (ap > bp) {
          ap = bp < 10 ? 11 : bp + 2;
        } else {
          bp = ap < 10 ? 11 : ap + 2;
        }
        System.out.println(ap + " " + bp);
        break;
      }
      for (int ii = 0; ii < line.length(); ii++) {
        char c = line.charAt(ii);
        if (ii == 0) {
          if (g == 0) {
            continue;
          }
          if (g % 3 != 0) {
            if (c == 'A') {
              ap = bp < 10 ? 11 : bp + 2;
            } else {
              bp = ap < 10 ? 11 : ap + 2;
            }
            System.out.println(ap + " " + bp);
            ap = bp = 0;
          } else {
            if (ap > bp) {
              ap = bp < 10 ? 11 : bp + 2;
            } else {
              bp = ap < 10 ? 11 : ap + 2;
            }
            System.out.println(ap + " " + bp);
            ap = bp = 0;
          }
          continue;
        }
        if (c == 'A') {
          ap++;
        } else {
          bp++;
        }
      }
      g++;
    }
  }
}

Measured memory_bytes: 17152
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <climits>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

double dp[3000][3000];
double p[3001];
int n;

double solve(int i, int j) {

	if (j < 0)
		return 0;
	if (i == n) {
		if (j == 0)
			return 1;
		return 0;
	}

	if (dp[i][j] != -1)
		return dp[i][j];

	dp[i][j] = p[i] * solve(i + 1, j - 1) + (1 - p[i]) * solve(i + 1, j);
	return dp[i][j];
}

double prob(int x) {

	double ans = 0;
	for (int y = x; y <= n; ++y) {
		ans += solve(0, y);
	}
	return ans;
}

int main() {

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	// memset(dp, 10, sizeof(dp));
	for (int i = 0; i < 3000; ++i)
		for (int j = 0; j < 3000; ++j)
			dp[i][j] = -1;
	cout << setprecision(12) << prob(n / 2 + 1);

	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>

using namespace std;

int main(){
    int k;
    string s;

    cin >> k;
    cin >> s;

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

    return 0;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
	double x, q, y;
	while(scanf("%lf", &q), q >= 0.0){
		x = 0.5 * q;
		while(1){
			y = x * x * x - q;
			if(abs(y) < 1e-5 * q){
				break;
			}
			x -= y / (3.0 * x * x);
		}
		printf("%.15f\n", x);
	}
}

Measured memory_bytes: 1084
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	public void run()
	{
		Scanner file = new Scanner(System.in);
		int N = file.nextInt();
		int K = file.nextInt();
		System.out.println(N-K+1);
	}
	
}


Measured memory_bytes: 21844
#include<iostream>
#include<cmath>

using namespace std;

int n;
int h[100001];
int cost[100001];

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> h[i];
  }
  for(int i = 0; i < n; ++i){
    if(i == 0){
      cost[i] = 0;
    }else if(i == 1){
      cost[i] = abs(h[i] - h[i - 1]);
    }
    else{
      cost[i] += min(cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  cout << cost[n - 1] << endl;
}

Measured memory_bytes: 1024
N, M=map(int, input().split())
items=[int(input()) for i in range(M)]
mod=10**9+7
dp=[0 for i in range(N+1)]
dp[0] = 1
is_broken =[1 for i in range(N+1)]

for i in range(M):
    is_broken[items[i]] = 0

for i in range(N):
    if i-1 >= 0:
        dp[i+1] = dp[i]*is_broken[i] + dp[i-1]*is_broken[i-1]
    else:
        dp[i+1] = dp[i]*is_broken[i]
    dp[i+1] %= mod

print(dp[N])

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

int main()
{
	int N, back;
	N = 0; back = 0;
	cin >> N;
	if (N > 0 && N<=10000) {
		back = N % 1000;
		if (back == 0) {
			cout << "0" << endl;
		}
		else {
			cout <<1000 - back << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 3236
def readln():
    import sys
    input = sys.stdin.readline
    return list(map(int, input().split()))


N, M = readln()
AB = [readln() for _ in range(M)]
A = [ab[0]-1 for ab in AB[::-1]]
B = [ab[1]-1 for ab in AB[::-1]]


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def concat(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True


ans = [N * (N - 1) // 2]
uni = UnionFind(N)
for a, b in zip(A, B):
    if uni.root(a) == uni.root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uni.size(a) * uni.size(b))
        uni.concat(a, b)

for a in ans[-2::-1]:
    print(a)


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

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll res = 0;
    if(A<B) swap(A, B);
    res += A;
    A--;
    if(A<B) swap(A, B);
    res += A;
    cout << res << endl;
    return 0;
}

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

const int INF = 1e9;

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

  set<int> s;
  int cnt_3200 = 0;
  for (int i=0; i<n; i++) {
    int ai;
    cin>>ai;
    int tmp = ai / 400;
    if (tmp > 7) {
      ++cnt_3200;
    } else {
      s.insert(tmp);
    }
  }
  cout<<max((int)s.size(), 1)<<" "<<s.size()+cnt_3200<<endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, K;
bool dp[5005];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;
  vint a(N);
  rep(i, N) cin >> a[i];
  sort(all(a));
  int lb = -1, ub = N;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    memset(dp, false, sizeof(dp));
    dp[0] = true;
    rep(i, N) {
      if(i == mb) continue;
      for(int j = K; j >= 0; --j) {
	//dp[min(j+a[i], K)] |= dp[j];
	if(j-a[i] >= 0) dp[j] |= dp[j-a[i]];
      }
    }
    bool flag = false;
    rep(i, K) {
      if(i+a[mb] >= K) flag |= dp[i];
    }
    if(flag) ub = mb;
    else lb = mb;
  }
  cout << ub << endl;

  return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(long &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

long gcd(long x, long y) {
   return y == 0 ? x : gcd(y, x%y);
}
long lcm(long x, long y) {
   return x / gcd(x, y) * y;
}
long gcdall(std::vector<long> xs) {
   return std::accumulate(xs.begin(), xs.end(), xs.front(), gcd);
}
long lcmall(std::vector<long> xs) {
   return std::accumulate(xs.begin(), xs.end(), (long)1, lcm);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); scan(xs);
      long res = lcmall(xs);
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	static int INF = (int)1e9 + 7;
	int N;
	int[][] C;
	
	public void solve(){
		N = nextInt();
		C = new int[N][N];
		for(int i = 0;i < N;i++){
			for(int j = 0;j < N;j++){
				C[i][j] = nextInt();
			}
		}
		long ans = 0;
		for(int i = 0;i < N;i++){
			for(int j = i + 1;j < N;j++){
				ans += Math.min(C[i][j],C[j][i]);
			}
		}
		out.println(ans);
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 28484
from functools import lru_cache
P = 10**9+7
@lru_cache(maxsize=None)
def subcalc(l, r):
    if l > r: return 0
    if r == 0: return 1
    aa, bb = l.bit_length(), r.bit_length()
    if aa == bb:
        return subcalc(l-(1<<aa-1), r-(1<<bb-1))
    if (r & (r+1) == 0) and (l == 0):
        return pow(3, r.bit_length(), P)
    return (subcalc(l, r-(1<<bb-1)) + subcalc(l, (1<<bb-1)-1) + subcalc(0, r-(1<<bb-1))) % P

@lru_cache(maxsize=None)
def calc(L, R):
    if L > R: return 0
    a = L.bit_length()
    b = R.bit_length()
    if b > a:
        return (calc(L, (1<<b-1)-1) + calc(1<<b-1, R)) % P
    a = 1 << L.bit_length() - 1 if L else 0
    return subcalc(L-a, R-a)

L, R = map(int, input().split())
print(calc(L, R))


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i=1;i<10;i++){
    for (int j=1;j<10;j++){
      s.insert(i*j);
    }
  }
  if (s.count(N))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256