akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a, b, c;
        cin >> a >> b >> c;
        cout << min(c, b / a) << '\n';
    }
}

Measured memory_bytes: 31488
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int i = 1;
		while(num != 0){
			System.out.println("Case " + i + ": " + num);
			num = sc.nextInt();
			i++;
		}
	}
}

Measured memory_bytes: 33044
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,pair<ll,ll> >
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
ll powMod( ll base , ll expo )
{
    ll ans = 1 ;
    while( expo > 0 )
    {
        if( expo & 1 )
            ans = ( ans * base ) % hell ;
        expo>>=1;
        base = ( base * base )%hell;
    }
    return ans ;
}
ll findroot( ll x )
{
    ll lo = 1 , hi = hell , mid ;
    while( hi - lo > 1 )
    {
        mid = ( lo + hi ) / 2 ;
        if( mid*mid > x )
            hi = mid ;
        else
            lo = mid ;
    }
    return lo ;
}
ll calc( ll n )
{
    ll x = findroot( n ) , y ;
    y = n - x * x ;
    ll a1 , a2 , ans = 1 ;
    a1 = powMod( 3 , x ) ;
    a2 = powMod( a1 , x ) ;
    if( y < hell )
    {   
        ans = ( ans * a2 ) % hell ;
        ans = ( ans * powMod( 3 , y ) ) % hell ;
        return ans ;
    }
    else
    {
        ans = ( ans * a2 ) % hell ;
        ans = ( ans * calc(y) ) % hell ;
        return ans ;
    }
}
void solve() 
{ 
    string s ;
    cin >> s ;
    stack<char> st ;
    rep( i , 0 , sz(s) )
    {
        if( !st.empty() )
        {
            if(st.top()==s[i])
                st.push(s[i]);
            else
            {
                st.pop();
            }
        }
        else
            st.push(s[i]);
    }
    ll cnt = 0 ;
    while( !st.empty() )
    {
        cnt++;
        st.pop();
    }
    cout << sz(s) - cnt ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll n,tmp,k,cnt = 0,ans = 0;
    cin>>n>>k;
    unordered_map<ll,ll>mp;
    priority_queue<Pl,vector<Pl>,greater<Pl>>que;
    rep(i,n){
        cin>>tmp;
        mp[tmp]++;
        if(mp[tmp]==1)cnt++;
    }
    for(auto &itr:mp){
        que.push(make_pair(itr.second,itr.first));
    }
    while(cnt>k){
        ans += que.top().first;
        que.pop();
        cnt--;
    }
    cout<<ans<<endl;

}




Measured memory_bytes: 14148
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
        }
        vector<long long> acc(n);
        acc[0] = a[0];
        for (int i = 1; i < n; i ++) {
                acc[i] += acc[i - 1] + a[i];
        }
        map<long long, int> cnt;
        long long ans = 0;
        cnt[0] = 1;
        for (int i = 0; i < n; i ++) {
                ans += cnt[acc[i]];
                cnt[acc[i]] ++;
        }
        printf("%lld\n", ans);
        return 0;
}



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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans = 0;
  int MAX = max(A, max(B,C));
  int MIN = min(A, min(B,C));
  int MED = A+B+C-MAX-MIN;
  if((MAX%2) == ((A+B+C)%2)){
    cout <<  MAX-MED+(MED-MIN)/2;
  }else{
    cout << MAX-MED+(MED-MIN)/2+2;
  }
  return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int n, ans; scanf( "%d", &n );
	if( n % 10 == 0 ) return puts( "10" ), 0;
	for( ans = 0; n; n /= 10 ) ans += n % 10;
	printf( "%d\n", ans );
	return 0;
}

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

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

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var list = new List<int>();
            for (int i = 0; i < N; i++)
            {
                list.Add(cin.ReadInt);
            }
            var sortedList = new List<int>(list);
            sortedList.Sort();
            var max = list.Max();
            var secondMax = sortedList[N - 2];
            for (int i = 0; i < N; i++)
            {
                if (list[i] == max)
                {
                    Console.WriteLine(secondMax);
                }
                else
                {
                    Console.WriteLine(max);
                }


            }



        }



    }


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


Measured memory_bytes: 23224
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long int fac[100001];
long long int ksm(long long int x,int b){
	long long int res = 1;
	while(b){
		if(b&1)	res = res * x %mod;
		x=x*x%mod;
		b>>=1;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	fac[0]=1;
	long long int ans = 0, tot = 0;
	for(int i=1;i<=n;i++)
		fac[i] = fac[i-1]*i%mod;
	for(int i=1;i<=n;i++)
		tot = (tot + fac[n]*ksm(i,mod-2))%mod;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		ans = (ans+tot*x)%mod;
		tot = (tot + fac[n]*ksm(i+1,mod-2)-fac[n]*ksm(n+1-i,mod-2))%mod;
	}
	cout << (ans%mod+mod)%mod<<endl;
}


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


int main(){
  int n;
  cin >> n;
  ll a[n];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  REP(i,n-1) {
    if (a[i]==a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int m;
    int n;
    while (1) {
        cin >> m >> n;
        if (m == 0 && n == 0) {
            break;
        }

        vector<int> v(7368792, 0);
        int base = m;
        int count = 0;
        while (1) {
            for (int i = 1; i * base < v.size(); i++) {
                v[i * base] = 1;
            }
            count++;

            if (count == n) {
                break; 
            }

            while (1) {
                if (v[base] == 0) {
                    break;
                } else {
                    base++;
                }
            }
        }


        int check = m;
        while (1) {
            if (v[check] == 0) {
                cout << check << endl;
                break;
            }
            check++;
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long int

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}

ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll ans = b-a+1;
	ll lc = lcm(c,d);
	ans -= b/c-(a-1)/c;
	ans -= b/d-(a-1)/d;
	ans += b/lc-(a-1)/lc;
	cout << ans << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int n,k;
  cin >> n >> k;
  long long num = 1;
  for(int i = 0; i < n; i++){
    if(num*2 < num + k) num *= 2;
    else                num += k;
  }
  cout << num << endl;
  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    OP((x - y - 2 * z) / (y + z) + 1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x,y,i,n;
  scanf("%d %d",&x,&y);
  if(x<y){n=y;
    y=x;
    x=n;
  }
  while(1){
    n=y;
    y=x%y;
    if(y==0){
      printf("%d\n",n);
      break;
    }
    x=n;
  }
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
  ll n, m;
  cin >> n >> m;

  vi a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  sort(all(a)); reverse(all(a));
  sort(all(b)); reverse(all(b));

  a.pb(-1); b.pb(-1);

  rep(i, n-1) if(a[i] == a[i+1]){
    cout << 0 << endl;
    return 0;
  }
  rep(i, m-1) if(b[i] == b[i+1]){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  for(int i = n*m; i > 0; i--){
    ll c = 0, r = 0;
    while(a[c] > i and c < n) c++;
    while(b[r] > i and r < m) r++;

    if(a[c] == i and b[r] == i){

    }else if(a[c] == i){
      ans *= r;
    }else if(b[r] == i){
      ans *= c;
    }else{
      ans *= max(0LL, r*c - (n*m-i));
    }
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>

using namespace std;

template<typename C, typename C::value_type low, typename C::value_type high>
class PalindromeTree{
  const static int m = high - low + 1;
  typedef typename C::value_type T;

  struct node{
    int next[m];
    int len;
    int sufflink;
  };

  const C s;
  int len;
  int num;

  void initTree(){
    num = 2; suff = 2;
    tree[1].len = -1; tree[1].sufflink = 1;
    tree[2].len = 0; tree[2].sufflink = 1;
  }

public:
  vector<node> tree;
  int suff;

  bool addLetter(int pos){
    int cur = suff;
    int curLen = 0;
    const int let = s[pos] - low;

    while(true){
      curLen = tree[cur].len;
      if(pos - 1 - curLen >= 0 && s[pos - 1 - curLen] == s[pos]) break;
      cur = tree[cur].sufflink;
    }

    if(tree[cur].next[let]){
      suff = tree[cur].next[let];
      return false;
    }

    num++;
    suff = num;
    tree[num].len = tree[cur].len + 2;
    tree[cur].next[let] = num;

    if(tree[num].len == 1){
      tree[num].sufflink = 2;
      return true;
    }

    while(true){
      cur = tree[cur].sufflink;
      curLen = tree[cur].len;
      if(pos - 1 - curLen >= 0 && s[pos - 1 - curLen] == s[pos]){
	tree[num].sufflink = tree[cur].next[let];
	break;
      }
    }

    return true;
  }

  PalindromeTree(const C &s)
    : s(s), len(s.size()), tree(s.size() + 3){
    initTree();
  }

  void build(){
    for(int i = 0; i < len; i++){
      addLetter(i);
    }
  }

  static long long countSamePalindrome(const C &s, const C &t, const C &sp){
    long long ans = 0;
    const C sum = s + sp + t;
    PalindromeTree tree(sum);
    vector<long long> scnt(sum.size() + 3);
    vector<long long> tcnt(sum.size() + 3);

    for(int i = 0; i < (int)sum.size(); i++){
      tree.addLetter(i);

      int pos = tree.suff;
      const node &nd = tree.tree[pos];
      if(i - nd.len + 1 < (int)s.size()){
	scnt[pos]++;
      }else if(i - nd.len + 1 >= (int)(s.size() + sp.size())){
	tcnt[pos]++;
      }
    }

    for(int i = 0; i < 2; i++){
      vector<long long> &v = i == 0 ? scnt : tcnt;

      vector<int> ref(v.size());
      for(int j = 3; j < (int)v.size(); j++){
	if(v[j] > 0 && tree.tree[j].sufflink >= 3){
	  ref[tree.tree[j].sufflink]++;
	}
      }

      queue<int> q;
      for(int j = 3; j < (int)v.size(); j++){
	if(v[j] > 0 && ref[j] == 0) q.push(j);
      }

      while(q.size()){
	const int pos = q.front(); q.pop();
	const int suff = tree.tree[pos].sufflink;
	if(suff >= 3){
	  v[suff] += v[pos];
	  ref[suff]--;
	  if(ref[suff] == 0) q.push(suff);
	}
      }
    }

    for(int i = 3; i < (int)scnt.size(); i++){
      ans += scnt[i] * tcnt[i];
    }

    return ans;
  }
};

typedef PalindromeTree<string, 'a', 'z'> SPalindromeTree;

int main(){
  string s, t;
  cin >> s >> t;
  typedef PalindromeTree<string, 'A' - 2, 'Z'> SPalindromeTree;
  std::cout << SPalindromeTree::countSamePalindrome(s, t, "@?") << std::endl;

  return 0;
}

Measured memory_bytes: 15184
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to

    return wrappedfunc


def memodict(f):
    """ Memoization decorator for a function taking a single argument. """

    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__


def main():
    r, g, b, n = map(int, input().split())


    print(sum((n - (i + j)) % b == 0 for i in range(0, n + 1, r) for j in range(0, (n - i) + 1, g)))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        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):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    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)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


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

# endregion

if __name__ == "__main__":
    main()


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

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

int main(){
    int h , w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    rep(row,h) rep(col,w){
        if (s[row][col] == '.') continue;
        bool ok = false;
        rep(i, 4){
            int x, y;
            x = col+dx[i];
            y = row+dy[i];
            if (x < 0 || x >= w || y < 0 || y >= h) continue;
            if (s[y][x] == '#') ok = true;
        }
        if (!ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, g;
    cin >> n >> g;

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

    int ans = INT32_MAX;
    for (int mask = 0; mask < (1 << n); mask++) {
        int te = 0;
        int num = 0;
        int idx = -1;
        for (int i = 0; i < n; i++) {
            if ((mask >> i) & 1) {
                te += 100 * (i + 1) * v[i] + c[i];
                num += v[i];
            } else {
                //0となる最大
                idx = i;
            }
        }
        if (te < g) {
            int s1 = 100 * (idx + 1);
            int need = (g - te + s1 - 1) / s1;
            if (need >= v[idx]) {
                continue;
            }
            num += need;
        }

        ans = min(num, ans);
    }
    cout << ans << endl;
}

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

using namespace std;

#define endl "\n"
#define maxn 100000
#define OO 1e5
#define F first
#define S second
#define B begin()
#define E end()
#define PB push_back
#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    int k,n;
    cin >> k >> n;
    int sol = 9999999999;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin >> a[i];

    sol = k;
    int ans = sol;
    for(int i=1;i<n;i++)
        ans=min(ans,sol-a[i+1]+a[i]);
    ans=min(ans,sol-(k-a[n]+a[1]));
    cout << ans;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  string str = "";
  cin >> str;
  int n = (int)str.size() + 1;
  vector<long long> a(n);
  for (int i=0; i<n-1; i++) {
    if (str.at(i) == '<') {
      a.at(i+1) = a.at(i) + 1;
    } else {
      if (i != n-2 && str.at(i+1) == '<') {
        a.at(i+1) = 0;
      }
    }
  }
  for (int i=n-1; i>0; i--) {
    if (str.at(i-1) == '>') {
      if (i != 1 && str.at(i-2) == '<') {
        a.at(i-1) = max(a.at(i-1), a.at(i) + 1);
      } else {
        a.at(i-1) = a.at(i) + 1;
      }
    }
  }
  long long ans = 0;
  for (long long x : a) {
    ans += x;
  }
  cout << ans << endl;
}

      

Measured memory_bytes: 4740
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let inputs = line.as_str().split(' ').collect::<Vec<&str>>();
    let input0 = inputs[0].trim();

    match next_word(String::from(input0)) {
        Some(w) => print!("{}", w),
        None => print!("{}", -1),
    }
}

fn next_word(w: String) -> Option<String> {
    if w.len() < 26 {
        let unused_chars = find_unused_chars(&w.as_str());
        return Some(w + &unused_chars[0].to_string().as_str());
    }

    for i in (0..w.len()).rev() {
        let unused_chars = find_unused_chars(&w.as_str()[..i]);
        for c in unused_chars {
            if c > w.chars().nth(i).unwrap() {
                let mut new_w = String::from(&w.as_str()[..i]);
                new_w.push(c);
                return Some(new_w);
            }
            continue;
        }
    }
    return None;
}

fn find_unused_chars(w: &str) -> Vec<char> {
    let mut chars: Vec<Option<char>> = "abcdefghijklmnopqrstuvwxyz"
        .chars()
        .map(|c| Some(c))
        .collect();
    for j in 0..w.len() {
        chars[w.chars().nth(j).unwrap() as usize - 'a' as usize] = None;
    }
    chars
        .into_iter()
        .filter(|v| if let &Some(_) = v { true } else { false })
        .map(|c| c.unwrap())
        .collect()
}

#[cfg(test)]
mod test {
    use super::*;

    fn assert(input: &str, expected: &str) {
        let output = next_word(String::from(input)).unwrap();
        assert_eq!(
            output.as_str(),
            expected,
            "expected {:?}, got {:?}",
            expected,
            output,
        );
    }

    fn assert_none(input: &str) {
        let output = next_word(String::from(input));
        assert!(output == None, "expected None, got {:?}", output);
    }

    #[test]
    fn test_next_abc() {
        assert("abc", "abcd");
    }

    #[test]
    fn test_next_abcdefghijklmnopqrstuvwzyx() {
        assert("abcdefghijklmnopqrstuvwzyx", "abcdefghijklmnopqrstuvx");
    }

    #[test]
    fn test_next_zyxwvutsrqponmlkjihgfedcba() {
        assert_none("zyxwvutsrqponmlkjihgfedcba");
    }
}


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

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

    int sum = 0;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
int A,N,M,X[105],i;
scanf("%d",&N);
for(i=1;i<=N;i++){ scanf("%d",&X[i]); }
scanf("%d",&M);
for(i=0;i<M;i++){
   scanf("%d",&A);
   if( A==N ){ X[A]++; }
   else {
         if( X[A+1]>X[A]+1){X[A]++;}
      }
  if( X[A] > 2019 ){X[A] = 2019 ;}
   }

for(i=1;i<=N;i++){ printf("%d\n",X[i]); }
return 0;
}



Measured memory_bytes: 2760
sentence = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
sentence = sentence.replace(' ', '').split(',')
k = int(input())
output = sentence[k-1]
print(output)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
typedef struct P{
    int parent;
    int *child;
    int childlen;
}Node;

int depth(Node node[],int n){
    if(node[n].parent==-1){
        return 0;
    }
    return depth(node,node[n].parent)+1;
}

int main(void){
    int n,i,j,k,l,d;
    Node *node;
    scanf("%d",&n);
    node = (Node*)malloc(sizeof(Node)*n);
    for(i=0;i<n;i++){
        node[i].parent = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d",&k);
        scanf("%d",&l);
        node[k].child = (int*)malloc(sizeof(int)*l);
        node[k].childlen = l;
        for(j=0;j<l;j++){
            scanf("%d",&node[k].child[j]);
            node[node[k].child[j]].parent = k;
        }
    }
    
    for(i=0;i<n;i++){
        printf("node %d: ",i);
        printf("parent = %d, ",node[i].parent);
        printf("depth = %d, ",depth(node,i));
        if(node[i].parent==-1){  printf("root, ");  }
        else if(node[i].childlen==0){  printf("leaf, ");  }
        else{  printf("internal node, ");  }
        printf("[");
        for(j=0;j<node[i].childlen;j++){
            printf("%d",node[i].child[j]);
            if(j!=node[i].childlen-1){
                printf(", ");
            }
        }
        printf("]\n");
    }
}


Measured memory_bytes: 7612
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#ifdef DEBUG
    #define GG(x) assert(x)
#else
    #define GG(x) (x)
#endif
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e>=0);while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    pr a[N];bool cmp(pr x,pr y){return max(x.FR,x.SE)>max(y.FR,y.SE);}
    ll sum[N];
    void main()
	{
        int n=qread();fo(i,1,n) a[i].FR=qread(),a[i].SE=qread();sort(a+1,a+n+1,cmp);
        ll S=0;fo(i,1,n) S+=a[i].FR,a[i].FR=max(a[i].FR,a[i].SE),sum[i]=sum[i-1]+a[i].FR;
        ll ansx=0,ansy=1;
        fo(k,1,n)
        {
            int fl=0,fr=n,q=-1;
            while(fl<=fr)
            {
                int mid=(fl+fr)/2;
                if(sum[mid]-(k<=mid?a[k].FR:0)+a[k].SE>=S) q=mid,fr=mid-1; else fl=mid+1;
            }
            if(q<0) continue;
            if(sum[q]-(k<=q?a[k].FR:0)>=S) continue;//debug
            ll nowx=ll(n-(q-(k<=q)))*a[k].SE-S+sum[q]-(k<=q?a[k].FR:0),nowy=1ll*a[k].SE*n;
            ll d=gcd(nowx,nowy);nowx/=d,nowy/=d;
            if(1.0*nowx*ansy>1.0*ansx*nowy) ansx=nowx,ansy=nowy;//爆ll
        }
        write1(ansx),write(ansy);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    using P = tuple<int, int>;
    vector<P> c(m);
    rep(i, m)
    {
        int p, y;
        cin >> p >> y;
        p--;
        c[i] = P(p, y);
    }

    vector<vector<int>> h(n);
    rep(i, m)
    {
        int p, y;
        tie(p, y) = c[i];
        h[p].push_back(y);
    }

    rep(i, n)
    {
        sort(h[i].begin(), h[i].end());
    }

    rep(i, m)
    {
        int p, y;
        tie(p, y) = c[i];

        int64_t result = (int64_t)(p + 1) * 1'000'000;
        result += lower_bound(h[p].begin(), h[p].end(), y) - h[p].begin() + 1;
        cout << setw(12) << setfill('0') << result << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer[] num = new Integer[n];
        boolean isNumber = true;
        for (int i = 0; i < m; i++) {
            sc.nextLine();
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (num[a-1] == null || num[a-1] == b) {
                num[a-1] = b;
            } else {
                isNumber = false;
                break;
            }
        }
        if (isNumber) {
            if ((n != 1 && num[0] != null && num[0] == 0)) {
                System.out.println("-1");
            } else {
                if (n != 1 && num[0] == null) {
                    num[0] = 1;
                }
                for (int i = 0; i < n; i++) {
                    System.out.print(num[i] != null ? num[i] : 0);
                }
                System.out.println();
            }
        } else {
            System.out.println("-1");
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

vector<ll> ans;
vector<vector<ll>> g;
vector<ll> vis;

    vector<ll> a;
void dfs(int r, vector<ll> &lis){
    //cout<<"hoge";
    auto itr = lower_bound(ALL(lis),a[r]);
    ll tmp = *itr;
    *itr=a[r];
    vis[r]=1;
    ans[r] = lower_bound(ALL(lis),INF)-lis.begin();
    for(ll to:g[r]){
        if(!vis[to])dfs(to,lis);
    }
    *itr = tmp;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    a=vector<ll>(n);
    rep(i,n)cin>>a[i];
    g = vector<vector<ll>>(n);
    vis=vector<ll>(n,0);
    ans=vector<ll>(n);
    rep(i,n-1){
        ll u,v;cin>>u>>v;
        g[u-1].push_back(v-1);
        g[v-1].push_back(u-1);
    }
    vector<ll> aa = vector<ll>(n,INF);
    dfs(0,aa);
    for(ll a:ans)cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 29004
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 
int32_t main(){
  fast; 
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif 
  */
  int T=1; //cin>>T; 
  while(T--){

    int n ; cin>>n; int k; cin>>k; 
    vi h(n+1,0); 
    for(int i=1;i<=n;i++) cin>>h[i]; 

    vi dp(n+1,-1); 
    dp[1]=0; 

    for(int i=2;i<=n;i++){
      for(int j=1;j<=k && i-j>=1;j++){
          if(dp[i]==-1) dp[i]=dp[i-j]+abs(h[i]-h[i-j]); 
          else dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));        
      }
    }
    cout<<dp[n]<<endl; 

  }
    


  return 0; 
} 


Measured memory_bytes: 1792
object Main extends App {
  var numList = readLine.split(" ")
  var a = numList(0).toInt
  var b = numList(1).toInt
  var isEven = (a * b) % 2 == 0

  if (isEven) {
    print("Even")
  } else {
    print("Odd")
  }
}

Measured memory_bytes: 25300
#include<stdio.h>

int main(void)
{
  int a,b,c,i,j,k;
  scanf("%d %d %d",&a,&b,&c);

  if(b>c){
    i=c,c=b,b=i;
    
  }
  if(a>b){
    j=b,b=a,a=j;
  }
  if(b>c){
    k=c,c=b,b=k;
  }
  
  printf("%d %d %d\n",a,b,c);
  return 0;
}

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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int n;
int arr[maxn];
int tree[maxn << 2];

void build(int node, int l, int r) {
  if(l == r) { tree[node] = arr[l]; return; } 
  int mid = (l + r) >> 1;
  build(node << 1, l, mid);
  build(node << 1|1, mid + 1, r);
  tree[node] = __gcd(tree[node << 1], tree[node << 1|1]); 
}

ll query(int node, int l, int r, int i, int j) {
  if(r < i || l > j) return 0;
  if(i <= l && r <= j) {
    return tree[node]; 
  } int mid = (l + r) >> 1;
  return __gcd(query(node << 1, l, mid, i, j), query(node << 1|1, mid+1, r, i,j));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  build(1, 1, n);
  int mx = 0;
  for (int i = 1; i <= n; ++i) {
    int le = query(1, 1, n, 1, i - 1);
    int ri = query(1, 1, n, i + 1, n);
    int g = __gcd(le, ri);
    mx = max(g, mx);
  }
  cout << mx << endl;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int s[100100], x, n, ans;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &x);
		s[x + 2]++;
		s[x + 1]++;
		s[x]++;
	}
	for(int i = 0; i <= 100002; i++) {
		ans = max(ans, s[i]);
	}
	printf("%d\n", ans);
	return 0;
} 

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

int main(void)
{
  int y,m,d;
  char s1,s2;
  cin>>y>>s1>>m>>s2>>d;
  if(m<=4)
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

bool isPrime(int x) {
  if (x < 2) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;

  double sqrtNum = sqrt(x);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, cnt = 0;
  std::cin >> n;
  while (n-- > 0) {
    int x;
    std::cin >> x;
    if (isPrime(x)) cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
const int mod = 1e9+7;
int n,m;
ll k;
char mp[1010][1010];
template<int S> struct matrix{
	ll a[S][S];
	void clear(int tag=0){
		memset(a,0,sizeof(a));
		for(int i=0;i<S;i++) a[i][i]=tag;
	}
	matrix<S>(int tag=0){clear(tag);}
	matrix<S>(vector<ll> v){
		for(int i=0;i<S;i++)
			for(int j=0;j<S;j++)
				a[i][j]=v[i*S+j];
	}
	matrix<S> operator * (const matrix &b){
		matrix<S> ans;
		for(int i=0;i<S;i++)
			for(int j=0;j<S;j++)
				for(int k=0;k<S;k++)
					ans.a[i][j]=(ans.a[i][j]+a[i][k]*b.a[k][j])%mod;
		return ans;
	}
};
template<int S> matrix<S> fp(matrix<S> a,ll k){
	matrix<S> ans(1);
	for(;k;k>>=1,a=a*a)
		if(k&1) ans=a*ans;
	return ans;
}
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		cin>>mp[i]+1;
	int flag1=0,flag2=0,sum=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum+=mp[i][j]=='#';
	for(int i=1;i<=n;i++) flag1|=mp[i][1]=='#'&&mp[i][m]=='#';
	for(int i=1;i<=m;i++) flag2|=mp[1][i]=='#'&&mp[n][i]=='#';
	if(flag1&&flag2){cout<<1<<'\n';return 0;}
	if(!flag1&&!flag2){cout<<fp(sum,k-1)<<'\n';return 0;}
	if(flag2){
		for(int i=1;i<=max(n,m);i++)
			for(int j=1;j<i;j++)
				swap(mp[i][j],mp[j][i]);
		swap(n,m);
	}
	int s1=0,s2=0;
	for(int i=1;i<=n;i++) s1+=mp[i][1]=='#'&&mp[i][m]=='#';
	for(int i=1;i<=n;i++)
		for(int j=1;j<m;j++)
			s2+=mp[i][j]=='#'&&mp[i][j+1]=='#';
	matrix<2> t({sum,0,s2,s1}),p({1,0,0,0});
	p=fp(t,k-1)*p;
	cout<<(p.a[0][0]-p.a[1][0]+mod)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>

using namespace std;
int main(){
    int N,i;
    cin >> N;
    int *V = new int[N];
    int *C = new int[N];
    for(i=0;i<N;i++) cin >> V[i];
    for(i=0;i<N;i++) cin >> C[i];
    int M=0;
    for(i=0;i<N;i++){
        if(V[i]-C[i]>0){
            M += V[i] - C[i];
        }
    }
    cout << M << endl;

    delete[] V,C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;
 
int main(){
    int mod=2019;
    ll L,R;cin >> L>>R;
    ll Min=2019;
    ll judge = R-L+1;
    if(judge>=2020) cout << 0<<endl;
    else{
        for(ll i=L;i<R;i++){
        for(ll j=i+1;j<=R;j++){
            ll t = i%mod*j%mod;
            Min=min(Min,t);
        }
    }
    cout<< Min<<endl;
    }    
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    int as = 0, bs = 0;
    set<int> difs;
    for (auto &ai:a) cin >> ai;
    for (auto &bi:b) cin >> bi;
    for (int i=0; i<n; i++) difs.insert(i);
    for (int i=1; i<=n; i++) {
        int ae = upper_bound(a, a+n, i) - a;
        int be = upper_bound(b, b+n, i) - b;
        if (ae > as && be > bs) {
            int start = as - (be-1);
            int goal  = (ae-1) - bs;
            if (start + n <= goal) {
                difs.erase(difs.begin(), difs.end());
            } else {
                start = (start + n) % n;
                goal  = (goal  + n) % n;
                if (start <= goal) {
                    auto s_itr = difs.lower_bound((start + n) % n);
                    auto g_itr = difs.upper_bound((goal  + n) % n);
                    difs.erase(s_itr, g_itr);
                } else {
                    auto s_itr = difs.lower_bound((start + n) % n);
                    difs.erase(s_itr, difs.end());
                    auto g_itr = difs.upper_bound((goal  + n) % n);
                    difs.erase(difs.begin(), g_itr);
                }
            }
        }
        as = ae;
        bs = be;
    }
    if (difs.size() == 0) {
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
        int d = *difs.begin();
        for (int i=0; i<n; i++) {
            cout << b[(i-d + n) % n] << (i < n-1 ? ' ' : '\n');
        }
    }
    return 0;
}

Measured memory_bytes: 14556
#include<cstdio>
const int N=1000005,P=1000000007;
int n,f[N];
int main()
{
	scanf("%d",&n);
	f[1]=n;
	f[2]=1ll*n*n%P;
	int sum=0;
	for(int i=3;i<=n;i++)
	{
		sum=(sum+f[i-3])%P;
		f[i]=(f[i-1]+(n-1ll)*(n-1ll)+(n-i+2)+sum)%P;
	}
	printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[9];
	int a,i,x=0,y=0,z=0;
	scanf("%s",s);
	a=strlen(s);
	if(s[0]=='A'){
		if(islower(s[1])){
			for(i=2;i<a-1;i++){
				if(s[i]=='C'){
					x++;
				}else{
					if(isupper(s[i])){
						y++;
					}
				}
			}
			if(islower(s[a-1])){
				if(x==1){
					if(y==0){
						z++;
					}
				}
			}
		}
	}
	if(z==1){
		printf("AC");
	}else{
		printf("WA");
	}return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.in","r",stdin); 
    //freopen("output.out","w",stdout);
    string s; cin>>s;
    int n=s.length();
    for(int i=0;i<n-8;i++) cout<<s[i];
    return 0;
}


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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D)
  {
    cout << "Left" << endl;
  }
  
  else if(A+B == C+D)
  {
    cout << "Balanced" << endl;
  }
  
  else
  {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    n=int(input())
    w=intLine()
    m=10^18
    for i in 2:n-1
        l=w[1:i]
        r=w[i+1:n]
        m=min(m,abs(sum(l)-sum(r)))
    end
    println(m)
end
main()

Measured memory_bytes: 121220
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    string s;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s;
            if(s=="snuke"){
                cout << (char)('A'+j) << i+1 << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
using namespace std;

#ifdef WAFDAYO
#define DBG_PRINT(s, t, u) { cerr << s << " \e[2m=\e[m \e[1m" << t << "\e[m" << u; }
#else
#define DBG_PRINT(s, t, u) {}
#endif
#define dbg(x) DBG_PRINT(#x, x, ", ")
#define dbgln(x) DBG_PRINT(#x, x, endl)
#define idbg(x, i) DBG_PRINT(#x "[" << i << "]", x[i], ", ")
#define idbgln(x, i) DBG_PRINT(#x "[" << i << "]", x[i], endl)

typedef long long i64;
const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	int s = 0;
	s += max(4 - x, 0) * 100000;
	s += max(4 - y, 0) * 100000;
	if(x == y && x == 1) {
		s += 400000;
	}
	printf("%d\n", s);
	return 0;
}


// wafdayo~~~


Measured memory_bytes: 256
using System;

class Class29
{
    static void Main()
    {
        string S = Console.ReadLine();
        int i = 0;
        long A = 0, B = 0, R = 0;

        while (i < S.Length)
        {
            for (; i < S.Length; i++)
            {
                if (S[i] == '<') A++;
                else break;
            }

            for (; i < S.Length; i++)
            {
                if (S[i] == '>') B++;
                else break;
            }

            R += Culc(A - 1) + Culc(B - 1) + Math.Max(A, B);
            A = B = 0;
        }

        Console.WriteLine(R);
    }

    static long Culc(long n)
    {
        return n > 0 ? n * (n + 1) / 2 : 0;
    }
}



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


void solve(std::vector<long long> H, std::vector<long long> M, long long K){
  long long hour = H[1] - H[0];
  long long minit = 0;
  if(M[0] > M[1]) {
    hour--;
    minit = 60 + (M[1] - M[0]);
  }
  else {
    minit = M[1] - M[0];
  }

  cout << ((60*hour+minit) - K) << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> H(2);
  std::vector<long long> M(2);
  for(int i = 0 ; i < 2 ; i++){
    scanf("%lld",&H[i]);
    scanf("%lld",&M[i]);
  }
  long long K;
  scanf("%lld",&K);
    solve(std::move(H), std::move(M), K);
    return 0;
}


Measured memory_bytes: 3688
# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


def solve():
    inf = 10 ** 14 + 10

    def dfs(v: 'vertex_index, 0-indexed') -> None:
        for c, t in e[v]:
            if d[t] != inf:
                continue
            d[t] = d[v] + c
            dfs(t)

    n = int(input())
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        e[a].add((c, b))
        e[b].add((c, a))

    q, v = map(int, input().split())
    v -= 1

    d = [inf] * n
    d[v] = 0

    dfs(v)

    for _ in range(q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        print(d[x] + d[y])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 163764
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    char pre = '1';
    
    int ans = 0;
    int temp = 0;
    int cnt = 0;
    int tail = 0;
    
    for(int i=0; i<N; i++){
        if(pre == '1' && S[i] == '0'){
            cnt++;
        }
        temp ++;
        if(cnt > K){
            bool tail_pre = false;
            while(1){
                if(S[tail] == '0') tail_pre = true;
                if(S[tail] == '1' && tail_pre) break;
                temp--;
                tail++;
            }
            cnt--;
        }
        ans = max(ans, temp);
        pre = S[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512