akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
 
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif
 
void d_err() {
    cerr << endl;
}
 
template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}
 
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;
 
ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;

    bool f[N+1];
    int P[N+1];
    memset(f, false, sizeof(f));
    memset(P, 0, sizeof(P));

    REP(i, M) {
      int a; string b;
      cin >> a >> b;

      f[a] |= b == "AC";
      if (!f[a]) ++P[a];
    }

    int a = 0;
    int p = 0;
    REP(i, N+1) {
      if(f[i]) {
        ++a;
        p += P[i];
      }
    }

    cout << a << " " << p << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <unordered_set>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


inline bool is_given(const int &nr, const unordered_set<int> &nrs)
{
    return nrs.find(nr) != end(nrs);
}


int main()
{
    cin.sync_with_stdio(0);

    int X, N;
    cin >> X >> N;

    unordered_set<int> nrs;
    nrs.reserve(4 * 100);
    nrs.max_load_factor(0.25);
    while (N--)
    {
        int nr;
        cin >> nr;

        nrs.emplace(nr);
    }

    for (int cand = X; ; --cand)
    {
        if (!is_given(cand, nrs))
        {
            cout << cand;
            return 0;
        }
        if (!is_given(2 * X - cand, nrs))
        {
            cout << 2 * X - cand;
            return 0;
        }
    }
}

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

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

    int x[n][d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int sum, cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            sum = 0;
            for (int k = 0; k < d; k++) {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for (int k = 0; k <= sum; k++) {
                if (k * k == sum) cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main()
{
	int N;
	int d[101];
	int sum = 0;

	scanf("%d", &N);

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

	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += d[i] * d[j];
		}
	}
	printf("%d", sum);

	return 0;
}
	

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  int n,m,wa=0,ac=0;
  cin >> n >> m;
  vi p(m) , temp(n+1,0) , wrong(n,0);
  vs s(m);
  rep(i,m){
    cin >> p[i] >> s[i];
    if(s[i] == "AC"){
      if(!temp[p[i]]) ac++;
      temp[p[i]] = 1;
    }
    if(s[i] == "WA"){
      if(!temp[p[i]]) wrong[p[i]]++; 
    }
  }
  rep(i,n+1){
    if(temp[i]) wa += wrong[i];
  }
  cout << ac << " " << wa ;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 6912
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        a: [usize; N],
    }

    println!("{}", a.iter().fold(0, |sum, ai| sum + ai - 1));
}


Measured memory_bytes: 4352
<?php

fscanf(STDIN,"%d %d",$r,$c);
$array = [];
while($r > 0){
    $array[] = explode(" ", trim(fgets(STDIN)));
    $r--;
}

foreach($array as $arr){
    $sum = 0;
    for($i=0; $i<count($arr); $i++){
        $sum += $arr[$i];
    }
    echo implode(" ", $arr)." ".$sum.PHP_EOL;
}

$sumArray = str_split(str_repeat(0, $c));
foreach ($array as $k=>$subArray) {
  foreach ($subArray as $id=>$value) {
    $sumArray[$id]+=$value;
    // var_dump($sumArray);
  }
}

echo implode(" ",$sumArray)," ",array_sum($sumArray);
echo PHP_EOL;


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

int main() {
  int count = 0; 
  int A, B;
  cin >> A >> B;
  
  for (int i = A; i < B + 1; i++) {
    int a, b, c, d;
    a = i % 10000;
    b = i % 1000;
    c = i % 100;
    d = i % 10;
    if (i/10000 == d && (a - b)/1000 == (c - d)/10) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, h, w) = readLine()!!.split(" ").map(String::toInt)
    var count = 0
    for (i in 1..n) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        if (h <= a && w <= b) {
            count++
        }
    }
    println(count)
}


Measured memory_bytes: 38484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


const int INF = 1<<30;

int main(){
    int n, m;
    cin >> n >> m;
    VI a(m), b(m);
    VVI c(m, VI(n, -1));
    rep(i,m){
        cin >> a[i] >> b[i];
        rep(j, b[i]){
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    VI dp(1<<n, INF);
    dp[0] = 0;
    rep(i,m){
        int now = 0;
        rep(j,b[i]){
            now |= 1<<c[i][j];
        }
        rep(j, 1<<n){
            dp[j | now] = min(dp[j | now], dp[j] + a[i]);
        }
    }
    if (dp[(1<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int a, b;
	cin >> a >> b;
	ans = a + b;
	chmax(ans, a - b);
	chmax(ans, a * b);

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;




int main() {
	string s;
	cin >> s;
	vector<int> v(s.size());
	for (int i = 0; i < s.size(); i++) {
		v[i] = (int)(s[i] - '0');
	}
	int ans = 0;
	int nowsum = 0;
	//debugv(v);
	for (int i = s.size()-1; i >= 0; i--) {
		nowsum = v[i];
		if (nowsum < 9) {
			if (i != 0) {
				v[i - 1]--;
				nowsum += 10;
				v[i] = 9;
			}
		}
	}
	for (int i : v) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> b(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		cin >> b[i];
	}
	long sum = b[n - 2];
	for (int j = n - 2; j >= 1; --j) {
		sum += min(b[j], b[j - 1]);
	}
	sum += b[0];
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(input()) for _ in range(n)]
A_Sorted = sorted(A)
A_max = A_Sorted[n-1]
A_sec = A_Sorted[n-2]

for i in range(n):
    a = A[i]
    if a == A_max:
        print(A_sec)
    else:
        print(A_max)


Measured memory_bytes: 14112
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
	std::vector<bool> sosu(100005, true);
	// 前処理1 素数を100000までかぞえておく 
	sosu[0] = false;	// 0は素数ではない 
	sosu[1] = false;	// 1は素数ではない 
	for(int i = 2; i < 100005; i++)
	{
		for(int j = 2; i * j < 100005; j++ )
		{
			sosu[i*j] = false;
		}
	}

	// 前処理2 sosu[0]からsosu[i]までの2017に似た数の数をかぞえておく 
	std::vector<int> like_amt(100005, 0);
	int like_cnt = 0;
	for(int i = 1; i < 100005; i++)
	{
		if(i % 2 == 0)
		{
			like_amt[i] = like_cnt;
			continue;
		}
		if(sosu[i] == true)
		{
			if(((sosu[(i+1)/2])) == true)
			{
				like_cnt++;
			}
		}
		like_amt[i] = like_cnt;
	}
	// rep(i, 100)
	// {
	// 	std::cout << i << "(" << sosu[i] <<"):";
	// 	std::cout << like_amt[i] << std::endl;
	// }

	// 問題を解く 
	int Q;
	std::cin >> Q;
	std::vector<std::pair<int, int>> query(Q);
	rep(i, Q)
	{
		std::cin >> query[i].first >> query[i].second;
	}

	for(int i = 0; i < Q; i++)
	{
		ll ans = 0;
		int l, r;
		l = query[i].first; r = query[i].second;
		l--; r--;	// インデックスとして扱う 
		
		if(sosu[r+1] == true)
		{
			// printf("li");
			if(((sosu[(r+1+1)/2])) == true)
			{
				// printf("ke");
				ans++;
			}
		}
		
		ans += like_amt[r] - like_amt[l];
		
		std::cout << ans << std::endl;
	}

	return 0;
}

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

ll acCount = 0;
ll waCount = 0;
ll N;
ll M;
ll p[100007];
string S[100007];
bool isAC[100007] = {false};
ll waCountArr[100007] = {0};

int main() {
    cin >> N >> M;

    for (ll i=0; i<M; i++) {
        cin >> p[i] >> S[i];
    }

    for (ll i=0; i<M; i++) {
        if(!isAC[p[i]]) {
            if (S[i].compare("AC") == 0) {
                isAC[p[i]] = true;
                acCount++;
                waCount += waCountArr[p[i]];
            } else if (S[i].compare("WA") == 0) {
                waCountArr[p[i]]++;
            }
        } else {
            continue;
        }
    }

    cout << acCount << " " << waCount << endl;

    return 0;
}

Measured memory_bytes: 7296
# include <bits/stdc++.h>
# define ll int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
  fast
  char a[2];
  cin>>a[0];
  cout<<char(a[0]+1);
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int num[7];
    map<int,int> label;
    for(int i=1;i<=6;i++){
        cin >> num[i];
        label[num[i]]=i;
    }

    map<pair<int,int>,int> ans;
    ans[make_pair(1,2)]=3;
    ans[make_pair(2,6)]=3;
    ans[make_pair(6,5)]=3;
    ans[make_pair(5,1)]=3;
    
    ans[make_pair(2,3)]=1;
    ans[make_pair(3,5)]=1;
    ans[make_pair(5,4)]=1;
    ans[make_pair(4,2)]=1;
    
    ans[make_pair(1,3)]=5;
    ans[make_pair(3,6)]=5;
    ans[make_pair(6,4)]=5;
    ans[make_pair(4,1)]=5;

    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int a,b;
        cin >> a >> b;
        a=label[a];
        b=label[b];
        
        if(ans[make_pair(a,b)]>0)
            cout << num[ans[make_pair(a,b)]] << endl;
        else
            cout << num[7-ans[make_pair(b,a)]] << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#!python3

import sys
iim = lambda: map(int, input().rstrip().split())
from collections import deque

def resolve():
    S = deque(input().rstrip())
    Q = int(input())

    rev = False
    for ti, *arg in (line.split() for line in sys.stdin):

        if ti == "1":
            rev = not rev
        else:
            fi, ci = arg
            fi = fi == "1"
            if fi ^ rev:
                S.appendleft(ci)
            else:
                S.append(ci)
    if rev:
        S.reverse()
    print(*S, sep="")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 12272
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	fastio;

	string s;
	cin >> s;
	rep(i, (ll)s.size()) {
		if (i % 2 == 0) cout << s[i];
	}
	cout << endl;
}

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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

int main() {
    int a = read(), b = read(), t = read();   
    printf("%d\n", t / a * b);
    return 0;    
}

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

int main(){
    int N,K;
    cin >>N>>K;
    
  	vector<int> H(N);
  	for(int i=0;i<N;i++){
    	cin>>H.at(i);
    }
  
  	sort(H.begin(), H.end(), greater<int>());
 
  	long sum=0;
  	for(int i=K;i<N;i++){
      sum+=H.at(i);
    }
  
  	if(N<=K)
      cout<<0<<endl;
	else
	  cout<<sum<<endl;
      
  	return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int[4] s;
  foreach (i; 0..3) {
    auto d = readln.chomp.split.to!(int[]);
    s[d[0]-1]++;
    s[d[1]-1]++;
  }
  int[4] cnt;
  foreach (i; 0..4) {
    cnt[s[i]]++;
  }

  if (cnt[1] == 2 && cnt[2] == 2) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
	int x[5];
  	for (int i = 0; i < 5; i++) {
    	cin >> x[i];
        if (x[i] == 0 ) {
        	cout << i+1 << endl;
          	return 0;
        }
    }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
         
    using namespace std;
                 
    #define pb push_back
    #define ll long long
    #define mp make_pair
    #define MOD 1000000007
    #define MAX 100000000
    #define MIN -1000000000
    #define LLINF 0x3f3f3f3f3f3f    
    #define INF 0x3f3f3f3f
    #define MAXN  100100

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n;
        cin >> n;
        vector<int> v(n + 1);
        for(int i = 1; i <= n; ++i){ 
            cin >> v[i];
        }
        vector<int> dp(n + 1);

        dp[1] = 0;
        for(int i = 2; i <= n; ++i){   
            if(i == 2){ 
                dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
                continue;
            } 
            dp[i] = min(dp[i-1] + abs(v[i] - v[i - 1]), dp[i-2] + abs(v[i] - v[i - 2]));   
        }
        cout << dp[n] << endl;
        return 0;
    }

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

int main(){
  int n,m,a;
  cin >> n;
  vector<int> v(n);
  r(i,n){
    cin >> v.at(i);
  }
  cin >> m;
  while(m--){
    cin >> a;
    cout << lower_bound(v.begin(),v.end(),a)-v.begin()<<" "<<upper_bound(v.begin(),v.end(),a)-v.begin()<<endl;
  }
  
}


Measured memory_bytes: 3124
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();

    let n = s.len();
    let mut ans = 0;
    for i in 0..n {
        for j in i..n {
            let t = &s[i..j + 1];
            let m = t
                .replace("A", "")
                .replace("T", "")
                .replace("G", "")
                .replace("C", "").len();
            if m == 0 {
                ans = max(ans, t.len());
            }
        }
    }

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

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

const int dy[] = {1, 0, -1, 0}, dx[] = {0, 1, 0, -1};
int main(int argc, char const *argv[]) {
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	bool flag = true;
	rep(y, h)rep(x, w) {
		if(s[y][x] != '#') continue;
		bool f = false;
		rep(k, 4) {
			int ny = y + dy[k], nx = x + dx[k];
			if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
			if (s[ny][nx] == '#') f = true;
		}
		if (!f)  flag = false;
	}

	printf("%s\n", flag ? "Yes" : "No");
	return 0;
}

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

#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    scanf("%d",&m);
    return m ;
}
inline ll lD()
{
    ll m ;
    scanf("%lld",&m);
    return m ;
}
inline double dD()
{
    double m ;
    scanf("%llf",&m);
    return m ;
}
ll LCM(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}
string s[105],s2[105];
int main()
{
    int n=D();
    for(int i=0; i<n; ++i)
        cin>>s[i];
    int m=D();
    for(int i=0; i<m; ++i)
        cin>>s2[i];
    ll ans=0,c=0;
    for (int i = 0; i < n; i++ )
    {
        for(int j = 0; j<n; j++)
        {
            if(s[i] == s[j])
            {
                c++;
            }
        }
        for(int a = 0; a < m; a++)
        {
            if(s[i]== s2[a])
            {
                c--;
            }
        }
            ans =max(ans,c);
        c = 0;
    }
    cout<<ans<<endl;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  double a = (1900 * M + 100 * (N - M)) * pow(0.5, M);
  double r = (1 - pow(0.5, M));
  long long int ans = (a * r / pow((1 - r), 2)) + a / (1 - r);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	vector<int> a(3);
	cin >> a;

	int mini = 1e9;
	do{
		mini = min(mini, abs(a[0] - a[1]) + abs(a[1] - a[2]));
	}while(next_permutation(all(a)));
	cout << mini << endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int a,b,c;
cin>>a>>b>>c;
if(a+b>=c)
cout<<"Yes"<<endl;
else
{
  cout<<"No"<<endl;
}




  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

typedef long long INT;
const INT mod = 1001;

int F[1001];

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
    F[0] = 2;
    F[1] = 3;
    for ( int i = 2; i < 1001; i++ ) {
        F[i] = ( F[i-1] + F[i-2] ) % mod;
    }

    int V, d;
    while ( cin >> V >> d ) {
        UnionFind uf(V);
        V = V % mod;
        for ( int i = 0; i < V; i++ ) {
            for ( int j = i+1; j < V; j++ ) {
                if ( abs( F[i] - F[j] ) < d ) {
                    uf.unionSet(i,j);
                }
            }
        }
        int answer = 0;
        for ( int i = 0; i < V; i++ ) {
            if ( uf.root(i) == i ) answer++;
        }
        cout << answer << endl;
    }

    return 0;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VAR(string, s, t);
  rep(i, 0, N) {
    bool ok = true;
    rep(j, 0, N - i) {
      if (s[i + j] != t[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      print(N + i);
      return;
    }
  }
  print(N * 2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int v,E;
vector<vector < int > > g; // adjacency list
vector <int> vis; // stores visit status
vector<int>dp;
int dfs(int cur)
{
	int p =cur;
    int m=0;
	for(int j=0;j<g[cur].size();j++)
	{
		int k =g[cur][j];
		if(vis[k]==0)
		{
			vis[k]=1;
			dfs(k);
		}
        if(dp[k] >m)
        {
            m=dp[k];
        }
	}
    dp[cur] = max(dp[cur],1 + m);
	// cout << cur <<" ";
	return 0;
}
int call_dfs()
{
	for(int i=1;i<=v;i++)
	{
		if(vis[i]==0)
		{
			vis[i]=1;
			dfs(i);

		}
	}
}
int main()
{
	cin >> v >> E;
	g.resize(v+1);
	vis.resize(v+1);
	dp.resize(v+1);
	for(int i=1;i<=v;i++)
	{
		vis[i]=0;
        dp[i]=0;
	}
	for(int i=0;i<E;i++)
	{
		int v1,v2;
		cin >> v1 >> v2;
		g[v1].push_back(v2);
	}
	call_dfs();
    int m1=0;
    for(int i=1;i<=v;i++)
    {
        if(dp[i] >m1)
            m1=dp[i];
    }
    cout << m1-1 << endl;
}

Measured memory_bytes: 8576
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class ARemainingBalls {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        string s, t;
        cin >> s >> t;
        int a, b;
        cin >> a >> b;
        string u;
        cin >> u;
        cout << a - (s == u) << " " << b - (t == u) << endl;
    }
};


int main() {
    ARemainingBalls solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << a*b;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
int comp_func(const void *x,const void *y)
{
	if(*(int *)x<*(int *)y)
		return 1;	
	if(*(int *)x==*(int *)y)
		return 0;
	if(*(int *)x>*(int *)y)
		return -1;
}

int main(void)
{
	int x,num[101]={0},sorted_num[101]={0};
	int i,count=0;

	while(scanf("%d",&x)!=EOF)num[x]++;

	for(i=1;i<101;i++)
		sorted_num[i-1]=num[i];

	qsort(sorted_num,100,sizeof(sorted_num[0]),comp_func);

	while(1){
		for(i=1;i<=100;i++){
			if(num[i]==sorted_num[count]){
				printf("%d\n",i);
				num[i]=0;
			}
		}
		if(sorted_num[count]!=sorted_num[1+count])break;
		count++;
	}

	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	    scanf("%d",&a[i]);
	sort(a+1,a+1+n);    
	printf("%d\n",a[(1+n)/2+1]-a[(1+n)/2]);    
}

Measured memory_bytes: 512
check = ["A", "C", "G", "T"]

s = input()
ans = 0
tmp = 0

for i in range(len(s)):
    if s[i] in check:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
else:
    ans = max(ans,tmp)
        
print(ans)

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

using namespace std;

int main(void)
{
	int n;
	bool sts=false;

	cin>>n;

	for(int i=0;i<=n/4;i++){
		for(int j=0;j<=n/7;j++){
			if((4*i+7*j)==n){
				sts=true;
				break;
			}
		}
		if(sts) break;
	}

	if(sts) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            var ab = cin.ReadStrArray(2);

            var joint = ab[0] + ab[1];
            var intJoint = int.Parse(joint);

            var result = "No";
            for(int i = 1; i <= intJoint; i++)
            {
                if (intJoint == i * i)
                {
                    result = "Yes";
                    break;
                }
            }

            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(void){
  int n;
  cin >> n;
  int A[n + 2];
  A[0] = 0;
  A[n + 1] = 0;
  for(int i = 1; i <= n; i++) cin >> A[i];
  int sum = 0;
  for(int i = 0; i <= n; i++) sum += abs(A[i] - A[i + 1]);
  for(int i = 1; i <= n; i++){
    int ans = sum + abs(A[i - 1] - A[i + 1]) - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> L(N);
    REP(i,N) cin >> L[i];
    vector<ll> cand;
    sort(L.begin(),L.end());
    ll ans = 0;
    int cnt = 0;
    REP(i,N) for(int j=i+1;j<N;j++){
        int cand = lower_bound(L.begin(),L.end(), L[i] + L[j]) - L.begin();
        
        cand -= j + 1;
        //cout << cand << endl;
        if(cand > 0) ans+=cand;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")

using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
char a[maxn];
int main(){
    scanf("%s",a);
    bool f=0;
    if(a[2]==a[3]&&a[4]==a[5]) f=1;
    judgef;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

result = 0
for i in range(K, N + 2):
    # max: N, N -1, ..., N - i + 1
    a = (N + (N - i + 1)) * i // 2
    # min: 0, 1, .., i - 1
    b = (0 + (i - 1)) * i // 2
    result += a - b + 1
    result %= 1000000007
print(result)


Measured memory_bytes: 9200
def solve(STR):
    CNT, tmp = 0, s
    while len(set(tmp)) > 1:
        CNT += 1
        bfo, tmp = tmp, []
        for i in range(len(bfo) - 1):
            tmp.append(bfo[i])
            if STR in {bfo[i], bfo[i + 1]}:
                tmp[-1] = STR
    return CNT


s = input()

ans = 100
for lttr in set(s):
    cnt = solve(lttr)
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 68300
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	map<int, int> ma;
	for (int i = 0; i < N; i++) {
		if (ma.count(A.at(i))) {
			cout << "NO" << endl;
			return 0;
		}
		ma[A.at(i)]++;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 10368
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    int h, w;
    cin >> h >> w;
    int sx, sy;
    cin >> sx >> sy;
    int gx, gy;
    cin >> gx >> gy;
    sx--;
    sy--;
    gx--;
    gy--;
    vv<char> vec(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> vec[i][j];
    vi dx = {1, 0, -1, 0};
    vi dy = {0, 1, 0, -1};
    vv<int> dist(h, vector<int>(w, INF));
    priority_queue<tuple<int, int, int>> q;
    q.emplace(0, sx, sy);
    dist[sx][sy] = 0;
    vi wx, wy;
    rep(i, 5) rep(j, 5) {
        if (abs(i - 2) + abs(j - 2) < 2) continue;
        wx.emplace_back(i - 2);
        wy.emplace_back(j - 2);
    }

    // dist
    while (!q.empty()) {
        int x, y, val;
        tie(val, x, y) = q.top();
        q.pop();
        val *= -1;
        if (dist[x][y] < val) continue;
        rep(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= h) continue;
            if (ny < 0 || ny >= w) continue;
            if (vec[nx][ny] == '#') continue;
            if (dist[nx][ny] > val) {
                dist[nx][ny] = val;
                q.emplace(-dist[nx][ny], nx, ny);
            }
        }
        rep(i, 20) {
            int nx = x + wx[i], ny = y + wy[i];
            if (nx < 0 || nx >= h) continue;
            if (ny < 0 || ny >= w) continue;
            if (vec[nx][ny] == '#') continue;
            if (dist[nx][ny] > val + 1) {
                dist[nx][ny] = val + 1;
                q.emplace(-dist[nx][ny],nx, ny);
            }
        }
    }
    if (dist[gx][gy] != INF)
        cout << dist[gx][gy] << '\n';
    else
        cout << -1 << '\n';
}


Measured memory_bytes: 8512
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include <sstream>
#include <cctype>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#define all(a) (a).begin(),(a).end()

using namespace std;


string toString(int a){
  ostringstream oss;
  oss << a;
  return oss.str();
}

vector<int> toVec(string s){
  vector<int>res;
  for(int i=s.size()-1;i>=0;i--){
    res.push_back(s[i]-'0');
  }
  return res;
}

int VecToInt(vector<int>v){
  int res=0;
  for(int i=0;i<v.size();i++){
    res+=v[i]*pow(10.,(double)v.size()-i-1);
  }
  return res;
}

int main(void){

  string a;
  int L;

  while(cin >> a >> L,L){
    int cnt=1;
    map<string,int> p;
    p[a]=cnt;

    while(true){

      if(a.size()<L)
	for(int i=a.size();i<L;i++)a+='0';
      
      vector<int>num=toVec(a);
      sort(all(num),greater<int>());
      int Max=VecToInt(num);
      
      sort(all(num));
      int Min=VecToInt(num);
      
      a=toString(Max-Min);

      if(p[a]>0){
	cout << p[a]-1 <<" "<<  a << " " << cnt-p[a]+1 << endl;
	break;
      }
      cnt++;
      p[a]=cnt;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int N;
  cin >> N;
  int x=N;
  int n=0;
  while(x>0){
    x/=10;
    n++;
  }
  int ans=0;
  if(n==1){
    ans=N;
  }
  if(n==2){
    ans=9;
  }
  if(n==3){
    ans=9+N-99;
  }
  if(n==4){
    ans=909;
  }
  if(n==5){
    ans=909+N-9999;
  }
  if(n==6){
    ans = 90909;
  }
  cout << ans << endl;
  return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  long long ans = 0;
  int cnt[201010];
  int cu = 0; int dg = 1;
  int N = S.size();
  for(int i = N - 1; i >= 0; i--)
  {
    cu = (cu + dg * (S[i] - '0')) % 2019;
    dg = (dg * 10) % 2019;
    ans += cnt[cu];
    if (cu == 0) ans++;
    
    cnt[cu]++;
  }
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main() {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  ll ans=0;
  for(i=1; i<=N; i++) {
    if(i%3&&i%5) ans+=i;
  }
  pt(ans);
  
  
}




Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
struct edge { int to; int cost; };

signed main() {
	int h, w, n; cin >> h >> w >> n;
	int sr, sc; cin >> sr >> sc;
	string s, t; cin >> s >> t;
	int ur = 1, dr = h, uc = 1, dc = w;
	for (int i = n - 1; i >= 0; i--) {
		if (t[i] == 'L'&&1<dc&&dc < w)dc++;
		if (t[i] == 'R'&&w>uc&&uc > 1)uc--;
		if (t[i] == 'U'&&1<dr&&dr < h)dr++;
		if (t[i] == 'D'&&h>ur&&ur > 1)ur--;
		
		if (s[i] == 'L')uc++;
		if (s[i] == 'R')dc--;
		if (s[i] == 'U')ur++;
		if (s[i] == 'D')dr--;
		//cout << ur << dr << uc << dc << endl;
	}
	if (uc <= sc&&sc <= dc&&ur <= sr&&sr <= dr)puts("YES");
	else puts("NO");
	//cout << ur << dr << uc << dc << endl;
}

Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int n;
bool f[4000010];
vector<int>v;
int s;
int mn=1e9;
int a[2010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),s+=a[i];
	v.push_back(0);
	for(int i=1;i<=n;i++)
	{
		int l=v.size();
		for(int j=0;j<l;j++)
		{
			if(!f[v[j]+a[i]])
			{
				f[v[j]+a[i]]=true;
				v.push_back(v[j]+a[i]);
			}
		}
	}
	for(int i=0;i<v.size();i++)
	{
		if(s-v[i]>=v[i])
		{
			mn=min(mn,s-v[i]);
		}
	}
	printf("%d",mn);
	return 0;
} 

Measured memory_bytes: 13292
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    int Q = N>>1;
    int R = N&1;
    int O = R==0 ? Q : Q+1;
    std::cout << static_cast<double>(O)/static_cast<double>(N) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(ll a,ll b,ll ar,ll br){
  return ar+(br-ar+b)%b*modinv(a,b)%b*a;
}
ll garner2(ll a,ll b,ll ar,ll br){
  ar%=a;
  br%=b;
  ll ret=(ar+  ( (br-ar)%b*(moddiv(1,a,b)%b) +b )%b *a)%(a*b);
  return ret;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}





int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner2(val0,val1,1,0)-1;
        ll ans1=garner2(val0,val1,0,1)-1;
        //ans0%=val0*val1;
        //ans1%=val0*val1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }


  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7056