akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<ll> x(N),y(N);
  rep(i,N)  cin >> x.at(i) >> y.at(i);

  vector<ll> ad(N),sb(N);
  rep(i,N){
    ad.at(i) = x.at(i) + y.at(i);
    sb.at(i) = x.at(i) - y.at(i);
  }
  sort(all(ad));
  sort(all(sb));

  ll ans = max(ad.at(N-1) - ad.at(0), sb.at(N-1) - sb.at(0));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9516
#include <stdio.h>
#include <string.h>

#define MAX 81

int get_line(char str[]);
int judge(char word[]);
void shift_word(char word[]);
void shift_line(int n, char line[]);

int main(void)
{
    char str[MAX];
    char line[MAX];
    char *word;
    int shift_num;

    while(get_line(str) != 0) {
        strcpy(line, str);
        word = strtok(str, " ");
        if ((shift_num = judge(word)) != -1) {
            shift_line(shift_num, line);
        } else {
            while((word = strtok(NULL, " ")) != NULL) {
                if ((shift_num = judge(word)) != -1) {
                    shift_line(shift_num, line);
                    break;
                }
            }
        }
        printf("%s\n", line);
    }

    return 0;
}

int get_line(char str[])
{
    int i = 0;
    char c;

    while ((c = getchar()) != '\n' && c != EOF) {
        str[i++] = c;
    }
    str[i] = '\0';

    return i;
}

int judge(char word[])
{
    int i;

    for (i = 0; i < 26; i++) {
        if (strcmp(word, "the") == 0 ||
                strcmp(word, "this") == 0 || strcmp(word, "that") == 0) {
            return i;
        }
        shift_word(word);
    }
    return -1;
}

void shift_word(char word[])
{
    int i;
    int len = strlen(word);

    for (i = 0; i < len; i++) {
        if ('a' <= word[i] && word[i] <= 'z') {
            word[i] = (word[i] - 'a' + 1) % 26 + 'a';
        }
    }

    if (word[len - 1] == '.') {
        word[len - 1] = '\0';
    }
}

void shift_line(int n, char line[])
{
    int i;

    for (i = 0; i < (int)strlen(line); i++) {
        if ('a' <= line[i] && line[i] <= 'z') {
            line[i] = (line[i] - 'a' + n) % 26 + 'a';
        }
    }
}

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


int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x=tx-sx;
  int y=ty-sy;
  for(int i=0;i<y;++i){
    cout << 'U';
  }
  for(int i=0;i<x;++i){
    cout << 'R';
  }
  for(int i=0;i<y;++i){
    cout << 'D';
  }
  for(int i=0;i<x;++i){
    cout << 'L';
  }
  cout << 'L';
  for(int i=0;i<=y;++i){
    cout << 'U';
  }
  for(int i=0;i<=x;++i){
    cout << 'R';
  }
  cout << 'D';
  cout << 'R';
  for(int i=0;i<=y;++i){
    cout << 'D';
  }
  for(int i=0;i<=x;++i){
    cout << 'L';
  }
  cout << 'U' << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a == b and b == c) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
long long modinv(long long a,long long mod)
{
  return modpow(a,mod-2,mod);
}
vector<long long> fact,inv;
long long mod=1e9+7;
void init(int n){
  fact.resize(n);
  inv.resize(n);
  fact[0]=1LL;
  rep(i,n-1){
    fact[i+1]=(long long)fact[i]*(i+1)%mod;
  }
  inv[n-1]=modinv(fact[n-1],mod);
  rrep(i,n-1){
    inv[i]=(long long)inv[i+1]*(i+1)%mod;
  }
}
long long comb(ll a,ll b){
  if(b<0||a-b<0)return 0;
  return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll k;cin>>k;
  init(1e5);
  repi(i,1,k+1){
    ll res=0;
    res=comb(n-k+1,i)*(comb(k-1,i-1))%mod;
    cout<<res<<endl;
  }
  return 0;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int UF[214514];
int UF2[214514];
void UFinit(int n){
    for(int i=0;i<=n;i++){
        UF[i]=i;
    }
}
int UFroot(int k){
    if(UF[k]==k){
        return k;
    }else{
        UF[k]=UFroot(UF[k]);
        return UF[k];
    }
}
int UFsame(int P,int Q){
    if(UFroot(P)==UFroot(Q)){
        return true;
    }else{
        return false;
    }
}
void UFunite(int P,int Q){
    int p=UFroot(P);
    int q=UFroot(Q);
    if(p==q)return;
    if(p>q)swap(p,q);
    UF[q]=p;
}


signed main(){
    string S,T;
    cin >> S >> T;
    int E[26];
    UFinit(S.size());
    REP(i,26){E[i]=-1;}
    REP(i,S.size()){
        if(E[S[i]-'a']==-1){
            E[S[i]-'a']=i;
        }else{
            UFunite(E[S[i]-'a'],i);
        }
    }
    REP(i,S.size()){
        UF2[i]=UF[i];
    }
    UFinit(T.size());
    REP(i,26){E[i]=-1;}
    REP(i,T.size()){
        if(E[T[i]-'a']==-1){
            E[T[i]-'a']=i;
        }else{
            UFunite(E[T[i]-'a'],i);
        }
    }
    /*REP(i,S.size()){
        cout << UF2[i] << " ";
    }cout << Endl;
    REP(i,S.size()){
        cout << UF[i] << " ";
    }cout << Endl;*/
    REP(i,S.size()){
        if(UF[i]!=UF2[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}   


Measured memory_bytes: 3848
H,W,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*N]
d={}
for a,b in ab:
    for i in (a-1,a,a+1):
        for j in (b-1,b,b+1):
            d[(i,j)] = d.get((i,j),0)+1
cnt = [0]*10
for k,v in d.items():
    a,b = k
    if a<2 or b<2:continue
    if a>H-1 or b>W-1:continue
    cnt[v] += 1
cnt[0] = (W-2)*(H-2)-sum(cnt)
for ans in cnt:
    print(ans)


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

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

  if(n==1 || n==2)cout<<0<<endl;
  else{
    long long div=1LL, ans=0LL;
    while(div<sqrt(n)){
      if(n%div==0 && n/div!=div+1)ans+=n/div-1;
      ++div;
    }
    cout<<ans<<endl;
  }
}


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

using namespace std;

int main(void) {
	int n; cin >> n;
	vector<pair<pair<string, int>,int>> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first.first >> v[i].first.second;
		v[i].second = i + 1;
		v[i].first.second *= -1;
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; ++i)cout << v[i].second << endl;
	return 0;
}


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

long long int MAX,MIN,i,n,m,x,y,z,ans1,ans2,ans3,ans4;
int main()
{
    cin>>n>>m;
    if(n%3==0||m%3==0)
    {
        cout<<0<<endl;
        return 0;
    }
    ans1=n;
    ans2=m;
    ans3=ans4=9999999;
    for(i=1;i<=n;i++)
    {
        x=i*m;
        if(m%2!=0)
        {
            y=(n-i)*(m/2+1);
            z=(n-i)*(m/2);
        }
        else
        {
            y=z=(n-i)*(m/2);
        }
        MAX=max(z,max(x,y));
        MIN=min(z,min(x,y));
        ans3=min(MAX-MIN,ans3);
    }
    for(i=1;i<=m;i++)
    {
        x=i*n;
        if(n%2!=0)
        {
            z=(m-i)*(n/2+1);
            y=(m-i)*(n/2);
        }
        else
        {
            y=z=(m-i)*(n/2);
        }
        MAX=max(x,max(y,z));
        MIN=min(x,min(y,z));
        ans4=min(MAX-MIN,ans4);
    }
    cout<<min(min(ans1,ans2),min(ans3,ans4))<<endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int n;
    cin >> n;
    vector<ll> ans(n + 1, 0);
    for (ll i = 1; i <= 200; i++) {
        for (ll j = 1; j <= 200; j++) {
            for (ll k = 1; k <= 200; k++) {
                ll res = i * i + j * j + k * k + i * j + i * k + j * k;
                if (res <= n)
                    ans[res]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 3636
def insertion_sort(data)
  1.upto(data.size - 1) { |i|
    puts data.join(' ')
    v = data[i]
    j = i - 1
    while j >= 0 and data[j] > v
      data[j + 1] = data[j]
      j -= 1
    end
    data[j + 1] = v
  }
  data
end

gets
data = gets.chomp.split(' ').map(&:to_i)
puts insertion_sort(data).join(' ')

Measured memory_bytes: 8840
package main

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

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	fmt.Fprintln(stdout, (n-1)*n/2)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>
#include <iomanip>
using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=0,cnt=1; cin >> n;
    int a[n];
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        if(a[i]==cnt)cnt++;
        else{
            ans++;
        }
    }
    if(ans == n)cout<<-1<<endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,y;
  cin>>n>>y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j+i<=n;j++){
      if(i*1000+j*5000+(n-i-j)*10000==y){
        cout<<n-i-j<<" "<<j<<" "<<i<<endl;
        return 0;
      }
    }
  }cout<<-1<<" "<<-1<<" "<<-1<<endl;
}
      

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    if(s[0] == 'A') {
        int cnt = 0;
        for (int i = 2; i < s.size()-1; ++i) {
            if(s[i] == 'C'){
                cnt++;
            }
        }
        if(cnt == 1){
            for (int i = 1; i < s.size(); ++i) {
                if(('A' <= s[i] && s[i] <= 'Z') && s[i] != 'C'){
                    cout << "WA" << endl;
                    return 0;
                }
            }
        cout << "AC" << endl;

        }else{
            cout << "WA" << endl;
        }
    }else{
        cout << "WA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin >> n;
    string s;cin>>s;
    int w_cnt= 0;
    rep(i,n)if(s[i]=='.')w_cnt++;
    int b_cnt = 0;
    int ans = w_cnt;
    rep(i,n){
        if(s[i]=='#')b_cnt++;
        else w_cnt--;
        ans = min(ans,b_cnt+w_cnt);
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    vector <pii> pos, neg;
    for (int i = 0; i < n; i++) {
        cin >> s;
        int bal = 0, mn = 0;
        for (auto &j : s) {
            if (j == '(') {
                ++bal;
            }
            else {
                --bal;
            }
            umin(mn, bal);
        }
        if (bal >= 0) {
            pos.pb({mn, bal});
        }
        else {
            reverse(all(s));
            bal = 0, mn = 0;
            for (auto &j : s) {
                if (j == ')') {
                    ++bal;
                }
                else {
                    --bal;
                }
                umin(mn, bal);
            }
            neg.pb({mn, bal});
        }
    }
    sort(all(pos));
    reverse(all(pos));
    int cur = 0;
    for (auto &i : pos) {
        if (cur + i.x < 0) {
            cout << "No\n";
            rr;
        }
        cur += i.y;
    }
    int cur1 = 0;
    sort(all(neg));
    reverse(all(neg));
    for (auto &i : neg) {
        if (cur1 + i.x < 0) {
            cout << "No\n";
            rr;
        }
        cur1 += i.y;
    }
    if (cur != cur1) {
        cout << "No\n";
        rr;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 11344
#include <iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	int b[a];
	int c[a+1];
	for(int i=1;i<=a;i++) c[i]=0;
	for(int i=2;i<=a;i++){
	    cin>>b[i];
	    int k=b[i];
		c[k]++;
    }
	for(int i=1;i<=a;i++){
		cout<<c[i]<<endl;
	}
}

Measured memory_bytes: 5100
import sys
N,M=map(int,input().split())
Ai=[]
Bi=[]
for i in range(N):
    Ai.append(input())
for i in range(M):
    Bi.append(input())
roop=N-M+1
for i in range(roop):
    for j in range(roop):
        #print("A")
        flag=1
        for k in range(M):
            #print(Ai[i+k][j:j+M])
            if(Ai[i+k][j:j+M]!=Bi[k]):
                flag=0
                break;
        if(flag==1):
            print("Yes")
            sys.exit()
print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repit(it,u) for(__typeof((u).begin())it=(u).begin();it!=(u).end();++it)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define uniq(u) (u).erase(unique(all(u)),(u).end())
#define ll long
#define long int64_t
#define mp make_pair
#define pb push_back

typedef double number;
typedef vector<vector<number> > matrix;

inline number my_hypot(number x, number y) { return sqrt(x * x + y * y); }
inline void givens_rotate(number& x, number& y, number c, number s) {
    number u = c * x + s * y, v = -s * x + c * y;
    x = u, y = v;
}
vector<number> givens(matrix A, vector<number> b) {
    const int n = b.size();
    rep(i, n) repi(j, i + 1, n) {
        const number r = my_hypot(A[i][i], A[j][i]);
        const number c = A[i][i] / r, s = A[j][i] / r;
        givens_rotate(b[i], b[j], c, s);
        repi(k, i, n) givens_rotate(A[i][k], A[j][k], c, s);
    }
    for (int i = n - 1; i >= 0; --i) {
        repi(j, i + 1, n) b[i] -= A[i][j] * b[j];
        b[i] /= A[i][i];
    }
    return b;
}

const double eps = 1e-4;

int d;
vector<number> v;

vector<number> solve_eq(int m, int n){
    matrix A(d+1,vector<number>(d+1));
    vector<number> b(d+1);
    int cnt = 0;
    rep(i,d+3)if(i != m && i != n){
        b[cnt] = v[i];
        rep(j,d+1) A[cnt][j] = pow(1.0*i,1.0*j);
        cnt++;
    }
    return givens(A,b);
}

int main(){
    while(cin >> d, d){
        v.resize(d+3);
        int ans = -1;
        rep(i,d+3) cin >> v[i];
        rep(i,d+3){
            repi(j,i+1,d+3){
                vector<number> b = solve_eq(i,j);
                number e = 0, f = 0;
                rep(k,d+1) e += pow(1.0*i,1.0*k) * b[k];
                rep(k,d+1) f += pow(1.0*j,1.0*k) * b[k];
                if(abs(e-v[i]) > eps && abs(f-v[j]) < eps){
                    ans = i;
                    break;
                }
                if(abs(e-v[i]) < eps && abs(f-v[j]) > eps){
                    ans = j;
                    break;
                }
            }
            if(ans >= 0) break;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll a,z;
bool flag;

int main(){
	string s;
	cin >> s;
	rep(i,s.length()){
		if(s[i]=='A'&&!flag){
			flag=true;
			a=i;
		}
		if(s[i]=='Z')
			z=i;
	}
	cout << z-a+1 << endl;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

long long gcd(long long a, long long b) {
   if (b < 0 || (a == 0 && b == 0)) return -1;
   if (b > a) return gcd(b, a);

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

int main() {
   int x, y; cin >> x >> y;
   cout << gcd(x, y) << endl;
   return 0;
}



Measured memory_bytes: 3084
from collections import defaultdict

def main():
    n = int(input())
    l = list(map(int, input().split(" ")))
    ans = 0

    for i1, one in enumerate(l):
        for i2, two in enumerate(l):
            if one>=two:
                continue
            for i3, three in enumerate(l):
                if one>=three or two>=three:
                    continue
                if three - two < one and one < three + two:
                    ans+=1
    print(ans)

if __name__=="__main__":
    main()


Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int limN = 105;

int xs[limN], ys[limN];
ll dp[limN][limN];
bool usd[limN][limN];

ll memo(int l, int r) {
    if(l>=r)
        return 0;
    if(usd[l][r])
        return dp[l][r];
    usd[l][r] = true;
    ll &ans = dp[l][r];
    ans = (1LL<<62);
    for(int i=l; i<r; i++) {
        // printf("%d %d %d\n", xs[l], ys[i], ys[i+1]);
        // printf("considerando %d %d %d => %d %lld %lld\n", l, i, r, xs[l]*ys[i]*ys[r], memo(l, i), memo(i+1, r));
        ans = min(ans, xs[l]*ys[i]*ys[r] + memo(l, i) + memo(i+1, r));
    }
    return ans;
}

int main() {
    int N ;
    scanf("%d", &N);
    for(int i=0; i<N; i++) {
        scanf("%d%d", &xs[i], &ys[i]);
    }
    printf("%lld\n", memo(0, N-1));
}



Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        for (int i= 1;i<Integer.MAX_VALUE;i++) {
            int min = (int)Math.pow(k, i-1);
            int max = (int)Math.pow(k, i);
            if (min <= n && n < max) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = pair<int,int>;
using itpl = tuple<int,int>;

int main(){
    int N,M,X;
    cin >> N >> M >> X;
    vector<int>C(N);
    vector<vector<int>> A(N,vector<int>(M,0));
    rep(i,0,N){
        cin >> C[i];
        rep(j,0,M) cin >> A[i][j];
    }

    int minCost = INF;
    for(int bit = 0;bit <(1<<N);bit++){
        int tmpCost = 0;
        vector<int> cnt(M,0);
        for(int i=0;i<N;i++){
            if(bit & (1 << i)){
                tmpCost += C[i];
                rep(j,0,M) cnt[j] +=A[i][j];
            }            
        }
        bool flag=true;
        rep(j,0,M) if(cnt[j]<X){flag=false;break;}
        if(flag && minCost>tmpCost)minCost = tmpCost;
    }
    if(minCost==INF) cout << "-1" << endl;
    else cout << minCost << endl;
}

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

int main() 
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
 
 int n;
 cin>>n;
 int m;
 cin>>m;
 if(m>=n)
  cout<<"unsafe";
else
  cout<<"safe";
  return 0; 
}

Measured memory_bytes: 3580
#include<iostream>
#include <cstdio>
#include<vector>

using namespace std;

int main(){
    int a,b,c,d,e,k;
    int tmp;
    int min = 1000000000;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

vector<int> S;

void f(int n) {
    if (n > 3234566667) return;
    S.push_back(n);
    int m = n % 10;
    if (m == 0) {
        f(n * 10);
        f(n * 10 + 1);
    }
    if (m == 9) {
        f(n * 10 + 8);
        f(n * 10 + 9);
    }
    if (m != 0 && m != 9) {
        f(n * 10 + m - 1);
        f(n * 10 + m);
        f(n * 10 + m + 1);
    }
    return;
}

signed main() {
    int K;
    cin >> K;
    
    REP(i, 10) f(i);
    sort(S.begin(), S.end());
    cout << S[K - 1] << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    string n;
    cin >> n;
    replace(n.begin(), n.end(), '1', 'a');
    replace(n.begin(), n.end(), '9', 'z');
    replace(n.begin(), n.end(), 'a', '9');
    replace(n.begin(), n.end(), 'z', '1');
    cout << n;
}


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

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    rep(i, N) rep(j, D) cin >> X[i][j];
    int ans = 0;

    rep(i, N) rep(j, i) {
        int S = 0;
        rep(d, D) S += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
        int sqrtS = sqrt(S);
        if (S == sqrtS * sqrtS) ++ans;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;

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

    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int dp[n];
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
      for (int j = 1; j <= k; ++j) {
        if (j > i) break;
        dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
      }
    }
    cout << dp[n - 1] << endl;

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> rate(8, 0);
	int in;
	int over = 0;//3200以上をカウント
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> in;
		if(in >= 3200)over++;//3200以上をカウント
		else rate[in / 400]++;//表埋め
	}

	for(int i = 0; i < 8; i++)if(rate[i] > 0)cnt++;//表の人数が正のものをカウント

	cout << max(1, cnt) << ' ' << cnt + over << endl;
}

Measured memory_bytes: 256
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 2e5 + 10;
const ll INF = 1e18;
ll n;
ll height[N], beauty[N], dp[N], tree[N * 8], li[N];

ll rangeMax(ll idx , ll l , ll r , ll a , ll b) {
  if (r < a || l > b) return -INF;
  if (a <= l && r <= b) return tree[idx];
  ll mid = (l + r) / 2;
  return max(
    rangeMax(idx * 2 , l , mid , a , b),
    rangeMax(idx * 2 + 1 , mid + 1 , r , a , b)
  );
}

void update(ll idx , ll l , ll r , ll x , ll val) {
  if (l == x && r == x) {
    tree[idx] = val;
    return;
  }
  if (l > x || r < x) return;
  ll mid = (l + r) / 2;
  update(idx * 2 , l , mid , x , val);
  update(idx * 2 + 1 , mid + 1 , r , x , val);
  tree[idx] = max(tree[idx * 2] , tree[idx * 2 + 1]);
}

void inputAndInit() {
  in(n);
  for (ll i = 1 ; i <= n ; i++) {
    in(height[i]);
    li[i] = height[i];
  }
  sort(li + 1 , li + 1 + n);
  for (ll i = 1 ; i <= n ; i++) {
    in(beauty[i]);
  }
  for (ll i = 1 ; i <= n ; i++) {
    dp[i] = beauty[i];
  }
}

void computeDP() {
  for (ll cur = 1 ; cur <= n ; cur++) {
    ll lb = (ll)(lower_bound(li + 1 , li + 1 + n , height[cur]) - (li + 1));
    ++lb;
    dp[cur] = rangeMax(1 , 1 , n , 1 , lb) + beauty[cur];
    update(1 , 1 , n , lb , dp[cur]);
  }
}

int main() {
  inputAndInit();
  computeDP();
  printf("%lld\n" , *max_element(dp , dp + N));
  return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


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

using namespace std;
typedef long long ll;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int min_tana = ceil((float)a/(float)d);
    int min_ao = ceil((float)c / (float)b);

    if (min_tana >= min_ao) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
N, K = (int(i) for i in input().split())
# B = [int(x) for x in stdin.readline().rstrip().split()]
# A = [[int(i) for i in input().split()] for i in range(N)]
sunuke = [0]*(N+1)
for j in range(K):
    d = int(input())
    l = [int(i) for i in input().split()]
    for i in l:
        sunuke[i] += 1

# print(sunuke)
print(sunuke.count(0)-1)


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

int main(){
    
    string h;
    
    cin >> h;
    
    int sz = (int) h.size();
    
    for(int i=sz-1;i>=0;i--){
        if((i+1)&1) continue;
        
        bool ok = true;
        for(int j=0;j<(i+1)/2;j++){
            if(h[j] != h[(i+1)/2+j]){
                ok = false;
                break;
            }
        }
        if(ok && i != sz-1){
            printf("%d\n",i+1);
            return 0;
        }
    }
    
    printf("0\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    int m[2][200000];
    
    int w_count = 0;
    int b_count = 0;
    
    for(int i = 0; i < n; i++){
        if(s[i] == '.'){
            w_count++;
        }else{
            b_count++;
        }
        m[0][i] = w_count;
        m[1][i] = b_count;
    }
    
    int ans = min(w_count, b_count);
    
    for(int i = 0; i < n; i++){
        ans = min(ans, m[1][i]+(m[0][n-1] - m[0][i]));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int s[100];
  int S = 0;
  for(int i=0;i<n;++i){
    cin>>s[i];
    S+=s[i];
  }
  sort(s,s+n);
  if(S%10==0){
    bool flg = false;
    for(int i=0;i<n;++i){
      int x=s[i];
      if(x%10){
	S-=x;
	flg = true;
	break;
      }
    }
    if(!flg)
      S=0;
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,m;
ll a[100010];
ll b[100010];
int main(){
	scanf("%lld%lld",&n,&m);
	if(m==0){
		puts("0");
		return 0;
	}
	rep(i,0,m)scanf("%lld",a+i);
	sortup(a,m);
	rep(i,0,m-1)b[i]=a[i+1]-a[i];
	sortup(b,m-1);
	ll ans=0;
	rep(i,0,max(0,m-n))ans+=b[i];
	printf("%lld",ans);
}

Measured memory_bytes: 2540
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
	
    if ((a % 2 == 1) && (b % 2 == 1)) {
      System.out.println("Odd");
    }
    else {
      System.out.println("Even");
    }
  }
}


Measured memory_bytes: 22868
import math
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
a = LI()
a.insert(0,0)
a.append(0)
diff = [abs(a[i] - a[i-1]) for i in range(1,len(a))]
money = sum(diff)
# print(a)
# print(diff)
for i in range(1,len(a)-1):
    if a[i-1] <= a[i] <= a[i+1]:
        print(money)
    elif a[i+1] <= a[i] <= a[i-1]:
        print(money)
    elif a[i] <= a[i-1] <= a[i+1]:
        print(money-2*abs(a[i-1]-a[i]))
    elif a[i+1] <= a[i-1] <= a[i]:
        print(money-2*abs(a[i-1]-a[i]))
    elif a[i-1] <= a[i+1] <= a[i]:
        print(money-2*abs(a[i+1]-a[i]))
    else:
        # a[i] <= a[i+1] <= a[i-1]
        print(money-2*abs(a[i+1]-a[i]))


Measured memory_bytes: 65516
k = int(input())
rem = [0] * (k + 1)
s = 0
for i in range(k + 1):
    rem[i] = 7 * pow(10, i, k) % k
    s += rem[i]
    if s % k == 0:
        print(i + 1)
        exit()
else:
    print(-1)


Measured memory_bytes: 71492
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        int[] sorted = new int[N];
        for(int n=0;n<N;n++){
        	int x = sc.nextInt();
        	array[n]=x;
        	sorted[n]=x;
        }
        Arrays.sort(sorted);
        
        int leftMed = sorted[N/2-1];
        int rightMed = sorted[N/2];
        
        for(int n=0;n<N;n++){
        	if(array[n]<=leftMed) System.out.println(rightMed);
        	else System.out.println(leftMed);
        }
    }
}

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

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


const ll INF = 1.01e18;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    ll k;
    while (scanf("%d%lld", &n, &k) == 2) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);


        const int K = 60;
        vector<vector<pair<int, ll>>> p(K, vector<pair<int, ll>>(n));

        const int N = *max_element(a.begin(), a.end()) + 1;

        vector<int> last(N, -1);
        for (int i = 0; i < n * 2; i++) {
            int x = a[i % n];
            if (last[x] != -1 && last[x] < n) {
                p[0][last[x]] = make_pair((i + 1) % n, (i + 1) / n);
            }
            last[x] = i;
        }
        for (int i = 1; i < K; i++) {
            for (int j = 0; j < n; j++) {
                p[i][j].first = p[i - 1][p[i - 1][j].first].first;
                p[i][j].second = p[i - 1][j].second + p[i - 1][p[i - 1][j].first].second;
                if (p[i][j].second >= INF) p[i][j].second = INF;
            }
        }

        int cur = 0;
        for (int i = K - 1; i >= 0; i--) {
            while (p[i][cur].second < k) {
                k -= p[i][cur].second;
                cur = p[i][cur].first;
            }
        }
        assert(1 <= k && k <= 2);

        vector<int> have(N);
        vector<int> ans;
        while (cur < n * k) {
            int x = a[cur % n];
            if (have[x]) {
                while (have[x]) {
                    have[ans.back()] = 0;
                    ans.pop_back();
                }
            } else {
                have[x] = 1;
                ans.push_back(x);
            }
            cur++;
        }
        for (int x : ans) printf("%d ", x);
        printf("\n");
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 193352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void)
{
    string S;
    int Q;
    cin >> S>> Q;
    vector<int> T(Q,0);
    vector<int> F(Q,0);
    vector<char> C(Q, 0);
    for(int i = 0; i < Q; i++){
        cin >> T[i];
        if(T[i] == 2){
            cin >> F[i] >> C[i];
        }
    }

    int sum = 0;
    for(int i = 0; i < Q; i++){
        sum += T[i];
        sum %= 2;
    }
    if(sum != 0){
        reverse(S.begin(), S.end());
    }

    string head = "";
    string tail = "";
    vector<int> flip(Q, 0);
    sum = 0;
    for(int i = 0; i < Q; i++){
        sum += T[Q - i - 1];
        sum %= 2;
        flip[Q - i - 1] = sum;
    }

    for(int i = 0; i < Q; i++){
        if(T[i] == 2){
            if(F[i] == 1){
                if(flip[i] == 0){
                    head = C[i] + head;
                } else {
                    tail = tail + C[i];
                }
            } else {
                if(flip[i] == 0){
                    tail = tail + C[i];
                } else {
                    head = C[i] + head;
                }
            }
        }
    }

    cout << head + S + tail << endl;

    return 0;
}


Measured memory_bytes: 6924
package main

import "fmt"

func main() {
	var h, w int
	var dp [][]int
	fmt.Scan(&h, &w)
	maze := make([]string, h+2)
	dp = append(dp, make([]int, w+2))
	dp = append(dp, make([]int, w+2))

	for i := 1; i <= h; i++ {
		dp = append(dp, make([]int, w+2))
		fmt.Scan(&maze[i])
		maze[i] = fmt.Sprintf("#%s#", maze[i])
	}
	for j := w; j >= 1; j-- {
		if j == w {
			dp[h][j] = 1
			continue
		}
		if maze[h][j+1] == '.' {
			dp[h][j] += dp[h][j+1]
		}
		dp[h][j] = dp[h][j] % 1000000007
	}

	for i := h - 1; i >= 1; i-- {
		for j := w; j >= 1; j-- {
			if maze[i][j+1] == '.' {
				dp[i][j] += dp[i][j+1]
			}
			if maze[i+1][j] == '.' {
				dp[i][j] += dp[i+1][j]
			}
			dp[i][j] = dp[i][j] % 1000000007
		}
	}

	fmt.Println(dp[1][1])
}


Measured memory_bytes: 10368
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

  vector<ll> tbl(5, 0);
  for (ll i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    if (tmp[0] == 'M') tbl[0]++;
    else if (tmp[0] == 'A') tbl[1]++;
    else if (tmp[0] == 'R') tbl[2]++;
    else if (tmp[0] == 'C') tbl[3]++;
    else if (tmp[0] == 'H') tbl[4]++;
  }

  ll ans = 0;
  for (int i = 0; i < 3; ++i){
    for (int j = i + 1; j < 4; ++j){ 
      for (int k = j + 1; k < 5; ++k){
        ans += tbl[i] * tbl[j] * tbl[k];
      }  // k
    } // j
  } // i
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main() {
	char c[6];
	scanf("%c%c%c\n%c%c%c",&c[0],&c[1],&c[2],&c[3],&c[4],&c[5]);
	if (c[0]!=c[5]||c[1]!=c[4]||c[2]!=c[3]) printf("NO\n");
	else printf("YES\n");
	return 0;
} 

Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        int a, b, c;
        int cou = 0;
        string[] num = Console.ReadLine().Split(' ');
        a = int.Parse(num[0]);
        b = int.Parse(num[1]);
        c = int.Parse(num[2]);

        while (a <= b)
        {
            if (c % a == 0)
            {
                cou++;
            }    
            a++;
        }
        Console.WriteLine(cou);
    }
}


Measured memory_bytes: 9216
n = int(input())
s = input()
cnt = 0
for i in range(1000):
  num = '{:03}'.format(i)
  t=0
  for j in range(n):
    if s[j] == num[t]:
      t += 1
      if t > 2:
        cnt += 1
        break
print(cnt)


Measured memory_bytes: 40924
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 3e5 + 5;
const int MAXM = 3e5 + 5;
const int MAXD = 3e5 + 5;

struct Node
{
	int x,y;
}p[MAXD];

int cntr[MAXN], cntc[MAXM];
vector<int> atr[MAXN];

int main(void)
{
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1; i<=d; ++i)
		scanf("%d%d",&p[i].x,&p[i].y);
	
	for(int i=1; i<=d; ++i)
		++cntr[p[i].x], ++cntc[p[i].y];
	
	for(int i=1; i<=d; ++i)
		atr[p[i].x].push_back(p[i].y);
	
	multiset<int> cc;
	for(int i=1; i<=m; ++i)
		cc.insert(cntc[i]);
	
	int ans = 0;
	for(int i=1; i<=n; ++i)
	{
		for(int j=0; j<(int)atr[i].size(); ++j)
		{
			int y = atr[i][j];
			cc.erase(cc.find(cntc[y]));
			cc.insert(cntc[y]-1);
		}
		
		ans = max(ans, cntr[i] + *cc.rbegin());
		
		for(int j=0; j<(int)atr[i].size(); ++j)
		{
			int y = atr[i][j];
			cc.erase(cc.find(cntc[y]-1));
			cc.insert(cntc[y]);
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S, T;
    cin >> S >> T;

    ll m = SZ(T), cnt = 0;
    REP(i,0,SZ(S)-SZ(T)+1) {
        cnt = 0;
        REP(j,0,SZ(T)) {
            if(S[i+j] == T[j]) ++cnt;
        }
        m = MIN(m,SZ(T)-cnt);
    }
    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,X;std::cin>>n>>X;
    lint g=0;
    while(n--){
        lint x;std::cin>>x;
        g=std::__gcd(g,std::abs(x-X));
    }
    std::cout<<g<<'\n';
}


Measured memory_bytes: 256