akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N);
    REP(i, N){
        double x; cin >> x;
        A[i] = (int)(x * 1000000000 + 0.5);
    }
    //vdebug(A);

    mat cnt(19, vec(19, 0));
    int ans = 0;
    REP(i, N){
        int n2 = 0, n5 = 0;
        while(A[i] % 2 == 0){
            n2++;
            A[i] /= 2;
        }
        while(A[i] % 5 == 0){
            n5++;
            A[i] /= 5;
        }
        chmin(n2, 18LL); chmin(n5, 18LL);

        ans += cnt[18 - n2][18 - n5];

        REP(j, n2 + 1)  REP(k, n5 + 1) cnt[j][k]++;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 4692
n = int(input())
a = list(map(int, input().split())) 
a = tuple(a)
if a.count(1) == 0:
    print(-1)
else:
    s = 0
    t = 1
    for i in range(n):
        if a[i] == t:
            t += 1
        else: s += 1
    print(s)

Measured memory_bytes: 77516
import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
	}
	
	public static void A(Scanner sc) {
		String s = sc.next();
		out.println(s.substring(0,3) + 8 + s.substring(4,10));
	}
	
	public static void B(Scanner sc) {
		int N = sc.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i=0;i<N;i++) set.add(sc.nextInt());
		out.println(set.size());
	}
}


Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main() {
    long long K, N;
    cin >> K >> N;

    long long A1, Ai1, Ai2, max = 0;
    cin >> A1;
    Ai1 = A1;
    for (int i = 0; i < N - 1; ++i) {
        cin >> Ai2;
        if (max < Ai2 - Ai1) {
            max = Ai2 - Ai1;
        }
        Ai1 = Ai2;
    }
    if (max < K - Ai2 + A1) {
        max = K - Ai2 + A1;
    }

    cout << K - max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;

int ans, f[100];

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

  sort(f, f+n);
  for(int i = n; i > n-k-1; i--)ans += f[i];

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
C = [list(map(int, input().split())) for i in range(3)]
a1 = 0
b1 = C[0][0] - a1
b2 = C[0][1] - a1
b3 = C[0][2] - a1
a2 = C[1][1] - b2
a3 = C[2][2] - b3
As = [a1, a2, a3]
Bs = [b1, b2, b3]
for i in range(3):
    for j in range(3):
        if C[i][j] != As[i] + Bs[j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 9156
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,A,B; R(N,A,B);
    if(A*(LL)B<N)W(-1);
    else if(A+B>N+1)W(-1);
    else{
        int r=N;
        VI an;
        FOR(i,1,B){
            int use=min(A,r-(B-i));
            REP(j,use)an.PB(r-use+1+j);
            r-=use;
        }
        W(an);
    }
    return 0;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
 
void solve() {
  LL x;
  cin >> x;
  LL cur = 100, step = 0;
  while (cur < x) {
    cur += cur / 100;
    step++;
  }
  cout << step << endl;
}
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  int t = 1;
  for (int tc = 1; tc <= t; tc++) solve();
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(m), cost{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  REP(i, m) cin >> a[i];

  vector<string> dp(n+1, "n");

  function<string(string, string)> smax = [](string s, string t) {
    if(s.length() == t.length()){
      REP(i, (int)s.length()){
        if(s[i] > t[i]) return s;
        if(s[i] < t[i]) return t;
      }
      return s;
    } else if(s.length() > t.length()) return s;
    else return t;
  };
  
  function<string(int)> rec = [&](int rest) {
    if(rest == 0) return static_cast<string>("");
    if(dp[rest] != "n") return dp[rest];

    string ans = "";
    FOR(i, 1, 10){
      if(find(a.begin(), a.end(), i) != a.end() && rest - cost[i] >= 0){
        string ret = rec(rest - cost[i]);
        if(ret == "nv") continue;
        ans = smax(ans, to_string(i) + ret);
      }
    }

    if(ans == "") ans = "nv";

    return dp[rest] = ans;
  };

  cout << rec(n) << endl;

  return 0;
}


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

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  throw invalid_argument("ctoi argument is not between '0' and '9'.");
}

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

  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> bs(tmp);
    string formula;
    formula.push_back(a.at(0));
    int sum = ctoi(a.at(0));

    for (int i = 0; i < ((int)a.size() - 1); i++) {
      // 1の場合は加算、0の場合は減算とする
      if (bs.test(i)) {
        sum += ctoi(a.at(i + 1));
        formula.push_back('+');
        formula.push_back(a.at(i + 1));
      } else {
        sum -= ctoi(a.at(i + 1));
        formula.push_back('-');
        formula.push_back(a.at(i + 1));
      }
    }
    if (sum == 7) {
      cout << formula << "=7" << endl;
      return 0;
    }
  }

  return 0;
}

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

int main(){
    int l,r,d,ans;
    cin>>l>>r>>d;
    ans = (r/d)-((l-1)/d);
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  cout << (sz(s)%2 ^ s[0]==s[sz(s)-1] ? "First" : "Second") << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int a, b, ans = 0, n[5], x;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		x = i;
		for (int j = 0; j < 5; j++) {
			n[j] = x % 10;
			x /= 10;
		}
		if (n[0] == n[4] && n[1] == n[3]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int cnt=0;
    rep(i,n){
        int m;
        cin >> m;
        if(m!=i+1){
            cnt++;
        }
        if(cnt==3){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}

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

ll calc_gcd(ll a, ll b) {
  if(a < b) calc_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
	int n;
	ll X,x,ans;
	cin >> n >> X;
	cin >> x;
	ans = abs(X-x);
	rep(i,n-1){
		cin >> x;
		ans = calc_gcd(abs(X-x),ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
using namespace std;

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

const int MN = 1e5 + 5;
const int MOD = 1e9 + 7;
int n;
vector<int> adj[MN];
ll dp[MN][2];

void dfs(int cur, int pv = 0)
{
	dp[cur][0] = dp[cur][1] = 1;
	for (auto &next : adj[cur])
	{
		if (next == pv) continue;
		dfs(next, cur);
		dp[cur][0] *= (dp[next][0] + dp[next][1]) % MOD;
		dp[cur][0] %= MOD;
		dp[cur][1] *= dp[next][0];
		dp[cur][1] %= MOD;
	}

}

int main()
{
	fastio;
	cin >> n;
	rep(i, 1, n)
	{
		int u, v; cin >> u >> v;
		adj[u].pb(v); adj[v].pb(u);
	}
	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % MOD;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};
int main(){
    combination c(110000);
    ll n;cin>>n;
    vl a(n+1);rep(i,n+1)cin>>a[i];
    ll L=-1,R=-1;
    vl cnt(n+1);
    rep(i,n+1){
        cnt[a[i]]++;
    }
    ll d;
    rep(i,n+1){
        if(cnt[a[i]]>1) d=a[i];
    }
    rep(i,n+1){
        if(L==-1&&a[i]==d) L=i;
        else if(R==-1&&a[i]==d) R=n-i;
    }
    //cout<<L<<" "<<R<<endl;
    mint ans=0;
    ans=c(n+1,1)-1;
    cout<<ans.x<<endl;
    for(ll i=2;i<=n+1;i++){
        ans=c(n+1,i)-c(L+R,i-1);
        cout<<ans.x<<endl;
    }
    return 0;
}

Measured memory_bytes: 4480
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		String[] ones = str.split("");
		str = scan.next();
		String[] twos = str.split("");
		boolean flag = false; 
			

	 	if(ones[0].equals(twos[2])){
       			if(ones[1].equals(twos[1])){
       				if(ones[2].equals(twos[0])){
					flag = true;					
				}
       			}
    		}

		if(flag == true){
		        System.out.println("YES");
		}else{
			System.out.println("NO");
		}
  }
}

Measured memory_bytes: 21844
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)


Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import System.IO.Unsafe
import Data.Graph
import Debug.Trace

solve :: Int -> Int -> V.Vector B.ByteString -> Int
solve h w ss = dfs
  where
    dfs :: Int
    dfs = snd $ (\f -> foldl' f (unsafePerformIO (VM.replicate (w*h) False), 0) [0..w*h-1]) $ \(!check,!acc) i ->
      if unsafePerformIO (VM.read check i)
        then (check,acc)
        else let acc' = ((\(x,y) -> x*y + acc) $ search check (toIndex i)) in (check,acc')

    search :: VM.IOVector Bool -> (Int,Int) -> (Int,Int)
    search check = fix (\f (!check,!bw,!i) ->
      if unsafePerformIO (VM.read check (fromIndex i))
        then bw
        else 
          let bw' = (if ss !+ i == '#' then first (+1) else second (+1)) bw in
          let ns = VU.fromList $ neighbors check i in
            ns `seq` unsafePerformIO (VM.write check (fromIndex i) True) `seq`
            VU.foldl' (\bw'' i' -> f (check,bw'',i')) bw' ns
      ) . (,,) check (0,0)

    toIndex :: Int -> (Int,Int)
    toIndex n = (n `mod` w, n `div` w)

    fromIndex :: (Int,Int) -> Int
    fromIndex (x,y) = y * w + x

    (!+) :: V.Vector B.ByteString -> (Int,Int) -> Char
    vec !+ (x,y) = (vec V.! y) `B.index` x

    neighbors check (x,y) =
      [(x',y') |
        (ix,iy) <- [(0,1),(0,-1),(1,0),(-1,0)],
        let x' = x + ix, let y' = y + iy,
        0 <= x' && x' < w, 0 <= y' && y' < h,
        ss !+ (x',y') /= ss !+ (x,y),
        not (unsafePerformIO (VM.read check (fromIndex (x,y))))
      ]

main = do
  let readInt = fmap (second B.tail) . B.readInt

  hw <- V.unfoldrN 2 readInt <$> B.getLine
  ss <- V.replicateM (hw V.! 0) B.getLine
  print $ solve (hw V.! 0) (hw V.! 1) ss


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

int  main(){
  ll x,y;cin>>x>>y;
  int c=1;
  while(true){
    if(2*x>y){break;}
    x*=2;c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2124
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;


int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) {
		int x;
		cin >> x;
		h[i] = x;
	}
	int ans = 0;
	rep(i, n - 1) {
		if (h[i] > h[i + 1]) {
			ans += h[i] - h[i + 1];
		}
	}
	ans += h[n-1];
	cout << ans << endl;
	return 0;
}


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

int main()
{
        int a, b, c;
        cin >> a >> b >> c;
        int ans = 0;
        for (int i = a; i <= b; ++i) {
                if (c%i == 0) {
                        ans++;
                }
        }
        cout << ans << endl;



}



Measured memory_bytes: 3120
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *LRD = map(int, read().split())

    G = [[] for _ in range(N)]
    for l, r, d in zip(*[iter(LRD)] * 3):
        G[l - 1].append((r - 1, d))
        G[r - 1].append((l - 1, -d))

    seen = [False] * N
    dist = [-1] * N
    for i in range(N):
        if seen[i]:
            continue

        dist[i] = 0
        queue = deque([i])
        while queue:
            v = queue.popleft()
            for nv, d in G[v]:
                if seen[nv]:
                    if dist[nv] != dist[v] + d:
                        print('No')
                        return
                else:
                    dist[nv] = dist[v] + d
                    seen[nv] = True
                    queue.append(nv)

    print('Yes')
    return


if __name__ == '__main__':
    main()


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

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

ll p=1e9+7 ;

int main()
{
	ll n,k ;
	cin>>n>>k ;
	ll lim ;
	ll dp[k+1] ;
	ll fake[k+1] ;
	
	memset(dp,0,sizeof(dp)) ;
	dp[0]=1 ;
	rep(i,0,n)
	{
		memset(fake,0,sizeof(fake)) ;
		cin>>lim ;
		for(ll used=k ; used>=0 ; used--)
		{
			int l=used+1 , r=used+min(lim,k-used) ;
			if(l<=r)
			{
				fake[l] = (fake[l] + dp[used])%p ;
				if(r+1<=k)
					fake[r+1] = ((fake[r+1] - dp[used]) + p ) %p  ;
 			}
		}
		ll pref=0 ;
		rep(i,0,k+1)
		{
			pref = (pref+fake[i])%p ;
			dp[i] = (dp[i]+pref)%p ;
		}
	}
	
	cout<<dp[k]<<endl ;

	return 0;
}

Measured memory_bytes: 5096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        int D = 50;
        public List<int> ret;
        public string s;
        public void Run()
        {
            N = Input.ReadInt();
            ret = new List<int>();

            int sign = 1;
            while (N != 0)
            {
                if(N % 2 == 0)
                    ret.Add(0);
                else
                {
                    ret.Add(1);
                    N -= sign;
                }
                N /= 2;
                sign *= -1;
            }

            ret.Reverse();
            if (ret.Count == 0)
            {
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(string.Join("", ret));
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

void solve(int X, int N, vector<int> p)
{
    int cand_l = X, cand_h = X;
    while (true)
    {
        bool has_l = false, has_h = false;
        for (int i = 0; i < N; i++)
        {
            if (cand_l == p.at(i))
                has_l = true;
            if (cand_h == p.at(i))
                has_h = true;
        }
        if (!has_l)
        {
            cout << cand_l << endl;
            break;
        }
        if (!has_h)
        {
            cout << cand_h << endl;
            break;
        }
        cand_l--;
        cand_h++;
    }
}

int main()
{
    int X;
    cin >> X;
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p.at(i);
    }
    solve(X, N, move(p));
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
long long h, n, a[1000005], ans;
 
int main () {
  cin >> h >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    ans+=a[i];
  }
  if(ans >= h) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 1024
# 解説を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
import math
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, K, As):
    ans = max(As)
    l, r = 1, ans
    for _ in range(30):
        m = (l + r) // 2
        cnt = 0
        for A in As:
            cnt += math.ceil(A / m) - 1
        if cnt <= K:
            ans = min(ans, m)
            r = m - 1
        else:
            l = m + 1
        if l > r:
            break
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    N, K = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, K, As)


Measured memory_bytes: 31884
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 2000100
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define FD T&q=fd[rt],&ql=fd[rt<<1],&qr=fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const LL MOD=1000000007;
int n, a[N], f[N];
int p, cnt;
LL ans = 1;
int main(){
 //   IN;
    SC(n);
    FF(i, 1, n)SC(a[i]);
    FF(i, 1, n){
        f[p] = i;
        int t = (a[i] + 1) >> 1;
        if(i > t)p = max(p, i - t);
    }
    RR(i, n, 1)f[i] = f[i - 1];
    f[0] = 0;
    FF(i, 1, n){
        int tmp = max(f[i] - f[i-1], 0);
        cnt += tmp;
        ans = ans * cnt % MOD;
        --cnt;
    }
    printf("%lld\n", ans);
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
using namespace std;
char s[MAXN],ch[MAXN];
inl char Chg(reg char x)
{
	return x=='b'?'d':(x=='d'?'b':(x=='p'?'q':'p'));
}
int main()
{
	scanf("%s",ch+1);
	reg int len=strlen(ch+1);
	memcpy(s,ch,sizeof(ch));
	reverse(ch+1,ch+len+1);
	for(reg int i=1;i<=len;i++) ch[i]=Chg(ch[i]);
	reg bool fg=1;
	for(reg int i=1;i<=len;i++)
	{
		if(ch[i]!=s[i])
		{
			fg=0;
			break;
		}
	}
	puts(fg?"Yes":"No");
	return 0;
}

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

int main(){
    int n, k, q;
    int pt[100001] = {0};
    cin >> n >> k >> q;
    for(int i=0;i<q;++i){
        int a;
        cin >> a;
        ++pt[a];
    }
    for(int i=1;i<=n;++i){
        if(pt[i]-q+k > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long int li;
typedef vector<char> vc;


int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 && C > 0)
    {
        C -= B;
        if (C <= 0)
            break;
        A -= D;
    }
    if (A > 0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 3632
a = int(input())
b = int(input())

if (a == 1 and b == 2) or (a == 2 and b == 1):
    print(3)
elif (a == 2 and b == 3) or (a == 3 and b == 2):
    print(1)
elif (a == 3 and b == 1) or (a == 1 and b == 3):
    print(2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  string S;
  cin >> S;
  ll N = S.size();
  ll K;
  cin >> K;
  vector<ll> a(0);
  ll count = 1;
  for (int i = 1; i < N; i++) {
    if (S.at(i-1) != S.at(i)) {
      a.push_back (count);
      count = 1;
    } else count++;
  }
  a.push_back (count);
    
  ll M = a.size();
  ll ans = 0;
  if (S.at(0) != S.at(N-1)) {
    for (int i = 0; i < M; i++) ans += (a.at(i) / 2) * K;
  } else {
    if (M == 1) ans = (a.at(0) * K) / 2;
    else {
      ans = a.at(0) / 2 + a.at(M-1) / 2 + ((a.at(0) + a.at(M-1)) / 2) * (K-1);
      for (int i = 1; i < M-1; i++) ans += (a.at(i) / 2) * K;
    }
  }
  
  cout << ans << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int L = A + B;
  int R = C + D;

  if(L>R){
    cout << "Left" << endl;
  }
  if(L==R){
    cout << "Balanced" << endl;
  }
  if(L<R){
    cout << "Right" << endl;
  }

  
}

Measured memory_bytes: 3604
def SelectionSort(A):
    cnt = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        if i != mini:
            A[i], A[mini] = A[mini], A[i]
            cnt += 1
    return A, cnt

N = int(input())
A = [int(_) for _ in input().split()]

A, cnt = SelectionSort(A)
print(" ".join([str(i) for i in A]))
print(cnt)



Measured memory_bytes: 5608
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int h = 0;
		int jikan = 0;
		int fun = 0;
		int nokori = 0;
		int amari = 0;
		int m = 0;
		int se = 0;
		Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int S = Integer.parseInt(s);
        h = S/3600;
        jikan = h*3600;
        nokori = S - jikan;
        m = nokori/60;
       fun = m*60;
       int  hiku  = 0;
       hiku = fun+jikan;
       amari = S - hiku;
        se = amari;
        System.out.print(h);
        System.out.print(":" + m);
        System.out.println(":" + se);
		
	}
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	// keisan
	int money = 1000;
	while(n > money){
		money += 1000;
	}
	// syutsuryoku
	cout << money - n;
}

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

using namespace std;
using LL = long long;

int N, M, Q;

int a[55], b[55], c[55], d[55];
int A[12];
int best;

void rec(int k, int last) {
	if (k == N) {
		int s = 0;
		for (int i = 0; i < Q; i++) {
			s += (A[b[i]] - A[a[i]] == c[i]? d[i] : 0);
		}
		best = max(best, s);
		return;
	}

	for (int i = last; i <= M; i++) {
		A[k] = i;
		rec(k + 1, i);
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}

	rec(0, 1);

	cout << best << endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int n, w;
long long weight[100];
long long val[100];
long long dp[110][100010];

int main()
{
	cin >> n >> w;
	for (int i = 0; i < n; i++)
	{
		cin >> weight[i] >> val[i];
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			if (j - weight[i - 1] < 0)
			{
				dp[i][j] = dp[i - 1][j];
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i-1]] + val[i-1]);
			}
		}
	}
	cout << dp[n][w];
}


Measured memory_bytes: 110592
#include<cstdio>
const int MAXM = 400;
const int MAXN = 100000;
int X[MAXN + 5], Y[MAXN + 5], N, M;
bool vis[MAXM + 5][MAXM + 5], f[MAXM + 5];
void Function(int x) {
	vis[x][x] = f[x] = true;
	for(int i=M;i>=1;i--) {
		if( vis[x][X[i]] && vis[x][Y[i]] ) {
			f[x] = false;
			return ;
		}
		if( vis[x][X[i]] || vis[x][Y[i]] )
			vis[x][X[i]] = vis[x][Y[i]] = true;
	}
}
int main() {
	scanf("%d%d", &N, &M);
	for(int i=1;i<=M;i++)
		scanf("%d%d", &X[i], &Y[i]);
	for(int i=1;i<=N;i++)
		Function(i);
	int ans = 0;
	for(int i=1;i<=N;i++) {
		for(int j=i+1;j<=N;j++) {
			if( (!f[i]) || (!f[j]) ) continue;
			bool flag = true;
			for(int k=1;k<=N;k++) {
				if( vis[i][k] && vis[j][k] ) {
					flag = false;
					break;
				}
			}
			if( flag ) ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int count = Integer.parseInt(line);
      
      int ac = 0;
      int wa = 0;
      int tle = 0;
      int re = 0;
      for(int i=0;i<count;i++){
        String judge = sc.nextLine();
        if(judge.equals("AC")){
            ++ac;
        } else if(judge.equals("WA")){
            ++wa;
        } else if(judge.equals("TLE")){
            ++tle;
        } else {
            ++re;
        }
      }
      
      System.out.println("AC x "+String.valueOf(ac));
      System.out.println("WA x "+String.valueOf(wa));
      System.out.println("TLE x "+String.valueOf(tle));
      System.out.println("RE x "+String.valueOf(re));
    }
}

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

int main(){
	string ss;
	while(cin>>ss){
		vector<int> spot;
		for(int i=0;i<ss.size();i++){
			switch(ss[i]){
				case 'I':
					spot.push_back(1);
					break;
				case 'V':
					spot.push_back(5);
					break;
				case 'X':
					spot.push_back(10);
					break;
				case 'L':
					spot.push_back(50);
					break;
				case 'C':
					spot.push_back(100);
					break;
				case 'D':
					spot.push_back(500);
					break;
				case 'M':
					spot.push_back(1000);
					break;
			}
		}
		int ans=0;
		for(int i=0;i<(spot.size()-1);i++){
			if(spot[i]<spot[i+1]){
				spot[i]*=-1;
			}
			ans+=spot[i];
		}
		ans+=spot[spot.size()-1];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <atcoder/all>
#define M_PI 3.14159265358979323846

using namespace std;
using namespace atcoder;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

#define MOD 1000000007
class UnionFind
{
public:
    vector<int> par;
    vector<int> siz;

    UnionFind(int sz_) : par(sz_), siz(sz_, 1)
    {
        for (int i = 0; i < sz_; ++i)
            par[i] = i;
    }
    void init(int sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }

    int root(int x)
    {
        while (par[x] != x)
        {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    int size(int x)
    {
        return siz[root(x)];
    }
};

ll modPow(ll x, ll n, ll mod = MOD)
{
    if (n == 0)
        return 1;
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * x) % mod;

        res %= mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;

    return GCD(b, a % b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(6);

    int t;
    cin >> t;
    while (t--)
    {
        ll N, M, A, B;
        cin >> N >> M >> A >> B;
        ll ans = floor_sum(N, M, A, B);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3680
#include <stdio.h>

int main(void) {
	// your code goes here
	int n,i,num=0;
	scanf("%d",&n);
	if(n<12)printf("0\n");
	else if(n>12) {
	for(i=13;i<=n;i++){
		if(i%2!=0){
		int cnt=0;
		for(int j=1;j<=i;j++){
			if(i%j==0)cnt++;
			if(cnt>7)num++;
		
		}
		//printf("%d ",cnt);
		}
		else continue;
	}
	printf("%d\n",num);
	}
	return 0;
}


Measured memory_bytes: 128
abcd = str(input())
w = ["+","-"]
s = []
for i in w:
    for h in w:
        for j in w:
            num = int(abcd[0])
            l = [i,h,j]
            for k in range(len(l)):
                if l[k] == "+":
                    num += int(abcd[k+1])
                else:
                    num -= int(abcd[k+1])
            if num == 7:
                s.append(abcd[0]+i+abcd[1]+h+abcd[2]+j+abcd[3]+"="+"7")
print(s[0])

Measured memory_bytes: 9136
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int vals[6];
int a0, l;

int update(int ai) {
    for (int i = 0; i < l; ++i) {
        vals[i] = ai % 10;
        ai /= 10;
    }
    sort(vals, vals + l);
    int max = 0;
    int min = 0;
    int d = 1;
    for (int i = 0; i < l; ++i) {
        max += d * vals[i];
        min += d * vals[l - i - 1];
        d *= 10;
    }

    return max - min;
}

int main() {
    while (1) {
        cin >> a0 >> l;
        if (a0 == 0 && l == 0) break;

        vector<int> v;
        v.push_back(a0);

        int ai = a0;
        bool found = false;
        while(1) {
            ai = update(ai);
            //cout << ai << endl;
            for (int j = 0; j < v.size(); ++j) {
                if (ai == v[j]) {
                    cout << j << " " << ai << " "<< v.size() - j << endl;
                    found = true;
                    break;
                }
            }
            v.push_back(ai);
            if (found) break;
        }
    }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll n;
    cin >> n;
    ll t[n] = {};
    
    ll ans = 0;
    rep(i,0,n){
        cin >> t[i];
        if(i == 0) ans = t[i];
        else ans = lcm(ans,t[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3616
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	relayFrom1 := make([]bool, n+1)
	relayToN := make([]bool, n+1)
	for i := 0; i < m; i++ {
		a, b := nextInt(), nextInt()
		if a == 1 {
			relayFrom1[b] = true
		} else if b == n {
			relayToN[a] = true
		}
	}

	ok := false
	for i := 2; i < n; i++ {
		if relayFrom1[i] && relayToN[i] {
			ok = true
			break
		}
	}

	if ok {
		puts("POSSIBLE")
	} else {
		puts("IMPOSSIBLE")
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 3584
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
   n <- readLn :: IO Int
   txy <- replicateM n (map read . words <$> getLine)

   putStrLn $ solve [0,0,0] txy

asolve :: [Int] -> [Int] -> Bool
asolve [] _ = True
asolve _ [] = True
asolve [t1,x1,y1] [t2,x2,y2] = if t < d
                               then False
                               else if even (t-d) == True
                                    then True
                                    else False
     where t = abs (t2-t1)
           d = (abs (x2-x1)) + (abs (y2-y1))
           
solve :: [Int] -> [[Int]] -> String
solve t0 [] = "Yes"
solve t0 (t:ts) = if asolve t0 t == True
                  then solve t ts
                  else "No"

Measured memory_bytes: 81276
a, b = map(int, input().split())

if a == b == 1:
  print("Draw")
elif a == 1 and b != 1:
  print("Alice")
elif a != 1 and b == 1:
  print("Bob")
elif a == b:
  print("Draw")
elif a > b:
  print("Alice")
else:
  print("Bob")

Measured memory_bytes: 2940
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

pm = 0
for i in range(N) :
    if a[i] >= b[i] :
        pm += 2 * (a[i] - b[i])
    else :
        if a[i] % 2 != b[i] % 2 :
            pm += 1
        pm -= b[i] - a[i]
        
if pm > 0 :
    print('No')
else :
    print('Yes')


Measured memory_bytes: 41584
#include <iostream>

using namespace std;

const int max_num = (1e5 + 5), max_answer = 1e9;
long long int dp[max_num];

int get_num() {
    int input;
    cin >> input;

    return input;
}

int main() {
    int num_of_stones = get_num(), height_of_stone[num_of_stones];
    for (int i = 0; i < num_of_stones; i++) {
        height_of_stone[i] = get_num();
    }

    dp[1] = abs(height_of_stone[1] - height_of_stone[0]);
    for (int i = 2; i < num_of_stones; i++) {
        dp[i] = max_answer;
        for (int j = i - 2; j < i; j++) {
            long long int answer = (dp[j] + abs(height_of_stone[i] - height_of_stone[j]));
            if (answer < dp[i]) {
                dp[i] = answer;
            }
        }
    }

    cout << dp[num_of_stones - 1];
}

Measured memory_bytes: 4316