akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vll A(4);
  ll a=1;
  ll b=0;
  FOR(i,0,4){
    ci(A[i])
      a*=A[i];
    b+=A[i];
  }
  if(a==252&&b==21){
    co("YES")
  }
  else{
    co("NO")
  }
}


Measured memory_bytes: 256
while 1:
    n = int(input())
    s = 0
    t = 0
    if n == 0:
        break
    a = list(map(float,input().split()))
    s += sum(a)
    h = float(sum(a)/int(n))
    for i in range(n):
        t += float(((a[i] - h)**2)/float(n))
    st = t**0.5
    print(st)


Measured memory_bytes: 5732
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define in insert
#define int ll
using namespace std;
using namespace __gnu_pbds;
 
const ll N =(3e5+5);
const ll MOD = 998244353;
const ll INF = 1e16;
const ll LOG = 25;
 
 
long long binpow(long long a, long long b) {
    // a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}
bool pali(string s){
    string t=s;
    reverse(all(t));
    if(t==s) return true;
    return false;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s;
    cin >> s;

    ll n = 1ll * s.size();
    string t;
    for(int i =0;i<((n-1)/2);i++){
        t+=s[i];
    }
    string x;
    for(int i = ((n+3)/2)-1;i<n;i++){
        x+=s[i];
    }
    if(pali(s) && pali(x) && pali(t)){
        cout<<"Yes\n";
    }
    else 
        cout<<"No\n";

}
/*
for(int i =1;i<=m;i++){
        for(int j = 1;j<=i;j++){
            cout<<"ELEMENTS : " << i << " , " << "ROUNDED DOWN : " << j << " DP VALUE : "<< dp[i][j] << endl;
        }
    }
*/

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

int main()
{
  int n;
  cin >> n;
  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  long long L0 = 2, L1 = 1, L;
  for(int i = 2; i <= n; ++i) {
    L = L0 + L1;
    L0 = L1;
    L1 = L;
  }

  cout << L << endl;
  return 0;
}

Measured memory_bytes: 3636
import sys
for s in sys.stdin:
  y,m,d=map(int,s[:-1].split())
  x=y*10000+m*100+d
  if x<18680908:print"pre-meiji"
  elif x<19120730:print"meiji",y-1867,m,d
  elif x<19261225:print"taisho",y-1911,m,d
  elif x<19890108:print"showa",y-1925,m,d
  else:print"heisei",y-1988,m,d

Measured memory_bytes: 4212
my $s = <STDIN>;

$ans = 0;
$N = 1;
for(my $i=0;$i<50;$i++){
#print "$i $N \n";
  $s = int($s/2);
  $ans = $ans + $N;
  if($s==0){
    print $ans;
    exit;
  }
  $N = $N *2;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 2200
ll dp[MAXN];

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

  dp[3]=dp[4]=dp[5]=1;
  for(int i=6; i<=n; i++){
    for(int j=3; j<=i-3; j++){
      dp[i] += dp[j];
      dp[i] %= MOD;
    }
    dp[i]++;
  }

  cout<<dp[n]<<endl;

  return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <array>
#include <vector>
 
//using namespace std;
 
int main()
{
    std::vector<bool> S;
    char c;
    long S_counter = 0;
    while (std::cin >> c) {
        if (c == '\n') {
            break;
        }
        S.push_back(c == 'B');
        S_counter++;
    }
 
    long result_counter = 0;
    long b_counter = S_counter;
 
    for (long i = S_counter - 1; i >= 0; i--) {
        if (S.at(i)) {
            b_counter--;
            result_counter += (b_counter - i);
        }
    }
    std::cout << result_counter << std::endl;
 
 
    return 0;
}


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

int main() {
  int N;
  int t = 1;
  double sum = 0.0;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++) {
    s.at(i) = t;
    ++t;
    if (s.at(i) % 2 != 0) {
      ++sum;
    }
  }
  double j;
  j = sum / N;
  cout << j << endl;
}


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

x = tx - sx
y = ty - sy
ans = 'R' * x + 'U' * y + 'L' * x + 'D' * y + 'D' + 'R' * (x + 1) + 'U' * (y + 1) \
    + 'L' + 'U' + 'L' * (x + 1) + 'D' * (y + 1) + 'R'

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){

	int N,A,B,count=0,t;

	cin >> N >>A >> B;

	for (int i = 0; i < N; ++i)
	{
		cin >> t;

		if(t<A||B<=t)count++;

	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

const int N = 1e5 + 1;
int a[N];
void solve(){
  memset(a, 0, sizeof(a));
  int n, sum = 0;
  cin >> n;
  for(int i = 0;i<n;i++){
    int x;
    cin >> x;
    a[x]++;
    sum += x;
  }
  int q;
  cin >> q;
  while(q--){
    int b, c;
    cin >> b >> c;
    sum += (c - b) * a[b];
    a[c] += a[b];
    a[b] = 0;
    cout << sum <<endl;
  }
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> v;v.assign(m,vector<int>());
    for(int i = 0;i < m;i++){
        int x; cin >> x;
        for(int j = 0;j < x;j++){
            int y; cin >> y;y--;
            v[i].push_back(y);
        }
    }
    vector<int> p;
    for(int i = 0;i < m;i++){
        int x; cin >> x;p.push_back(x);
    }
    
    int e = 0;
    
    for (int bit = 0; bit < (1<<n); bit++){
        vector<bool> S(n);
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                S[i] = true;
            }
        }
        int sum = 0;
        for(int j = 0;j < m;j++){
            int cnt = 0;
            for(int k = 0;k < v[j].size();k++){
                if(S[v[j][k]]) cnt++;
            }
            if(cnt % 2 == p[j]) sum++;
        }
        if(sum == m) e++;
    }
    cout << e;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
    int n; cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    rep(i,n - 1){
        v[i + 1] = (v[i] + v[i + 1]) / 2;
    }
    cout << v[n - 1] << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
    static int[][] round = new int[][]{{1,2,1,2,1,4,1,4},
        {1,2,1,4,1,4,1,2},{1,4,1,2,1,2,1,4},{1,4,1,4,1,2,1,2},
        {2,1,2,1,4,1,4,1},{2,1,4,1,4,1,2,1},{4,1,2,1,2,1,4,1},{4,1,4,1,2,1,2,1}
    };
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
                String spl[] = line.split(" ");
                int e[] = new int[8];
                for(int i=0; i<8;i++){
                    e[i]=Integer.parseInt(spl[i]);
                }
                
                int min = Integer.MAX_VALUE;int bestRoundN=-1;
                for(int i=0;i<8;i++){
                    int round1[] = round[i];
                    int amari = 0; 
                    for(int j=0;j<8;j++){
                        amari+= (e[j]-round1[j]<=0)? 0: e[j]-round1[j];
                    }
                    if(amari<min){bestRoundN=i; min=amari;}
                }
                int[] bestRound = round[bestRoundN];
                for(int i=0;i<8;i++){
                    System.out.print(bestRound[i]);
                    if(i!=7)System.out.print(" ");
                }System.out.println("");
               
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
    
     
     
}
 

Measured memory_bytes: 19336
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s, t; std::cin >> s >> t;
    int n=s.length();
    for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++){
            if(j==n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
            if(s.at(j)!=t.at((i+j)%n))break;
        }
    }
    std::cout << "No" << std::endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int h[n+1];
	h[0] = 0;
	for(int i=1; i<=n; i++)  cin >> h[i];
	int dp[n+1];

	dp[0] = 10001;
	dp[1] = 0;
	for(int i=2; i<=n; i++)
	{
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));

	}

	cout << dp[n] << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;

    vector<set<int>> v(10);

    for (int i = 0; i < n; ++i) {
        int t = s[i] - '0';
        v[t].insert(i);
    }

    int result = 0;

    for (int i = 0; i < 1000; ++i) {
        int n1 = i % 10;
        int n100 = i / 100;
        int n10 = i / 10 - 10 * n100;

        auto temp = v[n10].end();

        if (
            !v[n100].empty() &&
            !v[n10].empty() &&
            !v[n1].empty() &&
            (temp = v[n10].lower_bound(*v[n100].begin() + 1)) != v[n10].end() &&
            v[n1].lower_bound(*temp + 1) != v[n1].end()
            ){
            ++result;
            continue;
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 1664
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	if (n % 1000 == 0)
	{
		cout << 0 << "\n";
		return;
	}
	cout << 1000 - (n % 1000) << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3652
package main

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

type drink struct {
        problem int
        time    int
}

func main() {
        scanner := bufio.NewScanner(os.Stdin)
        line := make([]string, 0, 0)
        orgTime := make([]int, 0, 0)
        drinkTime := make([]drink, 0, 0)

        for scanner.Scan() && scanner.Text() != "" {
                if scanner.Err() != nil && scanner.Err() == io.EOF {
                        break
                }
                line = append(line, scanner.Text())
        }

        info := strings.Split(line[1], " ")
        for _, num := range info {
                data, _ := strconv.ParseInt(num, 10, 64)
                orgTime = append(orgTime, int(data))
        }

        for i := 3; i < len(line); i++ {
                info := strings.Split(line[i], " ")
                num, _ := strconv.ParseInt(info[0], 10, 64)
                time, _ := strconv.ParseInt(info[1], 10, 64)
                drinkTime = append(drinkTime, drink{problem: int(num), time: int(time)})
        }

        for i := 0; i < len(drinkTime); i++ {
                totalTime := 0
                for j := 0; j < len(orgTime); j++ {
                        if j+1 == drinkTime[i].problem {
                                totalTime += drinkTime[i].time
                        } else {
                                totalTime += orgTime[j]
                        }
                }
                fmt.Println(totalTime)
        }
}

Measured memory_bytes: 640
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    n=int(input())
    a=[0]*(n+1)
    for i in range(1,101):
        for j in range(1,101):
            for k in range(1,101):
                v=i*i+j*j+k*k+i*j+j*k+i*k
                if v>n:
                    break
                a[v]+=1
    for x in a[1:]:
        print(x)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 68844
while True:
  n = int(input())
  if not n: break
  count = 0
  flag = -1
  lst = [0]
  for i in range(n):
    a = int(input())
    if flag == a:
      lst[-1] += 1
    else:
      if i % 2 == 0:
        lst.append(1)
        flag = a
      else:
        if len(lst) == 1:
          lst[-1] += 1
          flag = a
        elif len(lst) >= 2:
          lst.append(lst.pop() + lst.pop() + 1)
          flag = a
  ans = 0
  if flag == 0:
    for i in range(-1,len(lst) * (-1) - 1,-2):
      ans += lst[i]
  elif flag == 1:
    for i in range(-2,len(lst) * (-1) - 1,-2):
      ans += lst[i]
  print(ans)



Measured memory_bytes: 5616
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int N, K; cin >> N >> K;
	vector<int> P(N), C(N);
	for (int i = 0; i < N; ++i){
		cin >> P[i]; --P[i];
	}
	for (int i = 0; i < N; ++i)
		cin >> C[i];

	ll res = *max_element(C.begin(), C.end());
	for (int i = 0; i < N; ++i){
		int now = i;
		ll score = 0;
		vector<ll> acc;
		do {
			now = P[now];
			acc.push_back(score += C[now]);
		} while (now != i);
		int T = acc.size();
		ll g = acc[T - 1];
		if (K % T == 0){
			ll i_st = max({
				g * (K / T),
				max(0LL, g * ((K / T) - 1)) + *max_element(acc.begin(), acc.end())
			});
			res = max(res, i_st);
		}
		else if (K < T){
			ll i_st = *max_element(acc.begin(), acc.begin() + K);
			res = max(res, i_st);
		}
		else{
			ll i_st = max({
				0LL,
				g * (K / T) + *max_element(acc.begin(), acc.begin() + (K % T)),
				max(0LL, g * ((K / T) - 1)) + *max_element(acc.begin(), acc.end())
			});
			res = max(res, i_st);
		}
	}

	cout << res << endl;

	return 0;
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll t , n, a[MAXX], b[MAXX], c[MAXX];

signed main()
{
	FAST;
	ll m;
	cin >> n >> m;
	n = n*m;
	cout << n;
	
}

Measured memory_bytes: 3608
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;


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

    int n;
    int t,a;
	cin >> n;
	cin >> t >> a;
	//cout << "a: " << a << endl;
	
	vector<int> h(n);
    FOR(i,0,n) cin >> h[i];
    
    float min1 = 1<<30;
    int index = 0;
    FOR(i,0,n){
        
        int temp1000 = 1000 * t - h[i] * 6;
        int dt1000 = abs(temp1000 - 1000 * a);
        //cout << "temp: " << temp << ", dt: " << dt << endl;
        
        if (min1 > dt1000){
            min1 = dt1000;
            index = i;
        }
        
    }
    
    cout << index+1 << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll A, ll B) {
  cout << (A + B) % 24 << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll B;
	ll A;
	scanf("%lld", &A);
	scanf("%lld", &B);
	solve(A, B);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  if(S[1] == 'B'){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e18
int n,x,a[2222],b[2222],ans=inf,sum;
signed main(){
	cin>>n>>x;
	rep(i,n)cin>>a[i];
	rep(i,n)b[i]=inf;
	rep(i,n+1){//長さ
		rep(j,n)b[j]=min(b[j],a[(j+n-i)%n]);
		sum=0;
		rep(j,n)sum+=b[j];
		ans=min(ans,sum+i*x);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/abc172/tasks/abc172_b
a= []
b= []

a= input(" ")

d= len(a)

b= input(" ")

e= 0
for i in range(0, d):
    if a[i]==b[i]:
        pass
    else:
        e= e+1
print(e)

Measured memory_bytes: 9508
nums = input().split(' ')

BadCookie = int(nums[0])
GoodCookie = int(nums[1])
GoodPoson = int(nums[2])
if GoodCookie + BadCookie > GoodPoson:
    print(GoodCookie+GoodPoson)
elif GoodCookie + BadCookie < GoodPoson:
    print(GoodCookie+BadCookie+GoodCookie+1)
else:
    print(GoodCookie+GoodPoson)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int x;
  scanf("%d",&x);
  printf("%d\n",x*x*x);
  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
	cin >> n >>m;
    long a[m+1];
    long ans[n+1];
    int j=0;
    int de =1000000007;
   fr(i,m){
     cin >> a[i];
   }
   a[m]=0;
   ans[0]=1;
   if(a[0]==1){
     ans[1]=0;
     j =1;
   }else{
     ans[1]=1;
   }
    for(int i=2;i<n+1;i++){
     if(a[j]==i){
       ans[i]=0;
       j++;
     }else{
       ans[i]=ans[i-2]+ans[i-1];
       ans[i]%=de;
     }
   }
    cout << ans[n] << endl;
}

Measured memory_bytes: 1792
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I:=h*w]*I
m+=d,
q=[a:=~w+a*w+b]
d[a]=1
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   if'.'!=m[(i:=s//w+y*~z)][(j:=s%w+x*~z)]or(p:=d[s]+1)>d[(t:=i*w+j)]:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 66352
#include<iostream>
#include<algorithm>
using namespace std;
long h,w,ans=0x7fffffffffffffff,a,b,c,d,e,i;
long f(long h,long w){
	for(i=0;i<=h/2;i++){
		a=w*i;b=w/2*(h-i);c=(h-i)/2*w;d=h*w-a-b;e=h*w-a-c;
		ans=min({ans,max({a,b,d})-min({a,b,d}),max({a,c,e})-min({a,c,e})});
	}
}
main(){cin>>h>>w;f(h,w);f(w,h);cout<<ans;}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 1005;
vector<int> A[MAX_N];

int main2() {
  REP(i, MAX_N) A[i].clear();
  int N = nextInt();
  REP(i, N) {
    REP(j, N-1) {
      A[i].push_back(nextInt() - 1);
    }
    A[i].push_back(-1);
  }
  vector<int> P(N);

  int day = 0;
  vector<int> target;
  REP(i, N) target.push_back(i);
  for (int done = 0; done < N; ) {
    set<int> gain;
    for (int i : target) {
      int next_i = A[i][P[i]];
      if (next_i == -1) continue;
      int next_j = A[next_i][P[next_i]];
      if (next_j == i) {
        gain.insert(i);
        gain.insert(next_i);
      }
    }
    if (gain.size() == 0) {
      day = -1;
      break;
    } else {
      target.clear();
      day++;
      for (int x : gain) {
        P[x]++;
        if (P[x] == N-1) done++; else target.push_back(x);
      }
    }
  }

  cout << day << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define N 22
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{ll an,ki;}dp[1000010];
ll jie[N*N],nj[N*N];
int m,n,x,y,p,no[N],f[N],d[N],g[1000010];
vector<pair<int,int> > a[N];
void dfs(int x,int fa,int dep){
	f[x]=fa;d[x]=dep;
	for (unsigned i=0;i<a[x].size();i++){
		if (a[x][i].first!=fa){
			no[a[x][i].first]=a[x][i].second;
			dfs(a[x][i].first,x,dep+1);
		}
	}
}
int co(int x){int an=0;while (x){an+=x&1;x/=2;}return an;}
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
int main(){
	read(n);read(m);p=n-1;
	jie[0]=1;for (int i=1;i<=m;i++)jie[i]=jie[i-1]*i%mo;
	nj[m]=po(jie[m],mo-2);for (int i=m-1;i>=0;i--)nj[i]=nj[i+1]*(i+1)%mo;
	for (int i=1;i<n;i++){
		read(x);read(y);
		a[x].push_back(make_pair(y,1<<(i-1)));
		a[y].push_back(make_pair(x,1<<(i-1)));
	}
	dfs(1,0,1);
	for (int i=n;i<=m;i++){
		read(x);read(y);
		int an=0;
		while (x!=y){
			if (d[x]<d[y]) swap(x,y);
			an+=no[x];
			x=f[x];
		}
		g[an]++;
	}
	for (int i=0;i<p;i++)
		for (int j=0;j<(1<<p);j++)
			if (j&(1<<i))g[j]+=g[j-(1<<i)];
	dp[0].ki=1;dp[0].an=0;
	for (int i=0;i<(1<<p);i++){
		int cs=co(i);
		int no=(g[(1<<p)-1]-g[(1<<p)-1-i])+cs;
		for (int j=0;j<p;j++){
			if ((i&(1<<j))==0){
				int nu=g[(1<<p)-i-1]-g[(1<<p)-1-i-(1<<j)];
				dp[i+(1<<j)].ki=(dp[i+(1<<j)].ki+(dp[i].ki*jie[no+nu]%mo)*nj[no])%mo;
				dp[i+(1<<j)].an=(dp[i+(1<<j)].an+(dp[i].an*jie[no+nu+1]%mo)*nj[no+1]+((dp[i].ki*(cs+1)%mo)*jie[no+nu]%mo)*nj[no])%mo;
			}
		}
	}
	cout<<dp[(1<<p)-1].an<<endl;
	return 0;
}

Measured memory_bytes: 12544
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    char a,b;
    cin>>a>>b;
    if (a=='H')
        cout<<b<<endl;
    else
    {
        if (b=='H')
            cout<<"D\n";
        else
            cout<<"H\n";
    }
}

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


int main(){
  int n,k;
  long long int s;
  cin >> n >> k >> s;
  if(n==k){
    for(int i=0; i<n; i++){
      cout << s << " ";
    }
    cout << endl;
  }else if(k==0&&s==1000000000){
    for(int i=0; i<n; i++){
      cout << 1 << " ";
    }
    cout << endl;
  }else if(k==0){
    for(int i=0; i<n; i++){
      cout << s+1 << " ";
    }
    cout << endl;
  }else if(s==1000000000){
    for(int i=0; i<k; i++){
      cout << s << " ";
    }
    for(int i=k; i<n; i++){
      cout << 1 << " ";
    }
    cout << endl;
  }else{
    for(int i=0; i<k; i++){
      cout << s << " ";
    }
    for(int i=k; i<n; i++){
      cout << s+1 << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 10000000;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int d[803][803];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    string a[803];
    for(int i = 0; i < h; i++){
        cin >> a[i];
    }
    queue<P> que;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == 'S') que.push(P(i, j));
            else d[i][j] = -1;
        }
    }
    int ans = INF;
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 4; i++){
            int u = x + dx[i], v = y + dy[i];
            if(u >= 0 && u < h && v >= 0 && v < w && a[u][v] != '#' && d[u][v] == -1){
                d[u][v] = d[x][y] + 1;
                que.push(P(u, v));
            }
        }
        if(d[x][y] <= k){
            ans = min(ans, min(min(x + k - 1, y + k - 1), min(h - x + k - 2, w - y + k - 2)) / k + 1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=2e5+5,mod=1e9+7,inf=2e9; 
char s[N];
int n,f[N]; 
inline int solve0(ri n){
	// f[i] 表示 col_i = R 1 ~ i 的染色方案
	f[1]=1; // 强制钦定 col_1 = R 
	for(ri i=2;i<=n;++i) f[i]=(f[i-1]+f[i-2])%mod;
	// BR...R f[n-1]
	// R...RB f[n-1]
	// R....R f[n]
	return ((ll)f[n-1]+f[n-1]+f[n])%mod;
}
int pre[N]; 
inline int solve1(ri r){
	// f[i] 表示 col_i = B 1 ~ i的染色方案 
	ri i,ans;
	for(i=1;i<=n/2;++i){
		if(i<=r/2) f[i]=1;
		f[i]=((ll)f[i]+pre[i-1]-pre[max(0,i-r/2-1)]+mod)%mod;
		pre[i]=(pre[i-1]+f[i])%mod;
	}
	// 首先考虑只有一个 B 的情况
	if(n<=r)
		ans=n;
	else
		ans=0;
	for(i=0;i+1<=n&&i+1<=r;++i) // 枚举 1 ~ i 都为 R 
		ans=((ll)ans+pre[max(0,(n-i-1)/2)]-pre[max(0,(n-r)/2-1)]+mod)%mod; 
	return ans;
}
int main(){
	ri m,i,j,flag,r;
	gi(n);gi(m);
	read(s);
	if(s[1]=='B'){
		for(i=1;i<=m;++i)
			s[i]=s[i]=='B'?'R':'B';
	}
	flag=1;
	for(i=1;i<=m;++i)
		if(s[i]!='R'){
			flag=0;
			break;
		}
	if(flag)
		return printf("%d\n",solve0(n)),0;
	if(n&1) return puts("0"),0;
	r=inf;
	for(i=1;i<=m;++i){
		if(s[i]!='R') continue;
		for(j=i;j+1<=m&&s[j+1]=='R';++j);
		if(i==1) r=min(r,j-i+1+1);
		else if(j==m){
			i=j;
			continue;
		}
		else if(j-i+1&1) r=min(r,j-i+1);
		i=j;
	}
	if(~r&1) --r;
	printf("%d\n",solve1(r+1));
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30
#define MOD 1000000007

vector<ll> red(2001,INF);

ll redis(int N){
    if(red[N]!=INF) return red[N];
    if(N<3){
        if(N>=1)red[N] = 0;
        return 0;
    }
    else if(N>=3&&N<=5){
        red[N] = 1;
        return 1;
    }
    else{
        ll R = 0;
        FOR(i,3,N-2){
            R = (R + redis(N-i) % MOD) % MOD;
        }
        R ++;
        R %= MOD;
        red[N] = R;
        return R;
    }
}

int main()
{
    int S;
    cin >> S;
    cout << redis(S) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

using namespace std;

int main(){
    ll ma=0,sum=0,n;
    cin>>n;
    for(int i=0;i<n;i++){
      ll a;cin>>a;
      ma=max(ma,a);
      sum+=a;
    }
    cout<<((sum-ma>ma)?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
# 2019/02/24
# AtCoder Beginner Contest 119 - A

import datetime

# Input
s = input()
time_s = datetime.datetime.strptime(s, "%Y/%m/%d")

# Calc
if time_s <= datetime.datetime(2019, 4, 30, 23, 59, 59):
    ans = "Heisei"
else:
    ans = "TBD"

# Output
print(ans)

Measured memory_bytes: 4696
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))


if sum(s) % 10 != 0:
    print (sum(s))
    
else:
    min_s = 0
    sorted_s = sorted(s, reverse=True)
    for ss in sorted_s:
        if ss % 10 != 0:
            min_s = ss

    if min_s == 0:
        print (0)
    else:
        print(sum(s) - min_s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int n, a;
multiset<int> s;
multiset<int> :: iterator it;

int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	int k = 0;
	for (int i = 0; i < n; i ++) {
		cin >> a;
		if (s.size() == 0) {
			k ++;
			s.insert(a);
		}
		else {
			it = s.lower_bound(a);
			if (it == s.begin()) {
				k ++;
				s.insert(a);
			}
			else {
				it --;
				s.erase(it);
				s.insert(a);
			}
		}
	}
	
	cout << k;

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

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

  while (n != 0) {
    if (n % 2 == 0) {
      ans = "0" + ans;
    } else {
      n--;
      ans = "1" + ans;
    }
    n /= -2;
  }

  if (ans == "") ans = "0";

  cout << ans << endl;

  return 0;
}


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

int main() {
    string s;
    int cnt[26] = {};
    while(cin >> s) {
        for(int i = 0; i < s.size(); i++) {
            if(isupper(s[i])) s[i] = tolower(s[i]);
            if(s[i] >= 'a' && s[i] <= 'z') {
                cnt[s[i] - 'a']++;
            }
        }
    }
    for(int i = 0; i < 26; i++)
        cout << (char)('a' + i) << " : " << cnt[i] << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,T;
int A[SIZE];

int main()
{
	cin >> N >> T;
	int mn = INF;
	int C = 0; //最大差
	rep(i,0,N){
		cin >> A[i];
		mn = min(mn,A[i]);
		C = max(C,A[i]-mn);
	}
	mn = INF;
	set<int> S;
	rep(i,0,N){
		mn = min(mn,A[i]);
		if(A[i]-mn == C){
			S.insert(A[i]);
			S.insert(mn);
		}
	}
	vector<int> V;
	rep(i,0,N){
		if(S.find(A[i]) != S.end()) V.push_back(A[i]);
	}

	deque<P> D; //(値,個数)
	rep(i,0,V.size()){
		if(D.empty()){
			D.push_back(make_pair(V[i],1));
			continue;
		}
		if(D.back().first == V[i]){
			D.back().second++;
		}else{
			D.push_back(make_pair(V[i],1));
		}
	}

	int ans = 0;
	while(!D.empty()){
		deque<P> dq;
		dq.push_back(D.front());
		D.pop_front();
		int p = dq.front().first;
		while(!D.empty()){
			if(D.front().first == p or D.front().first == p+C){
				dq.push_back(D.front());
				D.pop_front();
			}else{
				break;
			}
		}

		while(!dq.empty()){
			while(!dq.empty()){
				if(dq.front().first == p+C)dq.pop_front();
				else break;
			}
			while(!dq.empty()){
				if(dq.back().first == p)dq.pop_back();
				else break;
			}
			if(dq.empty()) continue;

			if(dq.front().second < dq.back().second){
				ans += dq.front().second;
				dq.pop_front();
			}else{
				ans += dq.back().second;
				dq.pop_back();
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    string s;cin>>s;
    string keyence = "keyence";

    int target_index;
    for (int i=0;i<keyence.size();i++){
        if (s[i] == keyence[i]){
            continue;
        } else {
            target_index=i;
            break;
        }
    }
    string trimmed_keyence = keyence.substr(target_index, keyence.size());
    string trimmed_s = s.substr(s.size()-trimmed_keyence.size(), s.size());
    if (trimmed_s == trimmed_keyence){
        cout << "YES" <<endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

class node {
public:
	int parent,children[2],depth,height,sib;
	node() {
		parent = -1;
		children[0] = -1;
		children[1] = -1;
		depth = -1;
		height = -1;
		sib = -1;
	}
	int deg() {
		int c = 0;
		for(int i=0;i<2;i++)if(children[i]!=-1)c++;
		return c;
	}
	string typ() {
		if(parent == -1)return "root";
		else if(deg() == 0)return "leaf";
		else return "internal node";
	}
};

int n;
node d[100000];

void pre(int i) {
	cout << " " << i;
	if(d[i].children[0] != -1) pre(d[i].children[0]);
	if(d[i].children[1] != -1) pre(d[i].children[1]);
}

void ino(int i) {
	if(d[i].children[0] != -1)ino(d[i].children[0]);
	cout << " " << i;
	if(d[i].children[1] != -1)ino(d[i].children[1]);
}

void pos(int i) {
	if(d[i].children[0] != -1)pos(d[i].children[0]);
	if(d[i].children[1] != -1)pos(d[i].children[1]);
	cout << " " << i;
}

int main(void) {
	char * c = new char[1000*1000*100];
	for(int i = 0;i < 1000*1000*100;i++)c[i]=0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b,c;
		cin >> a >> b >> c;
		d[a].children[0] = b;
		d[a].children[1] = c;
		d[b].sib = c;
		d[c].sib = b;
		d[b].parent = a;
		d[c].parent = a;
	}
	int rt = -1;
	for(int i = 0;i < n;i++){
		if(d[i].parent == -1) {
			rt = i;
		}
	}
	d[rt].depth = 0;
	cout << "Preorder" << endl;
	pre(rt);
	cout << endl << "Inorder" << endl;
	ino(rt);
	cout << endl << "Postorder" << endl;
	pos(rt);
	cout << endl;
}



Measured memory_bytes: 103088
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;
typedef pair<int,int> pr;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    ll n; cin >> n;
    ll b = 0, w = 0;
    ll ans = 10000000;
    string s;cin >> s;

    rep(i,s.length()){
        if(s[i] == '.') w ++;
        else b ++;
    }
    ans = min(b,w);
    b = 0;

    rep(i,s.length()){
        if(s[i] == '.') w --;
        else b ++;

        ans = min(ans,b+w);
    }

    cout << ans;
}

Measured memory_bytes: 3720
//package hiougyf;
import java.io.*;
import java.util.*;

public class Main {
	  public static void main(String[] args) throws IOException
	    {
		 Scanner sc =new Scanner(System.in);
		int d=sc.nextInt();
		int t=sc.nextInt();
		int s=sc.nextInt();
		float t1=(float)d/s;
		//System.out.println(t1);
		if(t1<=t) System.out.println("Yes");
		else System.out.println("No");
	    }
		static int div(int n,int b) {
			int g=-1;
			for(int i=2;i<=Math.sqrt(n);i++) {
				if(n%i==0&&i!=b) {
					g=i;
					break;
				}
			}
			return g;
		}
	    
	  
	  public static int gcd(int a, int b) 
	    { 
	        if (a == 0) 
	            return b; 
	          
	        return gcd(b%a, a); 
	    } 
	   public static int lcm(int a, int b)  
	  {  
	     return (a*b)/gcd(a, b);  
	  }  
	   public static boolean isPrime1(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
       public static boolean isPrime(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           if (n % 2 == 0) {
               return false;
           }
           for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
	      
	
}

  


Measured memory_bytes: 35624
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b != c){cout << c << endl;}
    else if(a == c && a != b){cout << b << endl;}
    else if(b == c && b != a){cout << a << endl;}

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>A(3);
  for(int i=0;i<3;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  cout<<A.at(0)+A.at(1)+A.at(2)*10<<endl;
}

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

set<int> dp;

bool judge(bool fst, vector<int> &D, int XY){
	dp.insert(0);
	for(int d:D){
		set<int> t; swap(t,dp);
		for(auto j:t){ if(!fst) dp.insert(j-d); dp.insert(j+d); }
		fst = false;
	}
	return dp.count(XY)!=0;
}

int main(){
	string S; int X,Y; cin>>S>>X>>Y;
	S += "T";
	vector<int> dx,dy;
	bool isX = true;
	int d = 0;
	for(auto s:S)
		if(s=='F') d++;
		else{
			if(isX) dx.push_back(d); else  dy.push_back(d);
			isX = !isX;
			d = 0;
		}
	bool x = judge(true, dx, X);
	dp.clear();
	bool y = judge(false, dy, Y);
	cout<< (x & y? "Yes":"No") <<endl;
}

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

void chess(int H, int W) {

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if ((i+j) % 2 == 0) {
                cout << '#';
            } else {
                cout << '.';
            }
        }
        cout << endl;
    }
    cout << endl;
}

int main(int argc, char const *argv[]) {

    while (1) {
        int H, W;
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) {
            break;
        } else {
            chess(H, W);
        }
    }

    return 0;
}



Measured memory_bytes: 3148
//???2:negFLG?°???\???
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int N,count,length;
	bool MATCH;

	char to_search[11],buf[11];

	scanf("%s",to_search);
	scanf("%d",&N);

	count = 0;

	for(length = 0; to_search[length] != '\0';length++);

	for(int i = 0; i < N; i++){
		scanf("%s",buf);

		MATCH = false;
		for(int k = 0;k <= 9; k++){
			for(int p = 0; p < length; p++){
				if(buf[(k+p)%10] != to_search[p])break;
				if(p == length-1){
					MATCH = true;
					count++;
					break;
				}
			}
			if(MATCH)break;
		}
	}
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 2644
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
t = [[] for i in range(n)]
c = [-1 for i in range(n)]
for i in range(m):
    x, y ,z = map(int, input().split())
    x -= 1
    y -= 1
    t[x].append(y)
    t[y].append(x)


def dfs(num, depth):
    if c[num] != -1:
        return
    else:
        c[num] = depth
    for i in t[num]:
        dfs(i, depth)


cnt = 0
for i in range(n):
    if c[i] == -1:
        cnt += 1
        dfs(i, cnt)

print(max(c))


Measured memory_bytes: 110204
#include<bits/stdc++.h>
using namespace std;
bool Prime(long long n);
main(){
  int n;
  int cnt=0;
  long long a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(Prime(a)){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}
bool Prime(long long n){
  if(n==2){
    return true;
  }
  else if(2>n||n%2==0){
    return false;
  }
  else{
    for(int i=3;i<=sqrt(n);i+=2){
      if(n%i==0){
	return false;
      }
    }
    return true;
  }
}

Measured memory_bytes: 1168
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstring>
#include<sstream>
#include<set>
#include<map>
#define maxn 100000007
using namespace std;
typedef long long ll;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(c-a+b,0);
    return 0;
}


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

A = []
for i in range(Q):
    A.append(int(input()))

#print(N,K,Q)
#print(A)

P = [K for _ in range(N)]
#print(P)
for a in A:
    P[a-1] += 1

#print(P)

for n in range(N):
    if(P[n]-Q>0):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10460