akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int a[600][600], t;
std::vector<ll> a1, a2, a3, a4;
int main() {
	in(int, H, W);
	loop(y, H)
		loop(x, W)
			cin >> a[x][y];
	auto show = [&]{
		cerr << " ---------- " << endl;
		loop(y, H){
			loop(x, W)
				cerr << a[x][y] << ", ";
			cerr << endl;
		}
		cerr << " ---------- " << endl;
	};
	//show();
	loop(y, H) loop(x, W-1){
		if(a[x][y] & 1){
			--a[x][y];
			++a[x+1][y];
			a1.push_back(y+1);
			a2.push_back(x+1);
			a3.push_back(y+1);
			a4.push_back(x+1+1);
			//show();
		}
	}
	loop(y, H-1){
		auto x = W-1;
		if(a[x][y] & 1){
			--a[x][y];
			++a[x][y+1];
			a1.push_back(y+1);
			a2.push_back(x+1);
			a3.push_back(y+1+1);
			a4.push_back(x+1);
			//show();
		}
	}
	out(a1.size());
	loop(i, a1.size())
		out(a1[i], a2[i], a3[i], a4[i]);
	return 0;
}



Measured memory_bytes: 7380
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)

void Main()
{
	int N, L;
	cin >> N >> L;
	vector<string> vectS(N);
	rep(i, N)
	{
		cin >> vectS[i];
	}

	sort(vectS.begin(), vectS.end());
	
	rep(i, N)
	{
		cout << vectS[i];
	}

	cout << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

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

const vector<long long> B={1000000000000000003LL,1000000000000000009LL};
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	vector<long long> Brev(2);
	for(int i=0;i<2;i++){
		Brev[i]=pow_binary_mod(B[i],P-2,P);
	}
	set<vector<long long> > se;

	int l=0,r=0;
	vector<long long> c={s[0],s[0]};
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			for(int i=0;i<2;i++)c[i]=(s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P)+c[i])%P;
		}else if(q=="L++"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[l]*(__int128_t)pow_binary_mod(B[i],r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			for(int i=0;i<2;i++)c[i]=((c[i]-s[r])%P+P)%P*(__int128_t)Brev[i]%P;
			r--;
		}else if(q=="R++"){
			r++;
			for(int i=0;i<2;i++)c[i]=(c[i]*(__int128_t)B[i]+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}

Measured memory_bytes: 31424
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    totala = sum(a)
    for i in range(n):
        if b[i] <= a[i]:
            a[i] = a[i]-b[i]
        else:
            a[i+1] = max(0, a[i+1]-(b[i]-a[i]))
            a[i] = 0
    print(totala-sum(a))
resolve()

Measured memory_bytes: 81892
#include <stdio.h>
 
int main(void)
{
    int i, j, mt[10], co;
     
    for (i = 0; i < 10; i++) {
        scanf ("%d", &mt[i]);
    }
    for (i = 0; i < 10; i++){
        for (j = 0; j < 10; j++){
            if (mt[j] < mt[i]){
                co = mt[j];
                mt[j] = mt[i];
                mt[i] = co;
            }
        }
    }
         
    for (i = 0; i < 3; i++){
        printf("%d\n", mt[i]);
    }
    return(0);
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		int ans = Integer.MAX_VALUE;
		
		for (int i = 0; i < s.length() - 2; i++){
			ans = Math.min(Math.abs((Integer.parseInt(s.substring(i, i + 3))) - 753), ans);
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;

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

    int h, w, k, ans = 0, cnt, cntB = 0;
    cin >> h >> w >> k;
    vector<string> c(h), t;
    for (int i = 0; i < h; i++) {
        cin >> c[i];
        for (int j = 0; j < w; j++) {
            cntB += c[i][j] == '#';
        }
    }

    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            t = c;
            cnt = cntB;
            for (int k = 0; k < h; k++) {
                if ((i >> k) & 1) {
                    for (int l = 0; l < w; l++) {
                        cnt -= t[k][l] == '#';
                        t[k][l] = ';';
                    }
                }
            }
            for (int k = 0; k < w; k++) {
                if ((j >> k) & 1) {
                    for (int l = 0; l < h; l++) {
                        cnt -= t[l][k] == '#';
                        t[l][k] = ';';
                    }
                }
            }
            if (cnt == k) {
                ans++;
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    string S;
    cin >>S;
    cout  <<S.substr(0,3)<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> c(H, vector<char>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> c[i][j];
        }
    }

    int ans = 0;
    for (int rmask = 0; rmask < 1 << H; ++rmask) {
        for (int cmask = 0; cmask < 1 << W; ++cmask) {
            int cnt = 0;
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    if (c[i][j] == '#' && (rmask >> i & 1) && (cmask >> j & 1)) {
                       cnt++;
                    }
                }
            }
            if(cnt == K){
                ans++;
            }
        }
    }

    cout << ans << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

A.sort(reverse=True)

a = min(A[0], A[1])
ans = A[0]
idx = 1
c = 1

while c <= N-1:
    if(c == N-1):
        break
    if(c == N-2):
        ans += a
        break
        
    ans += a*2
    c += 2

    idx += 1
    a = min(A[idx], A[idx-1])
         
print(ans) 

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
  	cin>>n;
	cout<<(n+1)/2<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int rp(int a,int t){
    int c=a*(100+t);
    int b=c/100;
    return b;
}

int main(){
    int x,y,s;
    while(cin >> x >> y >> s && x+y+s!=0){
        int maxx=0,maxy=0;
         int maxi=0;
        FOR(i1,1,s){
            FOR(i2,1,s-i1+1){
                 int x1=rp(i1,x);
                 int x2=rp(i2,x);
                if(s==x1+x2){
                    int y1=rp(i1,y);
                    int y2=rp(i2,y);
                    if(maxi<y1+y2){
                        maxx=i1;
                        maxy=i2;
                    }
                    maxi=max(maxi,y1+y2);
                    i2=s-i1;
                }
            }
        }
        cout << maxi << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll mondiv(ll a,ll m){
    ll b=m;ll u=1;ll v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}

int main(){
    int n;cin>>n;
    ll r=(ll)0,sum=(ll)0;
    vll a(n);
    rep(i,n){
        cin>>a[i];
        r+=a[i]*a[i];
        r%=inf;
        sum+=a[i];
        sum%=inf;
    }
    ll ans=sum*sum;
    ans%=inf;
    ans-=r;
    if(ans<0)ans+=inf;
    ans*=mondiv((ll)2,inf);
    ans%=inf;
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
#!/usr/bin/env python3
from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(n: int, v: "List[int]"):
    v1 = v[::2]
    v2 = v[1::2]
    c1 = Counter(v1)
    c2 = Counter(v2)
    mc1 = c1.most_common(2)
    mc2 = c2.most_common(2)
    if len(mc1) == 1:
        mc1.append((999990, 0))
    if len(mc2) == 1:
        mc2.append((999999, 0))
    cv1, cnt1 = mc1[0]
    cv2, cnt2 = mc2[0]
    if cv1 != cv2:
        print(n - cnt1 - cnt2)
    else:
        print(n - max(cnt1 + mc2[1][1], cnt2 + mc1[1][1]))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, v)


if __name__ == '__main__':
    main()


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

struct RollingHash {
  const int h = 1000000007;
  const int b = 10007;
  vector<int> ha;
  vector<int> po;
  RollingHash(const string &s) {
    int n = (int) s.size();
    ha.assign(n + 1, 0);
    po.assign(n + 1, 0);
    po[0] = 1;
    for (int i = 0; i < n; i++) {
      ha[i + 1] = ((long long) ha[i] * b + s[i]) % h;
      po[i + 1] = ((long long) po[i] * b) % h;
    }
  }
  int get(int l, int r) {
    return (ha[r] + h - ((long long) ha[l] * po[r - l]) % h) % h;
  }
};

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RollingHash sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    
    int n;
    cin >> n;
    
    vector<int> a;
    a.push_back(0);
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        a.push_back(x);
    }
    
    int cnt = 0;
    int now = 1;
    
    while(true)
    {
        now = a[now];
        cnt++;
        if(now == 2) {break;}
        if(cnt > n)
        {
            cnt = -1;
            break;
        }
    }
    
    cout << cnt << endl;
    return 0;
}





Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

string S;

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

	cin >> S;

	int N = SZ(S);
	string ts;
	int ans = 0;

	for (int i = 0; i < (1 << (N - 1)); i++)
	{
		i <<= 1;
		for (int j = 0; j < N; j++)
		{
			ts += S[j];
			if ((i&(1 << (N - j - 1))) == 0)
			{
				ans += stoll(ts);
				ts.clear();
			}
		}
		i >>= 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  int bigger[s.size()],smaller[s.size()];
  for(int i=0;i<s.size();i++){
    if(i==0){
      if(s[i]=='<') bigger[i]=1;
      else bigger[i]=0;
      continue;
    }
    if(s[i]=='<') bigger[i]=bigger[i-1]+1;
    else bigger[i]=0;
  }
  for(int i=s.size()-1;i>=0;i--){
    if(i==s.size()-1){
      if(s[i]=='>') smaller[i]=1;
      else smaller[i]=0;
      continue;
    }
    if(s[i]=='>') smaller[i]=smaller[i+1]+1;
    else smaller[i]=0;
  }
  ll sum=0;
  for(int i=0;i<s.size()+1;i++){
    if(i==0) sum+=smaller[0];
    else if(i==s.size()) sum+=bigger[s.size()-1];
    else sum+=max(bigger[i-1],smaller[i]);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 4868
N,K,L = map(int, input().split())

#print(N,K,L,D,T)

class UnionFind:
    def __init__(self, n: int) -> None:
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x: int) -> int:
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> None:
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        
    # 同じ集合に属するか判定
    #def same_check(self, x, y):
    #    return self.find(x) == self.find(y)

def uniteOne(num, uf):
    for _ in range(num):
        d0, d1 = map(int, input().split())
        uf.unite(d0-1, d1-1)
        
uf_D = UnionFind(N)
uf_T = UnionFind(N)

uniteOne(K, uf_D)
uniteOne(L, uf_T)

from collections import Counter

keys = []
counts = Counter()

for i in range(N):
    key = uf_D.find(i), uf_T.find(i)
    keys.append(key)
    counts[key] += 1

print(*(counts[key] for key in keys))

Measured memory_bytes: 58196
#include <stdio.h>
#include <stdlib.h>

int comp( const void *a, const void *b ) {
    return( *((int *)b) - *((int *)a) );
}

int main( int argc, char *argv[] )
{
    int n, m;
    int a[101];
    int t1 = 0;
    int t2 = 0;

    scanf( "%d %d", &n, &m );
    for( int i=0; i<n; i++ ) scanf( "%d", &a[i] );

    qsort( a, n, sizeof(int), comp );

    for( int i=0; i<n; i++ ) t1 += a[i];
    for( int i=0; i<m; i++ ) t2 += a[i];

//printf( "%d %d\n", t1, t2 );

    for( int i=0; i<m; i++ ) {
        if( a[i] < t1/4.0/m ) {
            puts( "No" );
            exit( 0 );
        }
    }

    puts( "Yes" );
}


Measured memory_bytes: 128
// An efficient C++ program to compute  
// sum of bitwise OR of all pairs 
#include <bits/stdc++.h> 
using namespace std; 
#define mod 1000000007
 
// Returns sum of bitwise OR 
// of all pairs 

long long  arr[300005];
long long n;
long long func(int p)
{
	if(p==0) return 1;
	long long ans = 1;
	for(int i = 1; i <= p; i++)
	{
		ans = ((ans%mod) * (2%mod))%mod;
	}
	return ans;
}
long long sumXOR() 
{ 
    long long int sum = 0; 
    for (int i = 0; i < 64; i++)  
    { 
        //  Count of zeros and ones 
        long long  zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        long long idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = ((oc%mod) * (zc%mod))%mod;
        idsum = ((idsum%mod)*(func(i)%mod))%mod;  
  
        // final sum     
        sum = ((sum%mod) + (idsum%mod))%mod;  
    } 
    return sum; 
} 
  
int main() 
{ 
    cin >> n;
    for(int i = 0; i < n; i++) cin >> arr[i]; 
    long long  sum = sumXOR(); 
    cout << sum << endl; 
    return 0; 
} 


Measured memory_bytes: 2560
from collections import deque

N,M=map(int,input().split())

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
ans=[0 for _ in range(N)]
for i in range(1,N):
    for t in tree[i]:
        if dist[t]==dist[i]-1:
            ans[i]=t+1
            break

print("Yes")
for j in range(1,N):
    print(ans[j])

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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
bool solve();
string s;

int main() {
  cin >> s;
  prians(solve());
  return 0;
}

bool solve() {
  while(s.size() > 3) {
    string nexts;
    bool ch[3] = {0};
    char nextc;
    for(int i = 0; i < s.size(); ++i) {
      if(i + 2 < s.size() && s[i] == 'A' &&
         s[i + 1] == 'B' && s[i + 2] == 'C') {
        nexts += '?';
        i += 2;
      }
      else {
        nexts += s[i];
        ch[s[i] - 'A'] = 1;
      }
    }
    if(ch[0] && ch[1] && (!ch[2]))
      nextc = 'C';
    else if(ch[0] && (!ch[1]) && ch[2])
      nextc = 'B';
    else if((!ch[0]) && ch[1] && ch[2])
      nextc = 'A';
    else
      return 0;
    for(int i = 0; i < nexts.size(); ++i)
      if(nexts[i] == '?') nexts[i] = nextc;
    s = nexts;
  }
  return s == "ABC";
}


Measured memory_bytes: 3232
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1000000000000001;
string cov(int n)
{
	string ans="";
	int cur=26;
	
	while(n--)
	{
		int x=n%cur;
		n/=cur;
		ans+=('a'+x);
	}
	reverse(ans.begin(),ans.end());
	return ans;
}

int32_t main()
{
	
	int n;
	cin>>n;
	cout<<cov(n);
	
}

Measured memory_bytes: 3624
/*

	@Raghul
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin>>s;
	if(s.length()==2)	cout<<s;
	else{
		reverse(s.begin(), s.end());
		cout<<s;
	}
	return 0;
}



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

using namespace std;

int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int takahashi=ceil(static_cast<double>(c)/b);
	int aoki=ceil(static_cast<double>(a)/d);
	printf("%s",takahashi<=aoki ? "Yes":"No");
}


Measured memory_bytes: 3712
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	mochi := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&mochi[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(mochi)))

	count := 1
	for i := 1; i < n; i++ {
		if mochi[i] == mochi[i-1] {
			continue
		}
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define ld long double
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define vi           vector<int>
#define vll          vector<long long>
#define all(x)       x.begin(),x.end()
#define mod 1000000007 
#define mx 1000005
#define mii          map<int,int>
#define mumii        multimap<int,int> 
#define mx2 65
#define inf 4e18
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gt           greater<int>()
//The ASCII value of the lowercase alphabet is from 97 to 122.
//The ASCII value of the uppercase alphabet is from 65 to 90.

void solve()
{
     ll int n,k;
     cin>>n>>k;
     
     if(n<k)
     {
          cout<<min(abs(n-k),n);
     }
     else
     cout<<min(n%k,abs(n%k-k));
}
int main()
{
	fast;
	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n = input.next().parse::<usize>().unwrap();
    let m = input.next().parse::<usize>().unwrap();
    let mut c = vec![0; n];
    for _ in 0..m {
        let a = input.next().parse::<usize>().unwrap() - 1;
        let b = input.next().parse::<usize>().unwrap() - 1;
        c[a] += 1;
        c[b] += 1;
    }
    println!("{}",
             if c.into_iter().find(|x| x % 2 == 1).is_none() {
                 "YES"
             } else {
                 "NO"
             });
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
typedef long long int ll;
int n;ll a[101000],s[101000];
int main(){
	int co=0;
	scanf("%d",&n);
	rep(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	rep(i,1,n){
		s[i]=s[i-1]+a[i];
		if(a[i]>s[i-1]+1){cout<<s[i-1]+1<<endl;return 0;}
	}
	cout<<s[n]+1<<endl;
	return 0;
}

Measured memory_bytes: 3368
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        System.out.printf("%d %d %f\n", a / b, a % b, (double)a / b);
    }
}

Measured memory_bytes: 17332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
          ll a,b,s;
          cin>>a>>b>>s;
          if(s<=a){
                    cout<<a-s<<" "<<b<<endl;
          }
          else{
                    cout<<0<<" "<<max(0LL,b-(s-a))<<endl;
          }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, M, A=0, W=0;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  rep(i,0,M) {
    cin >> p[i] >> S[i];
  }
  vector<int> a(N);
  vector<int> w(N);
  rep(i,0,N) {
    a[i]=0;
    w[i]=0;
  }
  rep(i,0,M) {
    if (S[i]=="AC") {
      a[p[i]-1]++;
    }
    else {
      if (a[p[i]-1]==0) {
        w[p[i]-1]++;
      }
    }
  }
  rep(i,0,N) {
    if (a[i]>0) {
      A++;
      W+=w[i];
    }
  }
  cout << A << " " << W << endl;
}


Measured memory_bytes: 7464
using System;
using System.Text;

class ABC163
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split();
        int[] list = new int[n];
        for(int i = 0; i < s.Length; i++)
        {
            list[int.Parse(s[i]) - 1]++;
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++)
        {
            sb.Append(list[i].ToString());
            if(i != n - 1)
                sb.Append("\r\n");
        }
        Console.WriteLine(sb.ToString());
    }
}

Measured memory_bytes: 38804
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a,b;
	cin >>n>>a>>b;
	long long int temp;
	if((b-a)%2==1)
	{
		if(n-a>b-1)
		{
			cout<<a-1+(b-a+1)/2<<endl;
		}
		else
		{
			cout<<n-b+(b-a+1)/2<<endl;
		}
		return 0;
	}
	else
		cout<<(b-a)/2<<endl;
}


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

typedef unsigned long long int ll; 
#define MOD 1000000007
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ff first
#define ss second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define mk make_pair
#define pb push_back
#define po pop_back




int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rs(s1);
  rs(s2);
  int count = 0;
  for(int i=0;i<3;i++){
  	if(s1[i]==s2[i])
  		count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

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

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(n, i) {
        cin >> a[i];
    }
    int sum = 0;
    rep(n, i) {
        sum += a[i];
    }
    double mid = sum / 2.0;
    int sum_a = 0;
    double diff = -1.0;
    rep(n, i) {
        if (sum_a + a[i] + 0.0 > mid) {
            diff = min(mid - sum_a, sum_a + a[i] - mid);
            // cout << sum_a << " " << mid << " " << mid - sum_a << " " << sum_a + a[i] - mid << endl;
            break;
        }
        sum_a += a[i];
    }
    int ans = diff * 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b,c = map(str,input().rstrip(""))


if(a=="R" and b == "R" and c == "R"):
  count = 3
  
elif(a=="R" and b == "R" and c == "S"):
  count = 2
elif(a=="R" and b == "S" and c == "S"):
  count = 1
elif(a=="S" and b == "R" and c == "R"):
  count = 2
elif(a=="S" and b == "R" and c == "S"):
  count = 1
elif(a=="S" and b == "S" and c == "R"):
  count = 1
elif(a=="R" and b == "S" and c == "R"):
  count = 1
else:
  count = 0

print(count)
  
  
  
  

Measured memory_bytes: 9080
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int N = 1E5+7;

struct Node{
	int day, val;
	int used;
	Node(){}
	Node(int d, int v) : day(d), val(v), used(0) {}
	friend bool operator< (Node a1, Node a2)
	{
		if(a1.val == a2.val)
			return a1.day > a2.day;
		return a1.val < a2.val;
	}
};
Node a[N];
vector<int> ve[N];
priority_queue<int> que;

int main()
{
	int n, m;
	cin >> n >> m;
	int d, v;
	for(int i = 0; i < n; i++)
	{
		cin >> d >> v;
		ve[d].push_back(v);
	}
	int ans = 0;
	for(int i=1; i <= m; i++)
	{
		for(auto x : ve[i])
			que.push(x);
		if(!que.empty())
		{
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << '\n';
	
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];

    int count = 1;
    int minnum = vec[0];
    for(int i=1;i<n;i++){
        if(vec[i]<=minnum){
            minnum = vec[i];
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int a,b,n;

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

    int x = n-a;
    cout << x - x/b*b << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Set<Integer> is = new HashSet<>();
        int count = 0;
        for (int i = 0; i < K; i++) {
        	int d = sc.nextInt();
        	for (int j = 0; j < d; j++) {
        		is.add(sc.nextInt());
        	}
        }
        for (int i = 1; i <= N; i++) {
        	if (!is.contains(i)) {
        		count++;
        	}
        }
        System.out.println(count);
    }
}

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

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

	char pre = ' '; string ans;
	for (int i = 0; i < n; i++) {
		if (pre != s[i]) {
			ans += s[i];
			pre = s[i];
		}
	}
	cout << ans.size() << endl;

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;
 
#define MAXN 10000000 + 2
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
////////////////////////////////////////////
    fastio;
    lli r,d,x;
    cin>>r>>d>>x;

    lli t=10;

    while(t--)
    {
        x = r*x - d;
        cout<<x<<endl;
    }



}


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

int main(){
    int k;
    cin >> k;
    if((k%2 == 0) || (k%5 == 0)){
        cout << "-1" << endl;
        return 0;
    }

    int n = k * 9;
    if(k%7 == 0) n /= 7;
    int count = 1;
    int tmp = 10;
    while(tmp % n != 1){
        count++;
        tmp = (tmp % n) * 10;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Set;

public class Main {
	char[][] fie;
	boolean[][] used;
	int h,w;
	int dx[]={1,0,-1,0,1,1,-1,-1};
	int dy[]={0,1,0,-1,1,-1,1,-1};

	int goindex(int first,int len){
		return first*200+len;
	}

	public void run(){
		Scanner sc = new Scanner(System.in);
		fie = new char[21][11];
		while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h+w==0)break;
			ArrayList<TreeSet<String>> magic = new ArrayList<TreeSet<String>>();
			for(int i=0;i<5200;i++){
				magic.add(new TreeSet<String>());
			}
			for(int i=0;i<h;i++){
				String line = sc.next();
				for(int j=0;j<w;j++){
					fie[j][i]=line.charAt(j); 
				}
			}
			String res="0";
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					for(int k=0;k<8;k++){
						boolean[][] used = new boolean[21][11];
						String str="";
						int x=j,y=i;
						while(!used[x][y]){
							used[x][y]=true;
							str+=fie[x][y];
							if(str.length()>=2){
								if(magic.get(goindex(str.charAt(0)-'A',str.length())).contains(str)){
									if(res.length()<str.length() || (res.length()==str.length() && str.compareTo(res)<0))res=str;
								}else if(res.length()<=str.length())magic.get(goindex(str.charAt(0)-'A',str.length())).add(str);
							}
							y=(y+dy[k]+h)%h;
							x=(x+dx[k]+w)%w;
						}
					}
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 220108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int x,a;cin >> x >> a;
    if(x<a)cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

vector<ll> a, b, c;

int K;

vector<ll> calc(vector<ll>& x, vector<ll>& y)
{
  vector<ll> res;
  for (ll X : x) {
    for (ll Y : y) {
      res.push_back(X + Y);
    }
  }
  sort(res.begin(), res.end(), greater<ll>());
  while (res.size() > K) res.pop_back();
  return res;
}

int main()
{
  int x, y, z;
  cin >> x >> y >> z >> K;
  a.resize(x);
  b.resize(y);
  c.resize(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];
  auto v = calc(a, b);
  v = calc(v, c);
  for (ll r : v) cout << r << endl;
}


Measured memory_bytes: 43112
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; scanf("%d",&x); return x;}

template <typename T>
void print(const std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

signed main()
{
  string s;
  int k;
  
  cin >> s >> k;

  for (int i = 0; i < s.size(); i++){
    if (s[i] == 'a') continue;
    if ('z' - s[i] + 1 <= k){
      k -= ('z' - s[i] + 1);
      s[i] = 'a';
    }
  }

  for (k %= 26; k > 0; k--){
    if (s[s.size() - 1] == 'z'){
      s[s.size() - 1] = 'a';
      continue;
    }
    s[s.size() - 1]++;
  }

  cout << s << endl;

  return 0;
}



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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;
  VVI to(N), cost(N);
  //N頂点のぞれぞれの行き先とコストを別配列で受け取る
  //行き先とコスト，同様にpbで加えることで入力順の情報を保存
  REP(i, N-1){
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    to.at(a).pb(b);
    cost.at(a).pb(w);
    to.at(b).pb(a);
    cost.at(b).pb(w);
  }



  VI ans(N,-1);
  queue<int> q;

  ans.at(0)=0; //基準として0番目の頂点を0とする
  q.push(0); //0から見ていく

  while(!q.empty()){
    int V=q.front(); //祖先を取り出す
    q.pop();
    REP(i,to.at(V).size()){ //祖先から直結の頂点を計算
      int u=to.at(V).at(i);
      int w=cost.at(V).at(i);
      if(ans.at(u)!=-1) continue;
      ans.at(u)=(ans.at(V)+w)%2; //0からの距離の偶奇を機能的に計算
      q.push(u); //qに先祖として入れる
    }
  }


  REP(i, N) cout << ans.at(i) << endl;
  return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
string rawS;
vector<int> S;
const int MAX_N=1e5,ALP='z'-'a'+1,MAX_M=1e5;
typedef pair<int,int> P;
int N,M;
int L[MAX_N],R[MAX_N],dif[MAX_M+1];
bool used[MAX_M+1];
vector<int> G[MAX_M+1];
int dfs(int v){
	used[v]=true;
	int ret=dif[v];
	for(auto e:G[v]){
		if(!used[e]){
			ret+=dfs(e);
			ret%=ALP;
		}
	}
	return ret;
}
int main(){
	cin>>rawS>>N;
	M=(int)rawS.size();
	bool ans;
	REP(i,M){
		S.push_back(rawS[i]-'a');
	}
	REP(i,N)cin>>L[i]>>R[i];
	REP(i,N){
		L[i]--;
		G[L[i]].push_back(R[i]);
		G[R[i]].push_back(L[i]);
	}
	REP(i,(M+1)/2){
		G[i].push_back(M-i);
		G[M-i].push_back(i);
	}
	REP(i,M+1){
		int a,b;
		a=(i<M ? S[i] : 0);
		b=(i-1>=0 ? S[i-1]:0);
		dif[i]=a-b;
		dif[i]+=ALP;
		dif[i]%=ALP;
	}
	ans=true;
	REP(i,M+1){
		if(!used[i]){
			if(dfs(i)>0){
				ans=false;
			}
		}
	}
	
	cout<<(ans ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 9976
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>X(N);
	rep(i, N) {
		cin >> X[i];
	}
	vector<int>XX(N);
	rep(i, N) {
		XX[i] = X[i];
	}
	sort(XX);

	rep(i, N) {
		if (X[i] < XX[(N / 2) ]) {
			cout << XX[(N / 2) ] << endl;
		}
		else {
			cout << XX[N / 2-1] << endl;
		}
	}

}




Measured memory_bytes: 3712