akhauriyash/Code-Regression huggingface dataset:
def solve():
  n, m = map(int, input().split())
  h = list(map(int, input().split()))
  tenbo = []
  ans = 0
  bit = [0]*n
  for i in range(m):
    tenbo.append(list(map(int, input().split())))
  hoge = [[] for i in range(n)]
  for i in range(m):
    hoge[tenbo[i][0]-1].append(tenbo[i][1]-1)
    hoge[tenbo[i][1]-1].append(tenbo[i][0]-1)
  for i in range(n):
    for j in hoge[i]:
      if h[i] <= h[j]:
        bit[i] = 1
        break
  print(bit.count(0))
  return 0

 
if __name__ == "__main__":
  solve()


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

int main() {
	while (1) {
		int n, x;
		cin >> n >> x;
		if (n + x == 0)
			break;
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1;  k <= n; k++) {
					if (i + j + k == x)
						sum++;
				}
			}
		}
		cout << sum << endl;
	}
}



Measured memory_bytes: 3088
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    vi v(n);
    for(int &x:v) cin>>x;
        sort(all(v));

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            auto it = lower_bound(all(v), v[i] + v[j]);

            int dist = 0;

            // cout<<v[i]<<" "<<v[j]<<" -> "<<*it<<" = ";

            if(it == v.end()) dist = n - j - 1;
            else dist = it - v.begin() - j - 1;

            // cout<<dist<<endl;

            ans += dist;
        }
    }

    cout<<ans;
} 

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

using namespace std;

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



int main(){

  vector<int> count(100000,0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    count[a[i]]--;
    count[a[i]+1]--;
    count[a[i]-1]--;
  }
  sort(count.begin(),count.end());
  cout << -1*count[0] << endl;


  return 0;
}


Measured memory_bytes: 1024
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=200009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int a[M+4];
int dan[M+3],bam[M+2];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    stack<pi>s;
    f(i,1,n)
    {
        int cur=a[i];
        while(!s.empty())
        {
            int val=s.top().fi;
            if(val>cur)
            {
                s.pop();
            }
            else break;
        }
        if(s.empty())bam[i]=0;
        else bam[i]=s.top().si;
        s.push(mp(a[i],i));
    }
    while(!s.empty())s.pop();
    rf(i,n,1)
    {
         int cur=a[i];
        while(!s.empty())
        {
            int val=s.top().fi;
            if(val>cur)
            {
                s.pop();
            }
            else break;
        }
        if(s.empty())dan[i]=n+1;
        else dan[i]=s.top().si;
        s.push(mp(a[i],i));
    }
    int sum=0;
    f(i,1,n)
    {
        int lft=bam[i];
        int rgt=dan[i];
        int x=i-lft-1;
        int y=rgt-i-1;
        int cnt=x*y+x+y+1;
        sum+=(cnt*a[i]);

    }
    cout<<sum<<endl;

















    return 0;

}













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

using namespace std;

int main() {
    int h, n;
    scanf("%d%d", &h, &n);

    long long sum = 0;

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        sum += x;
    }

    if (sum >= h) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> matrix;

void solve() {
  int h, w, n;
  cin >> h >> w >> n;
  set<pii> interesting;
  set<pii> valid;
  vector<ll> ret;
  ret.resize(10);
  ret[0] = (h-2LL)*(w-2LL);
  while(n--) {
    int x, y;
    cin >> x >> y;
    valid.insert({x, y});
    for(int a = x-2; a <= x; a++) for(int b = y-2; b <= y; b++) if(a >= 1 && b >= 1 && a+2 <= h && b+2 <= w) interesting.insert({a, b});
  }
  for(auto out: interesting) {
    int amt = 0;
    for(int i = out.first; i <= out.first+2; i++) for(int j = out.second; j <= out.second+2; j++) amt += valid.count({i, j});
    ret[0]--;
    ret[amt]++;
  }
  for(ll out: ret) cout << out << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 47104
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = list(map(int, input().split(" ")))
	
	ans = 0
	gu = []
	
	for i in A:
		if i % 2 == 0:
			ans += 1
			gu.append(int(i / 2))
			
	while True:
		if len(gu) == 0:
			break
			
		tmp = []
		for i in gu:
			if i % 2 == 0:
				ans += 1
				tmp.append(int(i / 2))
		gu = tmp
	
	print(ans)
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 14256
#include<iostream>

using namespace std;

const int N(1e5 + 9);

int n, m, ans;
long long f[N];
int w[N], v[N];

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=m;j>=w[i];j--)
		{
			f[j] = max(f[j], f[j - w[i]] + v[i]);
		}
	}
	cout<<f[m]<<endl;
	return 0;
}

Measured memory_bytes: 1024
import * as fs from 'fs';
const DEBUG = false;
const input = fs.readFileSync("/dev/stdin", "utf8").trim();
// 処理
const [N, Y] = input.split(" ").map(v => parseInt(v));
let [x, y, z] = [-1, -1, -1];

const maxX = Math.floor(Y / 10000);
debuglog(maxX);
ST: for (let xi = maxX; xi >= 0; xi--) {
    for (let yi = N - xi; yi >= 0; yi--) {
        const zi = N - xi - yi;
        if (xi * 10000 + yi * 5000 + zi * 1000 === Y && xi + yi + zi === N) {
            x = xi; y = yi; z = zi;
            break ST;
        }
    }
}

console.log(`${x} ${y} ${z}`);
// テスト実行は`npm run test` -> 値input -> `ctrl+d`


function debuglog(n: any) {
    if (DEBUG) {
        console.log(n);
    }
}

Measured memory_bytes: 7500
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int answer = 0;
	for (int C = 1; C <= N; C += 2) {
		int num_of_divisors = 0;
		for (int X = 1; X <= C; ++X) {
			if (C % X == 0) {
				++num_of_divisors;
			}
		}
		if (num_of_divisors == 8) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}

Measured memory_bytes: 3556
/**
 * Finding_a_Word2.cpp
 * Create:20180430
 * Description:文章Tの中に存在する
 * 単語Wの数をカウントするプログラム。
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cstdio>

const std::string END_KEYWORD = "END_OF_TEXT";

/**
 * 一致判定関数
 * @param  target  対象文字列
 * @param  keyword 検索文字列
 * @return         一致判定
 */
bool isMatch(const std::string &target, const std::string &keyword){
  if(target == keyword)
    return true;
  return false;
}

int main(int argc, char* argv[]){
  std::string keyword;
  std::vector<std::string> words;

  std::cin >> keyword;
  // すべて小文字に変更
  std::transform(keyword.begin(), keyword.end(), keyword.begin(), tolower);

  while (true){
    std::string input;
    std::cin >> input;
    if (input == END_KEYWORD)
      break;
    // すべて小文字に変更
    std::transform(input.begin(), input.end(), input.begin(), tolower);
    words.push_back(input);
  }

  int result = 0;
  for (std::string str:words){
    if (isMatch(str, keyword)){
      result++;
    }
  }

  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
#define over ((1ll << 32))
using namespace std;
#define N 2005
 
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl
 
typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;
 
signed main()
{
    FAST;
    int n;
    cin >> n;
    vector<int> arr(n , 0);
    rep(i , 0 , n)
        cin >> arr[i];
    int dp[n];
    memset(dp , 0 , sizeof dp);
    int ma = 0;
    for (int i = 1 ; i < n ; i++)
    {
        if (arr[i] <= arr[i - 1])
            dp[i] = dp[i - 1] + 1;
        else
            dp[i] = 0;
        ma = max(ma , dp[i]);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);

		sa = br.readLine().split(" ");
		int[] pre = new int[n + 1];
		int[] last = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int c = Integer.parseInt(sa[i]);
			pre[i + 1] = last[c];
			last[c] = i + 1;
		}

		List<List<Obj>> list = new ArrayList<>();
		for (int i = 0; i <= n; i++) {
			list.add(new ArrayList<>());
		}
		Obj[] arr = new Obj[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.i = i;
			o.l = Integer.parseInt(sa[0]);
			o.r = Integer.parseInt(sa[1]);
			list.get(o.r).add(o);
			arr[i] = o;
		}
		br.close();

		BIT bit = new BIT(n);
		int j = 1;
		for (List<Obj> list2 : list) {
			for (Obj o : list2) {
				while (j <= o.r) {
					bit.add(j, 1);
					if (pre[j] > 0) {
						bit.add(pre[j], -1);
					}
					j++;
				}
				o.ans = bit.sum(o.r) - bit.sum(o.l - 1);
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			pw.println(arr[i].ans);
		}
		pw.flush();
	}

	static class Obj {
		int i, l, r;
		long ans;
	}

	static class BIT {
		int n;
		long[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new long[n + 1];
		}

		void add(int idx, long val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		long sum(int idx) {
			long sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


Measured memory_bytes: 121384
using System;
using System.Text.RegularExpressions;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = Console.ReadLine();
            var S = Console.ReadLine();

            var r = Regex.Matches(S, "ABC");
            Console.WriteLine(r.Count);
        }
    }
}


Measured memory_bytes: 14356
#include <bits/stdc++.h>
using namespace std;
char a[1005][1005];
bool vis[1005][1005];
long long n,m,dp[2005][2005],mod = 1e9 + 7;
bool valid(int i, int j){
    return i > -1 && j > -1 && i < n && j < m && a[i][j] != '#';
}
long long solve(int i, int j){
    if (a[i][j] == '#')
        return 0;
    if (i >= n || j >= m)
        return 0;
    if(i == n - 1 && j == m - 1)
        return 1;
    long long &ans = dp[i][j];
    if(ans != -1)
        return ans;
    ans = 0;
    ans = (ans % mod + solve(i + 1, j) % mod) % mod;
    ans = (ans % mod + solve(i, j + 1) % mod) % mod;
    return ans % mod;
}
int main()
{
    cin >> n >> m;
    //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    memset(dp , -1, sizeof dp);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }

    cout << solve(0,0) % mod<< endl;
    return 0;
}


Measured memory_bytes: 33792
n = int(input())
a = sorted(list(map(int, input().split())))
q = int(input())
l = [0]*(10**5+10)
for i in a:
    l[i] += 1
s = sum(a)
for _ in range(q):
    b, c = map(int, input().split())
    s += (c - b) * l[b]
    l[c] += l[b]
    l[b] = 0
    print(s)


Measured memory_bytes: 21064
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    string s;
    getline(cin,s);
    for(int i = 0; i < s.length(); i++){
        if(s[i] >= 65 && s[i] <= 90) s[i] += 32;
        else if(s[i] >= 97 && s[i] <= 122) s[i] -= 32;
        cout << s[i];
    }
    cout << endl;
}



Measured memory_bytes: 3144
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, map) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll x; cin >> x;
    ll c = x / 11; ll ret = c * 2;
    if(x % 11 >= 7){
        ret += 2;
    }
    else if(x % 11 >= 1){
        ret += 1;
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
# d = [[0]*3] * 3

a = [[i for i in map(int, input().split())] for j in range(3)]
n = int(input())

# a = [[66, 85, 92], [56, 37, 86], [7, 52, 23]]
# n = 9
# B = [30, 85, 52, 48,89, 92, 26, 5, 67]

d = [[0] * 3 for i in range(3)]
for i  in range(n):
    b = int(input())
    # b = B[i]
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1
if d[0][0] + d[0][1] + d[0][2] == 3 or d[1][0] + d[1][1] + d[1][2] == 3 or d[2][0] + d[2][1] + d[2][2] == 3 or d[0][0] + d[1][0] + d[2][0] == 3 or d[0][1] + d[1][1] + d[2][1] == 3 or d[0][2] + d[1][2] + d[2][2] == 3 or d[0][0] + d[1][1] + d[2][2] == 3 or d[0][2] + d[1][1] + d[2][0] == 3:
    print('Yes')
else:
    print('No')

# flag = False
# for i in range(3):
#     cnt = 0
#     for j in range(3):
#         cnt += d[i][j]
#     if cnt == 3:
#         flag = True
#
# for i in range(3):
#     cnt = 0
#     for j in range(3):
#         cnt += d[j][i]
#     if cnt == 3:
#         flag = True
#
# cnt = 0
# for i in range(3):
#     cnt += d[i][i]
#     if cnt == 3:
#         flag = True
#
# cnt = 0
# for i in range(3):
#     cnt += d[i][2-i]
#     if cnt == 3:
#         flag = True
# print("Yes") if flag == True else print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int m,n;
  cin>>m>>n;
  int a[m][n];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++)cin>>a[i][j];
  }
  int c=0;
  float t;
  for(int i=0;i<m-1;i++){
    for(int k=i+1;k<m;k++){
      t=0;
      for(int j=0;j<n;j++){t+=pow(a[i][j]-a[k][j],2);}
      if((int)sqrt(t)==(float)sqrt(t))c++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
a = input()
over = int(a[:2])
under = int(a[2:])
if 0<over<13 and 0<under<13:
   print("AMBIGUOUS")
elif 0<over<13 and (1>under or under>12):
     print("MMYY")
elif 0<under<13 and (1>over or over>12):
     print("YYMM")
else:
     print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int r;
    cin >> r;
    cout << r * r << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x >> y >> k;
    if(x == k or x < k and x + y > k)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(char c='a';c<='z';c++){
		if(s.find(c)==string::npos){
			cout<<c<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


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

int main(){
    string S;
    int count = 0;
    cin >> S;

    if (S[0] == 'o') count = count + 1;
    if (S[1] == 'o') count = count + 1;
    if (S[2] == 'o') count = count + 1;

    int ans = 0;
    ans = 700 + 100 * count;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	string s;
	scanf("%d", &n);
	scans(s);
	string t, tt;
	int ans = 0;
	rep(i, n) {
		t = s.substr(0, i);
		tt = s.substr(i, n);
		sort(all(t));
		sort(all(tt));
		t.erase(unique(all(t)), t.end());
		tt.erase(unique(all(tt)), tt.end());
		int tmp = 0;
		for (auto aa : t) {
			tmp += (tt.find(aa) != string::npos);
		}
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,tl;
  cin >> n >> tl;
  int ans = 10000;
  rep(i,0,n) {
    int c,t;
    cin >> c >> t;
    if (t <= tl) ans = min(ans,c);
  }
  if (ans == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

unsigned long long mod = 3;
class mint{
    public:
        ll x;
        //constexpr static unsigned long long mod = 1e+9 + 7;
        mint(){}
        mint(ll _x) : x((_x % mod + mod)%mod){}
        mint& operator=(const ll &a){
            x = a;
            return *this;
        }

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            mint res(*this);
            return res += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            mint res(*this);
            return res -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        mint& operator*=(const ll& a){
            mint temp(a);
            return *this *= temp;
        }
        mint operator*(const mint& a) const{
            mint res(*this);
            return res *= a;
        }
        mint operator*(const ll& a) const{
            mint res(*this);
            return res *= a;
        }
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            mint res(*this);
            return res /= a;
        }
};
ostream& operator>>(ostream& os, const mint& a){
    os >> a.x;
    return os;
}
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}


int main() {
    cin>>N>>M;
    mod = M;
    vector<vector<mint> >  dp(N + 1, vector<mint>(N * 3 + 1, mint(0)));
    dp[N][N * 3] = 1;
    mint ans(0);
    Rrep(i, N + 1){
        Rrep(j, N * 3 + 1){
            if(i == 0){
                ans += dp[i][j];
            }else{
                if(j >= 1) dp[min(i, (j - 1) / 2)][j - 1] += dp[i][j];
                if(j >= 2) dp[i - 1][j - 2] += dp[i][j] * (j - 1);
                if(j >= 3) dp[min(i - 1, (j - 3) / 2)][j - 3] += dp[i][j] * (j - 1) * (j - 2);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 94208
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,temp4=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=-1,minn=1e10,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0;
    
    cin>>k;
    
    if(k<=10)
    {
        cout<<k<<endl;
        return 0;
    }
    
    vector<string> vect;
    string a;
    vect.push_back("1");
    vect.push_back("2");
    vect.push_back("3");
    vect.push_back("4");
    vect.push_back("5");
    vect.push_back("6");
    vect.push_back("7");
    vect.push_back("8");
    vect.push_back("9");
    char c,dd;
    for(i=0;i<vect.size();i++)
    {
        a = vect[i];
        if(a[a.size()-1]=='0')
        {
            vect.push_back(a+'0');
            vect.push_back(a+'1');
            //vect.push_back(a+'2');
        }
        
        else if(a[a.size()-1]=='9')
        {
            vect.push_back(a+'8');
            vect.push_back(a+'9');
            //vect.push_back(a+'2');
        }
        
        else
        {
            c = a[a.size()-1];
            //dd=c;
            c--;
           vect.push_back(a+c);
            c++;
            vect.push_back(a+c);
            ++c;
           // cout<<c<<"  "<<a<<endl;
            vect.push_back(a+c);
            
        }
        
        if(vect.size()>=100009) break;
        
        
    }
    
   
    cout<<vect[k-1]<<endl;
    
    
    
    
    
    
    
}


Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int val=n/500;
int ans=val*1000;
n=n-val*500;
val=n/5;
ans+=val*5;
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#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--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}



struct edge {
	int from;
	int to;
	int cost=1;
};


auto dijkstra(vector<vector<edge>> &g, int start = 0) {
	vector<int> d(g.size(), I_MAX);
	d[start] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> nodes;//first dist, second edgenum
	nodes.push(pair<int, int>(0, start));


	while (!nodes.empty()) {
		pair<int, int> n = nodes.top();
		int s_node = n.second;
		nodes.pop();
		if (n.first > d[n.second])continue;
		rep(i, 0, g[s_node].size()) {
			int new_dist = d[s_node] + g[s_node][i].cost;
			int n_num = g[s_node][i].to;
			if (new_dist < d[n_num]) {
				nodes.push(make_pair(new_dist, n_num));
				d[n_num] = new_dist;
			}
		}
	}
	return d;
}

int main() {

	int n;
	cin >> n;
	vector<int> h(n);
	vector<int> dp(n, I_MAX);
	dp[0] = 0;
	rep(i, 0, n) {
		cin >> h[i];
	}
	dp[1] = abs(h[0] - h[1]);
	rep(i, 2, n) {
		dp[i] = min(dp[i], 
			    min(dp[i - 1] + abs(h[i] - h[i - 1]), 
					dp[i - 2] + abs(h[i] - h[i - 2])));
	}

	cout << dp[n-1] << endl;

	return 0;
}

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

using namespace std;

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

  int mx = 0;
  int number = 1;
  for(int i = 1; i <= n; i++) {
    int count = 0;
    int tmp = i;
    while(tmp != 0 && tmp != 1) {
      tmp = tmp / 2;
      count++;
    }
    if(mx < count) {
      mx = count;
      number = i;
    }
  }

  cout << number << endl;
}

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

using namespace std;

typedef long long ll;

int g[16][16];

int main() {
  memset(g, -1, sizeof g);
  int n; cin >> n;
  for(int i = 1; i <= n; i++) {
    int t; cin >> t;
    for(int j = 0; j < t; j++) {
      int x, y; cin >> x >> y;
      g[i][x] = y;
    }
  }
  int ans = 0;
  for(int i = 0; i < (1 << n); i++) {
    bool valid = true;
    for(int j = 0; j < 15; j++) {
      if(!((i >> j) & 1)) continue;
      for(int k = 0; k < 15; k++) {
        if(k == j) continue;
        if(!((i >> k) & 1)) continue;
        if(g[k + 1][j + 1] == 0 or g[j + 1][k + 1] == 0) {
          valid = false;
          break;
        }
      }
      for(int k = 0; k < 15; k++) {
        if(((i >> k) & 1)) continue;
        if(g[j + 1][k + 1] == 1) {
          valid = false;
          break;
        }
      }
      if(valid == false) break;
    }
    if(valid) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << '\n';
}



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

int main() {
  int N, n, f=0;
  cin >> N;
  n = N;
  while (n>0)f+=n%10,n/=10;
  if (N%f==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(void)
{
	int A[3];
	scanf("%d%d%d", &A[0], &A[1], &A[2]);
	sort(A, A+3);
	int res = A[2]-A[1];
	A[0] += A[2]-A[1];
	A[1] = A[2];
	if((A[2]-A[0])%2) A[2]++, res++;
	res += (A[2]-A[0])/2;
	printf("%d\n", res);
}

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

using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
bool dp[100000 + 2][7];

bool solve(const int X) {
  int v[6] = {100, 101, 102, 103, 104, 105};
  for(int i = 0; i <= X; i+=v[0]) dp[i][0] = true;
  for(int j = 1; j <= 5; j++) {
    for(int i = 0; i <= X; i++) {
      dp[i][j] |= dp[i][j-1];
      int k = i - v[j];
      if(k >= 0) {
	dp[i][j] |= dp[k][j];
      }
    }
  }
  //  REP(i, X+1) cout << i << " " << dp[i][5] << endl;
  return dp[X][5] ;
}

int main() {
  int X; cin>>X;
  bool ret = solve(X);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 896
import qualified Data.ByteString.Lazy.Char8 as B
import Data.ByteString.Lazy.Char8 (ByteString)
import Control.Monad.Trans.State.Strict
import Control.Applicative (many)
import Data.Char (isSpace)

main :: IO ()
main = B.interact $ output . solve . input

output :: Int -> ByteString
output = B.pack . show
{-# INLINE output #-}

solve :: [Int] -> Int
solve = sum . map pred
{-# INLINE solve #-}

input :: ByteString -> [Int]
input = maybe (error "parse error") fst . runStateT (parseInt *> many parseInt)
{-# INLINE  input #-}

parseInt :: StateT ByteString Maybe Int
parseInt = StateT $ B.readInt . B.dropWhile isSpace
{-# INLINE parseInt #-}


Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, m, x;
	bool valid = true;
	cin >> n;
	map<int, int> ct;
	for (i = 0; i < n; i++) {
		cin >> x;
		ct[x]++;
	}
	cin >> m;
	for (i = 0; i < m; i++) {
		cin >> x;
		if (ct[x] <= 0) valid = false;
		else ct[x]--;
	}

	if (valid) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}



Measured memory_bytes: 9600
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
#define SIZE 131072
int f[SIZE<<1],g[SIZE<<1];
int n,k,a[SIZE],b[SIZE],l[SIZE],r[SIZE];
int inv[SIZE<<1];
map<int,int>mp;
void rc(int l,int r,int k,const int &ql,const int &qr,const int &val){
	if(ql>qr)return;
	if(r<ql||qr<l)return;
	if(ql<=l&&r<=qr){
		g[k]=min(g[k],val);
		return;
	}
	rc(l,(l+r)/2,k<<1,ql,qr,val);
	rc((l+r)/2+1,r,k<<1|1,ql,qr,val);
}
int query(int l,int r,int k,const int &pos){
	if(l==r)return g[k];
	int mid=(l+r)/2;
	if(pos<=mid)return min(g[k],query(l,mid,k<<1,pos));
	else return min(g[k],query(mid+1,r,k<<1|1,pos));
}
signed main(){
	memset(g,inf,sizeof g);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		if(b[i]==1&&a[i]*2>k){
			puts("-1");
			return 0;
		}
		a[i]+=a[i-1];
		if(b[i]==2)l[i]=0,r[i]=k-1;
		else l[i]=(-a[i-1]*2ll%k+k)%k,r[i]=(-a[i]*2ll%k+k)%k;
		mp[l[i]];mp[r[i]];
	}
	int tot=0;for(auto &p:mp)p.second=++tot;
	for(int i=1;i<=n;i++){
		inv[mp[l[i]]]=l[i];inv[mp[r[i]]]=r[i];
		l[i]=mp[l[i]];r[i]=mp[r[i]];
	}
	for(int i=n;i>=1;i--){
		int pos=query(0,SIZE-1,1,l[i]);
		if(pos<=n){
			f[i]=f[pos]+(inv[l[pos]]-inv[l[i]]+k)%k;
		}else{
			f[i]=0;
		}
		if(l[i]<=r[i]){
			rc(0,SIZE-1,1,r[i]+1,tot,i);
			rc(0,SIZE-1,1,1,l[i]-1,i);
		}else{
			rc(0,SIZE-1,1,r[i]+1,l[i]-1,i);
		}
	}
	ll ans=(ll)inf*inf;
	for(int i=1;i<=tot;i++){
		int pos=query(0,SIZE-1,1,i);
		if(pos>n)ans=0;
		else ans=min(ans,(ll)f[pos]+(inv[l[pos]]-inv[i]+k)%k);
	}
	ans+=a[n]*2ll;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15488
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,x,sum[410],dp[410][410];

LL dfs(int lb,int ub)
{
  if(dp[lb][ub]!=-1) return dp[lb][ub];
  if(lb==ub) return dp[lb][ub]=0;
  dp[lb][ub]=1e18;
  for(int i=lb;i<ub;i++) dp[lb][ub]=min(dp[lb][ub],dfs(lb,i)+dfs(i+1,ub)+sum[ub+1]-sum[lb]);
  return dp[lb][ub];
}

int main()
{
  cin>>n;
  repn(i,n)
  {
    cin>>x;
    sum[i]=sum[i-1]+x;
  }
  rep(i,405) rep(j,405) dp[i][j]=-1;
  cout<<dfs(0,n-1)<<endl;
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

// 二項係数計算
long long COM(int n, int k){
   if (n < k) return 0;
   if (n < 0 || k < 0) return 0;
   return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(int argc, char const *argv[]) {
  COMinit();
  int n,k;
  cin >> n >> k;

  for(int j=1; j<=k; j++){
    cout << COM(k-1,j-1)*COM(n-k+1,j)%MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 12160
import sys
sys.setrecursionlimit(10**7)
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
visited=[[False]*w for _ in range(h)]

def dfs(y,x):
    visited[y][x]=True
    blk,wht=0,0
    for dy,dx in ((-1,0),(0,-1),(1,0),(0,1)):
      ny,nx=y+dy,x+dx
      if (not (0<=ny<h)) or (not (0<=nx<w)) or visited[ny][nx]: 
        continue
      if s[y][x]!=s[ny][nx]:
        nb,nw=dfs(ny,nx)
        blk+=nb
        wht+=nw
    if s[y][x]=="#":
      blk+= 1
    else:
      wht+= 1
    return blk,wht

ans=0
for i in range(h):
  for j in range(w):
    #到達できる限り進み、残ったやつを順にdfs
    if not visited[i][j]:
      blk,wht=dfs(i,j)
      ans+=blk*wht
print(ans)

Measured memory_bytes: 155740
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <set>
//#include <bits/stdc++.h>
#define ll  long long
#define cn(i,n,a) for(int i=0;i<n;i++)cin>>a[i];
#define co(i,n,a) for(int i=0;i<n;i++)cout<<a[i]<<" ";
#define lp(i,n) for(int i=0;i<n;i++)
const ll mod = 1e9 + 7;
using namespace std;
void right() {
	cout << "Yes\n";
	exit(0);
}
void fail() {
	cout << -1;
	exit(0);
}
ll gcd(int a, int b) {
	if (a == 0 || b == 0)
		return 0;
	else if (a == b)
		return a;
	else if (a > b)
		return gcd(a - b, b);
	else return gcd(a, b - a);
}
map<int, int>m;
int main()
{
	int n, k;
	cin >> n >> k;
	if (n == k)cout << "Yes";
	else cout << "No";
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    vector<vector<ll>>g(n);
    vector<ll>ans(n,-1);
    for (int i = 0; i < m; ++i) {
        ll a,b;cin >>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<ll>que;
    que.push(0);
    ll p=-1;
    while(!que.empty()){
        ll v=que.front();
        que.pop();
//        cout <<v<<endl;
        for(auto u:g[v]){
            if(ans[u]!=-1)continue;
            ans[u]=v;
            que.push(u);
        }
    }
    puts("Yes");
    for (int i = 1; i < n; ++i) {
        cout <<ans[i]+1<<endl;
    }
    return 0;
}



Measured memory_bytes: 12856
#include <iostream>

int main() {
    int a, b;
    char op;

    while (std::cin >> a >> op >> b, op != '?') {
        if (op == '+') std::cout << a + b << std::endl;
        if (op == '-') std::cout << a - b << std::endl;
        if (op == '*') std::cout << a * b << std::endl;
        if (op == '/') std::cout << a / b << std::endl;
    }
}


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

using ll=long long;
const ll INF=1e15;


int main(){
    int n,m;
    ll l;
    cin>>n>>m>>l;
    vector<ll> k(n);
    for(int i=0;i<n;i++){
        cin>>k[i];
        k[i]--;
    }   
    sort(k.begin(),k.end());
    vector<ll> s(m); 
    for(int i=0;i<m;i++){
        cin>>s[i];
    }
    vector<ll> sum(m+1);
    partial_sum(s.begin(),s.end(),sum.begin()+1);
    
    auto rev=[&](int a,int b){
        return (sum[b+1]-sum[a])/l;
    };
    vector<vector<ll>> dp(n,vector<ll>(n,INF));
    dp[0][0]=0;
    for(int i=0;i+1<n;i++){
        for(int j=0;j+1<n;j++){
            int to=max(i,j)+1;
            dp[to][j]=min(dp[to][j],dp[i][j]+rev(k[i],k[to]));
            dp[i][to]=min(dp[i][to],dp[i][j]+rev(k[j],k[to]));
        }
    }
    
    ll res=INF;
    for(int i=0;i<n;i++){
        res=min(res,dp[i][n-1]+rev(k[i],k[n-1]));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 35836