akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;

// input
int S;

const int MOD = 1e9 + 7;
const int MAX = 1e6;
ll fac[MAX], finv[MAX], inv[MAX];


void input() {
    cin >> S;
}


void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    input();
    comb_init();
    ll ans = 0;
    for (int i = 1; i <= S / 3; i++) {
        int x = S - 3 * i;
        ans = (ans + comb(x + i - 1, x)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 27064
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N];
  int B[N];
  for(int n=0; n<N; ++n){
    cin >> A[n];
    B[n] = A[n];
  }
  int ans = 0;
  int ans2 = 0;
  int cnt =0;
  for(int j=0; j<N; ++j){
    ans = max(A[j], ans);
  }
  for(int j=0; j<N; ++j){
    if(B[j] == ans && cnt ==0){
      B[j] = 0;
      cnt +=1;
    }
    ans2 = max(B[j], ans2);
  }
  for(int i=0; i<N; ++i){
    if(A[i] == ans) cout << ans2 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
int main(void){
    vector<int> A(3), sub(3);
    int MAX, sum = 0;
    
    for(int i = 0; i < 3; i++){
        cin >> A[i];
    }
    
    sub[0] = abs(A[0] - A[1]);
    sub[1] = abs(A[1] - A[2]);
    sub[2] = abs(A[2] - A[0]);
    
    sort(sub.begin(), sub.end());
    
    cout << sub[0] + sub[1] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
#define N 3332
using namespace std;

const int mo = 1e9 + 7;
int n;
ll f[N], sumFront[N], sumBack[N];
char s[N];

int main() {
	scanf("%d%s", &n, s + 2);
	f[1] = sumFront[1] = sumBack[1] = 1;
	for (int i = 2; i <= n; ++i) {
		if (s[i] == '<')for (int j = 1; j <= i; ++j)f[j] = sumFront[j - 1];
		else for (int j = 1; j < i; ++j)f[j] = sumBack[j];
		for (int j = 1; j <= i; ++j)(sumFront[j] = sumFront[j - 1] + f[j]) %= mo;
		for (int j = i; j >= 1; --j)(sumBack[j] = sumBack[j + 1] + f[j]) %= mo;
		//printf("->%d\n", i);
		//for (int j = 1; j <= i; ++j)printf("%d %lld\n", j, f[j]);
	}
	printf("%lld\n", sumFront[n]);
	return 0;
}


Measured memory_bytes: 256
program walking_takahashi
  implicit none
  integer(16) :: x, k, d, m
  read(*,*) x, k, d
  if (k * d < abs(x)) then
    write(*,'(i0)') abs(merge(k * d + x, x - k * d, x < 0))
    stop
  end if
  m = abs(x) / d
  x = merge(m * d + x, x - m * d, x < 0)
  k = k - m
  if (mod(k, 2_16) == 0) then
    write(*,'(i0)') abs(x)
  else
    write(*,'(i0)') abs(merge(d + x, x - d, x < 0))
  end if
end program walking_takahashi

Measured memory_bytes: 2828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  int sum = p.at(0)/2;
  
  for (int i = 1; i < N; i++) {
    sum += p.at(i);
  }
  cout << sum << endl;
}



Measured memory_bytes: 3620
void main() {
	auto N = ri;
	auto A = iota(N).map!(a => ri).array;
	if(A[0] > 0) { // むりむりのむり(X[0]は0以外の非負整数になれない)
		writeln(-1);
		return;
	}
	foreach_reverse(i; 1..N) {
		if(A[i]-A[i-1] > 1) { // むりむりのむり(数列を作る過程で(後ろ)-(前)が2以上にすることはできない)
			writeln(-1);
			return;
		}
	}
	ulong ans;
	foreach_reverse(i; 1..N) {
		debug writefln("i: %d", i);

		/*
		1, 2, 3, ..., n のような列はn回の操作で作れる
		ex)	1 2 3 4
			0 0 0 0
		1	1 0 0 0
		2	1 2 0 0
		3	1 2 3 0
		4	1 2 3 4
		こういう、iota(1, n+1)のような列を「いいやつ」とする。

		もし A[i] が A[i-1]+1 より小さいなら、A[i]で完成する「いいやつ」を作った後に、
		A[i-1]で完成する別の「いいやつ」を作らないといけない。
		ex) 1 2 3 3
			0 0 0 0
		1	0 1 0 0
		2	0 1 2 0
		3	0 1 2 3	… 1つ目の「いいやつ」が完成

		4	1 1 2 3 … 2つ目の「いいやつ」を作り始める
		5	1 2 2 3
		6	1 2 3 3 … 2つ目の「いいやつ」が完成

		こうして見ると、A[i]とA[i-1]が一つの「いいやつ」の中で存在するなら、その差は1であるから、
		A[i]を作るための操作回数は1回でいい。
		もしA[i]とA[i-1]が一つの「いいやつ」の中で存在しない、すなわちその差が2以上なら、
		まずA[i]のための「いいやつ」を作る回数、すなわちA[i]回の操作が必要。
		*/
		if(A[i] - A[i-1] == 1) ans++;
		else ans += A[i];
	}
	ans.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

ulong[] generate_prime_list(T)(T N) if(isIntegral!T) {
	ulong[] prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N.to!ulong+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
	return prime_list;
}

bool isPrime(ulong n) {
	if(n <= 1) return false;
	else if(n == 2) return true;
	else if(n % 2 == 0) return false;

	foreach(i; iota(3, n.to!double.sqrt.ceil+1, 2)) {
		if(n % i == 0) return false;
	}
	return true;
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n+1;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}


Measured memory_bytes: 4092
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef pair<long long int,long long int> vect;
typedef pair<vect,long long int> seta;

long long int digitsum(long long int n)
{
  if(n==0)
    return 0;
  else
    return n%10+digitsum(n/10);
}

int main()
{
  deque<seta> que;
  long long int K,graph[100001],vortex,count,suchi,res;
  seta temps;
  vect x,y;
  cin >> K;
  REP(i,100001)graph[i] = INF;
  que.push_front(make_pair(make_pair(1,1),0));
  while(1){
    temps = que.front();
    que.pop_front();
    x = temps.first;
    count = temps.second;
    vortex = x.first;
    suchi = x.second;
    
    if(vortex == 0){
      cout << suchi << endl;
      return 0;
    }
    if(graph[vortex] == 0)
      continue;
    graph[vortex] = 0;
    que.push_back(make_pair(make_pair((vortex+1) % K,suchi+1),count+1));
    que.push_front(make_pair(make_pair((vortex*10) % K,suchi),count+1));
  }
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define fi first
#define se second
typedef long long ll;
typedef std::pair < int, int > pr;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
using std::cin;
using std::cout;

inline void reduce(int &x) { x >= mod ? x -= mod : 0; }

int n, m, x, lst, A[N], a[N], b[N], cnt, p[N];
pr P[N];
std::vector < pr > v;

namespace bit {
	int s[N];
	inline int lowbit(int x) { return x & -x; }
	inline void insert(int x, int y) { for (; x <= n; x += lowbit(x)) reduce(s[x]+= y); }
	inline int query(int x, int ret = 0) { for (; x; x -= lowbit(x)) reduce(ret += s[x]); return ret; }
}

inline bool cmp(pr a, pr b) {
	if (a.fi == b.fi) return a.se > b.se;
	else return a.fi < b.fi;
}
inline int dp_solve() {
	int tot;
	std::sort(P + 1, P + cnt + 1, cmp);
	n = std::unique(P + 1, P + cnt + 1) - P - 1;
	for (int i = 1; i <= n; ++i) A[i] = P[i].se;
	std::sort(A + 1, A + n + 1);
	tot = std::unique(A + 1, A + n + 1) - A - 1;
	for (int i = 1; i <= n; ++i) p[i] = std::lower_bound(A + 1, A + tot + 1, P[i].se) - A;
	int ans = 1, cur;
	for (int i = 1; i <= n; ++i) cur = bit::query(p[i] - 1) + 1, reduce(ans += cur), bit::insert(p[i], cur);
	return ans;
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= m; ++i) cin >> b[i], v.push_back(std::make_pair(b[i], 0));
    for (int i = 1; i <= n; ++i) if (a[i] > b[1] && a[i] < b[m]) v.push_back(std::make_pair(a[i], ++cnt));
    std::sort(v.begin(), v.end());
    lst = 0;
	for (int i = 0; i < v.size(); ++i) {
    	if (v[i].se == 0) lst = v[i].fi;
    	else P[v[i].se].fi = v[i].fi - lst;
	}
	std::reverse(v.begin(), v.end());
	lst = 0;
    for (int i = 0; i < v.size(); ++i) {
    	if (v[i].se == 0) lst = v[i].fi;
    	else P[v[i].se].se = lst - v[i].fi;
	}
	cout << dp_solve() << '\n';
}

Measured memory_bytes: 7396
#include <stdio.h>

int main(){
  int a[100];
  int i,j,minj,n,alt,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++)
      if(a[minj]>a[j])minj=j;
    if(i!=minj){
      alt=a[i];
      a[i]=a[minj];
      a[minj]=alt;
      count++;
    }
  }
  for(i=0;i<n-1;i++)printf("%d ",a[i]);
  printf("%d\n%d\n",a[i],count);

  return 0;
}

Measured memory_bytes: 600
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

// union find ------------------------------------------------------

type node struct {
	par  int
	rank int
}

type unionFind []*node

func (u unionFind) root(x int) int {
	if u[x].par == x {
		return x
	}
	u[x].par = u.root(u[x].par)
	return u[x].par
}

func (u unionFind) unite(x, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}

	if u[xr].rank > u[yr].rank {
		u[yr].par = xr
	} else {
		u[xr].par = yr
		if u[xr].rank == u[yr].rank {
			u[yr].rank++
		}
	}
}

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

func main() {
	n := readInt()
	m := readInt()
	uf := make(unionFind, n)
	for i := range uf {
		uf[i] = &node{
			par:  i,
			rank: 0,
		}
	}

	for i := 0; i < m; i++ {
		x := readInt()
		y := readInt()
		readInt()
		x--
		y--
		uf.unite(x, y)
	}

	roots := make(map[int]struct{})
	for _, node := range uf {
		roots[uf.root(node.par)] = struct{}{}
	}

	fmt.Println(len(roots))
}


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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::collections::HashMap;
fn main() {
    input!{
        n: usize,
        a: [i64; n],
    };
    let mut map = HashMap::new();
    for v in a{
        *map.entry(v).or_insert(0) += 1;
    }
    println!(
        "{}",
        map
        .values()
        .filter(|&x| x % 2 == 1)
        .count()
    );
}


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

using namespace std;

/*6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6*/



int main()
{
   long long n,m;
   cin >> n >> m;
   int h[n+1];
   int i;
   for(i=1;i<=n;i++)
   {
       cin >> h[i];
   }
   
   int a[m],b[m];
   
   
   vector < vector<int> > v(n+1); 
   
   for(i=1;i<=m;i++)
   {
       cin >> a[i] >> b[i];
       v[a[i]].push_back(b[i]);
       v[b[i]].push_back(a[i]);
   }
   
   int j;
   int count = n;
   
   
   int hmain,htemp;
   
   for(i=1;i<=n;i++)
   {
        hmain = h[i];
        for(j=0;j<v[i].size();j++)
        {
            htemp = h[v[i][j]];
            if(hmain <= htemp)
            {
                count--;
                break;
            }
            else
            {
                continue;
            }
        }
   }
   
   cout << count;
   
   
   /*for(i=1;i<=n;i++)
   {
        for(j=0;j<v[1].size();j++)
        {
            if(h[i] > h[v[i][j]])
            {
                continue;
            }
            else
            {
                count--;
                break;
            }
        }
   }*/
   
   /*cout << count;*/
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
int main()
{ 
	fast 
	stack<char> ss;
	ll i;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<n;i++)
	{
		if(ss.size()==0)
		{
			ss.push(s[i]);
		}
		else
		{
			if(s[i]!=ss.top())
			{
				ss.push(s[i]);
			}
		}
	}
	cout<<ss.size()<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val number: Int = sc.nextLine.split(" ").mkString.toInt
    val root_number = math.sqrt(number).toInt
    if (math.pow(root_number, 2) == number | math.pow(root_number + 1, 2) == number) println("Yes")
    else println("No")
  }
}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
ll n, a[N];
ll b[N];

ll ans ;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	ll n;
	cin >> n;
	ll l = 0, r = 50 * 1e16L + 10;
	fo(i, n)
		cin >> a[i];
	while(true)
	{
		int ok = 0;
		fo(i, n)
		{
			ll cnt = a[i] / n;
			if(cnt > 0)
				ok = 1;
			ans += cnt;
			a[i] %= n;
			for(int j = 1; j <= n; j++)
				if(j != i)
					a[j] += cnt;
		}
		if(!ok) break;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n,w,A[105],B[105],dp[105][100005];
long long int behmud(int node,int kilo){
	long long int cev=-1000000000;
	if(kilo>w) return -1000000000;
	if(node>n) return 0;
	if(dp[node][kilo]!=-1) return dp[node][kilo];
	cev=max(behmud(node+1,kilo),cev);
	cev=max(behmud(node+1,kilo+A[node])+B[node],cev);
	return dp[node][kilo]=cev;
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&w);
	for(int i=1;i<=n;i++) scanf("%lld %lld",&A[i],&B[i]);
	long long int ty=behmud(1,0);
	printf("%lld",ty);
	
	
	return 0;
}


Measured memory_bytes: 82304
S = input()

mod = 10 ** 9 + 7
ALL, A, AB, ABC = 1, 0, 0, 0

for s in S:
    if s == 'A':
        A = (A + ALL) % mod
    elif s == 'B':
        AB = (AB + A) % mod
    elif s == 'C':
        ABC = (ABC + AB) % mod
    elif s == '?':
        ABC = (3 * ABC + AB) % mod
        AB = (3 * AB + A) % mod
        A = (3 * A + ALL) % mod
        ALL = 3 * ALL % mod

print(ABC % mod)


Measured memory_bytes: 3188
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		char[] c = sc.next().toCharArray();
		int max = 0;
		int count = 0;

		for (int i = 0; i < c.length; i++) {
			if (c[i] == 'A' || c[i] == 'C' || c[i] == 'G' || c[i] == 'T') {
				count += 1;
			} else {
				max = Math.max(max, count);
				count = 0;
			}
		}
		max = Math.max(max, count);
		sc.close();

		System.out.println(max);
	}
};

Measured memory_bytes: 35592
#include <stdio.h>

int main(){
    int N;
    int A, min =1000000000, max = 0;

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&A);
        if(A < min){
            min = A;
        }
        if(A > max){
            max = A;
        }
    }
    printf("%d\n", max - min);
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);

  
  for(int i = 0; i < N; i++){
	cin >> x.at(i);
  }
  
  int ans = 0;
  
    for(int i = 0; i < N; i++){
	int num = min( x.at(i) , K - x.at(i));
      ans += num * 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    scan!(s; String);

    let mut r: u128 = 0;
    let mut g: u128 = 0;
    let mut b: u128 = 0;

    let mut s2 = Vec::with_capacity(n);

    for c in s.chars() {
        match c {
            'R' => r += 1,
            'G' => g += 1,
            'B' => b += 1,
            _ => (),
        }
        s2.push(c);
    }

    let mut res: u128 = r * g * b;
    let s = s2;

    for k in 1..n {
        for i in 0..k {
            if (k + i) % 2 == 1 { continue; }
            let j = (i + k) / 2;

            if s[i] == s[j] || s[i] == s[k] || s[j] == s[k] {
                continue;
            }

            res -= 1;
        }
    }

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


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

using namespace std;
int n,maxim,ans,lgmax,pozmax,lungime1[100001],lungime2[100001],poz;
pair<int,int> v[100001];
bool comp(pair<int,int> a, pair<int,int> b)
{
    if(a.first<b.first)
        return 1;
    else if(a.first==b.first&&a.second>b.second)
        return 1;
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i].first>>v[i].second;
    sort(v+1,v+n+1,comp);
    for(int i=1;i<=n;i++)
        if(v[i].second-v[i].first+1>lgmax)
    {
        lgmax=v[i].second-v[i].first+1;
        poz=i;
    }
    ans+=lgmax;
    int l=1;
    int r=1000000000;
    for(int i=1;i<=n;i++)
        if(i!=poz)
    {
        l=max(v[i].first,l);
        r=min(v[i].second,r);
    }
    ans+=max(0,r-l+1);
    maxim=ans;
    l=1;
    r=1000000000;
    for(int i=1;i<=n;i++)
    {
        l=max(v[i].first,l);
        r=min(v[i].second,r);
        lungime1[i]=max(0,r-l+1);
    }
    l=1;
    r=1000000000;
    for(int i=n;i>=1;i--)
    {
        l=max(v[i].first,l);
        r=min(v[i].second,r);
        lungime2[i]=max(0,r-l+1);
        if(i>1)
        {
            if(lungime2[i]+lungime1[i-1]>maxim)
                maxim=lungime2[i]+lungime1[i-1];
        }
    }
    cout<<maxim;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  char c; cin>>c;
  locale l = locale::classic();
  if(isupper(c)){
    cout<<'A'<<endl;
  }else{
    cout<<'a'<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
int main(){
  int x,y,z,i,j,k;
  cin >> x >> y >> z >> k;
  vector<long int>a(x);
  vector<long int>b(y);
  vector<long int>c(z);
  vector<long int>f(x*y);
  vector<long int>s(k*z);
  for(i=0;i<x;i++) cin >> a.at(i);
  for(i=0;i<y;i++) cin >> b.at(i);
  for(i=0;i<z;i++) cin >> c.at(i);
  for(i=0;i<x;i++) for(j=0;j<y;j++) f.at(y*i+j)=a.at(i)+b.at(j);
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  for(i=0;i<min(x*y,k);i++) for(j=0;j<z;j++) s.at(z*i+j)=f.at(i)+c.at(j);
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  for(i=0;i<k;i++) cout << s.at(i) << endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,n;
	cin>>h>>n;
	
	vector<pii> vp;
	REP(i,n){
		int a,b;
		cin>>a>>b;
		vp.push_back(pii(b,a));
	}
	sort(ALL(vp));
	
	vi dp(h+1,INF);
	dp[h]=0;
	for(int i=h-1;i>=0;--i){
		REP(j,n){
			if(i+vp[j].second>h){
				dp[i]=min(dp[i],vp[j].first);
				break;
			}
			dp[i]=min(dp[i],dp[i+vp[j].second]+vp[j].first);
		}
	}
	//line(dp);
	
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            required = True
            for k in range(N):
                if k == i or k == j:
                    continue
                if A[i][j] > A[i][k] + A[k][j]:
                    print(-1)
                    return
                if A[i][j] == A[i][k] + A[k][j]:
                    required = False
                    break
            if required:
                ans += A[i][j]

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 42588
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
#include <list>

using namespace std; 

int main()
{
    int n,i,j,k;
    cin>>n>>k;
    int a[n],ans[n];
    for(int i=0;i<n;i++)
		cin>>a[i];
	fill(ans,ans+n,2147483647);
	ans[0]=0;
	for(i=1;i<n;i++)
	{
		for(j=1;j<=k;j++)
		{
			if(j<=i)
			{
				ans[i]=min(ans[i],ans[i-j]+abs(a[i]-a[i-j]));
			}
			else 
				break;
		}
	}
	cout<<ans[n-1]<<endl;
    return 0;
}

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

using ll = long long;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> l(M), r(M);
  for (int i = 0; i < M; i++) {
    cin >> l[i] >> r[i];
  }

  sort(l.begin(), l.end());
  sort(r.begin(), r.end());

  int ans = 0;
  if (r[0]>=l[M-1]) {
    ans = r[0]-l[M-1]+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	int M;
	
	cin >> N >> M;

	int cityRoadCount[N] = { 0 };
	int a[M];
	int b[M];

	for (int i = 0; i < M; i++) {

		cin >> a[i] >> b[i];

		cityRoadCount[a[i] - 1]++;
		cityRoadCount[b[i] - 1]++;
	}
	
	for (int j = 0; j < N; j++) {		
		cout << cityRoadCount[j] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n;
	cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool b = true;
	bool ans = true;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] > a[i + 1]) {
			if (a[i] - a[i + 1] == 1 && b == true) {
				b = false;
			}
			else {
				ans = false;
				break;
			}
		}
		if (a[i] < a[i + 1]) {
			b = true;
		}
	}
	if (ans == true) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 4120
#include <stdio.h>
int main(){
  int i,j,a[100],n,tmp,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	cnt++;
      }
    }
  }
    
  for(j=0;j<n;j++){
    printf("%d",a[j]);
    if(j!=n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",cnt);
  return 0;
}

Measured memory_bytes: 604
struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.read_vec(n);
    for i in 0..n {
        a[i] -= i as i64;
    }
    a.sort();
    let b = a[n / 2];
    let res: i64 = a.iter().map(|x| x - b).map(|x| x.abs()).sum();
    println!("{}", res);
}


Measured memory_bytes: 6396
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;

const long long INF = 100000;
long long pow5(long long a);
long long root5(long long a);

int main(void){
        int i,j;
        long long a,b,x,y;
        
        scanf("%lld",&x);
       // printf("%lld\n",pow5(200)); 
      // printf("%d",root5(32));
        for(a=1;a<=200;a++){
                y = pow5(a)-x;
        //printf("%lld ",y);        
                if(root5(y) != INF){
                        printf("%lld %lld\n",a,root5(y) );
                        return 0;
                }
        }


        return 0;
}


long long pow5(long long a){
        return a*a*a*a*a;
}
long long root5(long long a){
        long long b;
        for(b=-100;b<=200;b++){
                if(pow5(b) == a){
                        return b;
                }
        }
        return INF;
}


Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;
typedef long long ll;

vector <int> v;

bool prime (int x)
{
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    for (int i = 2; i < 50000; i++)
    {
        if (i % 5 == 1 && prime (i))
        {
            v.push_back(i);
        }
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 

int main(){
  int n;
  cin >> n;
  int a[n][2];
  rep(i,n){
    cin >> a[i][0] >> a[i][1];
  }
  bool flag = false;
  rep(i, n-2)
    if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
      flag = true;
  if(flag)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	vector<int> a(n),b(n);
	vector<Pi> g(n);
	rep(i,n){
		cin>>g[i].fi>>g[i].se;
	}
	sort(begin(g),end(g),[](const Pi &a,const Pi &b){
		return a.fi<b.fi;
	});
	rep(i,n){
		a[i]=g[i].fi;
		b[i]=g[i].se;
	}
	vector<vector<int>> dp(n+1,vector<int>(7000,-INF));
	rep(i,n+1) dp[i][0]=0;
	rep(i,n)rep(j,7000){
		if(dp[i][j]==-INF) continue;
		chmax(dp[i+1][j],dp[i][j]);
		if(j<t) chmax(dp[i+1][j+a[i]],dp[i][j]+b[i]);
	}
	int ans=0;
	rep(j,7000){
		chmax(ans,dp[n][j]);
	}
	cout<<ans<<endl;
}

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

const int inf = 1012345678;

int main()
{
    vector<int> A(5);
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
    vector<int> P = {0, 1, 2, 3, 4};
    int ans = inf;
    do
    {
        int tmp = 0;
        for (int i = 0; i < 5; i++)
        {
            while (tmp % 10 != 0)
                tmp++; // 料理が注文可能になる時刻まで待機
            tmp += A[P[i]];
        }
        ans = min(ans, tmp);
    } while (next_permutation(P.begin(), P.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	int i,sum = 0,a;
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		sum += a;
		if(sum>x){
			printf("%d",i);
			break;
		}
		if(sum==x){
			printf("%d",i+1);
			break;
		}
	}
	if(sum<x) printf("%d",n+1);
	return 0; 
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define name "bai2"
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;

const ll mod=1e9+7;
ll n,k,a[2009];
int main()
{
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);
    cin >> n >> k;
    for(int i=1; i<=n; ++i)cin >> a[i];
    ll ans=0;
    /// cal in group
    for(int i=1; i<=n; ++i)
        for(int j=1; j<i; ++j)
        if(a[j]>a[i])++ans;
    ans=(ans*k)%mod;
    /// out group
    ll t=(k*(k-1)/2) % mod;
    for(int i=1; i<=n; ++i){
        ll s=0;
        for(int j=1; j<=n; ++j)
        if(a[i]>a[j])++s;
        ans=(ans+(s*t)%mod)%mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    int MAX = 0;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        MAX = max(MAX, a[i]);
    }
    int ans = -1;
    int diff = MAX;
    rep(i, n){
        if(max(MAX - a[i], a[i]) <= diff){
            diff = max(MAX - a[i], a[i]);
            ans = a[i];
        }
    }
    cout << MAX << " " << ans << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  int n;
  if(b/10==0)
    n=a*10+b;
  else if(b/10/10==0)
    n=a*100+b;
  else
    n=a*1000+b;
  int k=n/2+1;
  int count=0;
  for(int i=0; i<k; i++){
    for(int j=0; j<k; j++){
      if(i==j){
        if(i*j==n){
          count++;
        }
      }
    }
  }
  if(count==0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc168/tasks/abc168_a

#入力を受け取りｎに代入
n=list(input())
#１の位をとってくる

poo=n[-1]

if poo in "24579":
     print("hon")
elif poo in "0168":
    print("pon")
elif poo=="3":
    print("bon")


Measured memory_bytes: 8900
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int num;
	double a,b,c;
	double d=3.0000000000;
	double e=1.0000000000;
	cin>>num;
	double  n=(double)num;
	a=n/d; b=n/d; c=n/d;
	
	printf("%.8f",a*b*c);
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int n = nextInt();
        int d = nextInt();
        int x = nextInt();
        int[] a = nextIntArray(n);

        int ans = x;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j += a[i]) {
                ans += 1;
            }
        }
        out.print(ans);
    }

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

    static long nextLong() {
        return Long.parseLong(sc.next());
    }

    static String nextString() {
        return sc.next();
    }

    static int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

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

        solve();

        out.flush();
        sc.close();
    }

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
typedef long double ld;
typedef long long int ll;
const ll INF = (1LL << 63);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0; i < n;i++)
const int MAX = 1000000010;
int a[100];
void prime(int n) {
    while (n % 2 == 0) {
        a[2]++;
        n /= 2;
    }
    for (int i = 3; i <= n; i += 2) {
        while (n % i == 0) {
            a[i]++;
            n /= i;
        }
    }
}
const ll MOD = 1000000007;
int cnt(int n) {
    int res = 0;
    rep(i, 100) {
        if (a[i] >= n - 1) res++;
    }return res;
}
int main() {
    ll n,ans; cin >> n;
    if (n < 10) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 2; i <= n; i++) {
        prime(i);
    }
    ans = cnt(75) + cnt(25) * (cnt(3)-1) + cnt(15) * (cnt(5)-1);
    ans += cnt(5) * (cnt(5) - 1) * (cnt(3) - 2) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i=0; i<n; i++) cin >> s[i];
    sort(s.begin(), s.end());

    for (auto as : s) cout << as;
    cout << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;


int main()
{
   int r, g, b;
   cin >> r >> g >> b;

   int num = 100 * r + g * 10 + b;
   if (num % 4 == 0)
      cout << "YES" << endl;
   else
      cout << "NO" << endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
#define N_MAX 100000
using namespace std;

int N;
int ans[4];

int main()
{
    int i;
    string s;
    cin >> N;
    rep0(i,N) {
        cin>>s;
        if(s=="AC") ans[0]++;
        else if(s=="WA") ans[1]++;
        else if(s=="TLE") ans[2]++;
        else if(s=="RE") ans[3]++;
        else break;
    }
    cout << "AC x " << ans[0] <<endl;
    cout << "WA x " << ans[1] <<endl;
    cout << "TLE x " << ans[2] <<endl;
    cout << "RE x " << ans[3] <<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
 
int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r < 0 || x+r >w || y-r < 0 || y+r > h)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
long long n,m;
int k;
int main()
{
	cin>>n>>m>>k;
		if(m-n<k*2){
		
		for(int i=n;i<=m;i++)
		cout<<i<<endl;
	}
		else{
		
		for(int i=0;i<k;i++)
		cout<<n+i<<endl;
		for(int i=k-1;i>=0;i--)
		cout<<m-i<<endl;
		
	}
		
	}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H_list = list(map(int,input().split()))

kion_list = [T-H_list[i]*0.006 for i in range(N)]

tmp = 10**6
num = -1
for i in range(N):
  if tmp > abs(A-kion_list[i]):
    tmp = abs(A-kion_list[i])
    num = i+1

#print(H_list)
print(num)

Measured memory_bytes: 3064