akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
pair<bool, vector<long long>> bellman_ford_2(vector<vector<pair<int, int>>> &E, int s){
    int V = E.size();
    vector<long long> d(V, INF);
    d[s] = 0;
    for (int i = 0; i < V; i++){
        bool update = false;
        for (int j = 0; j < V; j++){
            for (int k = 0; k < E[j].size(); k++){
                int c = E[j][k].first;
                int v = E[j][k].second;
                if (d[v] > d[j] + c && d[j] != INF){
                    d[v] = d[j] + c;
                    update = true;
                    if (i == V - 1){
                        return make_pair(true, d);
                    }
                }
            }
        }
        if (!update){
            break;
        }
    }
    return make_pair(false, d);
}
int main(){
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<pair<int, int>>> e(V);
  for (int i = 0; i < E; i++){
    int s, t, d;
    cin >> s >> t >> d;
    e[s].push_back(make_pair(d, t));
  }
  pair<bool, vector<long long>> R = bellman_ford_2(e, r);
  if (R.first){
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < V; i++){
      if (R.second[i] == INF){
        cout << "INF" << endl;
      } else {
        cout << R.second[i] << endl;
      }
    }
  }
}


Measured memory_bytes: 3236
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class hawawa
{
  static Printer sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };

  static void Main()
  {
    Console.SetOut(sw);
    solve();
    Console.Out.Flush();
  }
  
  static void solve()
  {
    Scanner scanner = new Scanner();
    char[] str = scanner.next().ToCharArray();
    char[] t = scanner.next().ToCharArray();
    if(str.Count() < t.Count())
    {
      Console.WriteLine("UNRESTORABLE");
      return;
    }
    bool replace = false;
    for (int i = str.Count() - t.Count(); i >= 0; i--)
    {
      replace = true;
      for(int j = 0; j < t.Count(); j++)
      {
        if (str[i + j] == t[j] || str[i + j] == '?') { }
        else
        {
          replace = false;
          break;
        }
      }
      if (replace)
      {
        for (int j = 0; j < t.Count(); j++)
        {
          str[i + j] = t[j];
        }
        break;
      }
    }
    if (replace)
    {
      string ans = new string(str).Replace('?', 'a');
      Console.WriteLine(ans);
    }
    else
    {
      Console.WriteLine("UNRESTORABLE");
    }
  }
}

class Scanner
{
  string[] s;
  int i;


  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    i = 0;
    return next();
  }

  public int nextInt()
  {
    return int.Parse(next());
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }

}

class Printer : StreamWriter
{
  public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
  public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
  public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){
    /*??£???????????????????????????
            int a[2];
            cin >> a[1] >> a[2];
            cout << "[+] " << a[1] + a[2] << endl;
            cout << "[-] " << a[1] - a[2] << endl;
            cout << "[*] " << a[1] * a[2] << endl;
            cout << "[/] " << a[1] / a[2] << endl;
    */

    int a;
    while(cin >> a){
        if(a == 0){break;}
        int ans[10] = {0,0,0,0,0,0,0,0,0,0};
        string ans2[10] = {"","","","","","","","","",""};
        int p;
        for(int i = 1;a >= i;i++){
            cin >> p;ans[p]++;
        }
        for(int i = 0;9 >= i;i++){
            if(ans[i] == 0){
                ans2[i] = "-";
            }else{
                for(int ii = 1;ans[i] >= ii;ii++){
                    ans2[i] += "*";
                }
            }
            cout << ans2[i] << endl;
        }

    }
}

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


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

    int n, count = 0;
    bool ans = false;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            count++;
            if (count == 3) ans = true;
        } else {
            count = 0;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

string word_toupper(string a){
    string b = a;
    for(int i=0;i<a.size();i++){
        if(isalpha(a[i])) b[i] = toupper(a[i]);
    }
    return b;
}

int main(){
    string keyword;
    string a;
    int count = 0;
    cin>>keyword;
    keyword = word_toupper(keyword);

    while(true){
        cin>>a;
        if(a=="END_OF_TEXT") break;
        a = word_toupper(a);
        if(keyword==a) count+=1;
    }
    cout<<count<<'\n';

}


Measured memory_bytes: 3160
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int n, m, k;
vector<int> a, b;

int main() {

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

	cin >> n >> m >> k;

	a = vector<int> (n);
	b = vector<int> (m);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}

	int i = 0;
	long long curr_time = 0;
	int books = 0;
	while (i < n) {
		curr_time += a[i];

		if (curr_time > k) {
			curr_time -= a[i];
			break;
		}

		++i;
		++books;
	}

	int ans = books;
	int j = 0;
	--i;
	while (j < m) {
		if (curr_time + b[j] <= k) {
			curr_time += b[j];
			++j;
			++books;
		} 
		else if (i >= 0) {
			curr_time -= a[i];
			--i;
			--books;
		} else {
			break;
		}

		ans = max(ans, books);
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 4764
h, n = gets.split.map(&:to_i)

ab = []
max = 0
n.times do 
    ab << gets.split.map(&:to_i)
    max = ab[-1][0] if max < ab[-1][0]
end

dp = Array.new(h + max + 1, 10 ** 9)
dp[0] = 0

1.upto(h + max) do |i|
    ab.each do |a, b|
        next if i < a
        dp[i] = dp[i - a] + b if dp[i] > dp[i - a] + b
    end
end

puts dp[h..h+max].min

Measured memory_bytes: 1916
N, Y = [int(i) for i in input().split()]

flag = 0

cand_list = []
for x in range(N + 1):
    for y in range(N + 1):
        money = Y - 10000*x - 5000*y
        z = N - x - y
        if z >= 0:
            if money % 1000 == 0:
                if money//1000 == z:
                    if flag == 0:
                        flag = 1
                        print(x, y, z)
                
if flag == 1:
    pass
else:
    print(-1, -1 , -1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int k,n,a[200009],dis[200009];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>k>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	a[0]=k+a[0];
	for(int i=0;i<n;i++) dis[i]=a[(i+1)%n]-a[i];
	int mx=0;
	for(int i=0;i<n;i++) mx=max(mx,dis[i]);
	cout<<k-mx<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>i) & 1
#define setpre(n) fixed << setprecision((n))
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VVI A(N, VI(N-1));
  REP(i, N) REP(j, N-1) cin >> A.at(i).at(N - j - 2);
  VPII today, tomorrow;
  int ans = 0;
  REP(i, N-1)
  {
    int ai = A.at(i).back() - 1;
    REP2(j, i+1, N)
    {
      int aj = A.at(j).back() - 1;
      if (ai == j && aj == i) today.push_back(make_pair(i, j));
    }
  }
  REPx(x, today)
  {
    int a = x.first;
    int b = x.second;
    A.at(a).pop_back();
    A.at(b).pop_back();
  }
  while(!today.empty())
  {
    PII game = today.back();
    today.pop_back();
    int a = game.first;
    int b = game.second;
    if (!A.at(a).empty() && !A.at(A.at(a).back()-1).empty() && a == A.at(A.at(a).back()-1).back()-1)
    {
      tomorrow.push_back(make_pair(min(a, A.at(a).back()-1), max(a, A.at(a).back()-1)));
    }
    if (!A.at(b).empty() && !A.at(A.at(b).back()-1).empty() && b == A.at(A.at(b).back()-1).back()-1)
    {
      tomorrow.push_back(make_pair(min(b, A.at(b).back()-1), max(b, A.at(b).back()-1)));
    }

    if (today.empty())
    {
      ans++;
      today = tomorrow;
      tomorrow.clear();
      SORT(today);
      today.erase(unique(ALL(today)), today.end());
      REPx(x, today)
      {
        int a = x.first;
        int b = x.second;
        A.at(a).pop_back();
        A.at(b).pop_back();
      }
    }
  }
  REPx(x, A)
  {
    if (!x.empty())
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6272
<?php

  $n = trim(fgets(STDIN));
  
  $a = explode(" ", trim(fgets(STDIN)));
  
  $search=1;
  $ans=0;
  for($i=0;$i<$n;$i++){
    if($a[$i]!=$search){
      $ans++;
    }
    else{
      $search++;
    }
  }
  if($ans==$n){
    echo "-1";
  }
  else{
    echo $ans;
  }
  


Measured memory_bytes: 19060
x, k, d = gets.split.map(&:to_i)
 
x = x.abs
 
result = if x < k * d
  if k.even?
    n = x / (2 * d)
    a = x - n * 2 * d
    b = a - 2 * d
    [a.abs, b.abs].min
  else
    if x <= d
      (x - d).abs
    else
      x -= d
      n = x / (2 * d)
      a = x - n * 2 * d
      b = a - 2 * d
      [a.abs, b.abs].min
    end
  end
else
  x - k * d
end
 
puts result

Measured memory_bytes: 14376
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  map<ll, ll> m1;
  map<ll, ll> m2;
  rep(i, N + 1) {
    if (i == 0) continue;
    ll a;
    cin >> a;
    m1[i + a]++;
    m2[i - a]++;
  }

  ll ans = 0;
  for (auto mm : m1) {
    ans += mm.second * m2[mm.first];
  }
  ANS;
  return 0;
}

Measured memory_bytes: 37748
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
m=n-1
if m%2==1:
    k=(m-1)//2
    ans=a[n-1]
    for i in range(k):
        ans+=2*a[n-2-i]
    print(ans)
else:
    k=m//2
    ans=a[n-1]+a[n-k-1]
    for i in range(k-1):
        ans+=2*a[n-2-i]
    print(ans)
    

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

using namespace std;

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

  vector<long> p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }

  vector<long> cum_sum(n + 1, 0);
  for (int i = 0; i < n; ++i)
  {
    cum_sum[i + 1] = cum_sum[i] + (p[i] + 1);
  }

  long ek_max = 0;
  for (int i = 0; i + k <= n; ++i)
  {
    ek_max = max(ek_max, cum_sum[i + k] - cum_sum[i]);
  }

  cout << fixed << setprecision(10) << (double) (ek_max) / 2.0 << endl;

}

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

bool print(int *Path){
    for (int i = 0;i < 4; i ++){
        if (Path[i] >= 3){
            return false;
        }
    }
    return true;
}

int main(){
    int Path[4] = {};
    int x, y;
    for (int i = 0; i < 3; i ++){
        cin >> x >> y;
        Path[x - 1] += 1;
        Path[y - 1] += 1;
    }
    if (print(Path)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] numberArray = new int[n];
		for(int i =0;i < n;i++) {
			numberArray[i] = sc.nextInt();
		}
		int answer =0;
		boolean continueFlg = true;
		while(continueFlg){
			for(int i = 0;i < n;i++) {
				if(numberArray[i] % 2 ==0) {
					numberArray[i] /= 2;
					if(i == n-1) {
						answer++;
					}
				}else {
					continueFlg = false;
					break;
				}
			}
		}
		System.out.println(answer);
	}
}

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

int main(void){
  int N = 0;
  cin >> N;
  int count = 0;
  vector<int> vec(N);
  vector<int> result(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  for(int i = 0; i < N - 1; i++){
    int j = i + 1;
    if(vec.at(i) >= vec.at(j)){
      result.at(count) = result.at(count) + 1;
    } else {
      count++;
    }
  }
  sort(result.begin(),result.end());
  reverse(result.begin(),result.end());
  cout << result.at(0);
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

static const int N = 100;
static const int I=(1<<21);
static const int W= 0;
static const int G =1;
static const int B =2;

int n,M[N][N];

int dij(){
  int minv,d[N],color[N];
  for(int i=0;i<n;i++){
    d[i]=I;
    color[i]=W;
  }

  d[0]=0;
  color[0]=G;

  while(1){
    minv=I;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=B){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=B;
    for(int v=0;v<n;v++){
      if(color[v]!=B&&M[u][v]!=I){
        if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=G;
        }
  
      
          
      }
      }
        
    }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==I ? -1 : d[i])<<endl;
  }
}

int main(){
  cin>>n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=I;
    }
  }

  int k,c,v,u;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      M[u][v]=c;
    }
  }

  dij();
  return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
bool H(int x,int y,int z){
    int sum=0;
    while(x!=0){
        sum+=x%10;
        x/=10;
    }
    return y<=sum && sum<=z;
}
int main(){
    int x,y,z,sum=0;
    cin>>x>>y>>z;
    for(int i=1;i<=x;i++)
        if(H(i,y,z)) sum+=i;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int flip;
    long long rotate;
} Query;

long long n, k, q;

Query tree[(1 << 20) * 2];

void  build(long long _n);
Query merge(Query a, Query b);
void  update(Query data, long long i);
Query sum(void);

int main()
{
    long long _n;
    long long a;

    scanf("%lld %lld %lld", &k, &_n, &q);

    build(_n);

    for (long long i = 0; i < _n; i++) {
        scanf("%lld", &a);

        Query data = {0, 0};

        if (a == 0) data.flip = 1;
        else data.rotate = -a;

        update(data, i);
    }

    for (long long i = 0; i < q; i++) {
        long long left, right;
        Query l, r;
        scanf("%lld %lld", &left, &right);
        left--;
        right--;

        l = tree[left + n - 1];
        r = tree[right + n - 1];

        update(l, right);
        update(r, left);


        Query total = sum();

        long long num;
        if (total.rotate < 0) total.rotate = k + total.rotate;
        num = 1 + total.rotate;

        if (total.flip) {
            if (num == 1) num *= -1;
            else num = ((k + 2) - num) * -1;
        }

        printf("%lld\n", num);
        //        printf("%d %lld\n", total.flip, total.rotate);
    }
    
    return 0;
}

void  build(long long _n)
{
    n = 1;

    while (n < _n) {
        n *= 2;
    }

    for (long long i = 0; i < 2 * n; i++) {
        tree[i] = (Query){0, 0};
    }

    return;
}

Query merge(Query a, Query b)
{
    Query x;

    x.flip = (a.flip + b.flip) % 2;

    if (b.flip) {
        x.rotate = (b.rotate - a.rotate) % k;
    } else {
        x.rotate = (a.rotate + b.rotate) % k;
    }

    return x;
}

void update(Query data, long long i)
{
    i += n - 1;

    tree[i] = data;

    while (i != 0) {
        i = (i - 1) / 2;
        tree[i] = merge(tree[i * 2 + 1], tree[i * 2 + 2]);
    }

    return;
}

Query sum(void)
{
    return tree[0];
}



Measured memory_bytes: 5964
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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



signed main(){
	ll n;
	cin >> n;
	ll x[n],l[n];
	P p[n];
	
	rep(i,0,n){
		cin >> x[i] >> l[i];
		p[i].fs = x[i]+l[i]-1;
		p[i].sc = x[i]-l[i]+1;
	}
	
	sort(p,p+n);
	
	ll cnt = 0,pos = -5 *LINF;
	
	rep(i,0,n){
		if(pos < p[i].sc){
			cnt++;
			pos = p[i].fs+1;
		}
	}
	
	cout << cnt << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int tmp = N;
  
  for (int i = 0; i < 8; i++) {
    sum = sum + tmp % 10;
    tmp /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')
mod = 10**9 + 7

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())


x = I()

n = ceil( ( -1 + sqrt(1+8*x) )/2 )
print(n)

Measured memory_bytes: 77280
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        long a = int.Parse(inputs[1]);
        long b = int.Parse(inputs[2]);
        var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] dp = 
            Enumerable.Repeat((long)int.MaxValue, n + 1).ToArray();
        dp[0] = 0;
        foreach(int num in array)
        {
            dp[num] = dp.Take(num).Min();
            foreach(int i in Enumerable.Range(0, num))
            {
                dp[i] += a;
            }
            foreach(int i in Enumerable.Range(0, n + 1).Skip(num + 1))
            {
                dp[i] += b;
            }
            //System.Console.WriteLine(string.Join(" ", dp));
        }
        System.Console.WriteLine(dp.Min());
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13664
#include <stdio.h>

int main(){
	int n, in, max = 0, sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		if(in > max)max = in;
		sum += in;
	}
	sum -= max / 2;
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5+4;

int main(){
	string S;
	cin>>S;
	int K;
	cin>>K;
	int l=S.size();
	
	set<string> d;
	rep(i,l){
		string T={};
		int ind=i;
		while(ind<i+K && ind<l){
			char p=S[ind];
			T.push_back(p);
			d.insert(T);
			ind++;
		}
	}
	set<string>::iterator it;
	int x=1;
	it=d.begin();
	while(x<K){
		it++;
		x++;
	}
	cout<<*it;
}

Measured memory_bytes: 1664
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int[] a = new int[3 * N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static long solve(int[] a) {
        long[] leftSums = buildLeftSums(a);
        long[] rightSums = buildRightSums(a);

        return IntStream.range(0, a.length - 1).filter(i -> leftSums[i] != -1 && rightSums[i + 1] != -1)
                .mapToLong(i -> leftSums[i] - rightSums[i + 1]).max().getAsLong();
    }

    static long[] buildLeftSums(int[] a) {
        int N = a.length / 3;

        PriorityQueue<Integer> pq = new PriorityQueue<>();
        long sum = 0;

        long[] result = new long[a.length];
        for (int i = 0; i < result.length; ++i) {
            if (pq.size() == N && pq.peek() < a[i]) {
                sum -= pq.poll();
            }
            if (pq.size() != N) {
                pq.offer(a[i]);
                sum += a[i];
            }

            result[i] = (pq.size() == N) ? sum : -1;
        }

        return result;
    }

    static long[] buildRightSums(int[] a) {
        int N = a.length / 3;

        PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
        long sum = 0;

        long[] result = new long[a.length];
        for (int i = a.length - 1; i >= 0; --i) {
            if (pq.size() == N && pq.peek() > a[i]) {
                sum -= pq.poll();
            }
            if (pq.size() != N) {
                pq.offer(a[i]);
                sum += a[i];
            }

            result[i] = (pq.size() == N) ? sum : -1;
        }

        return result;
    }
}

Measured memory_bytes: 93488
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    int N = S.size();
    
    string ans = S[0] + to_string(N - 2) + S[N-1];

    cout << ans << endl;

    return 0;
}

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

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

  vector<int> box(N,1);
  vector<bool> red(N, false);
  red[0] = true;
  rep (i, M) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    if (red[x]) {
      red[y] = true;
      if (box[x] == 1) red[x] = false;
    }
    box[x]--; box[y]++;
  }

  int ans = 0;
  rep(i, N) {
    if (red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3700
import sys

input = sys.stdin.buffer.readline
n, q = map(int, input().split())
C = list(map(int, input().split()))
LR = []
for i in range(q):
    l, r = map(int, input().split())
    LR.append((l, r, i))
LR.sort(key=lambda x: x[1])


BIT = [0] * (n + 1)


def update(idx, val):
    while idx <= n:
        BIT[idx] += val
        idx += idx & (-idx)


def query(idx):
    res = 0
    while idx > 0:
        res += BIT[idx]
        idx -= idx & (-idx)
    return res


pos = [-1] * (n + 1)


def func(idx):
    temp = C[idx]
    if pos[temp] == -1:
        pos[temp] = idx + 1
        update(idx + 1, 1)
    else:
        pre = pos[temp]
        pos[temp] = idx + 1
        update(pre, -1)
        update(idx + 1, 1)


ans = [0] * (q)
idx = 0
for i in range(q):
    l, r, ans_num = LR[i]
    # l,rは0-indexに戻す
    l -= 1
    r -= 1
    while idx < r + 1:  # rになるまで増やす
        if idx < n:  # n超えないように注意
            func(idx)
            idx += 1
        else:
            break
    res = 0
    res += query(r + 1)
    if l > 0:
        res -= query(l)
    ans[ans_num] = res

print(*ans, sep="\n")


Measured memory_bytes: 189224
#include <bits/stdc++.h>
using namespace std;
using lld = int64_t;
const int N = 200000 + 5;

int a[ N ];
lld dp[ N ][ 5 ];

int main() {
	int n; scanf( "%d", &n );
	for ( int i = 1 ; i <= n ; ++ i )
		scanf( "%d", a + i );
	for ( int i = 1 ; i <= n ; ++ i ) {
		lld mi = dp[ i - 1 ][ 0 ];
		dp[ i ][ 0 ] = mi + a[ i ];
		mi = min( mi, dp[ i - 1 ][ 1 ] );
		dp[ i ][ 1 ] = mi + ( a[ i ] ? ( a[ i ] & 1 ) : 2 );
		mi = min( mi, dp[ i - 1 ][ 2 ] );
		dp[ i ][ 2 ] = mi + ( ( a[ i ] + 1 ) & 1 );
		mi = min( mi, dp[ i - 1 ][ 3 ] );
		dp[ i ][ 3 ] = mi + ( a[ i ] ? ( a[ i ] & 1 ) : 2 );
		mi = min( mi, dp[ i - 1 ][ 4 ] );
		dp[ i ][ 4 ] = mi + a[ i ];
	}
	lld mi = dp[ n ][ 0 ];
	for ( int i = 1 ; i < 5 ; ++ i )
		mi = min( mi, dp[ n ][ i ] );
	printf( "%" PRId64 "\n", mi );
	return 0;
}

Measured memory_bytes: 8832
#include <algorithm>
#include <iostream>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1000000007LL;
const ll INF = LONG_LONG_MAX / 2LL;

vector<ll> A;
vector<ll> B;

ll count_same(const ll value, const vector<ll> &xs) {
    auto l = lower_bound(xs.begin(), xs.end(), value);
    auto u = upper_bound(xs.begin(), xs.end(), value);
    return u - l;
}

ll count_same_or_larger(const ll value, const vector<ll> &xs) {
    auto l = lower_bound(xs.begin(), xs.end(), value);
    return xs.end() - l;
}

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    B.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    sort(B.begin(), B.end());

    ll acc = 1;
    const ll K = N * M;
    for (int i = K; i >= 1; i--) {
        ll count_same_A = count_same(i, A);
        ll count_same_B = count_same(i, B);
        ll count_sl_A = count_same_or_larger(i, A);
        ll count_sl_B = count_same_or_larger(i, B);

        if (count_same_A > 1 || count_same_B > 1) {
            cout << "0" << endl;
            return 0;
        } else if (count_same_A == 1 && count_same_B == 1) {
            // there is only one possiblity
        } else if (count_same_A == 1) {
            acc = acc * count_sl_B % MOD;
        } else if (count_same_B == 1) {
            acc = acc * count_sl_A % MOD;
        } else {
            acc = acc * ((count_sl_A * count_sl_B - (K - i)) % MOD) % MOD;
        }
    }

    cout << acc << endl;

    return 0;
}


Measured memory_bytes: 256
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0
if a[0][0]==0 and a[0][1]==0 and a[0][2]==0:
  print("Yes")
  exit()
elif a[1][0]==0 and a[1][1]==0 and a[1][2]==0:
  print("Yes")
  exit()
elif a[2][0]==0 and a[2][1]==0 and a[2][2]==0:
  print("Yes")
  exit()
elif a[0][0]==0 and a[1][0]==0 and a[2][0]==0:
  print("Yes")
  exit()
elif a[0][1]==0 and a[1][1]==0 and a[2][1]==0:
  print("Yes")
  exit()
elif a[0][2]==0 and a[1][2]==0 and a[2][2]==0:
  print("Yes")
  exit()
elif a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
  print("Yes")
  exit()
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  print("Yes")
  exit()
else:
  print("No")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,m,c;
	cin>>n>>m>>c;
	int b[30];
	fori(m){cin>>b[i];}
	int a[30][30];
	fori(n){
		forj(m){
			cin>>a[i][j];
		}
	}
	c*=-1;
	int count=0;
	fori(n){
		int sum=0;
		forj(m){
			sum+=a[i][j]*b[j];
		}
		if(sum>c){
			++count;
		}
	}
	cout<<count;
}

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

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


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

int main()
{
	int x,a,b,c,i,j,k,s=0;
	
	cin>>a>>b>>c;
	cin>>x;
	
	for (i=0;i<=a;i++)
	   for (j=0;j<=b;j++)
	      for (k=0;k<=c;k++)
	      {
	      	if (i*500+j*100+k*50==x) s++;
	      }
	      
	      cout<<s<<endl;
	      
	      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n)     for (ll i = k; i < n; ++i)
#define repr(i,k,n)    for (ll i = k; i >= n; --i)
#define repp(p,a)      for (p=a.begin();p!=a.end();++p)
#define all(a)         a.begin(),a.end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define reppn(p,a,n)    for (p=a.begin();(p+n)!=a.end();++p)
#define F              first
#define S              second
#define ll             long long
#define hell           1000000007
#define god            LLONG_MAX
#define lb             lower_bound
#define ub             upper_bound
#define pb             push_back
#define ct             continue
#define endl           '\n'
#define setprecision(n) sp(n)
#define srt(a)         sort(all(a))
#define srtd(a)        sort(a.rbegin(),a.rend())
#define sz(a)          ll((a).size())
#define sum(a)         accumulate(all(a),(ll) 0)
#define pdt(a)         accumulate(all(a),double(1),multiplies<double> ())
#define dotpdt(a,b)    inner_product(all(a),b.begin(),0)
#define mkp(a,b)       make_pair(a,b)
#define REP(x,s)       for (auto x : s)
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--)
  {
      ll x;
      cin>>x;
      vector<ll>v(1000001,1);
      for(ll i=2;i*i<1000001;i++)
      {
          if(v[i])
          {
              for(ll j=i*i;j<1000001;j+=i)
              {
                  v[j]=0;
              }
          }
      }
      rep(i,x,1000001)
      {
          if(v[i])
          {
              cout<<i;
              break;
          }
      }
  }
 return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    vi a(3);
    cin >>a[0]>>a[1]>>a[2];
    SORT(a);
    cout <<abs(a[2]-a[0]);
    
    return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    flag = 0
    for i in range(a[2]):
        count=0
        if flag == 0:
            if a[0] %2 ==1:
                a[0]-=1
            a[0]=a[0]//2
            a[1]+=a[0]
            flag=1
        else:
            if a[1] %2 ==1:
                a[1]-=1
            a[1]=a[1]//2
            a[0]+=a[1]
            flag=0
    print(str(a[0])+" "+str(a[1]))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 5e3 + 1;
int n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon";
    else if(n == 3)
        cout << "bon";
    else
        cout << "pon";
    return 0;
}

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

string W[105];
int main() {
    int N;
    cin >> N;
    for(int i=1;i<=N;i++) {
        cin >> W[i];
    }

    for(int i=1;i<=N-1;i++) {
        if (W[i].back()!=W[i+1].front()) {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=1;i<=N;i++) {
        for (int j=i+1;j<=N;j++) {
            if (W[j]==W[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;

const int mod = 1e9 + 7;

int add(int i, int j) {
  if((i += j) >= mod) i -= mod;
  return i;
}

int mult(int i, int j) {
  return (ll) i * j % mod;
}

struct Matrix {
  vvi M;
  Matrix(int n) : M(n, vi(n)) {}
  int size() { return M.size(); }
  vi& operator[](int n) { return M[n]; }
};

Matrix operator * (Matrix H, Matrix G) {
  Matrix T(G.size());
  for(int i = 0; i < G.size(); ++i)
    for(int j = 0; j < G.size(); ++j)
      for(int k = 0; k < G.size(); ++k)
        T[i][j] = add(T[i][j], mult(H[i][k], G[k][j]));
  
  return T;
}

Matrix operator ^ (Matrix H, ll k) {
	Matrix R(H.size());
    for(int i = 0; i < R.size(); ++i)
      R[i][i] = 1;
  	while(k) {
      if(k % 2)
        R = R * H;
      H = H * H;
      k /= 2;
    }
  
  return R;
}

int main() {
  int n;
  ll k; cin >> n >> k;
  Matrix Mat(n);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      cin >> Mat[i][j];
  
  Mat = (Mat ^ k);
  
  int mx = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      mx = add(mx, Mat[i][j]);
  
  cout << mx;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner in;
	
	private static int n;
	private static int[] h;
	private static int[] v;
	private static final int MOD = (int)1e9+7;
	private static long[] seg;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		h =  new int[n];
		v =  new int[n];
		for(int i=0; i<n; i++) {
			h[i] = in.nextInt();
		}

		for(int i=0; i<n; i++) {
			v[i] = in.nextInt();
		}
		
		int m = 4*(int)1e6;
		seg = new long[m];
		
		for(int i=n-1; i>=0; i--) {
			long value = query(h[i]+1, (int)1e6, 0, 4*n-1, 0);
			
			update(h[i], value+v[i], 0, 4*n-1, 0);
		}
		
		System.out.println(query(0, (int)1e6, 0, 4*n-1, 0));
		
	}
	
	private static long query(int qlow, int qhigh, int low, int high, int pos) {
		if (qlow>high || low>qhigh) {
			return -(long)1e15;
		} else if (qlow<=low && qhigh>=high) {
			return seg[pos];
		} else {
			int mid = (low+high)/2;
			return Math.max(query(qlow, qhigh, low, mid, 2*pos+1), query(qlow, qhigh, mid+1, high, 2*pos+2));
		}
	}
	
	private static void update(int index, long v, int low, int high, int pos) {
		if (low==high) {
			seg[pos] = Math.max(seg[pos], v);
			return;
		}
		
		int mid = (low+high)/2;
		if (index<=mid) {
			update(index, v, low, mid, 2*pos+1);
		} else {
			update(index, v, mid+1, high, 2*pos+2);
		}
		
		seg[pos] = Math.max(seg[2*pos+1], seg[2*pos+2]);
		
		
	}
	
	

}


Measured memory_bytes: 134080
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
    var str = input[1].split(" ");
	var ans = '';
  	for(var i=0; i<n; i++){
    	ans += str[0].charAt(i);
          	ans += str[1].charAt(i);
    }
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = max(0, A[0] - x)
p = min(A[0], x)
for i in range(1, N):
    d = p + A[i] - x
    if d > 0:
        A[i] -= d
        ans += d
    p = A[i]
print(ans)


Measured memory_bytes: 14132
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size();
    vector<char> s1(N), s2(N);
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) {
            s1[i] = '1';
            s2[i] = '0';
        }
        else{
            s1[i] = '0';
            s2[i] = '1';
        }
    }
    int cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < N; i++){
        if(S[i] != s1[i]) cnt1++;
        if(S[i] != s2[i]) cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}


string str;
int n;

int main() {
    int res = 0;
    cin >> str; cin >> n;
    for (int i = 0; i < n; ++i) {
        string ring; cin >> ring;
        ring = ring + ring;
        bool exist = false;
        for (int j = 0; j < ring.size(); ++j) {
            if (ring.substr(j, str.size()) == str) {
                exist = true; break;
            }
        }
        if (exist) ++res;
    }
    cout << res << endl;
    
    return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    int t; cin >> t;
    m[t]++;
  }
  vector<int> v;
  for (auto &i : m) {
    v.push_back(i.sc);
  }
  sort(all(v), greater<int>());
  int ans = 0;
  for (int i = v.size() - 1; i > k - 1; i--) {
    ans += v[i];
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

using ll = long long int;
constexpr int MOD = 1e9+7;

int main()
{
	int n; cin >> n;
	ll pre = 0;
	ll num;
	ll ans = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> num;
		ans = (ans + (pre * num)% MOD ) % MOD;
		pre += num;
		pre %= MOD;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3572
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 2019;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	string s;
	cin >> s;
	ll n = s.size();

	ll ans = 0;
	Vec prev(MOD), cur(MOD);
	rep(i, n){
		cur.assign(MOD, 0);
		ll k = s[i] - '0';
		cur[k]++;
		rep(i, MOD){
			cur[(i * 10 + k) % MOD] += prev[i];
		}

		ans += cur[0];
		swap(cur, prev);
	}

	co(ans);

	return 0;
}


Measured memory_bytes: 3728