akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
string s;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> s)
	{
		ll ans = 0, n = s.size();
		for (ll i = 0; i < n / 2; ++i)
			if (s[i] != s[n - i - 1])
				ans++;
		cout << ans << endl;
	}
}
/*
redcoder

vvvvvv

abcdabc
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    string s;
    cin >> n >> s;

    int now=0,maxval=0;
    for(int i=0;i<n;i++){
        if(s[i]=='I')now++;
        if(s[i]=='D')now--;

        maxval=max(maxval, now);
    }

    cout << maxval << endl;

    return 0;
}


Measured memory_bytes: 3624
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(s,n):
        def _f(s, n):
            # print('_f', s,n)
            l = len(s)
            if l == 0 or n < 1:
                return ''
            r = ''
            if '1' <= s[0] <= '9':
                c = int(s[0])
                ti = 1
                for i in range(1,l):
                    ti = i
                    if not ('0' <= s[i] <= '9'):
                        break
                    c *= 10
                    c += int(s[i])
                if s[ti] == '(':
                    k = 1
                    ki = ti+1
                    for i in range(ti+1,l):
                        if s[i] == '(':
                            k += 1
                        elif s[i] == ')':
                            k -= 1
                            if k == 0:
                                ki = i
                                break
                    kr = _f(s[ti+1:ki], n)
                    kl = len(kr)
                    if kl * c >= n:
                        r = kr * (n//kl+1)
                        return r[:n]
                    r = kr * c
                    r += _f(s[ki+1:], n - len(r))
                    return r
                else:
                    r += s[ti] * c
                    if len(r) >= n:
                        return r[:n]
                    r += _f(s[ti+1:], n - len(r))
                    return r
            r = s[0] + _f(s[1:], n - 1)
            return r

        fr = _f(s, n+1)
        # print(len(fr),fr[n:n+1])
        if len(fr) <= n:
            return '0'
        return fr[n]

    while 1:
        s,n = LS()
        if s == '0' and n == '0' :
            break
        rr.append(f(s, int(n)))
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 13144
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;


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

	int a, b;
	cin >> a >> b;
	string s, t;
	int ans = 0;
	forn(i, a, b+1){
		s = to_string(i);
		t = to_string(i);
		reverse(t.begin(), t.end());
		if(s == t)ans++;
	}

	cout << ans << endl;

}




Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n; cin >> n;
    int v[n], c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, pow(2, n)){
        int x = 0;
        int y = 0;
        rep(j, n)if((i>>j)&1){
            x += v[j];
            y += c[j];
        }
        ans = max(ans, x-y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
	int ans=0;
	int n,d,x,v,i;
	cin>>n>>d>>x;
	for(i=0;i<n;i++)
	{
		cin>>v;
		ans+=(d-1)/v+1;
	}
	cout<<x+ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    long long L, R;
    cin >> L >> R;
    if ((R - L) >= 2019)
    {
        cout << 0 << endl;
    }
    else
    {
        long long ans = 2018;
        for (long long i = L; i < R; i++)
        {
            for (long long j = i + 1; j <= R; j++)
            {
                long long tmp = (i * j) % 2019;
                if (tmp < ans)
                {
                    ans = tmp;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

cnt = Counter(a)
if any(n % 2 == i % 2 for i in cnt):
    print(0); exit()
if any(cnt[i] != 2 for i in cnt if i != 0):
    print(0); exit()
print(pow(2, n // 2, mod))


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 998244353;
const ll inf = (1LL << 50);

void solve(long long N, long long S, std::vector<long long> A) {
    int ans = 0;
    vi dp(S + 1, 0);
    rep(i, N) {
        dp[0]++;
        vi dp2 = dp;
        rep(jj, S + 1) {
            int j = S - jj;
            if (j - A[i] >= 0) {
                dp2[j] += dp[j - A[i]];
                dp2[j] %= mod;
            }
        }
        dp = dp2;
        ans = (ans + dp[S]) % mod;
    }
    cout << ans << endl;
}

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

    long long N;
    scanf("%lld", &N);
    long long S;
    scanf("%lld", &S);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, S, std::move(A));
    return 0;
}


Measured memory_bytes: 384
n = int(input())
for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j -n * (i+j) > 0:
            if n*i*j % (4*i*j-n*(i+j)) == 0:
                print(i,j,n*i*j // (4*i*j-n*(i+j)))
                exit()

Measured memory_bytes: 41196
#include <stdio.h>
main(void){
   int n,x;
   int i,j,k;
   int sum;
   int count;
   sum=0;
   scanf("%d%d",&n,&x);
   while(n!=0||x!=0){
      count=0;
      for(i=1;i<=n-2;i++){
         for(j=i+1;j<=n-1;j++){
            for(k=j+1;k<=n;k++){
               sum=i+j+k;
               if(sum==x)count+=1;
               sum=0;
            }
         }
      }
      printf("%d\n",count);
      scanf("%d%d",&n,&x);
   }
   return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ');
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);
        var s = Console.ReadLine().Split(' ');

        var dict = new Dictionary<int, int>();
        for (int i = 0; i < n; i++)
        {
            var x = int.Parse(s[i]);
            if (dict.ContainsKey(x))
            {
                dict[x]++;
            }
            else
            {
                dict[x] = 1;
            }
        }

        var values = dict.Values.ToArray();
        Array.Sort(values);

        var ans = 0;
        for (int i = 0; i < values.Length - k; i++)
        {
            ans += values[i];
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 61;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> ans_cnt(n, 0);
    rep(i, q) {
        int a;
        cin >> a;
        ++ans_cnt[a - 1];
    }

    rep(i, n) {
        if (k - (q - ans_cnt[i]) <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
counter = defaultdict(int)
max_ = 0
for _ in range(N):
    s = input()
    counter[s] += 1
    max_ = max(counter[s], max_)

words = [word for word, n in counter.items() if n == max_]
words.sort()
for word in words:
    print(word)

Measured memory_bytes: 97812
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int t1, t2; cin >> t1 >> t2;
    int a1, a2; cin >> a1 >> a2;
    int b1, b2; cin >> b1 >> b2;

    int x = a1 * t1 - b1 * t1;
    int y = (a1 * t1 + a2 * t2) - (b1 * t1 + b2 * t2);

    if(x == 0 || y == 0) {
        cout << "infinity" << endl;
        return;
    } else if((x > 0 && y > 0) || (x < 0 && y < 0)) {
        cout << 0 << endl;
        return;
    } else if(x > 0 && y < 0) {
        int c = x / (-y);
        if(x % (-y) == 0) {
            cout << 2 * c << endl;
            return;
        }
        cout << 2 * c + 1 << endl;
        return;
    } else if(x < 0 && y > 0) {
        int c = (-x) / y;
        if((-x) % y == 0) {
            cout << 2 * c << endl;
            return;
        }
        cout << 2 * c + 1 << endl;
        return;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

namespace ConsoleApp15
{
    class Class350
    {
        static void Main()
        {
            var ND = Console.ReadLine().Split().Select(int.Parse).ToArray();
            double N = ND[0], D = ND[1];
            Console.WriteLine(Math.Ceiling(N/(2*D+1)));
        }
    }
}


Measured memory_bytes: 11348
#!/usr/bin/env python3
#diverta C

N = int(input())
a = list(map(int,input().split()))
a.sort()
s = a[0]
l = a[-1]
log = []
for i in a[1:-1]:
    if i > 0:
        log += [(s, i)]
        s -= i
    else:
        log += [(l, i)]
        l -= i
log += [(l, s)]
print(l - s)
for i, j in log:
    print(i, j)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;
struct segtree{
    static const int SEG=1<<18;
    vint dat,put;
    segtree():dat(SEG*2,1001001001001001ll),put(SEG*2){}
    inline void push(int k){
        dat[k]+=put[k];
        if(k<SEG-1){
            put[k*2+1]+=put[k];
            put[k*2+2]+=put[k];
        }
        put[k]=0;
    }
    void add(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]+=x;
            push(k);
            return;
        }
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k);
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b)return dat[k];
        return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
    void update(int k,int x){
        int tmp=query(k,k+1);
        if(tmp<=x)return;
        add(k,k+1,-tmp+x);
    }
};

int N,Q,A,B;
int X[222222];
signed main(){
    cin>>N>>Q>>A>>B;
    X[0]=A;X[1]=B;
    for(int i=0;i<Q;i++)cin>>X[i+2];
    Q+=2;

    vint xs;
    rep(i,Q)xs.pb(X[i]);
    sort(all(xs));xs.erase(unique(all(xs)),xs.end());


    segtree seg1,seg2;
    int hoge=lower_bound(all(xs),A)-xs.begin();
    seg1.update(hoge,-A);
    seg2.update(hoge,A);

    for(int i=2;i<Q;i++){

        int pos=lower_bound(all(xs),X[i])-xs.begin();
        int pos2=lower_bound(all(xs),X[i-1])-xs.begin();

        int tmp=INF;
        chmin(tmp,seg1.query(0,pos)+X[i]);
        chmin(tmp,seg2.query(pos,xs.size())-X[i]);

        seg1.add(0,xs.size(),abs(X[i]-X[i-1]));
        seg2.add(0,xs.size(),abs(X[i]-X[i-1]));
        seg1.update(pos2,tmp-X[i-1]);
        seg2.update(pos2,tmp+X[i-1]);

    }

    int ans=INF;
    rep(i,xs.size()){
        chmin(ans,seg1.query(i,i+1)+xs[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 22000
#include <iostream>
using namespace std;
int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B || B == C || C == A){
        if(A == B && B == C){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

string str;
ll a, b, c, n, m,x ,t;
vector<ll> v;

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> str;
	ll x = 0;
	rep(i, str.size()){
		x += str[i];
	}
	if(x % 3 == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3752
#include<stdio.h>

int main(){
	int n;
	int c;
	int a=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&c);
		if(c%2==1)a=1;
	}
	if(a==0){
		printf("second");
	}else{
		printf("first");
	}
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

const ll mod = 998244353;
const ll N = 212345;
ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

vl fac;

ll inv (ll x) { return modpow(x, mod-2); }

ll ncr(ll n, ll r) {
  if (r < 0 or r > n) return 0;
  return (fac[n] * inv(fac[r]) % mod) * inv(fac[n-r]) % mod;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  fac.pb(1);
  rep(i,1,N) fac.pb(fac.back()*i%mod);

  ll n, m, k;
  cin >> n >> m >> k;

  ll ans = 0;
  rep(i,0,k+1) {
    ans += (m*modpow(m-1, n-1-i) % mod) * ncr(n-1, i) % mod;
    ans %= mod;
  }

  cout << ans << '\n';


}

Measured memory_bytes: 5304
#include<stdio.h>
#include<math.h>
int main(void){
    double a;
    scanf("%lf",&a);
    
    while(a>=1){
        double aroot=sqrt(a);
        if(aroot-(int)aroot==0){
            printf("%.0f\n",a);
            break;
        }
        a--;
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
template<typename T>
T rabs(T x)
{
	return x>0?x:-x;
}
int a[100];
int n;
int main()
{
	read(n);
	int mxp=1;
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		if(rabs(a[i])>rabs(a[mxp]))
			mxp=i;
	}
	cout<<2*n-1<<endl;
	for(int i=1;i<=n;i++)
		cout<<mxp<<' '<<i<<endl;
	if(a[mxp]<=0)
		for(int i=n-1;i>=1;i--)
			cout<<i+1<<' '<<i<<endl;
	else
		for(int i=1;i<n;i++)
			cout<<i<<' '<<i+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[2][16][1<<16];
int c[16][1<<16][2];

int Max(int &a,int b){return a=max(a,b);}

int main(){

  int h,w;
  string s[128];

  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<w;i++)
    for(int j=0;j<1<<w;j++){
      int cnt=0;

      for(int k=0;k<i;k++)
	cnt+=bool(j&(1<<k));
      
      c[i][j][0]=cnt;
      c[i][j][1]=__builtin_popcount(j)-cnt;
    }


  for(int i=0;i<h;i++){
    
    for(int j=0;j<w;j++)
      for(int k=0;k<1<<w;k++){
	dp[(i+1)%2][j][k]=-1e9;
      }

    for(int j=0;j<w;j++)
      for(int k=0;k<(1<<w);k++){
	int cs=0;
	
	int idx = c[j][k][0],o=(int)s[i-1].size()-c[j][k][1];
	
	if(i && k&(1<<j) && idx <(int)s[i].size() && 0<=o && o < (int)s[i-1].size() && s[i][idx] == s[i-1][o]) cs+=2;


	if(j && idx && idx < (int)s[i].size() && (k & 1<<(j-1) ) && s[i][idx -1] == s[i][idx]) cs+=2;
	
	if( j!=w-1 || idx == (int)s[i].size() -1){
	  Max(dp[(i+(j==w-1))%2][(j+1)%w][k|(1<<j)],dp[i%2][j][k]+cs);

	}
	int nk=k;
	if(k&1<<j) nk^=1<<j;
	
	if( j!=w-1 || idx == (int)s[i].size() ) Max(dp[(i+(j==w-1))%2][(j+1)%w][nk],dp[i%2][j][k]);
	
      }
  }

  int ans=0;

  for(int i=0;i<1<<w;i++)
    if((int)s[h-1].size()==c[0][i][1]){
      ans=max(ans,dp[h%2][0][i]);
    }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 19584
n,K=map(int,input().split())
xy=[]
x=[]
y=[]
for _ in range(n):
	X,Y=map(int,input().split())
	x.append(X+10**9)
	y.append(Y+10**9)
	xy.append((X+10**9,Y+10**9))
x.sort();y.sort();xy.sort()
num=[[0]*(n+1)for _ in range(n+1)]
for xx in xy:
	for i in range(n):
		if x[i]==xx[0]:
			break
	for j in range(n):
		if y[j]==xx[1]:
			break
	num[i+1][j+1]+=1
for i in range(n):
	for j in range(n):
		num[i+1][j+1]+=num[i+1][j]
for i in range(n):
	for j in range(n):
		num[i+1][j+1]+=num[i][j+1]
ans=10**20
for i in range(n):
	for j in range(n):
		for k in range(i+1,n+1):
			for l in range(j+1,n+1):
				if num[k][l]-num[i][l]-num[k][j]+num[i][j]>=K:
					r=(y[l-1]-y[j])*(x[k-1]-x[i])
					ans=min(ans,r)
print(ans)

Measured memory_bytes: 3064
import numpy as np

money = 1000
kabu = 0

n = int(input())

a = np.array(list(map(int, input().split())))

for i in range(n-1):
  if a[i] < a[i+1]:
    kabu += int(money/a[i])
    money = money%a[i]

  elif a[i] > a[i+1]:
    money += kabu*a[i]
    kabu = 0

print(money+kabu*a[-1])

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

int mod = 1000000007;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int p, q, r, left = 0, bottom = 0, right = W, top = H;
    for (int i = 0; i < N; i++)
    {
        cin >> p >> q >> r;
        if (r == 1)
            left = max(left, p);
        if (r == 2)
            right = min(right, p);
        if (r == 3)
            bottom = max(bottom, q);
        if (r == 4)
            top = min(top, q);
    }
    if (right <= left || top <= bottom)
        cout << 0;
    else
        cout << (right - left) * (top - bottom);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int S, W;
	cin >> S >> W;

	if (W >= S)
	{
		cout << "unsafe" << endl;
	}
	else
	{
		cout << "safe" << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

inline ll mul(ll a, ll b){
	if(a == 0 or b == 0) return 0LL;
	const ll limit = 1LL << 20;
	if(a > limit or b > limit) return limit;
	return min<ll>(limit, a * b);
}

int ary[2010][2010];
int csum[3][2010][2010];

bool query(int k,int a,int b,int c,int d){
	int total = (b - a) * (d - c);
	total -= csum[k][a][c];
	total += csum[k][b][c];
	total += csum[k][a][d];
	total -= csum[k][b][d];
	return (total == 0);
}

bool check(ll len,ll d){
	vector<ll> limit;
	limit.push_back(mul(len / d + 1LL, len / d + 1LL));
	limit.push_back(mul(len / d + 0LL, len / d + 1LL));
	limit.push_back(mul(len / d + 0LL, len / d + 0LL));

	rep(k,3){
		rep(i,2 * d)rep(j, 2 * d){
			csum[k][i][j] = (ary[i][j] <= limit[k]);
		}

		rrep(i, 2 * d)rrep(j, 2 * d){
			csum[k][i][j] += csum[k][i+1][j];
			csum[k][i][j] += csum[k][i][j+1];
			csum[k][i][j] -= csum[k][i+1][j+1];
		}
	}

	// (len / d) + (pos <= len % d)
	rep(i,d)rep(j,d){
		const int im = i + len % d + 1;
		const int ie = i + d;
		const int jm = j + len % d + 1;
		const int je = j + d;
		bool ok = true;
			
		if(query(0,i,im,j,jm) == false) ok = false;
		if(query(1,im,ie,j,jm) == false) ok = false;
		if(query(1,i,im,jm,je) == false) ok = false;
		if(query(2,im,ie,jm,je) == false) ok = false;
		if(ok) return true;
	}

	return false;
}
 
int main(void){
	int n,d;
	cin >> n >> d;
	
	vector<int> x(n),y(n);
	rep(i,n){
		cin >> x[i] >> y[i];
		ary[x[i] % d][y[i] % d]++;
	}
 
	rep(i,2*d)rep(j,2*d){
		if(i < d and j < d) continue;
		ary[i][j] = ary[i % d][j % d]; 
	}
 
	ll low = 0LL, high = 1LL << 40;
	while(high - low > 1){
		const ll mid = (low + high) / 2LL;
		if(check(mid,d))
			high = mid;
		else
			low = mid;
	}
 
	cout << high << endl;
	return 0;
}

Measured memory_bytes: 64128
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def query(self,top_num,front_num):

        self.save_data = [i for i in range(6)]
        #元の値の保存
        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        #元の値の復元
        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]

        return ret;




dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

num_query = int(input())
for loop in range(num_query):
    top_num,front_num = map(int,input().split())
    print("%d"%(dice.query(top_num, front_num)))



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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)


#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code	
	int a,b;
	cin >> a >>b;
	if(a<=8&&b<=8)
		cout << "Yay!";
	else
		cout << ":(";

	return 0;

}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int out=0,ok=0,i,j=0;
  char square[8][4],str[64];
  
  for(i=0;i<2;i++)
  {
  	fgets(str,sizeof(str),stdin);
  	sscanf(str,"%c%c%c",&square[i][0],&square[i][1],&square[i][2]);
  }

  while ((out == 0)&&(ok<3))
  {
    if(square[0][j] == square[1][2-j])
    {
      ok++;
    }else
    {
      out++;
    }
    j++;
  }
  if(out == 0)
  {
    puts("YES");
  }else
  {
    puts("NO");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void) {
	int a, b;

	scanf("%d %d",&a,&b);

	if (a == b) {
		printf("Draw\n");
	}
	else if (a == 1 || (a > b)&&(b != 1)) {
		printf("Alice\n");
	}
	else if (b == 1 || a < b) {
		printf("Bob\n");
	}

	return 0;
}

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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    string S;
    cin >> S;
    for(int i=0;i<S.size()-2;i++){
        if(S.substr(i,3)=="ABC"){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	vector<int> score(N);
	int sum = 0;
	rep(i,N){
		cin>>score[i];
		sum += score[i];
	}
	vector<vector<bool>> dp(N+1,vector<bool>(sum+1,false));
	REP(i,N){
		rep(j,sum+1){
			if(dp[i-1][j])dp[i][j] = true;
			if(j < score[i-1])continue;
			if(j == score[i-1])dp[i][j] = true;
			if(dp[i-1][j-score[i-1]])dp[i][j] = true;
		}
	}
	/*
	REP(i,N){
		rep(j,sum+1)cout<<dp[i][j]<<' ';
		cout<<endl;
	}*/
	for(int i = sum; i>=0; --i){
		if(dp[N][i]){
			if(i%10!=0){
				cout<<i<<endl;
				return 0;
			}
		}
	}
	cout<<0<<endl;
	return 0;
}

/*
int main(){
	int N;
	cin>>N;
	vector<int> score(N);
	int ans = 0;
	int rest = inf;
	rep(i,N){
		cin>>score[i];
		ans += score[i];
		if(score[i]%10 != 0)rest = min(rest,score[i]);
	}
	if(ans % 10 != 0){cout<<ans<<endl; return 0;}
	if(rest != inf){cout<<ans-rest<<endl; return 0;}
	cout<<0<<endl;
	return 0;
}
*/

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

long long int dp[100] = {0}, n;

long long int ryuka(int i){
	if(i == 0)
		return dp[i];
	if(dp[i] == 0){
		dp[i] = ryuka(i-1) + ryuka(i-2);
	}
	return dp[i];
}

int main(){
	cin >> n;
	dp[0] = 2;
	dp[1] = 1;
	cout << ryuka(n) << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
int main(void)
{
    int a, b, c, i = 0;
    scanf("%d %d %d", &a, &b, &c);
    while(a <= b)
    {
        if(c % a == 0)
        {
            i++;
        }
        a++;
    }
    printf("%d\n", i);
    return 0;
}


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
//typedef unsigned long long u64;
//const double pi = 3.141592653589793238460;

const int MAX = 1e6 + 1;

int arr[200001];
int freq[MAX];

int main()
{
	//IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		for(int i = 1; i <= n; i++)
		{
			cin >> arr[i];
			freq[arr[i]]++;
		}

		vector<int> adj[n + 1];

		for(int i = 1; i <= n; i++)
		{
			int num = arr[i];
			for (int ii = 1; ii <= sqrt(num); ii++)
			{
				if (num % ii == 0)
				{
					if (num / ii == ii)
						adj[i].push_back(ii);
					else
					{
						adj[i].push_back(ii);
						adj[i].push_back(num / ii);
					}
				}
			}
		}

		ll ct = 0;
		bool fl;
		for(int i = 1; i <= n; i++)
		{
			fl = true;
			for(int j : adj[i])
			{
				if(j == arr[i] && freq[j] > 1)
				{
					fl = false;
					break;
				}
				else if(j != arr[i] && freq[j] > 0)
				{
					fl = false;
					break;
				}
			}
			if(fl) ct += 1;
		}
		cout << ct << endl;
	}
	return 0;
}


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

bool isGuu(const string& s, int n)
{
    if (n%2) return false;

    for(int i=0; i<n/2; ++i)
        if (s[i]!=s[n/2+i]) return false;
    return true;
}

int main()
{
    string s;
    cin>>s;
    int n=s.size()-1;
    while (!isGuu(s, n)) --n;
    cout<<n<<endl;
}


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


int64_t intceil(int64_t a,int64_t b){
    if(a>=0){
        return (a+b-1)/b;

    }
    else{
        return a/b;
    }
}

int64_t intfloor(int64_t a,int64_t b){
    if(a<0){
        return (a-b+1)/b;
    }else{
        return a/b;
    }
}

int main(){
    int64_t N,K;
    cin>>N>>K;
    vector<int64_t>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.begin(),A.end());

    const int64_t INF=1e18;
    int64_t ok=INF,ng=-INF-1;
    while(ok-ng>1){
        int64_t m=(ok+ng)/2;
        int64_t num=0;
        for(int i=0;i<N;i++){
            if(A[i]<0){
                int64_t v=intceil(-m,-A[i]);
                num+=A.begin()+i-lower_bound(A.begin(),A.begin()+i,v);
                
            }else if(A[i]==0){
                if(m>=0)num+=i;

            }else{
                int64_t v=intfloor(m,A[i]);
                num+=upper_bound(A.begin(),A.begin()+i,v)-A.begin();
            }
        }
        (num>=K ? ok:ng)=m;
    }
    cout<<ok<<endl;
    return 0;
}

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

int KMP[100];
int buildKMP(char *pat,char *s) {
//	cout << "pat =>";
//	for(int i=0;i<n;i++){
//		cout << " " << pat[i];
//	}
//	cout << endl;
//	
//	cout << "s =>";
//	for(int i=0;i<2*n;i++){
//		cout << " " << s[i];
//	}
//	cout << endl;
	
	
	int lpat = strlen(pat), pos = KMP[0] = -1;
	for (int i=0; i<lpat; i++) {
		while (pos >= 0 && pat[i] != pat[pos]) pos = KMP[pos];
		KMP[i+1] = ++pos;
	}
	int ls = strlen(s), res = pos = 0;
	for (int i=0; i<ls; i++) {
		while (pos>=0 && s[i]!=pat[pos]) pos = KMP[pos];
		if (++pos == lpat) pos = KMP[pos], res += 1;
	}
//	cout << "GET " << res << endl;
	return res; // return the number of occurrences
}

char pat[5];
char s[55];
int n;

int main(){
	scanf("%d",&n);
	scanf("%s",s);
	strcpy(pat,"ABC");
	printf("%d\n",buildKMP(pat,s));
	return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.readline
    N, W = map(int, readline().split())
    WV = (map(int, readline().split()) for _ in range(N))
    dp = [0] * (W+1)
    for w, v in WV:
        for i in range(W, w-1, -1):
            tmp_dp = dp[i-w] + v
            if dp[i] < tmp_dp:
                dp[i] = tmp_dp
    return max(dp)


if __name__ == "__main__":
    answer = solve()
    print(answer)


Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int N = S.size();
    map<char,int> M;
    rep(i,N) M[S[i]]++;
    bool able = false;
    switch(N) {
    case 0:
    case 1:
        able = true;
        break;
    case 2:
        if (M.size() == 2) {
            able = true;
        }
        break;
    case 3:
        if (M.size() == 3) {
            able = true;
        }
        break;
    default:
        if (M.size() >= 3) {
            able = true;
            for (auto [k,v] : M) {
                if (v < N/3) able = false;
                if (v == N/3 + 2) able = false;
            }
        }
        break;
    }
    if (able) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3744
import sys
input = sys.stdin.buffer.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    N = int(input())
    #N, M = map(int, input().split())
    #print(lcm(N, M))
    print("ABC" if N<1000 else "ABD")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import math


class vec2d(object):
    def __init__(self, x, y) -> None:
        self.x = float(x)
        self.y = float(y)

    def rot(self, theta: float):
        newx = self.x * math.cos(theta) - self.y * math.sin(theta)
        newy = self.x * math.sin(theta) + self.y * math.cos(theta)
        return vec2d(newx, newy)

    def __str__(self):
        return ' '.join(map(str, [self.x, self.y]))

    def __format__(self, format_spec):
        return ' '.join(map(lambda x: format(x, format_spec), [self.x, self.y]))

    def __add__(self, other):
        return vec2d(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return vec2d(self.x - other.x, self.y - other.y)

    def __mul__(self, k):
        return vec2d(self.x * k, self.y * k)

    def __truediv__(self, k):
        return self.__mul__(1 / k)

    def prod(self, other):
        return self.x * other.x + self.y * other.y


def cochcurve(p1, p2, n):
    if n > 0:
        pd = (p2 - p1) / 3
        ps = p1 + pd
        pu = ps + pd.rot(math.pi / 3)
        pt = ps + pd
        cochcurve(p1, ps, n-1)
        print(f'{ps:>12.6f}')
        cochcurve(ps, pu, n-1)
        print(f'{pu:>12.6f}')
        cochcurve(pu, pt, n-1)
        print(f'{pt:>12.6f}')
        cochcurve(pt, p2, n-1)


n = int(input())
S = vec2d(0, 0)
T = vec2d(100, 0)
print(f'{S:>12.6f}')
cochcurve(S, T, n)
print(f'{T:>12.6f}')


Measured memory_bytes: 5780
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, m, x] <- getIntList
  cas <- VB.replicateM n (getIntVec (m+1))

  d <- VM.new m

  let calc :: Int -> Int -> Int -> IO Int
      calc b i cost
        | i == n = do
          d' <- V.freeze d
          let xs = V.filter (< x) d'
          if V.length xs == 0
            then return cost
            else return inf
        | otherwise = do
            let x = (b `shiftR` i) .&. 1
                ci = (cas VB.! i) V.! 0
                cost' = if x == 1 then cost + ci else cost
            when (x == 1) $ do
              forM_ [0..(m-1)] $ \j -> do
                let aij = (cas VB.! i) V.! (j+1)
                t <- VM.read d j
                VM.write d j (t+aij)
            calc b (i+1) cost'

      solve :: Int -> Int -> IO Int
      solve b res | b == (1 `shiftL` n) = return res
                  | otherwise = do
                      VM.set d (0::Int)
                      c <- calc b 0 0
                      solve (b+1) (min res c)

  ans <- solve 1 inf
  print $ if ans < inf then ans else (-1)



Measured memory_bytes: 9168
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
T=input()
A=input()
t,b,l,r=0,H,0,W
for i in range(N-1,-1,-1):
    if A[i]=='U':
        b=min(b+1,H)
    elif A[i]=='D':
        t=max(t-1,0)
    elif A[i]=='L':
        r=min(r+1,W)
    else:
        l=max(l-1,0)
    if T[i]=='U':
        t+=1
    elif T[i]=='D':
        b-=1
    elif T[i]=='L':
        l+=1
    else:
        r-=1
    if t==b or l==r:
        break
print(['NO','YES'][t<sr<=b and l<sc<=r])

Measured memory_bytes: 3784
package main

import "fmt"

func SLoE(a, b int) string {
	switch {
	case a > b:
		return "a > b"
	case a < b:
		return "a < b"
	case a == b:
		return "a == b"
	default :
		return ""
	}
}

func main(){
	a := 0
	b := 0
		fmt.Scan(&a)
		fmt.Scan(&b)
	fmt.Println(SLoE(a, b))
}


Measured memory_bytes: 1104
class UnionFind():
  def __init__(self,n):
    self.parents=[-1]*n
  
  def find(self,x):
    if self.parents[x]<0:
      return x
    self.parents[x]=self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    
    self.parents[x]+=self.parents[y]
    self.parents[y]=x

N,M=map(int,input().split())
ans=0
A=[]
B=[]

for _ in range(M):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  
for i in range(M):
  uf=UnionFind(N+1)
  for j in range(M):
    if i==j:
      continue
    uf.union(A[j],B[j])
  else:
    if abs(min(uf.parents[1:]))!=N:
      ans+=1
print(ans)

Measured memory_bytes: 9072
blue=int(input())
b=[]
r=[]
count=[]
for i in range(blue):
  b.append(input())
red=int(input())
for i in range(red):
  r.append(input())
for i in b:
  count.append(b.count(i)-r.count(i))
if max(count)<0:
  print(0)
else:
  print(max(count))

Measured memory_bytes: 9112
N, Q = [int(i) for i in input().split()]
S = input()
dp = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        dp[i] = dp[i - 1] + 1
    else:
        dp[i] = dp[i - 1]
for _ in range(Q):
    l, r = [int(i) - 1 for i in input().split()]
    print(dp[r] - dp[l])



Measured memory_bytes: 6140
#include <iostream>
#define ll long long
using namespace std;
ll k[200];
int main()
{
    ll n;
    cin >> n;
    for (ll i = 0; i < 200; i++) {
        k[i] = i * i * i * i * i;
        for (ll j = 0; j < i; j++) {
            if (k[i] - k[j] == n) {
                cout << i << " " << j;
            }
            else if (k[i] + k[j] == n) {
                cout << i << " " << -j;
            }
        }
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,ans = 1,Mod = 998244353;
    cin >> n;
    vector<ll> a(n),cnt(n,0);
    rep0(i, n){
        cin >> a[i];
        ++cnt[a[i]];
    }
    if (a[0] != 0 || cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll Max = *max_element(all(a)) + 1;
    rep1(i, Max){
        rep0(j, cnt[i]){
            ans *= cnt[i - 1];
            ans %= Mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <cstdio>
using namespace std;

int main(int argc, char *argv[]){
  double const pi = 3.141592653589;
  double r,c,rim;
  cin >> r;
  c = pi * (r * r);
  rim = 2*pi*r;
  printf("%lf %lf\n",c, rim);
  // cout << d << " " << r << " " << endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int S = s.size()-2;
  cout << s[0] << S << s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
num_slimes = int(input())
input_line = input().split()

slimes = list(map(int, input_line))

emerged_slimes = []

past_color = slimes[0]
block = 0

for color in slimes:
    if past_color == color:
        block += 1
    else:
        emerged_slimes.append(block)
        past_color = color
        block = 1
else:
    emerged_slimes.append(block)

summon = 0
for element in emerged_slimes:
    if element > 1:
        summon += element // 2

print(str(summon))


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const int MAX_N=1e5+4;
const int INF=1e9+7;
ll a[MAX_N];
P b[MAX_N];
ll ans[MAX_N];
vector<int> IS;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){cin>>a[i+1];b[i+1]=P(a[i+1],i+1);}
	sort(b,b+n+1);
	int mi=INF;
	for(int i=n;i>=1;i--){
		mi=min(mi,b[i].second);
		ans[mi]+=(n+1-i)*(b[i].first-b[i-1].first);
	}
	for(int i=0;i<n;i++)cout<<ans[i+1]<<endl;
}


Measured memory_bytes: 4224