akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////
using ld = long double;
constexpr ld pi = acos(-1);

int32_t main() {
    ld a,b,x; cin >> a >> b >> x;
    if (2*x < a*a*b) {
        cout << atan(a*b*b/(2*x))/pi*180 << "\n";
    } else {
        ld y = a*a*b-x;
        cout << atan(2*y/(a*a*a))/pi*180 << "\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    int ans = max(max(a+b, a-b), a*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=200000+5;
const ll oo=1e18+5;
const ll mod=998244353;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=(int)s.size();
	int sum=0;
	int base=1;
	map<int,int> cnt;
	cnt[0]=1;
	ll ans=0;
	for(int i=n-1;i>=0;--i){
		int x=s[i]-'0';
		sum=(sum+x*base)%2019;
		ans+=cnt[sum];
		++cnt[sum];
		base=base*10%2019;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3784
sx, sy, tx, ty = map(int, input().split())
dy = ty - sy
dx = tx - sx
print("U"*(dy)+"R"*(dx)+"D"*(dy)+"L"*(dx)+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U")

Measured memory_bytes: 3060
import           Control.Monad.ST            (ST)
import           Data.Bits                   (shiftR)
import qualified Data.ByteString.Char8       as B
import           Data.Maybe                  (fromJust)
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM


readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = readInts <$> B.getLine

main :: IO ()
main = do
  [n, k] <- getInts
  hs <- getInts
  print $ solve n k hs

solve :: Int -> Int -> [Int] -> Int
solve n k hs = V.sum $ kill n k hs' where
  hs' = sort' $ V.fromList hs

kill :: Int -> Int -> V.Vector Int -> V.Vector Int
kill n k = V.take (n - k)

sort' :: (V.Unbox a, Ord a) => V.Vector a -> V.Vector a
sort' = V.modify (\v -> quicksort v 0 (VM.length v))

-- https://github.com/as-capabl/haskell-qsort-pfm/blob/master/src/UV.hs
quicksort :: (V.Unbox a, Ord a) => VM.STVector s a -> Int -> Int -> ST s ()
quicksort work iStart iEnd
    | iEnd - iStart <= 1 = return ()
    | otherwise = do
        pivot <- VM.unsafeRead work (((iEnd - iStart) `shiftR` 1) + iStart)
        med <- divide pivot iStart (iEnd - 1)
        quicksort work iStart med
        quicksort work med iEnd
  where
    divide pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            lower <- shrinkLower pivot iS' iE'
            higher <- shrinkHigher pivot lower iE'
            if lower >= higher
              then do
                return lower
              else do
                swapWork lower higher
                divide pivot (lower + 1) (higher - 1)

    shrinkLower pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise = do
            x <- VM.unsafeRead work iS'
            if x >= pivot
              then
                return iS'
              else
                shrinkLower pivot (iS' + 1) iE'

    shrinkHigher pivot iS' iE'
        | iS' > iE' = return iE'
        | otherwise = do
            x <- VM.unsafeRead work iE'
            if x <= pivot
              then
                return iE'
              else
                shrinkHigher pivot iS' (iE' - 1)

    swapWork i j = VM.unsafeSwap work i j


Measured memory_bytes: 11900
class Dice
  attr_accessor :status
  def initialize(status)
    @status = status
  end

  def compareSpec(dice)
    @d2 = dice.status
    d1 = matchDirect
    return (d1 == @d2) ? true : false
  end

  def matchDirect
    dt = Array.new(6)
    3.times do |i|
      idx = (i != 2) ? detectIndex(i) : detectSideIndex(@status.index(dt[0]) + 1, @status.index(dt[1]) + 1)
      dt[i] = @status[idx]
      dt[5-i] = @status[5-idx]
    end
    return dt
  end

  def detectIndex(i)
    idx = 0
    @status.each_with_index do |dir,j|
      if ((dir == @d2[i]) && (@status[5-j] == @d2[5-i]))
        idx = j
        break
      end
    end
    return idx
  end

  def detectSideIndex(top,front)
    idx = 0
    case top
    when 1,6
      s = [2,3,5,4]
      s.unshift(s.pop) while (s.include?(front))&&(s[0] != front)
      idx = (top == 1) ? s[1] - 1 : s[-1] - 1
    when 2,5
      s = [1,4,6,3]
      s.unshift(s.pop) while (s.include?(front))&&(s[0] != front)
      idx = (top == 2) ? s[1] - 1 : s[-1] - 1
    when 3,4
      s = [1,2,6,5]
      s.unshift(s.pop) while (s.include?(front))&&(s[0] != front)
      idx = (top == 3) ? s[1] - 1 : s[-1] - 1
    end
    return idx
  end
end

d1 = Dice.new(gets.split.map(&:to_i))
d2 = Dice.new(gets.split.map(&:to_i))
result = d1.compareSpec(d2)
puts (result == true) ? "Yes" : "No"

Measured memory_bytes: 8624
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
vector<int> v;
#define PI acos(-1)
const int maxn = 5e5+400;
typedef long long ll;

int n;ll k;
ll A[maxn],B[maxn];

bool check(ll x){
    ll t=0;
    for(int i=1;i<=n;i++){
        ll tmp=1ll*A[i]*B[n-i+1];
        if(tmp<=x)continue;
        ll d=x/B[n-i+1];
        t+=A[i]-d;
    }
    return t<=k;
}

int main(){
    cin>>n>>k;
    FOR(i,1,n)scanf("%d",&A[i]);
    FOR(i,1,n)scanf("%d",&B[i]);
    sort(A+1,A+1+n);
    sort(B+1,B+1+n);
    ll l=0,r=1e13,ans;
    while(l<=r){
        ll mid=(l+r)/2;
        if(check(mid)){
            r=mid-1;
            ans=mid;
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5888
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii>tri;

int hh(ii cc,tri pt){
	return pt.tm1+abs(pt.tm2-cc.ff)+abs(pt.tm3-cc.ss);
}

bool table[105][105];

int main(){
	int n;cin>>n;
	assert(n!=1);
	vector<tri>vec;
	FER(i,0,n){
		int x,y,h;cin>>x>>y>>h;
		if(h>0)vec.pb({h,{x,y}});
		else table[x][y]=true;
	}
	if(sz(vec)==1){
		cout<<vec[0].tm2<<" "<<vec[0].tm3<<" "<<vec[0].tm1<<endl;
		return 0;
	}
	FER(i,0,101)FER(j,0,101)if(!table[i][j]){
		vector<int>hs;
		for(tri lel: vec)hs.pb(hh(ii(i,j),lel));
		bool flag=(hs[0]>0);
		for(int lel: hs)if(lel!=hs[0])flag=false;
		if(flag){
			//assert(sz(hs)!=1);
			cout<<i<<" "<<j<<" "<<hs[0]<<endl;
			return 0;
		}
	}

	return 0;
}


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


int main(){

  int counter = 0;
  long long x;
  char op;
  
  long long result = 0;
  while(true){
    if( counter % 2 == 0){
      cin >> x;
    }else{
      cin >> op;
    }

    if(counter == 0){
      result += x;
    }else{
      if(counter % 2 == 0){
	switch(op){
	case '+':
	  result += x;
	  break;
	case '-':
	  result -= x;
	  break;
	case '*':
	  result *= x;
	  break;
	case '/':
	  result /= x;
	  break;
	default:
	  break;
	}
	
      }else{
	if(op == '=') break;
      }
    }

    ++counter;
  }

  cout << result << endl;
  
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    ll x;
    cin >> x;
    
    for(ll a=-200; a<200; a++){
        for(ll b=-200; b<200; b++){
        	if((a*a*a*a*a-b*b*b*b*b) == x){
              cout << a << " " << b;
              return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3600
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for i in range(n):
    lst = input().split()
    cards[pattern.index(lst[0])][int(lst[1]) - 1] = True

for j in range(4):
    for k in range(13):
        if cards[j][k] == False:
            print(pattern[j], k + 1)



Measured memory_bytes: 5600
a=int(input())
b=int(input())
c=int(input())
x=int(input())
counter=0
for i1 in range(0,a+1):
  for i2 in range(0,b+1):
    for i3 in range(0,c+1):
      if 500*i1+100*i2+50*i3==x:
        counter=counter+1
print(counter)

Measured memory_bytes: 3060
package main

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

const numOfTypes = 26

func main() {
	d := readInt()

	c := make([]int, numOfTypes)
	for i := range c {
		c[i] = readInt()
	}

	s := make([][]int, d)
	for i := range s {
		s[i] = make([]int, numOfTypes)
		for j := range s[i] {
			s[i][j] = readInt()
		}
	}

	t := make([]int, d)
	for i := range t {
		t[i] = readInt() - 1
	}

	satisfaction := 0
	last := make([]int, numOfTypes)
	for i := range t {
		d := i + 1
		satisfaction += s[i][t[i]]
		last[t[i]] = d

		for j := range last {
			span := d - last[j]
			satisfaction -= c[j] * span
		}
		fmt.Println(satisfaction)
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1924
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
	static final int MAX_NUM_TEAMS = 100;
	static final int ID_NOT_FOUND = -1;
	
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Team[] teams= new Team[MAX_NUM_TEAMS];
		Arrays.fill(teams, new Team(0,0));
	
		//チーム情報を取得
		int numTeams = 0;
		while(numTeams < MAX_NUM_TEAMS){
			String[] input = br.readLine().split(",");
			int id = Integer.parseInt(input[0]);
			int point = Integer.parseInt(input[1]);
			if(id == 0 && point == 0)	break;
			teams[numTeams++] = new Team(id, point);
		}
		
		judgeRank(teams, numTeams);
		
		String buf;
		while((buf = br.readLine()) != null){
			int id = Integer.parseInt(buf);
			System.out.println(getRank(teams, id));
		}
	}
	public static void judgeRank(Team[] teams, int numTeams){
		//ポイントでソート
		Arrays.sort(teams, new Comparator<Team>() {
			@Override
			public int compare(Team o1, Team o2) {
				return o2.getPoint() - o1.getPoint();
			}
		});
		//順位付け
		int rank = 1;
		teams[0].setRank(rank);
		for(int i = 1; i < numTeams; i++){
			if(teams[i - 1].getPoint() == teams[i].getPoint()){
				teams[i].setRank(rank);
			}else{
				teams[i].setRank(++rank);
			}
		}
	}
	public static int getRank(Team[] teams, int id){
		for(int i = 0; i < teams.length; i++){
			if(teams[i].getId() == id)	return teams[i].getRank();
		}
		return ID_NOT_FOUND;
	}
}

class Team{
	private int id;
	private int point;
	private int rank;
	public Team(int id, int point) {
		this.id = id;
		this.point = point;
		this.rank = 1000;
	}
	public int getId() {
		return id;
	}
	public int getPoint() {
		return point;
	}
	public void setRank(int rank) {
		this.rank = rank;
	}
	public int getRank() {
		return rank;
	}
	@Override
	public String toString(){
		return this.id + ":" + this.point + ":" + this.rank;
	}
}

Measured memory_bytes: 16924
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, x;
  cin >> n >> x;
  vi a(n), b(n);
  rep(i, n) cin >> a[i], b[i] = a[i];
  if (a[0] > x) a[0] = x;
  loop(i, 1, n) {
    if (a[i] + a[i - 1] > x) {
      a[i] = x - a[i - 1];
    }
  }
  int c = 0;
  rep(i, n) c += b[i] - a[i];

  cout << c << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, q;
  cin >> n >> q;

  vector<tuple<ll,ll,ll,ll>> ev;
  for (int i = 0; i < n; i++){
    ll s, t, x;
    cin >> s >> t >> x;
    
    ev.emplace_back(s-x, 0, x, 1);
    ev.emplace_back(t-x, 0, x, -1);
  }
  for (ll i = 0; i < q; i++){
    ll d;
    cin >> d;
    
    ev.emplace_back(d, 1, i, 0);
  }

  vector<ll> ans(q);
  multiset<ll> s;

  sort(ev.begin(), ev.end());

  
  for (auto e : ev){
    ll com = get<3>(e);
    ll val = get<2>(e);
    if (com == 1){
      s.insert(val);
    }
    else if (com == -1){
      s.erase(s.lower_bound(val));
    }
    else {
      ans[val] = (s.empty() ? -1 : *(s.begin()));
    }
  }

  for (auto v : ans){
    cout << v << endl;
  }
  
  


  return 0;
}


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

int main() {
	int n, k;
	cin>>n>>k;
	int arr[n];
	int dp[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
		int li = max(0, i-k);
		dp[i] = dp[li]+abs(arr[i]-arr[li]);
		for(int j=li;j<i;j++)
		{
			dp[i] = min(dp[j]+abs(arr[i]-arr[j]), dp[i]);
		}
	}
	cout<<dp[n-1];
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<vector<int> > plane(4*k, vector<int>(4*k, 0));
    for(int i=0; i<n; i++){
        int x,y;
        char c;
        cin >> x >> y >> c;
        if(c=='W') x += k;
        x %= 2*k;
        y %= 2*k;
        plane[x][y]++;
        plane[x+2*k][y]++;
        plane[x][y+2*k]++;
        plane[x+2*k][y+2*k]++;
    }
    
    for(int i=0; i<4*k; i++){
        for(int j=0; j<4*k-1; j++){
            plane[i][j+1] += plane[i][j];
        }
    }
    for(int i=0; i<4*k; i++){
        for(int j=0; j<4*k-1; j++){
            plane[j+1][i] += plane[j][i];
        }
    }

    int ans = 0;
    for(int i=0; i<2*k; i++){
        for(int j=0; j<2*k; j++){
            int sub = plane[i][j] -plane[i][j+k] -plane[i+k][j] +plane[i+k][j+k];
            sub += plane[i+k][j+k] -plane[i+k][j+2*k] -plane[i+2*k][j+k] +plane[i+2*k][j+2*k];
            ans = max(ans, sub);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 62976
n=int(input())
a=list(map(int,input().split()))

l=[0,0,0]

mod=10**9+7

ans=1
for i in a:
  l_cnt=l.count(i)
  ans*=l_cnt
  ans%=mod
  for j in range(3):
    if l[j]==i:
      l[j]+=1
      break

print(ans)

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

int main(){
  int N,a,b;
  int i;
  int v;
  int w;
  int x;
  int y;
  int z;
  vector<int> ok(100000);
  vector<int> ok2(100000);
  int sum = 0;
  int j;
  int k;
  cin >> N >> a >> b;
  for(i = 0;i < N;i++){
    v = (i + 1) / 10000;
    w = (i + 1 - v * 10000 ) / 1000;
    x = (i + 1 - 1000 *(10 * v + w))/100;
    y = (i + 1 - 100 * (100 * v + 10 * w + x))/10;
    z = (i + 1 - 10 * (1000 * v + 100 * w + x * 10+ y));
    ok.at(i) =v + w + x + y + z;
    ok2.at(i) = i + 1;
  }

  for(k = 0;k < N;k++){
    if(a <= ok.at(k) && ok.at(k) <= b){
    }
    else{
      ok2.at(k) = 0;
    }
  }

  for(j = 0;j < N;j++){
    sum += ok2.at(j);
  }

  cout << sum << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int L[110];
signed main() {
    cin >> N;
    rep(i, N) { cin >> L[i]; }
    sort(L, L + N);
    int ans = 0;
    rep(i, N) {
        rep(j, i) {
            rep(k, j) {
                if (L[k] != L[j] && L[j] != L[i] && L[k] + L[j] > L[i]) { ans++; }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <unordered_set>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define F first
#define S second
 
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ld long double
using namespace std;
 
int main()
{
    FAST int d, t, s;
    cin >> d >> t >> s;
    if (d <= s*t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,E,ans;
ll edge[64];
ll sum_edge[64];
void MDS(int cur,int cost,ll mask){
	if(cost>=ans)return;
	if(mask==(1LL<<V)-1){
		ans=min(ans,cost);
		return;
	}
	if(cur>=V)return;
	//if((mask|sum_edge[cur])!=(1LL<<V)-1)return;
	MDS(cur+1,cost+1,mask|edge[cur]);
	MDS(cur+1,cost,mask);
	//MDS(cur+1,cost+1,mask|edge[cur]);
}
int main(){
	while(cin>>V>>E,V){
		memset(edge,0,sizeof(edge));
		memset(sum_edge,0,sizeof(sum_edge));
		for(int i=0;i<V;i++)edge[i]|=(1LL<<i);
		for(int i=0;i<E;i++){
			int A,B;
			cin>>A>>B;
			edge[A]|=(1LL<<B);
			edge[B]|=(1LL<<A);
		}
		for(int i=V-1;i>=0;i--) sum_edge[i] |= edge[i];
		for(int i=V-2;i>=0;i--) sum_edge[i] |= sum_edge[i+1];
		ans=1e9;
		MDS(0,0,0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3076
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int main()
{
    ll Q, H, S, D;
    scanf("%lld%lld%lld%lld", &Q, &H, &S, &D);
    ll N;
    scanf("%lld", &N);
    H = min(H, Q*2);
    S = min(S, H*2);
    D = min(D, S*2);
    ll ans = 0;
    ans += D * (N/2);
    N %= 2;
    ans += S * N;
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	d, s, t := io.NextInt(), io.NextInt(), io.NextInt()
	if d <= s*t {
		io.Println("Yes")
	} else {
		io.Println("No")
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
n=gets.to_i

arr=gets.split.map(&:to_i)

arr2=[]

i=0
n.times{
    arr2<<arr[i]-i
    
    i+=1
}


arr3=arr2.sort



key=arr3[n/2]
   
ans=0
j=0
n.times{
   ans+=(arr[j]-key-j).abs
    
   j+=1 
}
  
puts ans

Measured memory_bytes: 20736
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int q = scanner.nextInt();
        int[] p = new int[n];
        Arrays.fill(p, k - q);
        for (int i = 0; i < q; i++) {
            p[scanner.nextInt() - 1]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(p[i] > 0 ? "Yes" : "No");
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=min(a,b)+min(c,d);
    cout<<ans<<endl;
    return  0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> R(H, vector<char>(W));
  vector<vector<int>> Bnum(H, vector<int>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> R.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int count = 0;
      if (R.at(i).at(j) == '.') {
        for (int I = i - 1; I < i + 2; I++) {
          for (int J = j - 1; J < j + 2; J++) {
            if(I >= 0 && J >= 0 && I < H && J < W) {
              if (R.at(I).at(J) == '#') count++;
            }
          }
        }
        Bnum.at(i).at(j) = count;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (R.at(i).at(j) == '#') {
        cout << R.at(i).at(j);
      }
      else cout << Bnum.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    double r;
    double s, l;
    double pi = 3.141592653589793238;
    scanf("%lf", &r);
    s = r * r * pi;
    l = 2.000000 * pi * r;
    printf("%.6f %.6f\n", s, l);
    return 0;
}

Measured memory_bytes: 2748
dp=[1000000 for i in range(100010)]
dp[0]=0
for n in range(1,100010):
  power=1
  while(power<=n):
    dp[n]=min(dp[n],dp[n-power]+1)
    power*=6
  power=1
  while(power<=n):
    dp[n]=min(dp[n],dp[n-power]+1)
    power*=9

i=int(input())
print(dp[i])

Measured memory_bytes: 3956
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<complex>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

typedef pair<ll,ll> P;
ll a[100010],b[100010]; P c[100010];


int main(){
  ll n;
  cin >> n;
  rep(i,n) cin >> a[i] >> b[i];

  rep(i,n) {
    c[i].fi = a[i] + b[i]; 
    c[i].sc = i;
  }

  sort(c,c+n,greater<P>());

  ll X = 0,Y = 0;
  rep(i,n) {
    if (i % 2 == 0) X += a[c[i].sc];
    else Y+=b[c[i].sc];
  }
  cout << X - Y << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
  
  int N;
  int b, r, f, v;
  
  //ポイント：配列の値を１つプラスにする　➡　入力するとき１、２、３と入力するから配列の０番目のは値が入らないタメ
  int house[5][4][11] = {};
  cin >> N;
  
  for(int i = 0; i < N; i++){
      
    //４棟について入居者数を入力
    cin >> b >> f >> r >> v;
      
    //４棟について入居者数と転居者数を計算する
    house[b][f][r] += v;
      
    //条件１：管理の過程で１部屋の入居者数が０より少なくなることはない。
    if(house[b][f][r] < 0) house[b][f][r] = 0;
      
    //条件２：管理の過程で１部屋の入居者数が9より多くなることはない。
    else if(house[b][f][r] > 9) house[b][f][r] = 9;
  }
  
  
    //４棟について入居者数を出力する
    for(int b = 1; b <= 4; b++){
        for(int f = 1; f <= 3; f++){
            for(int r = 1; r <= 10; r++){
                cout << " " << house[b][f][r];
            }
            cout << endl;
        }
        if(b < 4)cout << "####################" << endl;
    }
    
}

/********************************************　　コメントなしコード　　************************************************
 
#include <iostream>
using namespace std;
int main(void){
  
  int N;
  int b, r, f, v;
  int house[5][4][11] = {};
  
  cin >> N;
  
  for(int i = 0; i < N; i++){
  
      cin >> b >> f >> r >> v;
      
      house[b][f][r] += v;
      
      if(house[b][f][r] < 0) house[b][f][r] = 0;
      else if(house[b][f][r] > 9) house[b][f][r] = 9;
  }
  
    for(int b = 1; b <= 4; b++){
        for(int f = 1; f <= 3; f++){
            for(int r = 1; r <= 10; r++){
                cout << " " << house[b][f][r];
            }
            cout << endl;
        }
        if(b < 4)cout << "####################" << endl;
    }
    
}
 
 
*******************************************************************************************************************/
    






Measured memory_bytes: 3072
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
st = []
ans = 0
for i in range(n):
    st.append(list(tuple(s[i])))
    st[i].sort()
    st[i] = str(st[i])
st.sort()
count = Counter(st)
for v in count.values():
    if v != 1:
        for n in range(1, v):
            ans += n
print(ans)


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



typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=1010;

int a,b,c;

int main(){
	a=rd(),b=rd(),c=rd();
	cout<<max(0,c-(a-b))<<endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w,n;cin>>h>>w>>n;
  if(h<w)
  {
    h=h+w;
    w=h-w;
    h=h-w;
  }
  cout<<(n-1)/h+1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
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)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    int ans=0;
    for(int i=1;i<=x;i++){
        for(int j=1;j<=x;j++){
            for(int k=1;k<=x;k++){
                ans+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <cmath>

using namespace std;

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

	set<int> st;
	st.insert(1);

	for (int i = 0; i < n; i++) {
		set<int> st2;
		for (set<int>::iterator ite = st.begin(); ite != st.end(); ite++) {
			st2.insert(*(ite)*2);
			st2.insert(*(ite)+k);
		}
		st = st2;
	}

	set<int>::iterator it = st.begin();

	cout << *(it) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
void bfs(ll now) {
	queue<ll> Q;
	Q.push(now);
	D[now] = 0;
	flag[now] = 1;
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		X = u;
		ans = max(ans, D[u]);
		for (ll v = 0; v < path[u].size(); v++) {
			ll next = path[u][v];
			if (flag[next] == 0) {
				D[next] = D[u] + 1;
				flag[next] = 1;
				Q.push(next);
			}
		}
	}
}
int main() {
	ll X = 0;
	cin >> N;
	path.resize(N);
	flag.resize(N);
	D.resize(N);
	for (i = 0; i < N-1; i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
	}
	bfs(0);
	ll pre = 0;
	for (i = 0; i < N; i++) {
		if (pre < D[i]) {
			pre = D[i]; X = i;
		}
		flag[i] = 0; D[i] = 0;
	}
	bfs(X);
    cout << (ans % 3 == 1 ? "Second" : "First");
}

Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll v,e,s;
ll d[110000];
vector<l_l> g[110000];
void dijkstra(ll s){
    rep(i,110000)d[i]=LINF;
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> pq;
    pq.push({0,s});
    while(pq.size()){
        ll nowd=pq.top().fi;
        ll nowp=pq.top().se;
        pq.pop();
        if(nowd>d[nowp])continue;
        for(auto next:g[nowp]){
            ll nextp=next.fi;
            ll nextd=next.se;
            if(chmin(d[nextp],d[nowp]+nextd)){
                pq.push({d[nextp],nextp});
            }
        }
    }
    return;
}
int main(){
    cin>>v>>e>>s;
    rep(i,e){
        ll u,v,x;cin>>u>>v>>x;
        g[u].pb({v,x});
    }
    dijkstra(s);
    rep(i,v){
        if(d[i]!=LINF)cout<<d[i]<<endl;
        else cout<<"INF"<<endl;
    }
    return 0;
}


Measured memory_bytes: 19740
#include <iostream>
using namespace std;
int main(){
int H, W;
for (int i = 0; ; i++){
cin >> H >> W;
if (H==0 && W==0) break;
for (int h=0; h<H; h++){
for (int w=0; w<W; w++) cout << "#";
cout << endl;
}
cout << endl;
}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
	ll n,k;
	cin>>n>>k;
	vi a;
	a.resize(n);
	forn(i,n)cin>>a[i];

	ll simple_sum = 0;
	forn(i,n){
		forn(j,n){
			if(i >= j)continue;
			if(a[i]>a[j])simple_sum ++;
		}
	}    
	// cout<<simple_sum<<endl;
	ll delta = (k*(k-1))>>1;
	delta %= MOD;    
	simple_sum = (k)*simple_sum;
	simple_sum %= MOD;
	sort(all(a));
	forn(i,n){
		int idx = (int)(lower_bound(all(a), a[i]) - a.begin());
		// cout<<i<<" "<<idx<<endl;
		simple_sum += delta*(idx);
		simple_sum %= MOD; 
	}

	cout<<simple_sum<<endl;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    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++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n+10);
    ll ans = 0;
    ll sum = 0;
    rep(i, n)
    {
        cin >> a[i];
    }
    ll r = 0;
    for (ll l = 0; l < n; l++)
    {
        if(r<=l){
            r = l;
            sum = 0;
        }
        while (r < n && !(sum&a[r]))
        {
            sum+=a[r];
            r++;
        }
        ans +=r - l;
        sum-=a[l];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define int long long
#define endl '\n'
typedef long long ll;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin >> n >> k;
	int res = 0;
	for(int b = k+1; b <= n; ++b) {
		int maxMult = (n-k)/b;
		res += (b-k) * maxMult + min(n,(maxMult+1)*b-1) - (maxMult*b+k) + 1;
		if(k == 0) --res;
	}
	cout << res;
}


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

int main(){
  int N;
  cin>>N;
  multiset<int> A;
  for (int i=0; i<N; i++){
    int x;
    cin>>x;
    A.insert(x);
  }
  cout<<*A.rbegin()-*A.begin()<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,Q;
string S[2020];
int X1[202020],Y1[202020],X2[202020],Y2[202020];
int ret[202020];

int st[2020][2020];
int dep[2020][2020];
int SS[2020][2020];
int vis[2020][2020];

void dfs(int cy,int cx,int d) {
	// left
	int ty,tx;
	vis[cy][cx]=1;
	dep[cy][cx]=d;
	ty=cy,tx=cx-1;
	if(tx>=0 && S[ty][tx]=='1' && vis[ty][tx]==0) dfs(ty,tx,d+1);
	ty=cy,tx=cx+1;
	if(tx<W && S[ty][tx]=='1' && vis[ty][tx]==0) dfs(ty,tx,d+1);
	ty=cy-1,tx=cx;
	if(ty>=0 && S[ty][tx]=='1' && vis[ty][tx]==0) dfs(ty,tx,d+1);
	ty=cy+1,tx=cx;
	if(ty<H && S[ty][tx]=='1' && vis[ty][tx]==0) dfs(ty,tx,d+1);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>Q;
	FOR(y,H) cin>>S[y];
	
	FOR(i,Q) {
		cin>>Y1[i]>>X1[i]>>Y2[i]>>X2[i];
		X1[i]--;
		Y1[i]--;
		X2[i]--;
		Y2[i]--;
		
	}
	
	FOR(y,H) FOR(x,W) if(S[y][x]=='1' && vis[y][x]==0) {
		vis[y][x]=1;
		st[y][x]++;
		dfs(y,x,2);
	}
	FOR(y,H+1) FOR(x,W+1) SS[y+1][x+1]=SS[y+1][x]+SS[y][x+1]+st[y][x]-SS[y][x];
	
	
	FOR(i,Q) {
		r=SS[Y2[i]+1][X2[i]+1]+SS[Y1[i]][X1[i]]-SS[Y2[i]+1][X1[i]]-SS[Y1[i]][X2[i]+1];
		for(y=Y1[i];y<=Y2[i];y++) {
			if(X1[i]>0 && dep[y][X1[i]]==dep[y][X1[i]-1]+1) r++;
			if(X2[i]<W && dep[y][X2[i]]==dep[y][X2[i]+1]+1) r++;
		}
		for(x=X1[i];x<=X2[i];x++) {
			if(Y1[i]>0 && dep[Y1[i]][x]==dep[Y1[i]-1][x]+1) r++;
			if(Y2[i]<H && dep[Y2[i]][x]==dep[Y2[i]+1][x]+1) r++;
		}
		
		_P("%d\n",r);
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 74752