akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
ll a[100001],b[100001];
void init(int a[100001]){
    for(int i = 0; i < 100001; i++){
        a[i] = MM;
    }
}
vector<ll> v(0);
ll cnt = 0;
int main(){
    cin >> N;
    vector<ll> c;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++) c.push_back(a[i]-b[i]);
    sort(c.begin(),c.end());
    int ans = 0;
    ll sum = 0;
    for(int i = 0; i < N; i++){
        if(c[i] >= 0) break;
        sum -= c[i];
        ans++;
    }
    for(int i = N-1; i >= 0; i--){
        if(c[i] <= 0 || sum <= 0) break;
        sum -= c[i];
        ans++;
    }
    if(sum > 0) cout << -1 << endl;
    else cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  string ans = "Three";
  
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  priority_queue<int,vector<int>,greater<int> > pq;
  for(int i=K-1;i<N;i++){
    pq.push(h.at(i)-h.at(i-K+1));
  }
  cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 1660
import math
a, b, h, m = map(int, input().split())

hour = (h + m/60) / 12
minute = m / 60
if  abs(hour - minute) <= 0.5:
    x = abs(hour-minute)
else:
    x = 1 - abs(hour-minute)
cc = a * a + b * b -2 * a * b * math.cos(2 * math.pi * x)
print(math.sqrt(cc))


Measured memory_bytes: 9516
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif 80 <= m + f:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if 50 <= r:
            print('C')
        else:
            print('D')
    elif m + f < 30:
        print('F')


Measured memory_bytes: 5592
if __name__ == '__main__':

	while True:
		try:
			a,z = input().split("=")
			x,y = a.split("+")
			start = 0
			if (len(x) > 1 and x[0] == "X") or (len(y) > 1 and y[0] == "X") or (len(z) > 1 and z[0] == "X"):
				start = 1

			# x + y = zの形式に変換
			ans = False
			for i in range(start,10):
				x1 = x.replace("X",str(i))
				y1 = y.replace("X",str(i))
				z1 = z.replace("X",str(i))

				if int(x1) + int(y1) == int(z1):
					print(i)
					ans = True
					break

			if ans == False:
				print("NA")

		except EOFError:
			break




Measured memory_bytes: 5600
dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[0]*26]*dd
ans = [0]*dd
fdate = [0]*26
for i in range(dd):
    s[i] = list(list(map(int, input().split())))



for i in range(dd):

    for j in range(26):
        v[i][j] = s[i][j] + c[j] *(i-fdate[j]) *(i-fdate[j])
    maxv = -100000000
    for j in range(26):
        if maxv < v[i][j]:
            maxv = v[i][j]
            ans[i]=j+1
    fdate[ans[i]-1] =i+1

for a in ans:
    print(a)

Measured memory_bytes: 68332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //骨が健康のままで終わって行って良いわけないだろう
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int a,b=-1,c=-1;
    int na,nb,nc;
    cin >> a;
    na=1;
    nb=0;
    nc=0;
    bool ans=true;
    for(int i=1;i<N;i++){
        int x;
        cin >> x;
        if(x==a)na++;
        else{
            if(b==-1){
                b=x;
                nb++;
            }
            else if(b==x){
                nb++;
            }
            else if(c==-1){
                c=x;
                nc++;
            }
            else if(c==x){
                nc++;
            }
            else ans=false;
        }
    }
  cerr << a << b << c << endl;
  cerr << na << nb << nc;
    if(!ans)cout << "No";
    else if(a==0 && b==-1 && c==-1)cout << "Yes" << endl;
    else if(a==0 && c==-1){
        if(na*2==nb)cout << "Yes";
        else cout << "No" << endl;
    }
    else if(b==0 && c==-1){
        if(nb*2==na)cout << "Yes";
        else cout << "No" << endl;
    }
    else if(na==nb && nb==nc){
      bitset<40>ba(a);
      bitset<40>bb(b);
      bitset<40>bc(c);
      if((ba^bb) == bc)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
    else cout << "No";



    


}

/*



 */



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

using namespace std;

#define INPUT  "input.txt"
#define OUTPUT "output.txt"
#define ll long long
#define ld long double

void fileio()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	if (fopen(INPUT, "r")){
		freopen(INPUT, "r", stdin);
		freopen(OUTPUT, "w", stdout);
	}
}

int x;
vector<int> six, nine;
int dp[100001];

int main() {
    fileio();

    int t = 6;
    while (t <= 100000) {
        six.push_back(t);
        t *= 6;
    }
    t = 9;
    while (t <= 100000) {
        nine.push_back(t);
        t *= 9;
    }

    cin >> x;
    dp[1] = 1;
    dp[0] = 0;
    for (int i = 1; i <= x; i++) {
        dp[i] = dp[i - 1] + 1;
        for (int j = 0; j < (int)six.size(); j++) {
            if (six[j] > i) break;
            dp[i] = min(dp[i], dp[i - six[j]] + 1);
        }
        for (int j = 0; j < (int)nine.size(); j++) {
            if (nine[j] > i) break;
            dp[i] = min(dp[i], dp[i - nine[j]] + 1);
        }
    }

    cout << dp[x];
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string a,b;
    cin>>a>>b;
    reverse(ALL(a));
    if(a==b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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


using namespace std;


using ll = long long;


int main()
{
    ll acc;
    ll N;
    vector<ll> A;
    cin >> N;
    for (ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    ll ans_pos = 0;
    if (A[0] <= 0) {
        acc = 1;
        ans_pos += abs(A[0]) + 1;
    } else {
        acc = A[0];
    }
    for (ll i = 1; i < N; i++) {
        ll next = acc + A[i];
        if (acc * next >= 0) {
            ans_pos += abs(next) + 1;
            next = -1 * (acc / abs(acc));
        }
        // // cout << "acc: " << acc << ", next: " << next << endl;
        acc = next;
    }

    ll ans_neg = 0;
    acc = A[0];
    if (acc >= 0) {
        acc = -1;
        ans_neg += abs(A[0]) + 1;
    } else {
        acc = A[0];
    }
    for (ll i = 1; i < N; i++) {
        ll next = acc + A[i];
        if (acc * next >= 0) {
            ans_neg += abs(next) + 1;
            next = -1 * (acc / abs(acc));
        }
        // // cout << "acc: " << acc << ", next: " << next << endl;
        acc = next;
    }

    ll ans = min(ans_pos, ans_neg);
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;
const i64 infl = 4e18;

const int maxn = 100500;
const int N = 100010;

struct Fen {
    i64 a[maxn];
    Fen() {
        forn(i, maxn) a[i] = infl;
    }
    void add(int i, i64 x) {
        for (; i < maxn; i |= (i+1)) {
            a[i] = min(a[i], x);
        }
    }
    i64 get(int i) {
        i64 mn = infl;
        for (; i >= 0; i = (i&(i+1))-1) {
            mn = min(mn, a[i]);
        }
        return mn;
    }
} f1, f2;

int n, T, m;
int x[maxn];
i64 d[maxn];

void scan() {
    scanf("%d%d%d", &n, &m, &T);
    forn(i, n) scanf("%d", &x[i]);
    x[n] = m;
}

int f(int i, int j) {
    int d = x[i-1] - x[j];
    return 2*d >= T;
}

void solve() {
    d[0] = x[0];
    f1.add(0, d[0] - 3ll*x[0]);
    f2.add(N-0, d[0] - 1ll*x[0]);

    fore(i, 1, n) {
        d[i] = infl;

        int l = 0, r = i;
        assert(!f(i, r));
        while (r-l > 1) {
            int m = (l+r)/2;
            if (f(i, m)) l = m;
            else r = m;
        }
        if (f(i, l)) {
            d[i] = min(d[i], f1.get(l) + 2ll*x[i-1] + x[i]);
        } else {
            r = l;
        }
        d[i] = min(d[i], f2.get(N-r) + T + x[i]);

        f1.add(i, d[i] - 3ll*x[i]);
        f2.add(N-i, d[i] - 1ll*x[i]);
//         cerr << i << ": " << d[i] << endl;
    }

    cout << d[n] << endl;
}

int main() {
#ifdef LOCAL
    freopen("d.in", "r", stdin);
#endif

    scan();
    solve();

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

std::vector<int64_t> sixs;
std::vector<int64_t> nines;

int solves(int n) {
  if (n < 6)
    return n;
  auto six_itr = std::upper_bound(sixs.begin(), sixs.end(), n);
  six_itr--;
  auto nine_itr = std::upper_bound(nines.begin(), nines.end(), n);
  if (nine_itr == nines.begin())
    return solves(n-*six_itr) + 1;
  nine_itr--;
  return std::min(solves(n-*six_itr), solves(n-*nine_itr)) + 1;
}

int main () {
  int n;
  std::cin >> n;
  for (int i = 0; i < 7; ++i) {
    sixs.push_back((int)std::pow(6.0, i));
  }
  for (int i = 0; i < 6; ++i) {
    nines.push_back((int)std::pow(9.0, i));
  }
  std::cout << solves(n) << std::endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace __gnu_pbds;
using namespace std ;

typedef pair<i64, i64> pii;
typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 200005

int a[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++)
    {
        scanf("%d",&a[i]) ;
    }
    vector <int> ans ;
    for(int i=n ; i>=1 ; i-- )
    {
        int j ;
        for(j=i ; j>=1 ; j--)
        {
            if( a[j]==j ) break ;
        }
        if( j==0 )
        {
            printf("-1\n") ;
            return 0 ;
        }
        ans.pb(j) ;
        for( ; j<i ; j++)
        {
            a[j] = a[j+1] ;
        }
    }

    reverse( ans.begin() , ans.end() ) ;

    for(int i=0 ; i<ans.size() ; i++)
    {
        printf("%d\n",ans[i]) ;
    }

    return 0 ;
}


Measured memory_bytes: 256
import sys
si = sys.stdin.readline


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    if n < 3:
        print(0)
        return
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                    temp = sorted([l[i], l[j], l[k]])
                    if temp[0]+temp[1] > temp[2]:
                        cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define cy cout<<"Yes"<<endl;
#define cn cout<<"No"<<endl;
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////
int main(){
    int n,m;
    cin>>n>>m;
    vs a(n),b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    
    rep(i,n-m+1)rep(j,n-m+1){
        bool ok=true;
        rep(s,m)rep(t,m){
            if(a[s+i][t+j]!=b[s][t]){
                ok=false;
                break;
            }
        }
        if(ok){
            cy;
            return 0;
        }
    }
    cn;
    return 0;

}

Measured memory_bytes: 3616
mod = int(1e9+7)
n,m = map(int,input().split())
if abs(n-m) > 1:
    print(0)
    exit()
if n != m:
    ans = 1
    ans2 = 1
    for i in range(1, m+1):
        ans *= i
        ans %= mod
    for i in range(1,n+1):
        ans2 *= i
        ans2 %= mod
    print(ans*ans2%mod)
else:
    ans = 1
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    print(ans*ans*2%mod)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll a, v, b, w, t; cin >> a >> v >> b >> w >>t;


  bool ans = true;
  if (v <= w) ans = false;
  else if ((v-w)*t < abs(a-b)) ans = false;

  cout << (ans ? "YES" : "NO") << "\n";
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i=0;i< int (n);i++)

int main(void)
{
    int  left;
    int  b;
    string n;

    cin >> n;

    b = n.size();

    for (int i = 0; i< b-1; i++, b--)
    {
        if (n[i] != n[b-1])
        {
            cout << "No" << endl;
            return 0;
        }
        
    }
    b = n.size();
    b = ((b - 1) / 2 - 1);

    rep(i, b)
    {
        if (n[i] != n[b])
        {
            cout << "No" << endl;
            return 0;
        } 
        b--;
    }
        cout << "Yes" << endl;
        return 0; 
}

   

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if (a == b && b == c) {
		if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
			ans = -1;
	}
	else {
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			++ans;
			int next_a = b / 2 + c / 2,
				next_b = a / 2 + c / 2,
				next_c = a / 2 + b / 2;
			a = next_a, b = next_b, c = next_c;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long M=1e9+7 ;
signed main() {
  int n,m ;
  cin >>n >> m ;
  vector<string>a(n);
  for(string &x:a)
    cin >> x ;
  vector<vector<int>>dp(n+1,vector<int>(m+1));
  //dp[i][j] -> number of paths to reach cell {i,j} 
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      dp[i][j]=(a[i][j]=='.'?((i!=0?dp[i-1][j]:0)+(j!=0?dp[i][j-1]:0)+(i==0&&j==0))%M:0) ;
  cout << dp[n-1][m-1] ;
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

struct dat{
  int idx1, idx2, y, x, d;
};

bool d[101][11][51][51][4];
vector<P> G[51][51][4];
int memo[51][51][4];
int n, x_0, y_0, t, D[101];
char c[101];

void add_edge(int xs, int ys, int xe, int ye){
  if(ys==ye){
    for(int i=min(xs,xe);i<max(xs,xe);i++){
      G[ys][i][1].push_back(P(ys,i+1));
      memo[ys][i][1]=1; // E
      G[ys][i+1][3].push_back(P(ys,i));
      memo[ys][i+1][3]=1; // W
    }
  }else{
    for(int i=min(ys,ye);i<max(ys,ye);i++){
      G[i][xs][2].push_back(P(i+1,xs));
      memo[i][xs][2]=1; // S
      G[i+1][xs][0].push_back(P(i,xs));
      memo[i+1][xs][0]=1; // N
    }
  }
}

void bfs(){
  
  queue<dat> q;
  
  for(int i=0;i<4;i++) q.push(dat{0,0,y_0,x_0,i});
  
  while(!q.empty()){
    
    dat u=q.front(); q.pop();
    
    if(d[u.idx1][u.idx2][u.y][u.x][u.d]) continue;
    d[u.idx1][u.idx2][u.y][u.x][u.d]=true;

    if(u.idx1==t) continue;
    
    for(int i=0;i<G[u.y][u.x][u.d].size();i++){
      
      int ny=G[u.y][u.x][u.d][i].first;
      int nx=G[u.y][u.x][u.d][i].second;
      int nidx1, nidx2=u.idx2+1;
      
      if(nidx2==D[u.idx1]){
	int nd;
	if(c[u.idx1]=='S') nd=0;
	if(c[u.idx1]=='E') nd=1;
	if(c[u.idx1]=='N') nd=2;
	if(c[u.idx1]=='W') nd=3;
	nidx1=u.idx1+1;
	nidx2=0;
	if(u.d==nd){
	  for(int j=0;j<4;j++){
	    int nnd=(u.d+j)%4;
	    if(nnd==(u.d+2)%4) continue;
	    if(memo[ny][nx][nnd]) q.push(dat{nidx1,nidx2,ny,nx,nnd});
	  }
	}else{
	  for(int j=0;j<4;j++){
	    int nnd=(u.d+j)%4;
	    if(nnd==(u.d+2)%4) continue;
	    if(nnd!=nd) continue;
	    if(memo[ny][nx][nnd]) q.push(dat{nidx1,nidx2,ny,nx,nnd});
	  }
	}
      }else{
	nidx1=u.idx1;
	for(int j=0;j<4;j++){
	  int nd=(u.d+j)%4;
	  if(nd==(u.d+2)%4) continue;
	  if(memo[ny][nx][nd]) q.push(dat{nidx1,nidx2,ny,nx,nd});
	}
      }
      
    }
    
  }
  
  set<P> ans;
  
  for(int i=0;i<51;i++)
    for(int j=0;j<51;j++)
      for(int k=0;k<4;k++)
	if(d[t][0][i][j][k]) ans.insert(P(j,i));
  
  set<P>::iterator ite=ans.begin();
  
  while(ite!=ans.end()){
    cout<<(*ite).first<<' '<<(*ite).second<<endl;
    ite++;
  }
  
}

int main(){
  
  cin>>n>>x_0>>y_0>>t;
  
  for(int i=0;i<n;i++){
    int xs, ys, xe, ye;
    cin>>xs>>ys>>xe>>ye;
    add_edge(xs,ys,xe,ye);
  }
    
  for(int i=0;i<t;i++) cin>>D[i]>>c[i];
  
  bfs();
  
  return 0;
}

Measured memory_bytes: 9784
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll s; cin >> s;
    ll a, b, c, d;
    ll n = sqrt(s);
    if (n * n != s){
        n++;
    }
    a = n; d = n;
    if ((n * n - s) % 2 == 1){
        if (n * n - s > n){
            a--;
            b = 2;
            if (n % 2 == 0){
                d++;
                c = (a * d - s) / 2;
            }
            else c = (a * d - s) / 2;
        }
        b = 1;
        c = a * d - s;
    }
    else {
        b = 2;
        c = (a * d - s) / 2;
    }
    cout << 0 << " " << 0 << " " << a << " " << b << " " << c << " " << d << endl;
    if (abs(a*d-b*c) != s) cout << "no" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	A := make([]int, N)
	f := false
	for i, _ := range A {
		fmt.Scan(&A[i])
		if f {
			continue
		}
		if A[i]%2 == 0 && A[i]%3 != 0 && A[i]%5 != 0 {
			f = true
		}
	}
	if f {
		fmt.Println("DENIED")
	} else {
		fmt.Println("APPROVED")
	}
}


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

int n, x,y ;

bool f (vector <int> a, int k) {

    long long count = 0;

    for (int i = n - 1; i >= 0; --i) {
        if (a[i] > y*k) {
            int d = (a[i] - y*k) / (x - y);
            if ( (a[i] - y*k) % (x - y) != 0 ) d++;
            count+=d;
        } else break;
    }

    return (count <= k);

}

int main() {



    cin >> n >> x >> y;

    vector <int> a(n);

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

    int l = 0, r = max / y + 2;

    sort (a.begin(), a.end());


    while (l < r - 1) {

        int m = (l + r) / 2;

        if ( f(a, m) ) {
            r = m;
        } else {
            l = m;
        }

    }

    cout << r << '\n';
    return 0;
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;


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

	vector<vector<string>> vec(H);
	for (auto& v : vec) {
		string s;
		cin >> s;
		
		for (int i = 0; i < (int)s.size(); ++i) {
			v.push_back(s.substr(i, 1));
		}
	}

	int pattern = 0;
	for (int h = 0; h < pow(2, H); ++h) {
		bool h_flg[] = {
			h & 1,
			h & 2,
			h & 4,
			h & 8,
			h & 16,
			h & 32,
		};

		for (int w = 0; w < pow(2, W); ++w) {
			bool w_flg[] = {
				w & 1,
				w & 2,
				w & 4,
				w & 8,
				w & 16,
				w & 32,
			};

			int b_cnt = 0;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					if (!w_flg[j] && !h_flg[i] && vec[i][j] == "#") {
						++b_cnt;
					}
				}
			}

			if (b_cnt == K) {
				++pattern;
			}
		}
	}
	cout << pattern;
}

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

Measured memory_bytes: 4080
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b>>k;
    c=__gcd(a,b);
    vector<ll> v=divisor(c);
    cout<<v[v.size()-k]<<endl;

    

    return 0;
}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

i64 a[maxn] , cnt[maxn] ;
vector<i64> st[maxn] , en[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&m) ;

    for(i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;
    for(i=1 ; i<=n ; i++) a[i]-- ;

    for(i=1 ; i<n ; i++)
    {
        if(a[i]<a[i+1] || a[i]==m-1 )
        {
            st[ (a[i]+1)%m ].pb(0) ;
            en[ a[i+1] ].pb(a[i+1]- (a[i]+1)%m  ) ;
        }
        else{
            st[ (a[i]+1)%m ].pb(0) ;
            en[ m-1 ].pb( m-2-a[i] ) ;
            st[0].pb(m-1-a[i]) ;
            en[a[i+1]].pb( m-1-a[i]+a[i+1] ) ;
        }
    }
    i64 mx = -1 ;
    i64 cur = 0 , val = 0 ;

   /* for(i=0 ; i<m ; i++)
    {
        printf("start %lld: ",i+1) ;
        for(j=0 ; j<st[i].size() ; j++) printf("%lld ",st[i][j]) ;
        printf("\n") ;
        printf("end %lld: ",i+1) ;
        for(j=0 ; j<en[i].size() ; j++) printf("%lld ",en[i][j]) ;
        printf("\n") ;
    }
*/

    for(i=0; i<=m-1; i++)
    {
        val += cur ;
        for(j=0 ; j<st[i].size() ; j++) val += st[i][j] ;
        cur += j ;
   //     printf("%lld %lld\n",cur,val) ;
        if(mx<val) mx = val ;
        for(j=0 ; j<en[i].size() ; j++) val -= en[i][j] ;
        cur -= j ;
    }

    i64 ans = 0 ;

    for(i=1 ; i<n ; i++) ans += (a[i+1]-a[i]+m)%m ;

    printf("%lld\n",ans-mx) ;

    return 0 ;
}


Measured memory_bytes: 12776
#include <iostream>
using namespace std;
int N, K;
int main() {
  cin >> N >> K;
  if (K == 1) {

    cout << 0 << endl;
  } else {
    // 1   -- N-(K-1)
    // K-1 -- 1
    cout << (N - (K - 1) - 1) << endl;
  }
}

Measured memory_bytes: 256
class Matrix():
    mod=10**9+7

    def set_mod(m):
        Matrix.mod=m

    def __init__(self,L):
        self.row=len(L)
        self.column=len(L[0])
        self._matrix=L
        for i in range(self.row):
            for j in range(self.column):
                self._matrix[i][j]%=Matrix.mod

    def __getitem__(self,item):
        if type(item)==int:
            raise IndexError("you must specific row and column")
        elif len(item)!=2:
            raise IndexError("you must specific row and column")

        i,j=item
        return self._matrix[i][j]

    def __setitem__(self,item,val):
        if type(item)==int:
            raise IndexError("you must specific row and column")
        elif len(item)!=2:
            raise IndexError("you must specific row and column")

        i,j=item
        self._matrix[i][j]=val

    def __add__(self,other):
        if (self.row,self.column)!=(other.row,other.column):
            raise SizeError("sizes of matrixes are different")

        res=[[0 for j in range(self.column)] for i in range(self.row)]
        for i in range(self.row):
            for j in range(self.column):
                res[i][j]=self._matrix[i][j]+other._matrix[i][j]
                res[i][j]%=Matrix.mod
        return Matrix(res)

    def __mul__(self,other):
        if type(other)!=int:
            if self.column!=other.row:
                raise SizeError("sizes of matrixes are different")

            res=[[0 for j in range(other.column)] for i in range(self.row)]
            for i in range(self.row):
                for j in range(other.column):
                    temp=0
                    for k in range(self.column):
                        temp+=self._matrix[i][k]*other._matrix[k][j]
                    res[i][j]=temp%Matrix.mod
            return Matrix(res)
        else:
            n=other
            res=[[(n*self._matrix[i][j])%Matrix.mod for j in range(self.column)] for i in range(self.row)]
            return Matrix(res)

    def __pow__(self,m):
        if self.column!=self.row:
            raise MatrixPowError("the size of row must be the same as that of column")

        n=self.row
        res=Matrix([[int(i==j) for i in range(n)] for j in range(n)])
        while m:
            if m%2==1:
                res=res*self
            self=self*self
            m//=2
        return res

    def __str__(self):
        res=[]
        for i in range(self.row):
            for j in range(self.column):
                res.append(str(self._matrix[i][j]))
                res.append(" ")
            res.append("\n")
        res=res[:len(res)-1]
        return "".join(res)

N,M=map(int,input().split())
X=list(map(int,input().split()))+[N]
dp=[0]*(M+2)
dp[0]=1
A=Matrix([[4,-2,1],[1,0,0],[0,1,0]])
DP=Matrix([[0],[0],[0]])
first=0
base=Matrix([[5],[1],[0]])

for i in range(1,M+2):
    DP=(A**(X[i-1]-first))*(DP+base*(-dp[i-1]))
    dp[i]=DP[2,0]
    first=X[i-1]

print((-dp[-1])%(10**9+7))

Measured memory_bytes: 89092
import java.io.*;
import java.util.*;
import java.util.Map.Entry;


public class  Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		HashMap<String, Integer>map=new HashMap<String, Integer>();
		int n=sc.nextInt();
		int maxOcc=0;
		for(int i=0;i<n;i++) {
			String x=sc.nextLine();
			map.put(x, map.getOrDefault(x, 0)+1);
			maxOcc=Math.max(maxOcc, map.get(x));
		}
		TreeSet<String>t=new TreeSet<String>();
		for(Entry<String, Integer>e:map.entrySet()) {
			if(e.getValue()==maxOcc) {
				t.add(e.getKey());
			}
		}
		while(!t.isEmpty()) {
			pw.println(t.pollFirst());
		}
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int main(){
	int a,b,c;
  	cin >> a>>b>>c;
	if(a == b) {
		cout << c << endl;
    } else if(a==c) {
    	cout << b << endl;
    } else {
    	cout << a << endl;
    }
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;


int main() {
    
    long double A, B;
    cin >> A >> B;
    cout << (long long)(A * B + 0.001) << endl;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  
  string r;
  for (int i = 0; i < n; ++i) {
    r.push_back(s[i]);
    r.push_back(t[i]);
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func canDivideSlice(s []int) bool {
  for i, v := range s {
    s[i] = v / 2
    if v%2 == 1 {
      return false
    }
  }
  return true
}

func main() {
  var a int
  fmt.Scan(&a)

  nums := make([]int, a)
  for i := 0; i < a; i++ {
    fmt.Scan(&nums[i])
  }

  var count int
  for {
    if canDivideSlice(nums) == true {
      count++

    } else {
      break
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
S=input()
bb=S[0]
b=S[1]

flag=False
if bb==b :
    flag=True
    print("1 2")

if len(S)>2:
    for i in range(2,len(S)):
        if flag:
            break
        if S[i]==b or S[i]==bb:
            flag=True
            print(str(i-1)+" "+str(i+1))
            break
        bb,b=b,S[i]
if not flag:
    print("-1 -1")

Measured memory_bytes: 3316
function Main(input) {
  // 数字
  var A = parseInt(input[0], 10);
  var B = parseInt(input[1], 10);
  var C = parseInt(input[2], 10);
  // 文字
  // var A = input[0];

  if (A < B) {
    if (A < C && C < B) {
      console.log('Yes');
    } else {
      console.log('No');
    }
  } else {
    if (B < C && C < A) {
      console.log('Yes');
    } else {
      console.log('No');
    }
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<int> a(N);
    scan(a);

    auto check = [&](int sign) {
        ll cost = 0;
        ll sum  = 0;
        auto v  = a;
        for (auto &&i : v) {
            sum += i;
            if (sign * sum < 0) {
                cost += abs(sum) + 1;
                sum += -sum + sign;
            }
            if (sum == 0) {
                cost++;
                sum += sign;
            }
            sign *= -1;
        }
        return cost;
    };
    ll ans = min(check(1), check(-1));
    print(ans);

    return 0;
}

Measured memory_bytes: 1044
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	n := nextInt()
	max := nextInt64()
	sum := int64(0)
	for i := 1; i < n; i++ {
		a := nextInt64()
		if a < max {
			sum += max - a
		} else {
			max = a
		}
	}

	fmt.Println(sum)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 5028
#include <iostream>
#include <string>
#include <unordered_map>
typedef std::string str;
const std::unordered_map<str,int> W = {
    {"SUN", 0}, {"MON", 1}, {"TUE", 2}, {"WED", 3}, {"THU", 4}, {"FRI", 5}, {"SAT", 6}
};
str S;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> S;
    std::cout << (7 - W.at(S)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @author yuichirw
 *
 */
import java.util.*;
public class Main {
	static int n;
	static Scanner sc = new Scanner(System.in);
	
	static boolean read() {
		n = sc.nextInt();
		return (n == -1) ? false : true;
	}
	
	static String solve() {
		int m, a;
		String ans = "";
		do {
			a = n / 4; m = n % 4;
			ans = m + ans;
			n = a;
		} while(a >= 4);
		if(a != 0) ans = "" + a + ans;
		return ans;
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}

	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.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)

int memo[200010];
int f(int x){
	if(memo[x])return memo[x];
	if(x==0)return 0;
	return memo[x]=1+f(x%__builtin_popcount(x));
}

char s[200010];
int ans[200010];
int main(){
	int n;
	scanf("%d %s",&n,s);
	int c=0;
	rep(i,0,n)if(s[i]=='1')c++;
	int aaa=0,bbb=0;
	rep(i,0,n){
		if(c-1)aaa=(aaa*2+s[i]-'0')%(c-1);
		bbb=(bbb*2+s[i]-'0')%(c+1);
	}
	
	int p2aaa=1,p2bbb=1;
	for(int i=n-1;i>=0;i--){
		ll d;
		if(s[i]=='1'){
			if(c-1){
				d=((aaa-p2aaa)%(c-1)+(c-1))%(c-1);
				ans[i]=1+f(d);
			}
			else ans[i]=0;
		}
		if(s[i]=='0'){
			d=(bbb+p2bbb)%(c+1);
			ans[i]=1+f(d);
		}
		if(c-1)p2aaa=p2aaa*2%(c-1);
		p2bbb=p2bbb*2%(c+1);
	}
	
	rep(i,0,n)printf("%d\n",ans[i]);
}

Measured memory_bytes: 3048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABN = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            var A = ABN[0];
            var B = ABN[1];
            var N = ABN[2];
            long X = N;
            if(N>=B-1)
            {
                X = B-1;
            }
            Console.WriteLine(A * X / B - A * (X / B));
        }
    }
}

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

using namespace std;

typedef long long ll;

int main(){
    int n, m, x, y, xx, yy, lx = -101; int sy = 101;
    cin >> n >> m >> x >> y;
    for(int a = 0; a < n; a++){
        cin >> xx;
        lx = max(xx, lx);
    }
    for(int b = 0; b < m; b++){
        cin >> yy;
        sy = min(sy, yy);
    }
    if(lx < sy && x < lx && sy < y)cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n;
  	int A[n];
  	int flg=0,cnt=0;	
  
  	scanf("%d",&n);
  	for(int i=0;i<n;i++)scanf("%d",&A[i]);
  
  	do{
      flg = 0;
      for(int i=0;i<n;i++){
        if(A[i]%2==0){
          A[i] /= 2;
          cnt++;
          flg = 1;
        }else{
          A[i] *= 3;
        }
      }
    }while(flg);
  
  	printf("%d\n",cnt);
  	return(0);
}
          

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m)
    {
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    int range = x[m-1]-x[0];
    vector<int> dist(m-1);
    rep(i,m-1)
    {
        dist[i] = x[i+1]-x[i];
    }
    sort(dist.begin(),dist.end(),greater<int>());
    int sub = 0;
    int mn;
    mn = min(m-1,n-1);
    rep(i,mn)
    {
        sub += dist[i];
    }
    cout << range-sub << endl;
}

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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;


void test_case(){
	
}
int main() {
    fastio
    int a,b;
    cin>>a>>b;
    if(a<1 || a>9 || b<1 || b>9)
    	cout<<-1<<endl;
    else
    	cout<<a*b<<endl;
    return 0;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  vector<int> A(n);
  rep(i, n) A[i] = i+l;
  int a0 = A[0];
  int an = A[n-1];
  int sum = 0;
  if(an<=0){
    rep(i, n-1) sum += A[i]; 
  }
  else if(a0>=0){
    rep(i, n-1) sum += A[i+1]; 
  }
  else{
    rep(i, n) sum += A[i];
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
class Bit {
	std::vector<int> vec;
public:
	Bit(int size) : vec(size, 0) {};
	int count(int position) const {
		int result = 0;
		while (position >= 0) {
			result += vec[position];
			position -= ~position & (position + 1);
		}
		return result;
	}
	void add(int position, int value) {
		while (position < vec.size()) {
			vec[position] += value;
			position += ~position & (position + 1);
		}
	}
};

int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	std::vector<Bit> bits(26, Bit(n));
	for (auto i = 0; i < n; ++i) {
		bits[str[i] - 'a'].add(i, 1);
	}
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int type; std::cin >> type;
		int count;
		switch (type) {
		case 1:
			int pos; char c; std::cin >> pos >> c; --pos;
			if (str[pos] != c) {
				bits[str[pos] - 'a'].add(pos, -1);
				bits[c - 'a'].add(pos, 1);
				str[pos] = c;
			}
			break;
		case 2:
			int left, right; std::cin >> left >> right;
			count = 0;
			for (const auto& b : bits) {
				if (b.count(right - 1) != b.count(left - 2)) ++count;
			}
			std::cout << count << '\n';
			break;
		default: throw 0;
		}
	}
}

Measured memory_bytes: 53844
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
int a[200005];
int p;
int b[200005];
int main()
{
  int n;
  cin>>n;
  rep(i,n)
    {
      cin>>a[i];b[i]=a[i];
    }
  sort(a,a+n);
  p=a[n/2];
  rep(i,n)
    {
      if(b[i]<p)cout<<p<<endl;
      else cout<<a[n/2-1]<<endl;
    }
  return 0;
}

Measured memory_bytes: 3712