akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long sum = accumulate(a.begin(), a.end(), 0);
    size_t c = count_if(a.begin(), a.end(), [m, sum](int x) {
        return (x * 4 * m) >= sum;
    });
    if (m <= c)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
N = int(input())
S = input()

isF = [False for i in range(N)]
isT = [False for i in range(N)]

def isSatisfied():
    for i in range(2, N+2):
        different = (S[(i - 1) % N] == "x" and isT[(i - 1) % N]) or (S[(i - 1) % N] == "o" and isF[(i - 1) % N])
        if different:
            isF[i % N] |= not isF[(i-2) % N]
            isT[i % N] |= not isT[(i-2) % N]
        else:
            isF[i % N] |= isF[(i-2) % N]
            isT[i % N] |= isT[(i-2) % N]
    for j in range(2, N+2):
        i = 1-i
        different = (S[(i + 1) % N] == "x" and isT[(i + 1) % N]) or (S[(i + 1) % N] == "o" and isF[(i + 1) % N])
        if different:
            isF[i % N] |= not isF[(i+2) % N]
            isT[i % N] |= not isT[(i+2) % N]
        else:
            isF[i % N] |= isF[(i+2) % N]
            isT[ i% N] |= isT[(i+2) % N]
    for i in range(N):
        if isF[i] and isT[i]: return False
    return True

for a in [False, True]:
    for b in [False, True]:
        isF = [False for i in range(N)]
        isT = [False for i in range(N)]
        isF[0] = a
        isT[0] = not a
        isF[1] = b
        isT[1] =  not b
        if isSatisfied():
            print("".join(["S" if isT[i] else "W" for i in range(N)]))
            quit()
print(-1)


Measured memory_bytes: 70156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353LL

int cnt[3],n;
char s[300010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

int main()
{
	n=rd();
	scanf("%s",s+1);
	ll ans=1;
	for (int i=1;i<=n*3;i++)
	{
		int now=(s[i]=='R')?0:(s[i]=='G')?1:2;
		int id=-1,cur=0;
		for (int j=0;j<3;j++) if (j!=now&&cnt[j]) id=j,cur++;
		if (cur==2)
		{
			int mn=n;
			for (int j=0;j<3;j++) if (j!=now) mn=min(mn,cnt[j]);
			ans=ans*mn%mod;
			for (int j=0;j<3;j++) if (j!=now) cnt[j]--;
			continue;
		}
		if (cur==0) { cnt[now]++;continue; }
		if (cnt[id]>cnt[now]) ans=ans*(cnt[id]-cnt[now])%mod;
		cnt[now]++;
	}
	for (int i=1;i<=n;i++) ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

vector<int> evencnt;
bool iseven(int n, int r) {
    int tmp = evencnt[n] - evencnt[r] - evencnt[n - r];
    return tmp > 0;
}

int solve(string &a, bool flag = false) {
    int N = a.length();
    bool iszero = false;
    bool isone = false;
    for (int i = 0; i < N; ++i) {
        int num = a[i] - '0';
        if (num & 1)
            iszero = true;
        if ((num & 1) && !iseven(N - 1, i))
            isone ^= 1;
    }

    if (isone)
        return 1;
    else if (iszero || flag)
        return 0;
    else {
        for (int i = 0; i < N; ++i)
            if (a[i] == '2')
                a[i]--;
        return solve(a, true) << 1;
    }
}

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

    int N;
    string a;
    cin >> N >> a;
    for (int i = 0; i < N; ++i)
        a[i]--;

    evencnt.resize(N);
    evencnt[0] = 0;
    for (int i = 1; i < N; ++i) {
        evencnt[i] = evencnt[i - 1];
        if (!(i & 1))
            evencnt[i] += evencnt[i >> 1] - evencnt[(i >> 1) - 1] + 1;
    }

    cout << solve(a) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
ll inf = 100000000007ll;

int main(void)
{
  int n;
  string s;
  cin >> n >> s;
  ll l = 0;
  ll r = n+1;
  while(r-l>1) {
    ll piv = (l+r)/2;
    bool flag = false;
    map<string, ll> pos;
    REP(i,n-piv+1) {
      string str(s.begin()+i,s.begin()+i+piv);
      if(pos.count(str)) {
        if(pos[str] <= i - piv) flag = true;
      } else {
        pos[str] = i;
      }
    }
    if(flag) l = piv;
    else r = piv;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 6672
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    int value = 700;
    for (int i = 0; i < 3; i++) {
      if (S.charAt(i) == 'o') {
        value += 100;
      }
    }
    System.out.println(value);

  }

}

Measured memory_bytes: 21844
def f():
  c=[0]*101
  while 1:
    a,b=map(int,raw_input().split())
    if a==b==0:break
    c[a]+=1
    c[b]+=1
  f=0
  if c[1]%2==c[2]%2==1:
    for e in c[3:]:
      if e%2:break
    else:f=1
  print ["NG","OK"][f]
  return
while 1:
  try:f()
  except:break

Measured memory_bytes: 4220
N,M = (int(x) for x in input().split())
Broken = [True]*(N+1)
for TM in range(0,M):
    Broken[int(input())] = False

DP = [1]+[0]*N
for Now in range(0,N):
    for Next in range(Now+1,min(N+1,Now+3)):
        if Broken[Next]==True: DP[Next] += DP[Now]
print(DP[N]%1000000007)

Measured memory_bytes: 469184
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
ll big = 1000000007ll;
ll n,m,k,x,y;
 
vector<ll> A;
vector<ll> D;
vector<ll> P;
vector<ll> CS;
 
ll DP[100001][2] = {0};
 
ll dp(ll i, ll p){
    if(i == n)return 1;
    if(DP[i][p] != -1){return DP[i][p];}
    ll ans = 0;
    if(p == 1 || D[i] >= x || i == 0)ans += dp(i+1,0);
    bool bort = 0;
    ll pek = P[i];
    if(i >= 1 && p == 0 && i < n-1 && P[i] != i+1){
        if(A[i+1] - A[i-1] < x)bort = 1;
    }
    //if(pek == n)bort = 1;
   if(i < n-1){ if(CS[pek] - CS[i+2] > 0)bort = 1;}
    if(bort == 0){
        if(pek == i+1){
            ans += dp(pek,1);
        }
        else{
            ans += dp(pek,0);
        }
    }
    ans %= big;
    DP[i][p] = ans;
    //cout << i << " " << p << "  -  " << ans << " , " << bort <<"  " << dp(i+1,0) << " " << dp(pek,(pek == i+1)) << "\n";
    return ans;
}
 
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
 
    ll c1,c2,c3,c4,c5;
    ll a,b,c;
 
    cin >> n >> x >> y;
    if(x > y){
        a = x;
        x = y;
        y = a;
    }
    ll prev = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
        D.push_back(a-prev);
        prev = a;
    }
 
    CS.push_back(0);
    for(c1 = 0; c1 < n; c1++){
        if(c1 == 0){
            CS.push_back(0);
        }
        else{
            CS.push_back(CS[c1] + (D[c1] < x));
        }
        DP[c1][0] = -1;
        DP[c1][1] = -1;
    }
 
    for(c1 = 0; c1 < n; c1++){
        ll l = c1+1;
        ll r = n;
        if(c1 == n-1 || D[l] >= y){
            P.push_back(l);
        }
        else{
            while(l < r-1){
                ll mid = (l+r)/2;
                if(A[mid] - A[c1] < y){
                    l = mid;
                }
                else{
                    r = mid;
                }
            }
            P.push_back(r);
        }
 
        //cout << P[c1] << " ";
 
    }
 
    cout << dp(0,1) << "\n";
 
    return 0;
}

Measured memory_bytes: 9708
import copy
N = int(input())
M = list(map(int,input().split(" ")))
M_sorted=copy.copy(M)
M_sorted.sort()
bool_list=[]

for i in range(N):
  if M[i]==M_sorted[i]:
    bool_list.append(False)
  else:
    bool_list.append(True)
if sum(bool_list) in [0,2]:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3444
#include"bits/stdc++.h"
using namespace std;
using ll = long long;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

constexpr ll MOD = 998244353;

ll mod_pow(ll base, ll p) {
	ll res = 1;
	while (p > 0) {
		if (p & 1)(res *= base) %= MOD;
		(base *= base) %= MOD;
		p >>= 1;
	}
	return res;
}

ll red_area(ll N) {
	ll res = 0;
	rep(i, N) {
		res += 2 * (mod_pow(2, i) - 1);
		res += 2 * (mod_pow(2, N - 1 - i) - 1);
		res %= MOD;
	}
	return res;
}

ll sum(vector<ll>& bit, ll i) {
	i++;
	ll s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void add(vector<ll>& bit, ll i, ll x) {
	i++;
	while (i < bit.size()) {
		bit[i] += x;
		i += i & -i;
	}
}

ll blue_area(vector<pair<ll, ll>>& xys, vector<ll> ys) {
	const ll N = xys.size();
	map<ll, ll> mp;
	rep(i, N)mp[ys[i]] = i;

	ll res = 0;
	vector<ll> bit(N + 1, 0);
	rep(i, N) {
		ll y = xys[i].second;
		ll point = sum(bit, mp[y]);
		res += mod_pow(2, point) - 1;
		res += mod_pow(2, i - point) - 1;
		res %= MOD;
		add(bit, mp[y], 1);
	}

	fill(bit.begin(), bit.end(), 0);
	for (int i = N - 1; i >= 0; i--) {
		ll y = xys[i].second;
		ll point = sum(bit, mp[y]);
		res += mod_pow(2, point) - 1;
		res += mod_pow(2, (N - 1 - i) - point) - 1;
		res %= MOD;
		add(bit, mp[y], 1);
	}
	return res;
}

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

	vector<ll> xs, ys;
	vector<pair<ll, ll>> xys;
	rep(i, N) {
		ll x, y;
		cin >> x >> y;
		xs.push_back(x);
		ys.push_back(y);
		xys.push_back({ x,y });
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	sort(xys.begin(), xys.end());

	ll total = (N*(mod_pow(2, N) - 1)) % MOD;
	ll ignore = red_area(N) - blue_area(xys, ys);
	ll res = (total - ignore) % MOD;
	res = (res + MOD) % MOD;

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 22992
using System;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int state1 = 0;
        int state2 = 0;
        for(int i=0;i<s.Length;i++){
            if((state1 == 0 || state1 == 2) && s[i] == 'N'){
                state1 += 1;
            }
            else if((state1 == 0 || state1 == 1) && s[i] == 'S'){
                state1 += 2;
            }
            if((state2 == 0 || state2 == 2) && s[i] == 'E'){
                state2 += 1;
            }
            else if((state2 == 0 || state2 == 1) && s[i] == 'W'){
                state2 += 2;
            }
        }
        if((state1 == 0 || state1 == 3) && (state2 == 0 || state2 == 3)){
            Console.WriteLine("Yes");
        }
        else{
            Console.WriteLine("No");
        }
    }
    void getinput(){
        s = Console.ReadLine();
    }    
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    string S; cin >> S;

    vector<string> days = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    int day = 0;
    for (size_t i = 0; i < days.size(); ++i) {
        if (S == days[i]) day = (int)i + 1;
    }
    cout << day;
}

signed main() {
    solve();
    return 0;
}   

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[20][2];

signed main() {
    string s; cin >> s;
    int N = s.length();

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    rep(i,0,N) rep(k,0,2) {
        int lim = k ? 9 : (s[i] - '0');
        repq(x,0,lim) {
            if(dp[i][k] == -1) continue;
            chmax(dp[i+1][k || (x < lim)], dp[i][k] + x);
        }
    }
    cout << max(dp[N][0], dp[N][1]) << endl;
    return 0;
}

Measured memory_bytes: 256
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
X=(B1-A1)*T1
Y=(B2-A2)*T2
if X>0:
    X=-X
    Y=-Y
if X+Y<0:
    print(0)
elif X+Y==0:
    print("infinity")
else:
    A=(-X)//(X+Y)
    B=(-X)%(X+Y)
    if B!=0:
        print(2*A+1)
    else:
        print(2*A)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll k, x;
    cin >> k >> x;
    vector<ll>ans;
    for(ll i = -1000000; i <= 1000000; i++){
        if(abs(x - i) < k)ans.push_back(i);
    }
    for(ll i = 0; i < ans.size(); i++){
        cout << ans[i];
        if(i + 1 == ans.size())cout << endl;
        else cout << " ";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
   cin>>a>>b;
   int c=a*b;
   if(1*c%2!=0 || 2*c%2!=0 || 3*c%2!=0 )
    cout<<"Yes";
   else 
    cout<<"No";
} 

Measured memory_bytes: 3636
n=int(input())
s,p=10**100,10**100
t,q=-1000000000000,-1000000000000

for i in range(n):
  x,y=map(int,input().split())
  s=min(s,x+y)
  t=max(t,x+y)
  p=min(p,x-y)
  q=max(q,x-y)
  
print(max(t-s,q-p))


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    ll n, k;cin>>n>>k;
    vll a(n);
    ll s = 0;
    rep(i, n){
        cin>>a[i];
        s += a[i];
    }
    vll y;
    for(ll i = 1;i<=sqrt(s);i++){
        if(s%i==0){y.push_back(i);y.push_back(s/i);}
    }
    sort(all(y), greater<ll>());
    vll am(n);
    vll wa(n+1, 0);
    rep(i, y.size()){
        rep(j, n){
            am[j] = a[j] - y[i]*(ll)(a[j]/y[i]);
        }
        sort(all(am));
        rep(j, n){
            wa[j+1] = wa[j]+am[j];
        }
        debug("test %d\n", y[i]);
        rep(j, n+1){
            if( ( wa[j]-(y[i]*(n-j)-(wa[n]-wa[j])) )%y[i]==0 && wa[j]<=k&& (y[i]*(n-j)-(wa[n]-wa[j]))<=k){
                cout << y[i] << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long f(long long a) {
    long long b, c;
    b = a/2;
    if (a%2) b++;
    if (b%2) c = 1; else c = 0;
    if (a%2 == 0) c ^= a;
    return c;
}

int main(void) {
    long long A, B, C, X;
    scanf("%lld%lld", &A, &B);

    if (A == 0) printf("%lld\n", f(B));
    else printf("%lld\n", f(A-1) ^ f(B));
    return 0;
}



Measured memory_bytes: 128
a,b = gets.split.map(&:to_i)

c = gets.split.map(&:to_i)
d = c.length

e = c.sort
attack = 0

if b >= d 
  attack = 0
else
  for num in 0..d-b-1 do
    attack += e[num]   
  end
end
puts attack

Measured memory_bytes: 19312
#062_C
h,w=map(int,input().split())
if (h*w)%3==0:
    print(0)
else:
    #縦or横3分割
    ans=min(h,w)
    #縦→横or横→縦
    for x in [h//3,h//3+1]:
        ans=min(ans,max(x*w,(h-x)*(w//2),(h-x)*(w-w//2))-min(x*w,(h-x)*(w//2),(h-x)*(w-w//2)))
    for y in [w//3,w//3+1]:
        ans=min(ans,max(y*h,(w-y)*(h//2),(w-y)*(h-h//2))-min(y*h,(w-y)*(h//2),(w-y)*(h-h//2)))
    print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll MOD = 998244353;

class Combination {
public:
    Combination(ll max_num) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        for (ll i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % MOD;
            inv_fact_[i] = MODpow(fact_[i], MOD - 2);
            assert(fact_[i] * inv_fact_[i] % MOD == 1);
        }
    }
    ll operator()(ll n, ll m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % MOD * inv_fact_[m] % MOD;
    }
private:
    ll MODpow(ll n, ll m) const {
        ll result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= MOD;
            }

            m /= 2;
            n *= n;
            n %= MOD;
        }

        return result;
    }

    vector<ll> fact_, inv_fact_;
} comb(3e6);

//サイズがnの非負整数配列で総和がsであり奇数の要素がm個以下であるものの場合の数
ll f(ll n, ll s, ll m) {
    ll result = 0;

    //奇数の数を全探索
    for (ll a = s % 2; a <= min(n, m); a += 2) {
        //まず奇数になるところを決める
        ll curr_num = comb(n, a);

        //上で選んだ箇所に1を入れたとする
        //残りs - aをn個の要素にそれぞれ偶数となるように分ければ良い
        //そのような分け方は結局(s - a) / 2をn個に分ける
        //要素と仕切りのやつ
        (curr_num *= comb((s - a) / 2 + n - 1, n - 1)) %= MOD;

        (result += curr_num) %= MOD;
    }

    return result;
}

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

    //最大値が2Mを超えないという条件を無視した数
    ll ans = f(N, 3 * M, M);

    //最大値が2Mを超えるものの数を引く
    //  2Mを超えるのは1箇所。その1箇所が左端として、そこから2Mを引いた配列を考える
    //  その配列はN要素で合計がMで奇数がM個以下
    //  しかし左端が0になってはいけないのでN - 1要素で合計Mで奇数がM個以下となるものを引く
    ll illegal = (f(N, M, M) + MOD - f(N - 1, M, M)) % MOD;

    //2Mを超えるものがどこに来るかはN通りあり得るのでN倍する
    (ans += MOD - N * illegal % MOD) %= MOD;

    cout << ans << endl;
}

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

int main()
{
    int a,p;
    int sum = 0;

    cin >> a >> p;

    while(a > 0){
        p += 3;
        a -= 1;
    }

    while(p > 1){
        sum += 1;
        p -= 2;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	if resolve(parseProblem()) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func parseProblem() (int, []task) {
	n := scanInt(sc)
	result := make([]task, n)
	for i := 0; i < n; i++ {
		result[i] = task{
			take:  scanInt(sc),
			limit: scanInt(sc),
		}
	}
	return n, result
}

type task struct{ take, limit int }
type tasks []task

func (t tasks) Len() int {
	return len(t)
}

func (t tasks) Less(i, j int) bool {
	return t[i].limit < t[j].limit
}

func (t tasks) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}

func resolve(n int, ts []task) bool {
	sort.Sort(tasks(ts))
	sum := 0
	for _, t := range ts {
		sum += t.take
		if t.limit < sum {
			return false
		}
	}
	return true
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 7784
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, l, h, w, ans = 1e9;
  scanf("%lld%lld%lld", &h, &w, &k);
  char s[h][w + 10];
  ll sum[h][w + 1];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  for(i = 0; i < h; ++i) {
    sum[i][0] = 0;
    for(j = 0; j < w; ++j) sum[i][j + 1] = sum[i][j] + s[i][j] - '0';
  }
  for(i = 0; i < (1 << (h - 1)); ++i) {
    ll now = 0, t = 0, cnt;
    bool b;
    for(j = 0; j < h - 1; ++j) if((i >> j) & 1) ++now;
    for(j = 0; j < w; ++j) {
      b = false;
      cnt = 0;
      for(l = 0; l < h; ++l) {
        cnt += sum[l][j + 1] - sum[l][t];
        if(cnt > k) b = true;
        if((i >> l) & 1) cnt = 0;
      }
      if(b) {
        if(t == j) now = 1e9;
        else now++;
        t = j;
      }
    }
    if(now < ans) ans = now;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
package main

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

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	d := make([]int, n)
	for i := range d {
		sc.Scan()
		d[i], _ = strconv.Atoi(sc.Text())
	}

	sort.Ints(d)
	if d[n/2-1] == d[n/2] {
		fmt.Println(0)
		return
	}
	fmt.Println(d[n/2] - d[n/2-1])
}


Measured memory_bytes: 2048
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    const P: i64 = 1000000007;
    const L: usize = 100010;

    let mut f: Vec<i64> = vec![0; L];

    f[0] = 1;
    f[1] = 1;
    for i in 2..L {
        f[i] = (f[i-1] * (i) as i64) % P;
    }

    let (n, m) = get!(i64, i64);
    if (n-m).abs() > 1 {
        println!(0);
        return;
    }
    if n == m {
        println!("{}", f[n as usize] * f[m as usize] % P * 2 % P);
    } else {
        println!("{}", f[n as usize] * f[m as usize] % P);
    }
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int K,T;
    cin >> K >> T;
    int A[T];
    rep(i,T) cin >> A[i];
    sort(A,A+T,greater<int>());
    int maxi=A[0];
    int rem=accumulate(A,A+T,0);
    rem-=A[0];
    if(maxi<=rem+1) cout << 0 << endl;
    else cout << maxi-rem-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

vector<pair<int,int>> v[4];

int f(char c){
	if(c=='R')return 0;
	if(c=='U')return 1;
	if(c=='L')return 2;
	return 3;
}

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int x,y; char s;
	for(int i=0;i<n;i++){
		cin >> x >> y >> s;
		v[f(s)].push_back(make_pair(x,y));
	}
	int res=2e9;
	for(int i=0;i<4;i++){
		for(int j=i+1;j<4;j++){
			int vx=dx[i]-dx[j],vy=dy[i]-dy[j];
			vector<pair<pair<int,int>,int>> vv;
			for(auto p:v[i]){
				vv.push_back(make_pair(make_pair(p.first*vy-p.second*vx,p.first*vx+p.second*vy),0));
			}
			for(auto p:v[j]){
				vv.push_back(make_pair(make_pair(p.first*vy-p.second*vx,p.first*vx+p.second*vy),1));
			}
			sort(vv.begin(), vv.end());
			for(int k=0;k<vv.size();){
				int id=k;
				while(k<vv.size()&&vv[id].first.first==vv[k].first.first){
					k++;
				}
				int r=2e9;
				for(int t=id;t<k;t++){
					if(vv[t].second==0){
						r=vv[t].first.second;
					}
					else if(r!=2e9){
						res=min(res,(vv[t].first.second-r)*10/(vx*vx+vy*vy));
					}
				}
			}
		}
	}
	if(res==2e9){
		printf("SAFE\n");
	}
	else{
		printf("%d\n",res);
	}
}


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

int main(void) {
	
	char S[3];
	int ret = 700;
	cin >> S;

	for(int i=0; i<3; i++)
		if(S[i] == 'o') {
			ret += 100;
		}
	cout << ret;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	
int main(){
	lli N,K,i,p,inf,sup,tot=0;
	cin>>N;
	for(i=1;i<=N;i++){
		if(i%3==0||i%5==0)continue;
		tot+=i;
	}
	cout<<tot;
}

Measured memory_bytes: 3124
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<stack>

using namespace std;

int main() {
	int a, b;
	char op;
	vector<int> ans;
	while (cin >> a >> op >> b) {
		if (op == '?')break;
		switch (op){
		case '+':
			ans.push_back(a + b);
			break;
		case '-':
			ans.push_back(a - b);
			break;
		case '*':
			ans.push_back(a * b);
			break;
		case '/':
			ans.push_back(a / b);
			break;
		}
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
#include<set>
#include<algorithm>
using namespace std;
long long s[5];
int main()
{
	long long a, b, c, d, f;
	scanf("%lld %lld", &a, &b);
	c = a - b;
	d = a + b;
	f = a * b;
	s[0] = c;
	s[1] = d;
	s[2] = f;
	sort(s, s + 3);
	printf("%lld",s[2]);
	return 0;
}


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

int main() {
  int N, M, X;
  std::cin >> N;
  std::cin >> M;
  std::cin >> X;

  std::vector<int> A;
  A.resize(M);

  for(auto&& Ai : A)
    std::cin >> Ai;
    
  std::vector<bool> B;
  for(int i = 0; i < N+1; i++)
    B.push_back(std::find(std::cbegin(A), std::cend(A), i) != std::cend(A));
  
  const int sum1 = std::count_if(std::cbegin(B) + X, std::cend(B), [](auto x){ return x; });
  const int sum2 = std::count_if(std::cbegin(B), std::cbegin(B) + X, [](auto x){ return x; });
  
  std::cout << (sum1 < sum2 ? sum1 : sum2) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
// C以降はintじゃなくてllを使え
// これかな？は確証なくても5分で考えられなさそうなら出せ
// 極端なテストケースも試せ
int main(){
    ll N;
    cin >> N;
    vector<char> c(N);
    ll red=0;
    ll white=0;
    for(ll i=0; i<N; i++){
        cin >> c.at(i);
        if(c.at(i)=='R') red++;
        if(c.at(i)=='W') white++;
    }
    ll siro=0;
    for(ll i=0; i<red; i++){
        if(c.at(i)=='W') siro++;
    }
    cout << siro;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
//qsort(buf, sizeof(buf) / sizeof(*buf), sizeof(*buf), desc);
int main(){
  char s[100];
  scanf("%s",s);
  int size;
  size=strlen(s);
  for(int i=0;i<size;i++){
    printf("x");
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
A,B,C = map(int,input().split())

list = []
list.append(A)
list.append(B)
list.append(C)
list.sort()

if list[0] != 5:
    print('NO')
elif list[1] != 5:
    print('NO')
elif list[2] != 7:
    print('NO')
else:
    print('YES')


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

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

    rep(i, s.size()) if (i % 2 == 0) cout << s[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#include <ctime>
#define ff first
#define ss second
#define i1 fgvhdsjklfgh
#define j1 hvfdjsklfkgh
#define MAXN 1000005
#define INF 1000000000000000071LL
#define ll long long
#define int long long

using namespace std;

const int mod = 1000000007;
int n, m, d[MAXN], i;
vector <pair<int, int> > g[MAXN];
set <pair<int, int> > s;

void build(int v, int l, int r){
    int m = (l + r) / 2;

    if(l == r){
        g[v + n].push_back({l, 0});
        g[l].push_back({v + 5 * n, 0});
        return;
    }

    g[v * 2 + n * 5].push_back({v + 5 * n, 0});
    g[v * 2 + 1 + n * 5].push_back({v + 5 * n, 0});

    g[v + n].push_back({v * 2 + n, 0});
    g[v + n].push_back({v * 2 + 1 + n, 0});

    build(v * 2, l, m);
    build(v * 2 + 1, m + 1, r);
}

vector<int> pr;

void upd(int v, int tl, int tr, int l, int r, int x){
    int m = (tl + tr) / 2;

    if(l > r)
        return;

    if(tl == l && tr == r){
        //cout << "$$$" << v + 5 * n<< " " <<x << endl;
        pr.push_back(v);
        return;
    }

    upd(v * 2, tl, m, l, min(r, m), x);
    upd(v * 2 + 1, m + 1, tr, max(l, m + 1), r, x);
}

main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("terminator.in", "r", stdin);
    //freopen("terminator.out", "w", stdout);

    cin >> n >> m;

    build(1, 0, n - 1);

    for(i = 0; i < m; i++){
        int l, r, x;

        cin >> l >> r >> x;
        l--; r--;

        pr.clear();

        upd(1, 0, n - 1, l, r, x);

        for(int i1 = 0; i1 < pr.size(); i1++){
            for(int j1 = 0; j1 < pr.size(); j1++)
                g[pr[i1] + 5 * n].push_back({pr[j1] + n, x});
        }
    }

    fill(d, d + 9 * n, INF);
    d[0] = 0;

    s.insert({d[0], 0});

    while(!s.empty()){
        int v = s.begin() -> ss;
        s.erase(s.begin());

        if(v == n - 1){
            cout << d[n - 1];
            return 0;
        }

        for(i = 0; i < g[v].size(); i++){
            int to = g[v][i].ff, cost = g[v][i].ss;

            if(d[to] > d[v] + cost){
                s.erase({d[to], to});

                d[to] = d[v] + cost;

                s.insert({d[to], to});
            }
        }
    }

    cout << -1;

    return 0;
}





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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[500005];

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    memset(A, 0, sizeof(A));
    ll t = 0;
    REP(i, N) {
        A[i] = t;
        if (S[i] == '<')
            t++;
        else
            t = 0;
    }
    A[N] = t;
    t = 0;
    for (ll i = N; i > 0; --i) {
        A[i] = std::max(A[i], t);
        if (S[i - 1] == '>')
            t++;
        else
            t = 0;
    }
    A[0] = std::max(t, A[0]);

    ll ans = 0;
    REP(i, N + 1) {
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4740
# https://stackoverflow.com/questions/29194588/python-gcd-for-list

from math import gcd
from functools import reduce
from itertools import combinations

K = int(input())

def find_gcd(list):
    x = reduce(gcd, list)
    return x
  
s = 0
for i in range(3):
    if i == 0:
        s += sum(map(find_gcd, combinations(range(1, K + 1), i + 1)))
    else:
        s += sum(map(find_gcd, combinations(range(1, K + 1), i + 1))) * 6
print(s)

Measured memory_bytes: 9616
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const LL mod=998244353;
const int MAXN=205;
LL pow_mod(LL a,int b)
{
	LL ret=1;
	while(b)
	{
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ret;
}
void dl(LL &x,LL y){x-=y;if(x<0)x+=mod;}
void ad(LL &x,LL y){x+=y;if(x>=mod)x-=mod;}
struct pt{int x,y;}w[MAXN];
int n;
int multi(int p0,int p1,int p2)
{
	int u1=w[p0].x-w[p1].x;
	int u2=w[p0].x-w[p2].x;
	int v1=w[p0].y-w[p1].y;
	int v2=w[p0].y-w[p2].y;;
	return u1*v2-u2*v1;
}
bool ok(int u1,int u2)
{
	for(int i=1;i<u2;i++)if(i!=u1){if(!multi(u1,u2,i))return false;}
	return true;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)w[i].x=read(),w[i].y=read();
	LL ans=(pow_mod(2LL,n)-1+mod)%mod;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(ok(i,j))
	{
		int cnt=2;
		for(int k=j+1;k<=n;k++)if(!multi(i,j,k))cnt++;
		LL sum=(pow_mod(2,cnt)-(cnt+1)%mod+mod)%mod;
		dl(ans,sum);
	}
	pr2((ans-n+mod)%mod);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long Max=1, Min=1E9, n, in;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> in;
    Max = max(Max, in);
    Min = min(Min, in);
  }
  cout << Max - Min << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll A, B;

signed main()
{
    cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) { printf("Possible\n"); }
    else { printf("Impossible\n"); }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunused-result"

#include <cstdio>
#include <numeric>
 
int const N = 1000001;
 
int spf[N], u[N], s[17], d, i, j, k;
char const *r = "pairwise";
 
int main() {
    while (++i < N) spf[i] = i;
    for (i = 2; i * i < N; i++)
        for (j = i * i; j < N; j += i)
            if (spf[j] == j) spf[j] = i;
    for (scanf("%*d"); ~scanf("%d", &j);) {
        d = std::gcd(d, j);
        for (; j > 1; j /= i)
            if (u[s[k++] = i = spf[j]]) r = "setwise";
        while (k) u[s[--k]] = 1;
    }
    printf("%s coprime\n", d > 1 ? "not" : r);
    return 0;
}


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

long calcNumOfCombination(long n, long r)
{
    long num = 1;
    for (int i = 1; i <= r; i++)
    {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main()
{
    int i, j, n;
    long res = 0;
    cin >> n;

    string input[n], l;

    // 標準入力
    while (cin >> l)
    {
        input[i] = l;
        i++;
        if (i >= n)
        {
            break;
        }
    }

    for (i = 0; i < n; i++)
    {
        sort(input[i].begin(), input[i].end());
    }

    sort(input, input + n);

    string checked = "";
    long cou = 0;
    for (i = 0; i < n; i++)
    {
        if (checked != "" && input[i] == checked)
        {
            continue;
        }

        for (j = i + 1; j < n; j++)
        {
            if (input[i] == input[j])
            {
                // ++res;
                ++cou;
            }
            else
            {
                break;
            }
        }

        if(cou > 1) {
            res += calcNumOfCombination(cou + 1, 2);
        } else {
            res += cou;
        }

        checked = input[i];
        cou = 0;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 7296
from collections import Counter
import sys
s = input()
n = len(s)

b = Counter(s)
c = list(b)
ssc = []
for i in range(n):
    ssc.append(s[i])

ans = 114514191933-4

if len(b) == 1:
    print(0)
    sys.exit()

for l in c:
    a = 0
    s2 = ssc
    ss = []
    for i in range(n-1):
        k = len(s2)
        for j in range(k-1):
            if s2[j] == l or s2[j+1] == l:
                ss.append(l)
            else:
                ss.append(s2[j+1])
                
        d = Counter(ss)
        if d[l] == k-1:
            ans = min(n-len(ss),ans)
            break
            
        s2 = ss
        ss = []
    
print(ans)

Measured memory_bytes: 42096
#include <iostream>
#include <string>
#define foor for(int i=0;i<n;i++)
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define ic int a;cin>>a;
#define ic2 ic int b;cin>>b;
#define ic3 ic2 int c;cin>>c;
int s = 0;
using namespace std;
int main() {
	char a; cin >> a;
	a++;
	cout << a << endl;
}

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

const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << " ";
  cout << endl;
}

int main() {
  int a;
  cin >>a ;
  cout << a + a*a + a*a*a <<endl;
}


Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int en = sc.nextInt();
    int gohyaku = en/500;
    int temp = en%500;
    int goen = temp/5;
    int ans = (gohyaku*1000)+(goen*5);
    System.out.println(ans);
  }
}

Measured memory_bytes: 24148
# coding: UTF-8
# ???????????´??° a, b ?????????????????§???a ??¨ b ?????§?°???¢??????????????????????????°?????????????????????????????????

a, b = map(int, raw_input().split())

if a < b:
	print "a < b"
elif a > b:
	print "a > b"
else:
	print "a == b"

Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define N 100009

int dp[N], arr[109];

int main()
{
    int n, k;
    cin >> n >> k;
    int mn = INT_MAX;
    for(int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        mn = min(mn, arr[i]);
    }
    //memset(dp, -1, sizeof(dp));
    for(int i = 0; i <= k; i++)
    {
        if(i < mn) dp[i] = 0;
        for(int j = 1; j <= n; j++) if(i + arr[j] <= k)  dp[i + arr[j]] = dp[i + arr[j]] | (dp[i] ^ 1);
    }
    cout << (dp[k]? ("First\n") : ("Second\n")) << endl;
}



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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        int n;
        cin>>n;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        sort(a.begin(),a.end());
        ll total=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int k=j+1;
                int l=lower_bound(a.begin(),a.end(),a[i]+a[j])-a.begin();
                total+=max(0,l-k);
            }
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define en '\n'
#define out(x) cout << (x) << en
#define yes cout << "YES" << en
#define no  cout << "NO" << en
#define mems(arr,VAL)     memset(arr,VAL,sizeof(arr))
#define ll long long
#define vll vector<ll>
#define fo(i, a, b) for(ll i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpll vector<pll>
#define vplll vector<plll>
#define lbnd lower_bound
#define ubnd upper_bound
#define bs   binary_search
#define mi map<ll,ll>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define tle 1000000007

ll dp[3001][3001];
string s,l;

ll lcs(ll n,ll m){
  if(n==0|| m==0){
    return 0;
  }
  if(dp[n][m]==-1){
  //fo(i,0,s.length()){
    if(s[n-1]==l[m-1])
    dp[n][m]=(1+lcs(n-1,m-1));
    else
    dp[n][m]=max(lcs(n,m-1),lcs(n-1,m));
  }
  return dp[n][m];
  //}
}

void solve(){
  ll n,m,i,j,k,sum=0,flag=0,t,ans=0;

  // cin>>n>>m;
  cin>>s>>l;
  n=s.length();
  m=l.length();
  mems(dp,-1);
  ll index =lcs(n,m);
  //out(lcs(s,s1,n-1,m-1));
  //out(n);
  char lc[index+1];
  lc[index] = '\0';
   i =n; j =m;
   // out(s);
   while (i > 0 && j > 0)
   {
      if (s[i-1] == l[j-1])
      {
           //out(s);
          lc[index-1] = s[i-1];
          i--; j--; index--;
      }
      else if (dp[i-1][j] > dp[i][j-1] )
         i--;
      else
         j--;
   }
   out(lc);
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      int test=1;
      // cin>>test;
      while(test--){
          solve();
      }

    return 0;
}


Measured memory_bytes: 70912
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();

            int[][] S = new int[2][N];

            for(int i = 0 ; i< N ; i++){
                S[0][i] = sc.nextInt();
            }
            
            for(int i = 0 ; i< N ; i++){
                S[1][i] = sc.nextInt();
            }
        sc.close();

        int value = 0 ;
        int cost = 0 ;
        for(int i = 0 ; i < N ; i++){
            if(S[0][i] - S[1][i] > 0){
                value += S[0][i];
                cost += S[1][i];
            }
        }
        System.out.println(value-cost);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,ans=1,f=1,v=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            v=1;
    }
    if(v)
    {
        cout<< "0"<< "\n";
    }
    else
    {
         for(ll i=0;i<n-1;i++)
    {
         ans*=a[i];
         if(ans>(1000000000000000000)/a[i+1])
         {
             f=0;
             break;
         }
    }
    if(f)
    {
        ll dg=ans*a[n-1];
        cout<<dg;
    }

    else
        cout<<"-1";
    }

    return 0;
}


Measured memory_bytes: 4440
#include<stdio.h>
#include<string.h>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1000000000
int C,N,M,S,D,g1[101][101],s,t,c,d[11][101];
typedef struct P{int p,c,t;}P;
struct Order
{
	bool operator ()(P const& a, P const& b) const
	{
		return a.c>b.c;
	}
};

P tmp,tmp2;
priority_queue<P,vector<P>,Order>Q;
int main()
{
	for(;scanf("%d%d%d%d%d",&C,&N,&M,&S,&D),N;)
	{
		for(int i=0;i<=N;i++)
			for(int j=0;j<=N;j++)
				g1[i][j]=INF;
		for(int i=0;i<=C;i++)
			for(int j=0;j<=N;j++)
				d[i][j]=INF;
		for(int i=0;i<M;i++)
		{
			scanf("%d%d%d",&s,&t,&c);
			if(g1[s][t]>c)
				g1[s][t]=g1[t][s]=c;
		}
		d[C][S]=0;
		tmp.c=0;tmp.p=S;tmp.t=C;
		Q.push(tmp);
		for(;!Q.empty();)
		{
			tmp=Q.top(),Q.pop();
			for(int i=0;i<=N;i++)
			{
				int nc=tmp.c+g1[tmp.p][i];
				if(d[tmp.t][i]>nc)
				{
					tmp2.c=d[tmp.t][i]=nc;
					tmp2.p=i;
					tmp2.t=tmp.t;
					Q.push(tmp2);
				}
				nc=tmp.c+g1[tmp.p][i]/2;
				if(tmp.t>0&&d[tmp.t-1][i]>nc)
				{
					tmp2.c=d[tmp.t-1][i]=min(d[tmp.t][i],nc);
					tmp2.p=i;
					tmp2.t=tmp.t-1;
					Q.push(tmp2);
				}
			}
		}
		printf("%d\n",d[0][D]);
	}
}

Measured memory_bytes: 1172
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000007
using namespace std;
inline void Add(int& a,int b)
{
	a=(a+b)%mod;return;
}
int need1[25],need2[25],put[1048580],f[1048580];
int go[1048580][25];
int main(void)
{
	int i,j,S,a,b,c,n,m,k,ans=0;
	scanf("%d%d%d",&n,&m,&k);--n;
	for(i=1;i<=k;++i)
	{
		scanf("%d%d%d",&a,&b,&c);--a;--b;
		need1[a]|=(1<<b);
		need2[a]|=(1<<b)*c;
	}
	memset(go,-1,sizeof(go));
	for(S=0;S<(1<<n);++S)
	{
		int id=0;
		for(i=0;i<n;++i)
		{
			if(S&(1<<i))
			{
				if(i>0&&!(S&(1<<(i-1))))go[S][id]=S^(1<<i)^(1<<(i-1));
				++id;
			}
		}
	}
	for(S=0;S<(1<<n);++S)
	{
		put[S]=-1;
		for(i=n-1;i>=0;--i)
		{
			if(S&(1<<i))continue;
			put[S]=S^(1<<i);
			break;
		}
	}
	f[0]=1;
	for(i=0;i<m;++i)
	{
		for(S=0;S<(1<<n);++S)Add(f[put[S]],f[S]);
		for(j=0;j<n;++j)
		{
			for(S=(1<<n)-1;S>=0;--S)Add(f[go[S][j]],f[S]);
		}
		for(S=0;S<(1<<n);++S)if((S&need1[i])!=need2[i])f[S]=0;
	}
	for(S=0;S<(1<<n);++S)Add(ans,f[S]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 110848