akhauriyash/Code-Regression huggingface dataset:
unittest
{
	assert( [ "3", "2 0", "3 1", "1 3", "4 2", "0 4", "5 5" ].parse.expand.solve == 2 );
	assert( [ "3", "0 0", "1 1", "5 2", "2 3", "3 4", "4 5" ].parse.expand.solve == 2 );
	assert( [ "2", "2 2", "3 3", "0 0", "1 1" ].parse.expand.solve == 0 );
	assert( [ "5", "0 0", "7 3", "2 2", "4 8", "1 6", "8 5", "6 9", "5 4", "9 1", "3 7" ].parse.expand.solve == 5 );
	assert( [ "5", "0 0", "1 1", "5 5", "6 6", "7 7", "2 2", "3 3", "4 4", "8 8", "9 9" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	
	auto rs = new long[ 2 ][ n ];
	foreach( ref r; rs )
	{
		input.popFront;
		r = input.front.split.to!( long[] );
	}
	
	auto bs = new long[ 2 ][ n ];
	foreach( ref b; bs )
	{
		input.popFront;
		b = input.front.split.to!( long[] );
	}
	
	return tuple( n, rs, bs );
}

auto solve( long n, long[ 2 ][] rs, long[ 2 ][] bs )
{
	// x座標順にソート
	rs.sort();
	bs.sort();
	
	// x座標が小さい青点から順に判定
	auto c = 0L;
	foreach( b; bs )
	{
		// 範囲内の赤点のうち、一番y座標が大きいものを検索
		auto rmi = -1L;
		foreach( i, r; rs )
		{
			if( r[ 0 ] < b[ 0 ] && r[ 1 ] < b[ 1 ] )
			{
				if( rmi < 0 || rs[ rmi ][ 1 ] < r[ 1 ] )
				{
					rmi = i;
				}
			}
		}
		
		// 範囲内に赤点があったらペア数+1して使用済赤点を削除
		if( 0 <= rmi )
		{
			c++;
			rs = rs[ 0 .. rmi ] ~ rs[ rmi + 1 .. $ ];
		}
	}
	
	return c;
}


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

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

  rep(a, 1000) {
    ll a5;
    a5 = 1;
    rep(i, 5) a5 *= a;
    for (int b = -1000; b < 1000; b++) {
      ll b5;
      b5 = 1;
      rep(i, 5) b5 *= b;
      if (a5 - b5 == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3616
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B, K;
	cin >> A >> B >> K;
	REP(i, K) {
		if (i % 2 == 0) {
			if (A % 2) A--;
			A /= 2;
			B += A;
		}
		else {
			if (B % 2) B--;
			B /= 2;
			A += B;
		}
	}
	cout << A << " " << B << "\n";

	return 0;
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n, t, a; cin >> n >> t >> a;
    int ans;
    int s = 100000000;
    rep(i, n){
        int h; cin >> h;
        int x = (t * 1000 - h * 6) - a * 1000;
        if(x < 0) x = -x;
        if(x < s){
            s = x;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            if (n == 0 && w == 0) break;
            var a = new int[100];
            var pmax = 0;
            var amax = 0;
            for (int i = 0; i < n; i++)
            {
                var te = int.Parse(Console.ReadLine().Trim()) / w;
                a[te]++;
                amax = Math.Max(amax, a[te]);
                pmax = Math.Max(pmax, te);
            }
            var res = 0;
            for (int i = 0; i < pmax; i++)
                res += (pmax - i) * a[i];
            var res2 = (double)res / (amax * pmax) + 0.01d;
            Console.WriteLine(res2);
        }
    }
}


Measured memory_bytes: 7912
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};
use std::cmp;


fn solve(a: Vec<usize>) -> u64 {
    let mut counter = [0; 100001];
    for x in a.into_iter() {
        counter[x] += 1;
    }
    let mut result = 0;
    for i in 1..100000 {
        result = cmp::max(result, counter[i - 1] + counter[i] + counter[i + 1]);
    }
    result
}


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


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

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

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

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

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

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

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


#[allow(dead_code)]
fn print_foreach<T: Display>(answer: &[T]) {
    for x in answer {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_yn(answer: bool, yes: &str, no: &str) {
    println!("{}", if answer { yes } else { no });
}


#[allow(dead_code)]
fn print_or<T: Display>(answer: &Option<T>, or: &T) {
    match *answer {
        Some(ref x) => println!("{}", x),
        None => println!("{}", or),
    }
}


Measured memory_bytes: 5116
str = gets.chomp

fs = ["apple", "peach"]
idxs = {}

for f in fs
  idxs[f] = []
  k = -1

  while ! (k = str.index(f, k + 1)).nil?
    idxs[f].push k
  end
end

for i in (0..1)
  f0 = fs[i]
  f1 = fs[1 - i]

  for idx in idxs[f0]
    str[idx, f0.length] = f1
  end
end

puts str

Measured memory_bytes: 6096
#2019/09/27
O = input()
E = input()
S = []
for i in range(len(O)-1):
    S.append(O[i])
    S.append(E[i])
if (len(O) == len(E)):
    S.append(O[-1])
    S.append(E[-1])
else:
    S.append(O[-1])
    
print(*S, sep="")

Measured memory_bytes: 3064
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N;
string s;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>N && N){
		cin>>s;
		int c[11]={};
		int p=0;
		rep(i,sz(s)){
			int cur=i%N;
			if(s[i]=='M')c[cur]++;
			if(s[i]=='S'){
				p+=1+c[cur];
				c[cur]=0;
			}
			if(s[i]=='L'){
				c[cur]+=1+p;
				p=0;
			}
		}
		sort(c,c+N);
		rep(i,N)cout<<c[i]<<" ";
		cout<<p<<endl;
	}
}

Measured memory_bytes: 1232
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] num = strToIntArray(sc.nextLine(), " ");
        String[] str = new String[num[0]];

        for(int i = 0; i < num[0]; i++) {
        	str[i] = sc.nextLine();
        }
        Arrays.sort(str);
        for(String s : str) {
        	System.out.print(s);
        }
    }

    static char[] strToCharArray(String str) {
    	char[] chAr = new char[str.length()];
    	chAr = str.toCharArray();
    	return chAr;
    }

    static String[] strToArray(String str, String delim) {
    	String[] strAr= new String[str.length()];
    	strAr = str.split(delim);
    	return strAr;
    }

    static int[] strToIntArray(String str, String delim) {
    	String[] strAr = str.split(delim);
    	int[] intAr = new int[strAr.length];
    	for(int i = 0; i < strAr.length; i++) {
    		intAr[i] = Integer.parseInt(strAr[i]);
    	}
    	return intAr;
    }

    static int toInt(String str) {
    	int num = Integer.parseInt(str);
    	return num;
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
 
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
 
 
int main() {
	int a,b,c;
cin >> a >> b >> c;
cout << (a+b+c-max(max(a,b),c));
	return 0;
}
 

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;

#define all(x) x.begin(), x.end()
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define ford(i, n) for(int i = 1; i <= (int)(n); ++i)
#define en '\n'
#define debug(x) cout << #x  << " : " << x << en
#define debug2(x, y) cout << #x << " : " << x  << " " << #y << " : " << y << en

const int N = 7;
char ar[N][N];

void solve() {
  int r, c, k;
  cin >> r >> c >> k;
  for(int i = 0; i < r; i++) cin >> ar[i];
  int ans = 0;
  for(int i = 0; i < (1<<r); i++) {
      for(int j = 0; j < (1<<c); j++) {
          int black = 0;
          for(int m = 0; m < r; m++) {
              for(int n = 0; n < c; n++) {
                  if(((i>>m) & 1) == 0 && ((j>>n) & 1) == 0 && ar[m][n] == '#') {
                      black++;
                  }
              }
          }
          if(black == k) ans++;
      }
  }
  cout << ans;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 998244353
#define pai acos(-1)
#define N 1000005



int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
//   freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
   ll ar,x,y;
   scanf("%lld %lld.%lld",&ar,&x,&y);
   ll ans=(ar*x);
   ar=(ar*y);
   vector<ll>vc;
   while(ar) vc.pb(ar%10),ar/=10;
   reverse(vc.begin(),vc.end());
   if(vc.size()>=2){
      ll n=0;
      for(int i=0;i<vc.size()-2;i++){
         n=n*10+vc[i];
      }
      ans+=n;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3728
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    ll T;
    in2(N, T);

    ll cost = INF;
    rep(i, N)
    {
        ll c, t;
        in2(c, t);

        if (t <= T) chmin(cost, c);
    }

    if (cost == INF)
    {
        outl("TLE");
    }
    else
    {
        outl(cost);
    }

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h> 

int main(void){
	int n,i,cnt(0);
	scanf("%d",&n);
	int p[n];
	for(i = 0 ; i < n ; i++){
		scanf("%d",&p[i]);
	}
	for(i = 0 ; i < n - 2 ; i++){
		if (p[i + 1] > p[i] &&  p[i + 1] < p[i + 2] ||  p[i + 1] < p[i] &&  p[i + 1] > p[i + 2]) {
			cnt++;
		}
	}
	printf("%d\n",cnt);
	
}

Measured memory_bytes: 128
#include <stdio.h>
typedef long long ll;
int min(int x, int y) {
	return x > y ? y : x;
}
int max(int x, int y) {
	return x < y ? y : x;
}
int a[200000];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int amax = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		amax = max(amax, a[i]);
	}
	int ok = amax, ng = 0, mid;
	while (ok - ng > 1) {
		mid = (ng + ok) / 2;
		ll cutCnt = 0;
		for (int i = 0; i < n; i++) {
			cutCnt += (a[i] + mid - 1) / mid - 1;
		}
		if (cutCnt <= k)
			ok = mid;
		else
			ng = mid;
	}
	printf("%d\n", ok);
	return 0;
}

Measured memory_bytes: 2508
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let s = sc.read::<String>();
    let mut ans = 0;
    for i in 2..n {
        if &s[(i - 2)..(i + 1)] == "ABC" {
            ans += 1;
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int a, b;
  std::cin >> a >> b;
  if (b % a == 0) {
    cout(a+b);
  } else {
    cout(b-a);
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int a, b;
			int c = 0;
			int d = 0;
			for(int i=0;i<n;i++){
				a = sc.nextInt();
				b = sc.nextInt();
				if(a==b){
					c += a;
					d += b;
				}else if(a>b){
					c += a+b;
				}else{
					d += a+b;
				}
			}
			System.out.println(c + " " + d);
		}
	}
}

Measured memory_bytes: 51720
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n),c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] >= 0)res += v[i] - c[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 24
int a[maxn];
int n,q;
bool solve(int i,int m)
{
    if(m==0)
        return true;
    if(i>n)
        return false;
    return(solve(i+1,m)||solve(i+1,m-a[i]));
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    while(q--)
    {
        int k;
        scanf("%d",&k);
        if(solve(0,k))
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11];
    scanf("%s", s);
    int ans = 0;
    int i, x;
    x = 0;
    for (i = 0; i < strlen(s); i++)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            x++;
            if (ans < x)
                ans = x;
        }
        else
            x = 0;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template v2
//   Address :
//   Date    :   2020/09/19
// =====================================================
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<db> vdb;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

// TO_STRING
#define ts to_string
string ts(char c) { return string(1,c); }
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
string ts(bool b) { return b ? "true" : "false"; }
string ts(vector<bool> v) { string res; F0R(i,sz(v)) res += char('0'+v[i]); return res; }
template<size_t SZ> string ts(bitset<SZ> b) { string res; F0R(i,SZ) res += char('0'+b[i]); return res; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

const ll MOD = 1e9+7; // 998244353;
const int MX = 1e5+5;

// BIT
int tree[1];
int sum(int k, int a = 0) {
    while (k >= 1) { a += tree[k]; k -= k&-k; }
    return a; }
void add(int k, int x) {
    while (k <= MX) { tree[k] += x; k += k&-k; }
}
// Disjoint Set
int find(vi& ds, int i) {
    return ds[i] < 0 ? i : ds[i] = find(ds, ds[i]);
}

void solve()
{
    string str;
    cin >> str;
    if (str.back() == 's') {
        cout << str << "es" << endl;
    } else {
        cout << str << "s" << endl;
    }
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define LOCAL
#ifdef LOCAL
    freopen("data.in", "r", stdin); while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) solve();

#ifdef LOCAL
    }    printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3648
sx, sy, tx, ty = list(map(int, input().split()))

sol = ""
sol += "R"*(tx-sx) + "U"*(ty-sy) + "L"*(tx-sx) + "D"*(ty-sy)
sol += "D"+ "R"*(tx-sx + 1) + "U"*(ty-sy + 1) + "LU" + "L"*(tx-sx + 1) + "D"*(ty-sy+1) + "R"

print(sol)

Measured memory_bytes: 9140
H = int(input())
W = int(input())
N = int(input())

if (H >= W):
    if(N%H == 0):
        print(N//H)
    else:
        print(N//H +1)
else:
    if(N%W == 0):
        print(N//W)
    else:
        print(N//W+1)

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void)
{
	int a, b, c, rec = 0, rho = 0;
	int i, j;
	char ap, bp;
	
	while (scanf("%d%c%d%c%d", &a, &ap, &b, &bp, &c) != EOF){
		if (c == sqrt(pow(a, 2) + pow(b, 2)))rec++;
		if (a == b)rho++;
	}
	
	printf("%d\n%d\n", rec, rho);
	
	return (0);
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int val;
  int count[101];

  fill(count, count+101, 0);

  while(cin>>val){
    ++count[val];
  }

  val = 0;
  for(int i = 1; i < 101; ++i)
    val = max(val, count[i]);

  for(int i = 1; i < 101; ++i)
    if(count[i] == val)
      cout << i << endl;

  return 0;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

ll per(const ll i, ll j, const ll K)
{
    j %= i;
    if (j == 0) {
        return i - 1;
    } else {
        const ll next = K - j + i;
        const ll rem = next % K;
        if (rem == 0) {
            return per(i - next / K + 1, 0, K);
        } else {
            return per(i - next / K, K - rem, K);
        }
    }
}

ll grundy(ll A, const ll K)
{
    const ll i = A / K + 1;
    const ll j = A % K;
    return per(i, j, K);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> K(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> K[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans = ans ^ grundy(A[i], K[i]);
    }
    cout << (ans == 0 ? "Aoki" : "Takahashi") << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	char RF[128];
	int AF, i;

	while(scanf("%s", RF) != EOF){

		i = 0;
		AF = 0;

		while(1){

			if(RF[i] == 'M') {
				AF += 1000;
				i++;
			} else if(RF[i] == 'D') {
				if(RF[i+1] == 'M') {
					AF += 500;
					i += 2;
				} else {
					AF += 500;
					i++;
				}
			} else if(RF[i] == 'C') {
				if(RF[i+1] == 'D') {
					AF += 400;
					i += 2;
				} else if(RF[i+1] == 'M') {
					AF += 900;
					i += 2;
				} else {
					AF += 100;
					i++;
				}
			} else if(RF[i] == 'L') {
				if(RF[i+1] == 'C') {
					AF += 50;
					i += 2;
				} else if(RF[i+1] == 'D') {
					AF += 450;
					i += 2;
				} else if(RF[i+1] == 'M') {
					AF += 950;
					i += 2;
				} else {
					AF += 50;
					i++;
				}
			} else if(RF[i] == 'X') {
				if(RF[i+1] == 'L') {
					AF += 40;
					i += 2;
				} else if(RF[i+1] == 'C') {
					AF += 90;
					i += 2;
				} else if(RF[i+1] == 'D') {
					AF += 490;
					i += 2;
				} else if(RF[i+1] == 'M') {
					AF += 990;
					i += 2;
				} else {
					AF += 10;
					i++;
				}
			} else if(RF[i] == 'V') {
				if(RF[i+1] == 'X') {
					AF += 5;
					i += 2;
				} else if(RF[i+1] == 'L') {
					AF += 45;
					i += 2;
				} else if(RF[i+1] == 'C') {
					AF += 95;
					i += 2;
				} else if(RF[i+1] == 'D') {
					AF += 495;
					i += 2;
				} else if(RF[i+1] == 'M') {
					AF += 995;
					i += 2;
				} else {
					AF += 5;
					i++;
				}
			} else if(RF[i] == 'I') {
				if(RF[i+1] == 'V') {
					AF += 4;
					i += 2;
				} else if(RF[i+1] == 'X') {
					AF += 9;
					i += 2;
				} else if(RF[i+1] == 'L') {
					AF += 49;
					i += 2;
				} else if(RF[i+1] == 'C') {
					AF += 99;
					i += 2;
				} else if(RF[i+1] == 'D') {
					AF += 499;
					i += 2;
				} else if(RF[i+1] == 'M') {
					AF += 999;
					i += 2;
				} else {
					AF++;
					i++;
				}
			} else
				break;

		}
		printf("%d\n", AF);

	}

	return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

void use_io_optimizations()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    use_io_optimizations();

    long long n;
    cin >> n;
    int res = to_string(n).size();
    for (long long i = 1; i * i <= n; ++i ) {
        if (n % i == 0) {
            long long j = n / i;
            res = min(res, (int)max(to_string(i).size(), to_string(j).size()));
        }
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int sum=0;
   for(int i=1;i<=n;i++)
   {
       if(i%3!=0 && i%5!=0)
        sum+=i;
   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3660
N = int(input())
S = input()

left_W = [0] * N
for i in range(N-1):
    if S[i] == "W":
        left_W[i+1] = left_W[i] + 1
    else:
        left_W[i+1] = left_W[i]

right_E = [0] * N
for i in range(N-1):
    if S[N-i-1] == "E":
        right_E[N-i-2] = right_E[N-i-1] + 1
    else:
        right_E[N-i-2] = right_E[N-i-1]


min_count = 100000000
#print(left_W)
#print(right_E)

for i in range(N):
    change_count = left_W[i] + right_E[i]
    if change_count < min_count:
        min_count = change_count
print(min_count)


Measured memory_bytes: 17632
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


h, w, m = inpl()
dic1 = [0] * h
dic2 = [0] * w
mine = [set() for i in range(h)]
for _ in range(m):
    y, x = inpl()
    dic1[y - 1] += 1
    dic2[x - 1] += 1
    mine[y - 1].add(x - 1)

sub1 = []
tmp = -1
for i in range(h):
    if tmp < dic1[i]:
        sub1 = [i]
        tmp = dic1[i]
    elif tmp == dic1[i]:
        sub1.append(i)
temp = -1
sub2 = []
for i in range(w):
    if temp < dic2[i]:
        sub2 = [i]
        temp = dic2[i]
    elif temp == dic2[i]:
        sub2.append(i)
ans = -1
FLAG = False
for i in sub1:
    for j in sub2:
        if j not in mine[i]:
            ans = 0
            FLAG = True
            break
    if FLAG:
        break
print(ans + tmp + temp)


Measured memory_bytes: 178016
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
        ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
 
    map<ll,ll> mp;
 
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(mp.find(-a[i] + i) != mp.end()){
            ans += mp[-a[i] + i];
        }
        mp[a[i] + i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 17128
n = int(input())
ta = [list(map(int,input().split())) for _ in range(n)]
ans = [ta[0][0],ta[0][1]]
for i in range(1,n):
  if ans[0] / ta[i][0] <= 1 and ans[1] / ta[i][1] <= 1:
    ans[0] = ta[i][0]
    ans[1] = ta[i][1]
  else:
    x = max(-(-ans[0]//ta[i][0]),-(-ans[1]//ta[i][1]))
    ans[0] = ta[i][0]*x
    ans[1] = ta[i][1]*x
print(sum(ans))

Measured memory_bytes: 40944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Sumitrust_2019
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            int[][] graph = new int[n][];
            graph[n - 1] = new int[10];
            for (int i = 0; i < 10; i++) graph[n - 1][i] = int.MaxValue;
            for (int i = n - 2; i >= 0; i--)
            {
                graph[i] = new int[10];
                for (int j = 0; j < 10; j++) graph[i][j] = graph[i + 1][j];
                graph[i][s[i + 1] - '0'] = i + 1;
            }
            int[] start = new int[10];
            for (int i = 0; i < 10; i++) start[i] = graph[0][i];
            start[s[0] - '0'] = 0;
            int res = 0;
            for(int i = 0; i < 10; i++)
            {
                int first = start[i];
                if (first == int.MaxValue) continue;
                for(int j = 0; j < 10; j++)
                {
                    int second = graph[first][j];
                    if (second == int.MaxValue) continue;
                    for(int k = 0; k < 10; k++)
                    {
                        int third = graph[second][k];
                        if (third == int.MaxValue) continue;
                        res++;
                    }
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main()
{
  	int a, b;
  	cin>>a>>b;
  	if(a == b)
      	cout<<"Draw"<<"\n";
  	else if(((a > b) && (b != 1)) || (a == 1 && b != 1))
      	cout<<"Alice"<<"\n";
  	else if(b > a || (a != 1 && b == 1))
      	cout<<"Bob"<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int S;
    int ue=0,sita=0;//0:no,1:M
    cin>>S;
    if(0<S/100&&S/100<13){
        ue ++;
    }
    if(0<S%100&&S%100<13){
        sita ++;
    }
    if(ue==0&&sita==0){
        cout<<"NA"<<endl;
        return 0;
    }
    if(ue==1&&sita==0){
        cout<<"MMYY"<<endl;
        return 0;
    }
    if(ue==0&&sita==1){
        cout<<"YYMM"<<endl;
        return 0;
    }
    if(ue==1&&sita==1){
        cout<<"AMBIGUOUS"<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

int n;
int a[100005];
int cnt[100005];
int ans;

int main(){

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

cin>>n;

for(int i=0; i<n; i++) cin>>a[i];

for(int i=0; i<n; i++){
  if(a[i]>n){
    ans++;
  }
  else{
    cnt[a[i]]++;
  }
}

for(int i=0; i<=100000; i++){
  if(cnt[i]>0){
    if(cnt[i]<i) ans+=cnt[i];
    else if(cnt[i]>i) ans+=(cnt[i]-i);
  }
}

cout<<ans<<endl;

}



Measured memory_bytes: 768
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    string s;
    cin>>n>>s;
    ll x=0;
    rep(i,0,n-2)
    {
        if( s[i] == 'A' )
        {
            if( s[i+1]=='B')
            {
                if( s[i+2]=='C' )
                {
                    x++;
                }
            }
        }
    }   
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    VI a(N);
    int sum=0;
    rep(i,N){
        cin >> a[i];
        sum+=a[i];
    }
    int ave=sum/N;
    int mini=INF;
    int tmp1=0;
    int tmp2=0;
    int tmp3=0;
    rep(i,N){
        tmp1+=pow((ave-a[i]),2);
    }
    rep(i,N){
        tmp2+=pow((ave-1-a[i]),2);
    }
    rep(i,N){
        tmp3+=pow((ave+1-a[i]),2);
    }
    mini=min(mini,tmp1);
    mini=min(mini,tmp2);
    mini=min(mini,tmp3);
    cout << mini << endl;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  cin>>a[0];
  int max=a[0];
  int min=a[0];
  for(int i=1; i<n; i++){
    cin>>a[i];
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  cout<<max-min<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,d,r;
	double f;
	scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

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

const int MX=200010,INF=1001001001,mod=1e9+7;
int dp[MX];

int main(){
    int n;
    cin>>n;
    rep(i,MX)dp[i]=INF;
    dp[0]=0;
    rep(i,n){
        for(int j=1; j<=100000; j*=6){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
        for(int j=1; j<=100000; j*=9){
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4416
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (n, a, b): (isize, isize, isize) = (sc.input(), sc.input(), sc.input());
    let xs: Vec<isize> = (0..n)
        .map(|_| sc.input())
        .collect();

    let mut acc = 0;
    for iter in xs.windows(2) {
        let next = iter[1];
        let cur = iter[0];
        let dist = next - cur;

        acc += if dist * a < b {
            dist * a
        } else {
            b
        };
    }

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


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

int main() {
    long long int n, k, ans = 0;
    cin >> n >> k;

    if (k % 2 == 1) {
        ans += (n / k) * (n / k) * (n / k);
    } else {
        ans += (n / k) * (n / k) * (n / k) + ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
int main() {
    int n;
    ll sum = 0;
    cin >> n;
    vector<int>a(n);
    rep(i, 0, n)cin >> a[i];
    rep(i, 0, n){
        if(i==n-1){
            sum += abs(a[i]);
            continue;
        }
        sum +=abs(a[i+1]-a[i]);
    }
    sum += abs(a[0]);
    rep(i, 0, n){
        ll tempsum = sum;
       if(i==0){
           tempsum -=(abs(a[0])+abs(a[1]-a[0])-abs(a[1]));
           cout << tempsum << endl;
           continue;
       }
       if(i==n-1){
           tempsum -=(abs(a[n-1]-a[n-2])+abs(0-a[n-1])-abs(a[n-2]));
            cout << tempsum << endl;
            continue;
       }
       tempsum -=(abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]));
       cout << tempsum << endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>





std::vector<int> primes(const int upper_limit) {
	std::vector<bool> is_prime(upper_limit + 1, true);
	for (auto i = 2; i * i <= upper_limit; ++i) {
		if (is_prime[i]) for (auto j = i * i; j <= upper_limit; j += i) {
			is_prime[j] = false;
		}
	}
	std::vector<int> result;
	for (auto i = 2; i <= upper_limit; ++i) {
		if (is_prime[i]) result.push_back(i);
	}
	return result;
}
int main() {
	long long int a, b; std::cin >> a >> b;
	auto prime = primes(1000000);
	int count = 1;
	for (const auto p : prime) {
		if (a % p == 0 && b % p == 0) ++count;
		while (a % p == 0) a /= p;
		while (b % p == 0) b /= p;
	}
	if (a != 1 && b != 1 && a == b) ++count;
	std::cout << count << std::endl;
}

Measured memory_bytes: 1652
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double a_rad = ((h*60+m)/360)*M_PI;
    double b_rad = (m/30)*M_PI;
    double diff = max(a_rad,b_rad) - min(a_rad,b_rad);
    double c = a*a+b*b-2*a*b*cos(diff);
    c = sqrt(c);
    cout << setprecision(10) << c << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>

int main() {
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  bool yes = 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h;
  if (yes) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 3080