akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

  char c;
  std::cin >> c;
  c += 1;
  std::cout << c << '\n';
  return 0;

}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e4+10;
const int MOD = 1e9+7;

vii factorize(ll N) {
    vii res;
    ll n = N;
    for (ll p = 2; p*p <= n; p++) {
        if (N%p != 0) continue;
        int count = 0;
        while (N%p == 0) {
        count++;
        N /= p;
        }
        res.push_back(make_pair(p, count));
    }
    if (N != 1) res.push_back(make_pair(N, 1));
    return res;
}

int pow_(ll n, ll k) {
    ll res = 1;
    while (k) {
        if (k&1) res = (res * n) % MOD;
        n = n * n % MOD;
        k >>= 1;
    }
    return res;
}

int inv(int n) {
    return pow_(n, MOD-2);
}

int N;
int A[MAX];
ll cnt[10][10];
map<ll, ll> lcm_map;
set<ll> primes;

int main() {
    cin >> N;
    REP (i, N) {
        cin >> A[i];
        FORE (f, factorize(A[i])) {
            ll p = f.first, cnt = f.second;
            lcm_map[p] = max(lcm_map[p], cnt);
            primes.insert(p);
        }
    }
    ll lcm = 1;
    for (auto iter = primes.begin(); iter != primes.end(); iter++) {
        int p = *iter;
        int cnt = lcm_map[p];
        REP (i, cnt) lcm = lcm * p % MOD;
    }

    ll ans = 0;
    REP (i, N) {
        ll b = lcm;
        FORE (f, factorize(A[i])) {
            ll p = f.first, cnt = f.second;
            b = b * inv(pow(p, cnt)) % MOD;
        }
        ans = (ans + b) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
w, h, c = gets.chomp.split
w, h = w.to_i, h.to_i
flag = Array.new(h)
flag[0] = flag[-1] = "+" + "-" * (w - 2) + "+"
1.upto(h - 2){|i| flag[i] = "|" + "." * (w - 2) + "|"}
flag[h / 2][w / 2] = c
flag.each{|f| puts f}


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

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

    int n;
    cin >> n;

    const int N = 1e6 + 2;
    vector<int> a(n), f(N);
    for(auto & aa : a){
        cin >> aa;
        f[aa]++;
    }

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

    int ct = 0;
    for(int i = n -1; i >= 0; i--){

        int x = a[i], g = 0;
        if(f[x] > 1 or (f[1] >= 1 and x != 1)) continue;
        if(x == 1 and f[1] > 1) continue;
        for(int j = 2; j * j <= x; j++){
            if(x % j == 0){
                auto it = lower_bound(a.begin(), a.begin() + i, j);
                if(it != a.end() and *it == j){
                    g = 1;
                    break;
                }
                 it = lower_bound(a.begin(), a.begin() + i, x/j);
                if(it != a.end() and *it == x/j){
                    g = 1;
                    break;
                }
            }
        }
        if( g == 1) continue;
        ct++;
    }

    cout << ct << "\n";

    return 0;
}


Measured memory_bytes: 7880
N,M,C=list(map(int,input().split()))
B=list(map(int,input().split()))
ac=0

for i in range(N):
  A=list(map(int,input().split()))
  D=0
  for j in range(M):
    D+=A[j]*B[j]
  D+=C
  if D>0:
    ac+=1
print(ac)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


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


void solve() {
    int N; cin >> N;
    vector<vector<int>> happy(N, vector<int>(3));
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> happy[i][j];
        }
    }

    vector<vector<int>> dp(N, vector<int>(3));

    for (int i = 0; i < 3; i++) {
        dp[0][i] = happy[0][i];
    }

    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    chmax(dp[i][j], dp[i-1][k] + happy[i][j]);
                }                
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        chmax(ans, dp[N-1][i]);
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 100100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int N,M;
string s;
ModInt dp[5010][5010];
int main(){
	init();
	cin >> N;
	cin >> s;
	M = s.size();
	dp[0][0]=ModInt(1ll);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			dp[i+1][max(j-1,0)]+=dp[i][j];
			dp[i+1][j+1]+=dp[i][j]*ModInt(2ll);
		}
	}
	cout << dp[N][M]*pow(pow(ModInt(2ll),M),MOD-2ll) << endl;
    return 0;
}


Measured memory_bytes: 198784
#include<iostream>
using namespace std;
int main(){
    int n,A[100];
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=n-1;i>=0;i--){
        if(i!=n-1)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int i = 0;
    if(S.contains("E") && !S.contains("W")) {
      i = 1;
    }
    if(S.contains("N") && !S.contains("S")) {
      i = 1;
    }
    if(!S.contains("E") && S.contains("W")) {
      i = 1;
    }
    if(!S.contains("N") && S.contains("S")) {
      i = 1;
    }
    if(i==0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35608
a = int(input())
b = [int(s) for s in input().split()]
su = sum(b) - b[a-1]
ar = b[a-1]
ans = abs(su - ar)

for i in range(2, a-1):
  su = su - b[a-i]
  ar = ar + b[a-i]
  tmp = abs(su - ar)
  if tmp < ans:
    ans = tmp
  tmp = 0

print(ans)


Measured memory_bytes: 31396
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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 void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
long dp[32];
inline void solve(void){
  dp[0]=1;
  dp[1]=1;
  dp[2]=2;
  up(i,3,30){
    dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
  }
  int n;
  while(cin>>n,n){
    cout<<((dp[n]+9)/10+364)/365<<endl;
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}



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

template<typename T, class F, const T I>
struct SegmentTree {
    const F op;
    int n; vector<T> dat;
    SegmentTree() : op() {}
    SegmentTree(F f) : op(f) {}
    T operator [](int i) const { return dat[n + i]; }
    void build(const vector<T>& v) {
        int n_ = v.size(); init(n_); for (int i = 0; i < n_; ++i) dat[n + i] = v[i];
        for (int i = n - 1; i; --i) dat[i] = op(dat[i * 2], dat[i * 2 + 1]);
    }
    void init(int n_) { n = 1; while (n < n_) n *= 2; dat.assign(n * 2, I); }
    void update(int k, T v) { dat[k += n] = v; while (k /= 2) dat[k] = op(dat[k * 2], dat[k * 2 + 1]); }
    T query(int a, int b) {
        T vl = I, vr = I;
        for (int l = a + n, r = b + n; l < r; l /= 2, r /= 2) { if (l & 1) vl = op(vl, dat[l++]); if (r & 1) vr = op(dat[--r], vr); }
        return op(vl, vr);
    }
    template<class C> int find(int a, int b, C& check) const { return find(a, b, check, 1, 0, n); }
private:
    template<class C> int find(int a, int b, C& check, int k, int l, int r) const {
        if (!check(dat[k]) || r <= a || b <= l) return -1; else if (k >= n) return k - n;
        int m = (l + r) / 2; int vl = find(a, b, check, k * 2, l, m);
        if (~vl) return vl; else return find(a, b, check, k * 2 + 1, m, r);
    }
};

template<typename T> struct min_of { constexpr T operator ()(T& lhs, T& rhs) const { return min(lhs, rhs); } };
constexpr int identity = INT32_MAX;

using ST = SegmentTree<int, min_of<int>, identity>;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> com(q), x(q), y(q);
    for (int i = 0; i < q; ++i) cin >> com[i] >> x[i] >> y[i];

    ST rmq;
    rmq.build(vector<int>(n, INT32_MAX));
    for (int i = 0; i < q; ++i) {
        if (com[i]) cout << rmq.query(x[i], y[i] + 1) << endl;
        else rmq.update(x[i], y[i]);
    }
}


Measured memory_bytes: 5404
a, b, c, k = map(int, input().split())

# 合計の金額
wa = 0
# 残機
res = k


if res > 0:
    wa += min(res, a)
    res -= min(res, a)

if res > 0:
    res -= min(res, b)
    
if res > 0:
    wa -= res

print(wa)

Measured memory_bytes: 9128
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

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

    for(int i=0;i<n;i++){
        if(a[i]%2 == 0){
            if(!(a[i]%3 == 0 || a[i]%5 == 0)){
                printf("DENIED\n");
                return 0;
            }
        }
    }

    printf("APPROVED\n");
    return 0;
}

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

int main(void){
    int x=0;
    int temp;
    cin>>temp;
    x += temp*100;
    cin>>temp;
    x += temp*10;
    cin>>temp;
    x += temp;
    if (x%4) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    while(cin >> n >> k, n){
        ll s = 1, b = 1, x = 1;
        for (x = 1; x <= 10; ++x) {
            ll t = b*9*x;
            if(s+t > n) break;
            s += t; b *= 10;
        }
        ll o = (n-s)/x+b, p = (n-s)%x;
        string t;
        for (int i = o; i < o+100; ++i) {
            t += to_string(i);
        }
        cout << t.substr(p, k) << "\n";
    }
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
ll gr, gs, gp;
string t;

int r = 0, s = 1, p = 2;

ll dp[MAX_N][3];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  scanf("%d %d %d", &gr, &gs, &gp);

  cin >> t;

  for (int i = 0; i < n; ++i) {
    if (i < k) {
      if (t[i] == 'r') {
        dp[i][r] = 0LL;
        dp[i][s] = 0LL;
        dp[i][p] = gp;
      } else if (t[i] == 's') {
        dp[i][r] = gr;
        dp[i][s] = 0LL;
        dp[i][p] = 0LL;
      } else if (t[i] == 'p') {
        dp[i][r] = 0LL;
        dp[i][s] = gs;
        dp[i][p] = 0LL;
      }
    } else {
      if (t[i] == 'r') {
        dp[i][r] = max(dp[i - k][s], dp[i - k][p]) + 0LL;
        dp[i][s] = max(dp[i - k][r], dp[i - k][p]) + 0LL;
        dp[i][p] = max(dp[i - k][r], dp[i - k][s]) + gp;
      } else if (t[i] == 's') {
        dp[i][r] = max(dp[i - k][s], dp[i - k][p]) + gr;
        dp[i][s] = max(dp[i - k][r], dp[i - k][p]) + 0LL;
        dp[i][p] = max(dp[i - k][r], dp[i - k][s]) + 0LL;
      } else if (t[i] == 'p') {
        dp[i][r] = max(dp[i - k][s], dp[i - k][p]) + 0LL;
        dp[i][s] = max(dp[i - k][r], dp[i - k][p]) + gs;
        dp[i][p] = max(dp[i - k][r], dp[i - k][s]) + 0LL;
      }
    }
  }

  ll ans = 0;

  for (int i = 0; i < k; ++i) {
    ans += max(dp[n - 1 - i][r], max(dp[n - 1 - i][s], dp[n - 1 - i][p]));
  }

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

  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
左右のうち、短い方のロープを解く
ロープを解けなくなったらIMPOSSIBLE

3 2 1 1 2 3
*/

void solve(){
    ll n,len;
    cin >> n >> len;
    ll a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    ll l=0;
    ll r=n-1;
    //a[l]+...+a[r]を計算する必要がある
    //s[i]:a[0]+...+a[i]
    ll s[n+10];
    s[0]=a[0];
    for(ll i=1; i<n; i++){
        s[i]=s[i-1]+a[i];
    }
    //a[l]+...+a[r]=s[r]-a[l-1]
    //ただしl=0ならs[r]
    //番兵の配置が面倒なので

    string ans = "Possible";
    vector<ll> answer;
    while(r-l>0){
        ll sum;
        if(l==0) sum = s[r];
        else sum = s[r]-s[l-1];

        if(sum<len){
            ans = "Impossible";
            cout << ans << endl;
            return;
        }
        else{
            if(a[l]+a[l+1]>a[r]+a[r-1]){
                answer.emplace_back(r-1);
                r--;
            }
            else{
                answer.emplace_back(l);
                l++;
            }
        }
    }
    cout << ans << endl;
    rep(i,answer.size()){
        cout << answer[i]+1 << endl;
    }
}

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



Measured memory_bytes: 3316
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var arr = input.trim().split("\n");
var [n,a,b,c,d]=arr.shift().split(" ").map(Number);

var min = Infinity;
for(var i=0;i<=1000;i++)if(a*i>=n)min=Math.min(min,b*i);
for(var i=0;i<=1000;i++)if(c*i>=n)min=Math.min(min,d*i);
console.log(min);


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

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int   devnull;
  char  s[ 16 ];
  int   res[ 4 ] = { 0 };
  int   i;

  while ( scanf ( " %d,%s", &devnull, s ) == 2 )
  {
    ++res[ 1 * !strcmp ( s, "B" )
         + 2 * !strcmp ( s, "AB" )
         + 3 * !strcmp ( s, "O" ) ];
  }

  for ( i = 0; i < 4; ++i )
  {
    printf ( "%d\n", res[ i ] );
  }

  return ( 0 );
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int n;

int main() {
  cin >> n;
  int x, y;
  cin >> x >> y;
  x--;
  y--;

  VI ans(n, 0);
  int d;

  REP(i, n - 1) {
    FOR(j, i + 1, n - 1) {
      if (i <= x) {
        if (j <= x) {
          d = j - i;
        } else if (x <= j && j <= y) {
          d = min(j - i, x - i + 1 + y - j);
        } else if (y <= j) {
          d = x - i + j - y + 1;
        }
      } else if (x <= i && i <= y) {
        if (j <= y) {
          d = min(j - i, i - x + 1 + y - j);
        } else if (y <= j) {
          d = min(j - i, j - y + 1 + i - x);
        }
      } else {
        d = j - i;
      }
      ans[d]++;
      // cout << i << " " << j << " " << d << endl;
    }
  }

  FOR(k, 1, n - 1) {
    ANS(ans[k]);
  }

  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())

k = n*4

r = k-m

if(r == 0):
    print("Yes")
elif(r>0):
    if(r % 2 == 0 and r/2 <= n):
        print("Yes")
    else:
        print("No")
else:
    
    print("No")

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main() {
    ll n, m; cin >> n >> m;
    ll mod = 1000000007;
    int a[100003];
	FILL(a,0);
    REP(i,0,m) {
        int tmp; 
		cin>>tmp;
        a[tmp]=1;
    }
    int dp[100003]; 
    FILL(dp,0);
    dp[n] = 1;
    for(int i=n-1;i>=0;i--) {
        if (a[i] == 1) {
            continue;
        }
        dp[i]=0;
        dp[i]+=dp[i+1];
        dp[i]+=dp[i+2];
        dp[i]%=mod;
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 4416
sx,sy,tx,ty=map(int,input().split())
x = abs(tx-sx)
y = abs(ty-sy)
print("U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w,h,x,y,r;
    cin >>w>>h>>x>>y>>r;
    if(x>=r && w-x>=r && y >= r && h-y>=r)cout <<"Yes"<<endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    if(k>n)
    {
        if(k-n<n)
            cout<<k-n;
        else
            cout<<n;
        return 0;
    }

    if(n>=k)
        n=n%k;
    if(k>n)
    {
        if(k-n<n)
            cout<<k-n;
        else
            cout<<n;
    }
}


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

int main(){
 int n; cin >> n;
 vector< int > v(n);
 //vector< int > zi(n);
 int h_min = INT_MAX;
 int h_max = INT_MIN;
 for(int i = 0; i < n; ++i){
   cin >> v[i];
   h_min = min(h_min,v[i]);
   h_max = max(h_max,v[i]);
 }
 //cout << h_min << ' ' << h_max << '\n';
 int ans = h_min;
 int count = h_min;
 bool flag = false;  
 for(int i = h_min; i <=  h_max; ++i){
  flag = false;
  for(int j = 0; j < n; ++j){
    if(v[j] - count > 0){
      if(!flag) ans++;
      flag = true;
    }
    else flag = false;
  }
   count++;
 }
 cout << ans << '\n';
}

Measured memory_bytes: 3576
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int r,a,b,c,i=10;
	scanf("%d %d",&a,&b);
	while(b>=i) i*=10;
	c=a*i+b;
	//printf("%d %d %d %d",i,a,b,c);
	r=sqrt(c);
	if(r*r==c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
	int h,n;
  	cin >> h >>n;
  	vector<int>a(n);
  	for(int i=0;i<n;i++){
      cin >> a.at(i);
    }
  	int sum=0;
    for(int i=0;i<n;i++){
       sum += a.at(i);
    }
    if(h <=sum) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
}

Measured memory_bytes: 640
def main():
    a, b, c = map(int, input().split())

    if c - a - b <= 0:
        print("No")
    else:
        if 4*a*b < (c - a - b)**2:
            print("Yes")
        else:
            print("No")
    
if __name__ == "__main__":
    main()

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

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

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

  int n = S.size();
  rep(i, n){
    cout << "x";
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    char[] c = s.toCharArray();
    
    if(c[0]==c[1]&&c[2]==c[3]&&c[0]!=c[2]) {
      System.out.println("Yes");
    } else if(c[0]==c[2]&&c[1]==c[3]&&c[0]!=c[1]) {
      System.out.println("Yes");
    } else if(c[0]==c[3]&&c[1]==c[2]&&c[0]!=c[1]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
      
    
    
  }
}


Measured memory_bytes: 23124
n,k = map(int,input().split())
r,s,p = map(int,input().split())
tl = list(input())
ansl = []

for i in range(n):
    if i - k < 0:
        ansl.append(1)
    else:
        if ansl[i-k] == 1 and tl[i] == tl[i-k]:
            ansl.append(0)
        else:
            ansl.append(1)

ans = 0
for t,a in zip(tl, ansl):
    if a == 1:
        if t == "r":
            ans += p
        if t == "s":
            ans += r
        if t == "p":
            ans += s

print(ans)



Measured memory_bytes: 50060
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
typedef double db;
const int N=1e6+7;
vector<int> tu[N];

int n,fa[N],dep[N],col[N],cnt=0;
void dfs(int x){
	dep[x]=dep[fa[x]]+1;
	for(int i=0;i<tu[x].size();i++){
		int v=tu[x][i];
		if(v!=fa[x]){
			fa[v]=x;
			dfs(v);
		}
	}
}
void dfs2(int x){
	if(col[x])return;
	col[x]=1,cnt++;
	for(int i=0;i<tu[x].size();i++){
		int v=tu[x][i];
		if(v!=fa[x]){
			dfs2(v);
		}
	}
}
int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		tu[x].push_back(y);
		tu[y].push_back(x);
	}
	dfs(1);
	int len=(dep[n]-dep[1]-1)>>1,now=n;
	rep(i,1,len)now=fa[now];
	col[now]=1;
	dfs2(1);
	printf(cnt>n-cnt ? "Fennec\n" : "Snuke\n");
}

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

using namespace std;

typedef unsigned long long int ulli;

int main(){
	int n;
	cin >> n;
	int sum = 0;
	int min_ = 100;
	vector<int> v(n);
	for(int i = 0 ;  i <  n; i++){
		cin >> v[i];
		sum+= v[i];
		min_ = min(v[i],min_);
	}
	sum = round(1.0 * sum/n);
	ulli sum2 = 0;
	for(int i = 0; i <n; i++){
		sum2+= pow((sum - v[i]),2);
	}
	cout << sum2;
} 


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

int N, T, S;
int A[3002], B[3002];
int dp[3002][3002];

int main(){
  while(cin >> N >> T >> S){
    for(int i = 0; i < N; i++){
      cin >> A[i] >> B[i];
    }

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    for(int i = 0; i < N; i++){
      for(int j = 0; j <= T; j++){
        if(dp[i][j] == -1) continue;
        dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        if((S <= j || j + B[i] <= S) && j + B[i] <= T){
          dp[i + 1][j + B[i]] = max(dp[i + 1][j + B[i]], dp[i][j] + A[i]);
        }
      }
    }

    int ans = 0;

    //Challenge Succeeded : (i <= T)テつづδつづδ「テつづδァテつづδ暗つづつッテつづδェテつづδ偲つづδ暗つづδァテつづδ暗つづつ「テつづδ古つづδー(i < T)
    for(int i = 0; i <= T; i++){
      ans = max(ans, dp[N][i]);
    }

    /*
    for(int i = 0; i <= N ;i++){
      for(int j = 0; j <= T; j++){
        printf("%4d",dp[i][j]);
      }
      cout<<endl;
    }
    */

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int n,k,s[200005],ans=0;
int main(){
	cin>>n>>k;
	for(int i=1,x;i<=n;i++)cin>>x,s[i]=s[i-1]+x;
	for(int i=k;i<=n;i++)ans=max(ans,s[i]-s[i-k]);
	printf("%.10lf\n",1.0*(ans+k)/2);
}

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

using namespace std;

int main (){
int n,i;
cin>>n;
vector <int> a(n);
vector <int> b(n);
for(i=0;i<n;i++){
    cin>>a[i]>>b[i];
}
for(i=0;i<n-2;i++){
    if(a[i]==b[i]){
        if(a[i+1]==b[i+1]){
            if(a[i+2]==b[i+2]){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

}
cout<<"No"<<endl;
//system("pause");
return 0;
}



Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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; }

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>cnt(100015,0);
    rep(i,n) {
        cnt[a[i]]++;
    }
    int ans = 0;
    
    rep(i,n) {
        int initcnt = cnt[i];
        if(i == 0) {
            if(cnt[i+1]) cnt[i] += cnt[i+1];
            ans = max(ans,cnt[i]);
            cnt[i] = initcnt;
            continue;
        }

        if(cnt[i-1]>0 && cnt[i+1]>0) {
            cnt[i] += cnt[i-1]+cnt[i+1];
            ans = max(ans,cnt[i]);
        }    
        if(cnt[i-1] > 0 && cnt[i+1] == 0) {
            cnt[i] += cnt[i-1];    
            ans = max(ans,cnt[i]);
        }    
        if(cnt[i-1] == 0 && cnt[i+1] > 0) {
            cnt[i] += cnt[i+1];
            ans = max(ans,cnt[i]);
        }
        
        cnt[i] = initcnt;
    }
    if(n==1) {
        rep(i,100000) {
            ans = cnt[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<set>
#include<vector>
#include<cstdio>
#include<algorithm>
#define MAXN 200000+9
#define INF 0x7fffffff
using namespace std;

int n;
int num[MAXN],aloc[MAXN];
struct T{
	int ls,rs,left_range,right_range;
	int val[2];
}tree[MAXN<<1];
int cnt;
vector<int> vec[MAXN];
set<int> s;
int to[MAXN];

void update(int x){
	tree[x].val[0]=min(tree[tree[x].ls].val[0],tree[tree[x].rs].val[0]);
	tree[x].val[1]=min(tree[tree[x].ls].val[1],tree[tree[x].rs].val[1]);
}

int Build(int l,int r){
	int now=++cnt;
	tree[now].left_range=l;
	tree[now].right_range=r;
	if(l==r){
		tree[now].val[l&1]=num[l];
		tree[now].val[(l&1)^1]=INF;
		return now;
	}
	int mid=(l+r)>>1;
	tree[now].ls=Build(l,mid);
	tree[now].rs=Build(mid+1,r);
	update(now);
	return now;
}

int getnum(int k,int l,int r,int t){
	if(l<=tree[k].left_range && tree[k].right_range<=r){
		return tree[k].val[t];
	}
	int mid=(tree[k].left_range+tree[k].right_range)>>1;
	int re=INF;
	if(l<=mid) re=min(re,getnum(tree[k].ls,l,r,t));
	if(r>=mid+1) re=min(re,getnum(tree[k].rs,l,r,t));
	return re;
}

void DFS(int l,int r,int t,int f){
	int x=aloc[getnum(1,l,r,t)];
	int y=aloc[getnum(1,x,r,t^1)];
	vec[f].push_back(x);
	to[x]=y;
	if(l<x) DFS(l,x-1,t,f);
	if(x+1<y) DFS(x+1,y-1,t^1,x);
	if(r>y) DFS(y+1,r,t,f);
}

void solve(){
	DFS(1,n,1,0);
	int i;
	for(i=0;i<vec[0].size();i++){
		s.insert(num[vec[0][i]]);
	}
	for(i=1;i<=n/2;i++){
		int x=aloc[*s.begin()];
		s.erase(num[x]);
		printf("%d %d ",num[x],num[to[x]]);
		for(int j=0;j<vec[x].size();j++)
			s.insert(num[vec[x][j]]);
	}
	puts("");
}

int main(){
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&num[i]);
		aloc[num[i]]=i;
	}
	Build(1,n);
	solve();
	return 0;
}

Measured memory_bytes: 30840
#include <bits/stdc++.h>
#define lld long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define nmax 100005
using namespace std;
vector<pii>g[nmax];
set<int>st[nmax];
int n, x, y, k;
int ans[nmax];
void dfs(int k, int lst, int color){
    int col = 1;
    for (auto x:g[k]){
        if (x.first == lst){
            continue;
        }
        if (col == color){
            ++col;
        }
        ans[x.second] = col;
        dfs(x.first, k, col);
        ++col;
    }
}
int main()
{
    cin>>n;
    for (int i=1;i<n;++i){
        cin>>x>>y;
        g[x].pb(mp(y,i));
        g[y].pb(mp(x,i));
    }
    for (int i=1;i<=n;++i){
        k = max(k, (int)g[i].size());
    }
    dfs(1, -1, 0);
    cout<<k<<'\n';
    for (int i=1;i<n;++i){
        cout<<ans[i]<<'\n';
    }
    return 0;
}


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

int main()
{
    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    for(int i = 0; i < m; ++i) cin >> b[i];
    for(int i = 0; i < n; ++i){
        
        for(int j = 0; j < m; ++j){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; ++i){
        long long int d = 0;
        for(int j = 0; j < m; ++j){
            d += a[i][j]*b[j];
        }
        d += c;
        if(d > 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


tmp = []


def func(n):
    global tmp
    if n < 10**9:
        tmp.append(n)
        func(n*10+3)
        func(n*10+5)
        func(n*10+7)
    return tmp


N = int(input())
n = len(func(0))
func(0)
ans = 0
for i in range(n):
    if tmp[i] <= N:
        x = str(tmp[i])
        if ('3' in x) and ('5' in x)and('7' in x):
            ans += 1
print(ans)


Measured memory_bytes: 6008
n=int(input())
a=list(map(int,input().split()))
cost=[0]*(n)
for i in range(1, n):
  if i==1:
    cost[i]=abs(a[i]-a[i-1])
  else:
    cost[i]=min(cost[i-1]+abs(a[i]-a[i-1]), cost[i-2]+abs(a[i]-a[i-2]))
print(cost[-1])

Measured memory_bytes: 20680
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n, a[MAX];
  long long x = 0, y = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  sort(a, a+n, greater<int>());
  for(int i = 1; i < n; i++){
    if(a[i-1] == a[i]){
      if(!x){
        x = a[i];
        a[i] = 0;
      }else{
        y = a[i];
        break;
      }
    }
  }
  printf("%lld\n", x*y);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<std::string> s){
  map<string,ll> m;
  auto inc_m=[&m](string s){
    if(m.count(s)){
      ++m[s];
    }else{
      m[s]=1;
    }
  };
  REP(s.size()){
    sort(s[i].begin(),s[i].end());
    inc_m(s[i]);
  }
  ll ans=0;
  for (auto &&i : m)
  {
    ans+=i.second*(i.second-1)/2;
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 18176
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

N = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]
# add dummy
h = h + [INF, INF, INF]

# 足場iにいるときの最小コスト
dp = [INF] * (N+10)
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], abs(h[i] - h[i+1])+dp[i])
    dp[i+2] = min(dp[i+2], abs(h[i] - h[i+2])+dp[i])

print(dp[N-1])

Measured memory_bytes: 79032
#include <bits/stdc++.h>
#define f(x) (x)*(x)
using namespace std;
int n,a[100000],cnt,ans,tt=0x7fffffff;
int main()
{
    cin>>n;
    int mi=tt,ma=-tt;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
        if(a[i]<mi) mi=a[i];
        if(a[i]>ma) ma=a[i];
    }
    int t=cnt/n;
    for(int k=mi;k<=ma;k++)
    {
        ans=0;
        for(int i=1;i<=n;i++) ans+=f(a[i]-k);
        if(ans<tt) tt=ans;
    }
    cout<<tt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;

int n,a[MAXN],b[MAXN],fa[MAXN],siz[MAXN],s1,s2,c[MAXN],d[MAXN];
int Ans=0;
bool ban[MAXN];
map<int,int> mp;

int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}

int main()
{
	// freopen("duliu.in","r",stdin);
	// freopen("duliu.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s1^=a[i];
	for(int i=1;i<=n;i++) scanf("%d",&b[i]),s2^=b[i];
	for(int i=1;i<=n+1;i++) fa[i]=i,siz[i]=1;
	for(int i=1;i<=n;i++) ban[i]=a[i]==b[i];
	a[++n]=s1;b[n]=s2;
	for(int i=1;i<=n;i++)
		c[i]=a[i],d[i]=b[i];
	sort(c+1,c+1+n);sort(d+1,d+1+n);
	for(int i=1;i<=n;i++)
		if(c[i]!=d[i])
			return puts("-1"),0;
	for(int i=1;i<=n;i++)
	{
		if(ban[i]) continue;
		if(mp[a[i]]) fa[i]=fa[mp[a[i]]],siz[mp[a[i]]]++;
		else mp[a[i]]=i;
	}
	for(int i=1;i<=n-1;i++)
	{
		if(ban[i]) continue;
		int x=find(i),y=find(mp[b[i]]);
		if(x!=y)  fa[x]=y,siz[y]+=siz[x];
	}
	// for(int i=1;i<=n;i++) printf("%d %d\n",i,fa[i]);
	for(int i=1;i<=n;i++)
	{
		if(ban[i]) continue;
		if(fa[i]==i)
		{
			Ans+=siz[i];
			if(find(n)!=i) Ans++;
			else Ans--;
		}
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 8960
#include<iostream>
 
 using namespace std;
   
   
int main()
{   int a, b;
    cin>>a>>b;
	if (a<b) cout<<"a < b"<<endl;
	
	else if (a>b) cout<<"a > b"<<endl;
	
	else if (a==b) cout<<"a == b"<<endl;
}



Measured memory_bytes: 3080
import scala.io.StdIn
 
case class Expr(l:Int, op: String, r:Int)
 
object Main extends App {
    Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foreach{
      line =>
        if(line.trim.isEmpty == false){
            val Array(left, op, right) = line.split(" ")
            Expr(left.toInt, op, right.toInt) match {
                case Expr(l, "+", r) => println(l + r)
                case Expr(l, "-", r) => println(l - r)
                case Expr(l, "*", r) => println(l * r)
                case Expr(l, "/", r) => println(l / r)
                case _ =>
            }
        }
    }
}

Measured memory_bytes: 43772
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let d: i32 = read();
    println!(
        "{}",
        if (a - c).abs() <= d || ((a - b).abs() <= d && (b - c).abs() <= d) {
            "Yes"
        } else {
            "No"
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  string s;
  while(cin>>s)
  {
    if (s=="0") return 0;
    int ans = 0;
    rep(i,s.size())
    {
      ans+=s[i]-'0';
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

int N;
ll A[200002];
ll now_sum;
ll now_xor;
bool used[200002];
int k;


int main(){
    cin>>N;
    rep(i,N) cin>>A[i];
    now_sum=0;
    now_xor=0;
    ll ans=0;
    int r=1;
    rep(l,N){
        while((now_sum+A[r])==(now_xor^A[r])&&r<=N){
            now_sum+=A[r];
            now_xor^=A[r];
            r++;
            ans+=(r-l);
        }
        now_sum-=A[l];
        now_xor^=A[l];
    }
    cout<<ans<<endl;
    return 0;
}



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

int main() {
  ll x, n;
  cin >> x >> n;
  vector <bool> v(102, 1);
  rep(i, n) {
    ll a; cin >> a;
    v.at(a) = 0;
  }
  ll res = INF, loc;
  rep(i, 102) {
    if (v.at(i)) {
      if (abs(x-i) < res) {
        res = abs(x-i);
        loc = i;
      }
    }
  }
  cout << loc << endl;
}

Measured memory_bytes: 3628
fun main() {
    val (x, y) = nextIntList()
    println(x * y)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36372
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
 {
	int n;
    cin>>n;

    int A[n+1];
    for(int i=0;i<=n;i++) cin>>A[i];

    int B[n];
    for(int i=0;i<n;i++) cin>>B[i];
    int c = 0;
    for(int i=0;i<n;i++){
        if(A[i] >= B[i]){
            c += B[i];
            A[i] -= B[i];
            B[i] = 0;
        }
        else{
            c += A[i];
            B[i] -= A[i];
            A[i] = 0;
        }

        if(A[i+1] >= B[i]){
            c += B[i];
            A[i+1] -= B[i];
            B[i] = 0;
        }
        else{
            c += A[i+1];
            B[i] -= A[i+1];
            A[i+1] = 0;
        }
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X;
    cin >> X;
    ll l = 0, r = 1e9;
    while(r - l > 1) {
        ll m = (l + r) / 2;
        if(m * (m + 1) >= 2 * X) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    string s;cin>>s;
    string x,y;
    x="keyence";y=x;
    reverse(y.begin(),y.end());
    ll a=0,b=0;
    ll si=s.size();
    rep(i,0,6){
        if(s[i]==x[i])a++;
        else break;
    }
    rep(i,0,6){
        if(s[si-1-i]==y[i])b++;
        else break;
    }
    if(a+b>=7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}






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

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        long[][] c = new long[n][l];
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                b[i][j] = sc.nextInt();
            }
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    c[i][j] += a[i][k] * b[k][j];
                }
                System.out.print(c[i][j]);
                if (j < l - 1) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}



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

int main(){
    int n;
    cin >> n;
    vector<int> c(n+10, 0), s(n+10, 0), f(n+10, 0);
    for(int i = 1; i < n; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 1; i <= n; i++){
        int ans = 0;
        for(int j = i; j < n; j++){
            if(ans < s[j]){
                ans = s[j];
            }else if(ans % f[j] != 0){
                ans = f[j] * (ans/f[j] + 1);
            }
            ans += c[j];
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
  long long x, y;
  cin >> x >> y;
  long long ans=0;
  if(abs(x)<abs(y)){
    if(x<0){
      x*=-1;
      ans++;
    }
    ans += abs(y) - x;
    x += abs(y) - x;
  }
  else if(abs(x)>abs(y)){
    if(x>0){
      x*=-1;
      ans++;
    }
    ans += -abs(y)-x;
    x += -abs(y)-x;
  }
  if(x!=y)ans++;
  cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
swap_flg = True
i = 0
while swap_flg:
    swap_flg = False
    for j in range(N - 1, i, -1):
        if (arr[j] < arr[j - 1]):
            arr[j], arr[j - 1] = arr[j - 1], arr[j]
            swap_cnt += 1
            swap_flg = True
    i += 1

print(' '.join(map(str, arr)))
print(swap_cnt)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll f[100010],n,m,w[110],c[110];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>c[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+c[i]);
		}
	}
	cout<<f[m]<<endl;
	return 0;
}

Measured memory_bytes: 1024