akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll a[maxn];

void solve() {
	ll n,x,mi=INF,id=INF; cin >> x >> n;
	set<ll> s;
	rep(i,0,n) {
		cin >> a[i];
		s.insert(a[i]);
	}
	if (n==0) {cout << x; return;}
	per(i,300,-1) {
		if (s.count(i)) continue;
		if (abs(x-i) <= mi) mi = abs(x-i), id = min(id,(ll)i);
	}
	cout << id;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> sum(n + 1);
  int sumw = 0;
  int sumb = 0;
  rep(i, n) {
    if(s[i] == '#') sumb++;
    else sumw++;
  }

  int ans = min(sumw, sumb);
  int black = 0;
  int white = 0;
  rep(i, n) {
    if (s[i] == '#') black++;
    else white++;
    int value = black + (n - sumb - white);
    ans = min(ans, value);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1412
while True:
    plen = input()
    if plen == 0:
        break
    cnum = input()
    width = input()
    cspace = input()
    def formated_print(note):
        for i in xrange(plen):
            print ("."*cspace).join(note[j*plen+i].ljust(width, ".") for j in xrange(cnum))
        print "#"
    note = []
    line = raw_input()
    while line != "?":
        if len(note) >= plen * cnum:
            formated_print(note)
            note = []
        if len(line) > width:
            note.append(line[:width])            
            line = line[width:]
        else:
            note.append(line)
            line = ""
        if line == "":
            line = raw_input()
    if note:
        while len(note) < plen * cnum:
            note.append("")    
        formated_print(note)
    print "?"

Measured memory_bytes: 4256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	H, _ := getInt(), getInt()

	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = getString()
	}

	for i := 0; i < H; i++ {
		out(S[i])
		out(S[i])
	}
}


Measured memory_bytes: 640
import sys
readline=sys.stdin.readline

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
DIV = 10 ** 9 + 7

# 正に出来る場合：
# ・すべて正の数を選べる
# ・選べる数が奇数個で、負の数が偶数個と正の数が1個以上存在する
# ・選べる数が偶数個で、負の数が偶数個存在する
# 負になる場合：
# ・すべて負の数で且つ、選べる数が奇数個
# ・0が存在していれば、0のほうがマシ

# 開始時点で、絶対値が少ないほうを目指すか大きいほうを目指すか決まる
# 負の数を目指す場合、大きいほうからK個掛ければOK

# 大きいほうを目指す場合、
# 正の数の大きい順リスト [2,1]
# 負の数の絶対値大きい順リスト [-4,-3]
# の先頭から、2個のペアが大きくなるほうを貪欲に取っていく。
# 取れる数が奇数の場合は、まず正のほうの一番大きいのを取っちゃえばOK

pluslist = []
minuslist = []
zerocnt = 0
for i in range(len(A)):
  if A[i] > 0:
    pluslist.append(A[i])
  elif A[i] < 0:
    minuslist.append(A[i])
  else:
    zerocnt += 1
    
# 必ずゼロを選んでしまう場合
if N - zerocnt < K:
  print(0)
  exit(0)
  
if K % 2 == 1 and len(pluslist) == 0:
  # 負になる場合
  if zerocnt > 0:
    print(0)
    exit(0)
  # 絶対値が小さい状態を目指す
  minuslist = sorted(minuslist, reverse = True)
  ans = 1
  for i in range(K):
    ans *= minuslist[i]
    ans %= DIV
  print(ans)
  exit(0)
  
if K + zerocnt == N:
  if len(minuslist) % 2 == 1 and zerocnt > 0:
    print(0)
    exit(0)
  else:
    ans = 1
    for p in pluslist:
      ans *= p
      ans %= DIV
    for m in minuslist:
      ans *= m
      ans %= DIV
    print(ans)
    exit(0)

# 正の数を目指す
pluslist = sorted(pluslist, reverse = True)
minuslist = sorted(minuslist)
from collections import deque

plusq = deque(pluslist)
minusq = deque(minuslist)

ans = 1
# この時点で、正にすることが出来る。
# Kが奇数の場合、最低でも1回正の数を使う必要がある
if K % 2 == 1 and len(plusq) > 0:
  ans *= plusq.popleft() # 一番大きいものを取っておく
  K -= 1

for i in range(K // 2):
  p = None
  m = None
  if len(plusq) >= 2:
    p1 = plusq.popleft()
    p2 = plusq.popleft()
    p = p1 * p2
  if len(minusq) >= 2:
    m1 = minusq.popleft()
    m2 = minusq.popleft()
    m = m1 * m2
  if p is None and m is None:
    ans *= (minusq.popleft() * plusq.popleft()) % DIV
    continue
  if m is None:
    ans *= p % DIV
    ans %= DIV
    continue
  if p is None:
    ans *= m % DIV
    ans %= DIV
    continue
  if p > m:
    ans *= p % DIV
    ans %= DIV
    minusq.appendleft(m2)
    minusq.appendleft(m1)
  else:
    ans *= m % DIV
    ans %= DIV
    plusq.appendleft(p2)
    plusq.appendleft(p1)

print(ans)

Measured memory_bytes: 31736
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

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

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i] - 1;
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
using namespace std;
 
int a[100001]; 
 
 main () {
	ios_base::sync_with_stdio (0);	
	cin.tie (0), cout.tie (0);
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	reverse (a + 1, a + n + 1);
	int l = 2, r = 2;
	for (int i = 1;i <= n;i ++) {
		int l1 = (l / a[i] + ((l % a[i]) > 0)) * a[i];               
		int r1 = (r / a[i]) * a[i];
		if (l1 > r) {
			cout << -1;
			return 0;
		}
		l = l1;
		r = r1 + a[i] - 1;
	}
	cout << l << ' ' << r;
	return 0;
}

Measured memory_bytes: 1024
k, n = map(int, input().split())
lst = list(map(int, input().split()))

d = 0
for i in range(len(lst)-1):
  if d < lst[i+1] - lst[i]:
    d = lst[i+1] - lst[i]
if k-lst[-1] + lst[0] > d:
  d = k-lst[-1] + lst[0]
print(k-d)
  

Measured memory_bytes: 77260
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	s.replace(5,1," ");
	s.replace(13,1," ");
	cout<<s<<endl;
	return 0;
}


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

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

    vector<int> c(S.size());
    rep(i, S.size()) c[i] = (S[i] - 'a');

    rep(i, S.size()) {
        if (S[i] == 'a')
            continue;
        if (K >= 26 - c[i]) {
            K -= 26 - c[i];
            c[i] = 0;
        }
    }

    if (K != 0) {
        c[S.size() - 1] += K;
        c[S.size() - 1] %= 26;
    }

    rep(i, S.size()) cout << char(c[i] + 'a');
    cout << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> l(n), r(n);
	for (int i = 0; i < n; i++)
		cin >> l[i] >> r[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += r[i] - l[i] + 1;
	cout << ans << endl;
	return 0;
}

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

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

  int N;
  cin >> N;

  int ans = 0;
  while (N > ans) {
    ans += 1000;
  }

  cout << ans - N << endl;

  return 0;
}


Measured memory_bytes: 3648
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 200005;
  const int INF = 1e16;
  const double PI = acos(-1);


int32_t main()
{
       

    IOS


    string s;
    cin >> s;


    bool ok = (s[2] == s[3] and s[4] == s[5]);


    if(ok)
    {
      cout <<"Yes";
    }
    else
    {
      cout << "No";
    }



  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{	
	int a, b;
	cin >> a;
	cin >> b;
	if(b < 24 && a + b < 24)
	{
		cout << a+b;
	}	
	else 
	{
		cout << (a+b)-24;
	}
}
 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  if(N == M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    string s;
    cin >> s;
    int n = sz(s);
    unordered_map <int, int> m;
    m[0] = 1;
    int rem = 0;
    int p = 1;
    int ans = 0;
    for(int i = n-1; i >= 0; i--){
    	rem = (rem + p * (s[i] - '0')) % 2019;
    	p = (p * 10) % 2019;
    	ans += m[rem];
    	m[rem]++;
    }
    cout << ans << '\n';
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tst=1;
//cin>>tst;
while(tst--)
{
	solve();
}
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pll> v(n);
    rep(i, n) {
        ll a, b;
        cin >> a>> b;
        v[i] = {a, b};
    }
    sort(all(v));
    ll ans = 0LL;
    rep(i, n) {
        if(m == 0) break;
        ll cnt = min(m, v[i].se);
        m -= cnt;
        ans += v[i].fi * cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <ctype.h>
/*#define debug*/
int main(int argv, char *argc[]){
    char answer[100] = {0}, target[100] = {0};
    int x, y, buf, flag=0;
    
    gets(answer);
    gets(target);
    #ifdef debug
        printf("debug-answer:%s\n", answer);
        printf("debug-target:%s\n", target);
    #endif
    
    for(x=0; '\0'!=answer[x]; x++){
        for(y=0, buf=x; target[y]==answer[buf] ||
             '\0'==target[y] || '\0'==answer[buf];){
            #ifdef debug
                printf("debug-entrance:target[%d] == answer[%d]\n", y, buf);
            #endif
            if('\0'== target[y]){
                flag=1;
                break;
            }
            
            if('\0'== answer[buf]){
                buf = 0;
                #ifdef debug
                    printf("debug-cleanup:buf is %d\n", buf);
                #endif
                continue;
            }
            
            buf++;
            y++;
            
        }
    }
    
    if(1 == flag) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  invar(int, K);
  invar(string, S);
  
  //もともと幸福，ブロック数を数える
  int moko = 0;
  int blocknum = 0;
  
  S = "R" + S + "L";
  
  for(int i = 1; i <= N; ++i) {
    if(S[i] == 'L') {
      if(S[i-1] == 'L') {
        moko++;
      }
    } else {
      //R
      if(S[i+1] == 'R') {
        moko++;
      }
    }
    
    //相違
    if(S[i] != S[i + 1] && i + 1 != N + 1) {
      blocknum ++;
    }
  }
  
  blocknum++;
  
  int opcount = blocknum / 2;
  if(K < opcount) {
    fin(moko + K * 2);
  } else {
    if(blocknum % 2 == 0) {
      fin(moko + (opcount - 1) * 2 + 1);
    } else {
      fin(moko + opcount * 2);
    }
  }
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var t=sc.S+"X";
		int ans=0;
		for(int i = 0;i<n;i++) {
			if(t[i]!=t[i+1]){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13536
void main()
{
    long n, m;
    rdVals(n, m);
    Pair[] pair = m.rdCol!Pair;

    pair.sort!"a.b < b.b";
    long pos;
    long cnt;
    foreach (p; pair)
    {
        if (p.a < pos) continue;
        pos = p.b;
        ++cnt;
    }

    cnt.writeln;
}

struct Pair
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

using namespace std;

int main(void) {
	string str;
	getline(cin,str);
	char c;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] >= 'a' && str[i] <= 'z') {
			c = 'A'+(str[i]-'a');
		}
		else if (str[i] >= 'A' && str[i] <= 'Z') {
			c = 'a'+(str[i]-'A');
		}
		else {
			c = str[i];
		}
		cout << c;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    ll s = 0;
    forn(i, n) {
        int x;
        int cnt = 0;
        cin >> x;
        while(x > 0 && x % 2 == 0){
            x /= 2;
            cnt++;
        }
        s += cnt;
    }
    cout << s;
}   

Measured memory_bytes: 256
program redistribution
  implicit none
  integer :: s
  integer(8) :: m(3, 3) = 0
  read(*,*) s
  if (s < 6) then
    write(*,'(i0)') s / 3
    stop
  end if
  m(1, 1) = 1
  m(2, 1) = 1
  m(3, 2) = 1
  m(1, 3) = 1
  m = modmatpow(m, s - 6)
  write(*,'(i0)') mod(m(1, 1) + m(1, 1) + m(1, 2) + m(1, 3), 1000000007_8)
contains
  function modmatmul(x, y) result(res)
    integer(8), parameter :: modu = 1000000007_8
    integer(8), intent(in) :: x(3, 3), y(3, 3)
    integer(8) :: tmp, res(3, 3)
    integer :: j, k
    do j = 1, 3
      res(1, j) = 0
      res(2, j) = 0
      res(3, j) = 0
      do k = 1, 3
        tmp = y(k, j)
        res(1, j) = res(1, j) + x(1, k) * tmp
        res(2, j) = res(2, j) + x(2, k) * tmp
        res(3, j) = res(3, j) + x(3, k) * tmp
      end do
      res(1, j) = mod(res(1, j), modu)
      res(2, j) = mod(res(2, j), modu)
      res(3, j) = mod(res(3, j), modu)
    end do
  end
  function modmatpow(x, n) result(res)
    integer(8), intent(in) :: x(3, 3)
    integer, intent(in) :: n
    integer(8) :: res(3, 3), tmp(3, 3)
    integer :: m
    res(1, 1) = 1
    res(2, 1) = 0
    res(3, 1) = 0
    res(1, 2) = 0
    res(2, 2) = 1
    res(3, 2) = 0
    res(1, 3) = 0
    res(2, 3) = 0
    res(3, 3) = 1
    tmp = x
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = modmatmul(res, tmp)
      tmp = modmatmul(tmp, tmp)
      m = rshift(m, 1)
    end do
  end
end program redistribution

Measured memory_bytes: 2904
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,K;
string S;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> K >> S;
  S[K-1] = (char)tolower(S[K-1]);
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws NumberFormatException {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int prev = sc.nextInt();
        int min = prev;
        int max = Integer.MIN_VALUE;
        for (int i = 1; i < N; i++) {
            int n = sc.nextInt();
            min = Math.min(min, prev);
            max = Math.max(n - min, max);

            prev = n;
        }

        System.out.println(max);
    }
}



Measured memory_bytes: 69076
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  ll e18 = 1000000000000000000;
  vector<ll> A(N);

  rep(i,N) cin >> A[i];
  sort(all(A));
  ll a = 1;
  if (A[0]==0){
    cout << 0 << endl;
    return 0;
  }
  else {
    
    rep(i,N) {
      if (A[i]>e18/a) {
        cout << -1 << endl;
        return 0;
      }
      else a *= A[i];
    }
  }

  cout << a << endl;






  // cout << fixed << setprecision(6);
  return 0;
}


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

std::vector<int> bipartite(std::vector<std::pair<int,int>> edge){
    int M = edge.size();
    if(M==0)return {};
    int N = 0;
    for(int i=0;i<M;i++){
        N=std::max(N,edge[i].first+1);
        N=std::max(N,edge[i].second+1);
    }
    std::vector<int> R(N,-1);
    std::vector<int> S(0);
    std::vector<std::vector<int>> es(N,std::vector<int>(0));
    for(int i=0;i<M;i++){
        es[edge[i].first].push_back(edge[i].second);
        es[edge[i].second].push_back(edge[i].first);
    }
    std::queue<int> Q;
    std::vector<bool> visited(N,false);
    for(int j=0;j<N;j++){
        if(visited[j])continue;
        Q.push(j);
        R[j]=0;
        visited[j]=true;
        while(!Q.empty()){
            int q=Q.front();
            Q.pop();
            visited[q]=true;
            for(int i=0;i<es[q].size();i++){
                if(R[es[q][i]]==R[q]){
                    return S;
                }
                if(visited[es[q][i]])continue;
                Q.push(es[q][i]);
                R[es[q][i]]=1-R[q];
            }
            
        }
    }
    return R;
}

signed main(void){
    long long N,M;
    int a,b;
    vector<int> A,B;
    cin >> N >> M;
    REP(i,M){
        cin >> a >> b;
        a--;b--;
        A.push_back(a);
        B.push_back(b);
    }
    vector<pair<int,int>> AB;
    REP(i,M){
        AB.push_back({A[i],B[i]});
        //cout << A[i] MM B[i] << endl;
    }
    
    vector<int> d=bipartite(AB);
    //vector<int> d(N,1);
    if(d.size()==0){
        cout << N*(N-1)/2 - M << endl;
        return 0;
    }
    //REP(i,N){cout << d[i] << " ";}cout << endl;
    long long x=0,y=0;
    REP(i,N){
        if(d[i]){
            x++;
        }else{
            y++;
        }
    }
    cout << x*y - M << endl;
    return 0;
}


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

namespace AtCoder
{
    class AtCoderr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            string s = ReadLine();
            char remain = s[0];
            int ans = 1;
            for (int i = 1; i < n; i++)
            {
                if (remain != s[i])
                {
                    remain = s[i];
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11232
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

vector<int> ud;
vector<int> vd;

vector<vector<int>> tree;
void dfs(int n, int prev, int depth, bool flag) {
  if(flag) {
    ud[n] = depth;
  } else {
    vd[n] = depth;
  }
  for(auto next : tree[n]) {
    if(next != prev) {
      dfs(next, n, depth + 1, flag);
    }
  };
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  tree = vector<vector<int>>(N, vector<int>());
  ud = vector<int>(N);
  vd = vector<int>(N);
  REP(i, N - 1) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    tree[A].push_back(B);
    tree[B].push_back(A);
  }
  dfs(u, -1, 0, true);
  dfs(v, -1, 0, false);
  // dump(ud);
  // dump(vd);

  auto reachable = vector<int>();
  int far;
  int max_d = -1;
  REP(i, N) {
    if(ud[i] < vd[i]) {
      if(vd[i] > max_d) {
        max_d = vd[i];
        far = i;
      }
    }
  }
  int sec_far = tree[far][0];
  // dump(ud[far], vd[far]);
  // dump(ud[sec_far], vd[sec_far]);
  cout << vd[sec_far] << endl;
}


Measured memory_bytes: 11648
N = int(input())
cnt = 0
A = 0
B = 0
BA = 0
for _ in range(N):
    s = input()
    cnt += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        BA += 1
    elif s[0] == "B":
        B += 1
    elif s[-1] == "A":
        A += 1

if BA == 0:
    ans = cnt + min(A, B)
else:
    ans = cnt + BA - 1
    if A > 0:
        ans += 1
        A -= 1
    if B > 0:
        ans += 1
        B -= 1
    ans += min(A, B)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int sx, sy, tx, ty;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> sx >> sy >> tx >> ty;
  int mx = tx - sx;
  int my = ty - sy;

  REP(i, mx) {
    cout << 'R';
  }
  REP(i, my) {
    cout << 'U';
  }

  REP(i, mx) {
    cout << 'L';
  }
  REP(i, my) {
    cout << 'D';
  }

  cout << 'L';
  REP(i, my + 1) {
    cout << 'U';
  }
  REP(i, mx + 1) {
    cout << 'R';
  }
  cout << 'D';

  cout << 'R';
  REP(i, my + 1) {
    cout << 'D';
  }
  REP(i, mx + 1) {
    cout << 'L';
  }
  cout << 'U';

  cout << endl;
}


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

int main(void) {
    int x, n;
    cin >> x >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;
    int flg;
    while (true) {
        flg = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] == x - count) {
                flg = 1;
            }
        }
        if (flg == 0) {
            cout << x - count << endl;
            break;
        }
        flg = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] == x + count) {
                flg = 1;
            }
        }
        if (flg == 0) {
            cout << x + count << endl;
            break;
        }
        count++;
    }
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, tw;
    cin >> n >> tw;
    vector<vector<long long>> dp(tw+1, vector<long long>(n+1,0));
    vector<int> w(n), v(n);
    for (int i = 0; i < n;++i)
    {
        cin >> w.at(i) >> v.at(i);
    }
    for (int i = 1; i <= n;++i)
    {
        for (int j = 1; j <= tw;++j)
        {
            if(w.at(i-1)<=j)
            {
                dp.at(j).at(i) = max(dp.at(j).at(i - 1), dp.at(j - w.at(i-1)).at(i-1) + v.at(i-1));
            }
            else
            {
                dp.at(j).at(i) = dp.at(j).at(i - 1);
            }
        }
    }
    cout << dp.back().back();
    return 0;
}

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

int main() {
  string a, s, c;
  cin >> a >> s >> c;
  cout << "A"s + s.at(0) + "C"s << endl;
  return 0;
}

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

using namespace std;

struct R
{
    int s;
    int e;
};


struct S
{
    int s;
    int c;
    vector<R> r;
};


int main()
{
    int pcN, stN;
    while(cin >> pcN >> stN, stN){
        auto sts = vector<S>(stN);

        for(auto& a: sts){
            a.s = -1;
            a.c = 0;
        }

        int logN;
        cin >> logN;
        while(logN--){
            int t, _, m, s;
            cin >> t >> _ >> m >> s;
            // cout << t << m << s << endl;
            m -= 1;

            sts[m].c += s ? 1 : -1;
            if(sts[m].s == -1)
                sts[m].s = t;

            // cout << sts[m].s << ", " << sts[m].c << endl;

            if(sts[m].c == 0){
                R re = {sts[m].s, t};
                sts[m].r.push_back(re);
                sts[m].s = -1;
            }
        }

        int qN;
        cin >> qN;
        while(qN--){
            int ts, te, m;
            cin >> ts >> te >> m;

            m -= 1;

            int ans = 0;
            for(R& a: sts[m].r){
                // cout << a.s << ", " << a.e << endl;
                ans += max(0, (max(a.e, te) - min(a.s, ts)) - abs(a.s - ts) - abs(a.e - te));
            }

            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 1536
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
const int MOD = 1000000007;
const int MAXN = 1000000;
int n, d, h, f[1000005], g[1000005], dp[2000005], p, sum[1000005];
int power(int A, int B)
{
    A %= MOD;
    int res = 1;
    while (B)
    {
        if (B & 1)
        {
            res = res * A % MOD;
        }
        A = A * A % MOD;
        B >>= 1;
    }
    return res;
}
int P(int M, int N)
{
    return f[M] * g[M - N] % MOD;
}
signed main()
{
    ios::sync_with_stdio(false);
    f[0] = 1;
    for (int i = 1; i <= MAXN; ++i)
    {
        f[i] = f[i - 1] * i % MOD;
    }
    g[MAXN] = power(f[MAXN], MOD - 2);
    for (int i = MAXN; i; --i)
    {
        g[i - 1] = g[i] * i % MOD;
    }
    cin >> n >> h >> d;
    for (int i = 1; i <= n; ++i)
    {
        p = (p + f[i]) % MOD;
    }
    for (int i = 1; i <= h; ++i)
    {
        if (i <= d)
        {
            dp[i] = (n + sum[i - 1] * p) % MOD;
        }
        else
        {
            dp[i] = (sum[i - 1] - sum[i - d - 1] + MOD) * p % MOD;
        }
        sum[i] = (sum[i - 1] + dp[i]) % MOD;
    }
    cout << dp[h] * P(n - 1, n - 1) % MOD << endl;
    return 0;
}

Measured memory_bytes: 34872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, k;
    cin >> n >> k;
    vi x(n);
    rep(i, n) cin >> x[i];
    ll l = 0, r = k - 1;
    ll mi = INF;
    rep(i, n - k + 1) {
        chmin(mi, min(abs(x[l]) + abs(x[r] - x[l]), abs(x[r]) + abs(x[r] - x[l])));
        ++l; ++r;
    }
    print(mi);
}

Measured memory_bytes: 1024
from collections import deque
def main():
  n,m=map(int,input().split())
  e=[[] for _ in range(n)]
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    e[a].append(b)
    e[b].append(a)
  ans=[-1]*n
  dq=deque([0])
  while dq:
    g=dq.popleft()
    for v in e[g]:
      if ans[v]==-1:
        ans[v]=g+1
        dq.append(v)
  ans[0]="Yes"
  print(*ans)
main()  


Measured memory_bytes: 95688
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        n: usize,
    }

    let mut vec = vec![0; n];

    for i in 1..=100 {
        for j in 1..=100 {
            for k in 1..=100 {
                let aa = (i+j)*(i+j) + (j+k)*(j+k) + (k+i)*(k+i);
                if aa <= 2*n {
                    vec[aa/2-1] += 1;
                } 
            }
        }
    }

    for &x in &vec {
        println!("{}",x)
    } 
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll la[n+1];
    vector<ll> l;
    for(ll i=1;i<=n;i++){
        cin>>la[i];
        l.push_back(la[i]);
    }
    sort(l.begin(),l.end());
    ll dp[n+1][2*1001];
    for(ll i=0;i<=n*1000;i++){
        dp[2][i]=0;
        if(i==l[0]+l[1]){
            dp[2][i]=1;
        }
    }

    ll count[n+1][1001];
    for(ll i=0;i<n;i++){
        for(ll j=i;j<n;j++){
            count[j][l[i]]++;
        }
    }
    for(ll i=2;i<n;i++){
        for(ll j=0;j<=2*1000;j++){
            if(j-l[i]>0 && j-l[i]<=1000){
                dp[i+1][j]=dp[i][j]+count[i-1][j-l[i]];
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    
    
    ll ans=0;
    ll c;
    for(ll i=2;i<n;i++){
        c=l[i];
        for(ll j=c+1;j<=2*c;j++){
            ans+=dp[i][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 46848
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
int n;
const int N=100005;
char a[N];
int main ()
{
	scanf("%s",&a);
	int len=strlen(a);
	for(int i=0;i<len;i++){
		if(a[i]=='A'&&a[i+1]=='C'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[100005];
ll sum[100005], cnt[100005];
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    ll ans = 0;
    for(int i=2;i<=n;i++){
        if(a[i-1] <= a[i]){
            ans += a[i]-a[i-1];
            if(a[i-1] < a[i]){
                cnt[a[i-1]+2]++;
                cnt[a[i]+1]--;
                sum[a[i]+1] -= a[i]-a[i-1]-1;
            }
        }
        else{
            ans += m-a[i-1]+a[i];
            cnt[1]++;
            cnt[a[i]+1]--;
            cnt[a[i-1]+2]++;
            sum[1] += m-a[i-1]-1;
            sum[a[i]+1] -= m-a[i-1]+a[i]-1;
        }
    }

    ll res = 0;
    for(int i=1;i<=m;i++){
        cnt[i] += cnt[i-1];
        sum[i] += sum[i-1];
        sum[i] += cnt[i];
        res = max(res, sum[i]);
    }
    ans -= res;
    printf("%lld\n", ans);
}

Measured memory_bytes: 5764
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/
const int N = 1000005;
int grundy[N];
set<int>coinSet;

int mex(set<int>&st)
{
    for(int i=0;;i++)
        if(st.find(i)==st.end()) return i;
    return 0;
}
int solve(int n)
{
    if(n==0) return 0;
    if(grundy[n]!=-1) return grundy[n];
    if(coinSet.find(n)!=coinSet.end()) return grundy[n]=1;

    set<int>tempSet;
    grundy[n]=0;
    for(auto it:coinSet)
    {
        if(it<=n){
        int x = solve(n-it);
        if(x==0)
            grundy[n]=1;
        }
    }

   
    return grundy[n];


}

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
   

    int n,k;
    cin>>n>>k;

    memset(grundy,-1,sizeof grundy);
 

    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        coinSet.insert(x);
    }
    cout<<(solve(k)!=0?"First":"Second");     
    
  
 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 24080
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

int main() {

int N,H;
int maxpower=0;
vector<int> A(100000);
vector<int> B(100000);
vector<pair<int,int>> S;

cin>>N>>H;
fx(N){
	cin>>A.at(x)>>B.at(x);
	S.push_back(make_pair(B.at(x),A.at(x)));
	if(maxpower<A.at(x)){
		maxpower=A.at(x);
	}
}
sort(S.begin(),S.end());
reverse(S.begin(),S.end());

int ans=0;
bool death=false;

fx(N){

if(S.at(x).first<maxpower){break;}

	if(H-S.at(x).first>0){
		H-=S.at(x).first;
		ans++;

	}else{
		ans++;
		death=true;
		break;
	}
}

if(death){
	ce(ans);
}else{
	while(H>0){
		ans++;
		H-=maxpower;

	}
	ce(ans);
}




}


Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=(LL)1<<50;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c;
	cin>>n>>m;
	LL s=n;
	for(i=2;i<40;i++){
		for(j=2;j<=1e6;j++){
			a=1;
			for(k=0;k<i;k++){
				a*=j;
				if(a>=n)break;
			}
			if(k==i)continue;
			for(k=0,a=1;k<i;k++)a*=j-1;
			b=1,c=m*(i-1);
			for(k=0;k<i;k++){
				b*=j,a/=j-1,c+=j;
				if(b*a>=n){
					c+=(j-1)*(i-k-1);
					break;
				}
			}
			if(s>c)s=c;
			break;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256