akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

bool ok(int l,int r,int x,int i,int j,int k){
    int cnt=0;
    if(l<=i and i<=r) ++cnt;
    if(l<=j and j<=r) ++cnt;
    if(l<=k and k<=r) ++cnt;
    return cnt==x;
}

void solve(){
    int N,M;
    cin >> N >> M;

    vector<vector<int>> l(N+1),x(N+1);
    rep(i,0,M){
        int l_,r_,x_;
        cin >> l_ >> r_ >> x_;
        l[r_].push_back(l_);
        x[r_].push_back(x_);
    }

    static char memo_ok2[301][301][301];
    fill_n((char*)memo_ok2,301*301*301,2);
    auto ok2=[&](int r,int i,int j,int k){
        auto &res=memo_ok2[i][j][k];
        if(res<2) return res;
        rep(i_,0,l[r].size()) if(!ok(l[r][i_],r,x[r][i_],i,j,k)) return res=0;
        return res=1;
    };

    i64 mod=1000000007;
    static i64 memo[301][301][301];
    fill_n((i64*)memo,301*301*301,-1);
    function<i64(int,int,int)> rec=[&](int i,int j,int k){
        auto &res=memo[i][j][k];
        if(res!=-1) return res;
        if(i==N) return res=1;
        res=0;
        int ma=max({i,j,k})+1;
        {
            int mi=min(j,k),md=j+k-mi;
            if(ok2(ma,ma,md,mi)) res=(res+rec(ma,md,mi))%mod;
        }
        {
            int mi=min(i,k),md=i+k-mi;
            if(ok2(ma,ma,md,mi)) res=(res+rec(ma,md,mi))%mod;
        }
        {
            int mi=min(i,j),md=i+j-mi;
            if(ok2(ma,ma,md,mi)) res=(res+rec(ma,md,mi))%mod;
        }
        return res;
    };

    if(!ok2(1,1,0,0)) cout << 0 << endl;
    else cout << rec(1,0,0)*3%mod << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 240000
S = list(input())
for i in range(len(S)):
  if (i == (len(S) - 1)):
    break
  if ( 'A' in (S[i] + S[i + 1]) and 'B' in (S[i] + S[i + 1]) ):
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 38384
/*
 *
 *    I am o0o0oo00.
 *
 */
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define p7          1000000007
#define p9          998244353
#define pb          push_back
#define ff          first
#define ss          second
#define vll         vector<ll>
#define pll         pair<ll,ll>
#define vpll        vector<pll>
#define mll         map<ll,ll>
#define test        ll T;cin>>T;while(T--)
#define ad(a,n)     vll a;a.resize(n);for(ll i=0;i<n;i++)cin>>a[i];
#define as(a,n)     for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define all(x)      x.begin(),x.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll powm(ll x, ll y, ll m = p7) {
    x = x % m; ll res = 1; while (y)
    {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res;
}
ll modi(ll a, ll m = p7) {return powm(a, m - 2, m);}
void yesno(bool f) {f ? cout << "YES" << endl : cout << "NO" << endl;}


void ss99()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


int32_t main()
{
 //   ss99();
//    test
    {
        ll n; cin >> n;
        double h[n + 1], t[n + 1];
        double dp[n + 1][n + 1];
        for (ll i = 1; i <= n; i++)
        {
            cin >> h[i];
            t[i] = (1 - h[i]);
        }
        dp[0][0] = 1;
        for (ll i = 0; i <= n; i++)
        {
            for (ll j = 0; j <= n; j++)
            {
                if (i == 0 && j == 0)
                    continue;
                if (j == 0)
                    dp[i][j] = dp[i - 1][j] * t[i];
                else if (j > i)
                    dp[i][j] = 0;
                else
                    dp[i][j] = dp[i - 1][j - 1] * h[i] + dp[i - 1][j] * t[i];
            }
        }
    /*    for (ll i = 0; i <= n; i++)
        {
            for (ll j = 0; j <= n; j++)
            {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/
        double ans = 0;
        for (ll i = (n + 2) / 2; i <= n; i++)
            ans += dp[n][i];
        cout << fixed << setprecision(15) << ans << endl;
    }
    return 0;
}

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

using namespace std;

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	while(1){
		int a,b;
		cin >> a >> b;
		if(a==0&&b==0) return 0;
		V<V<ll>> dp(a,V<ll>(b,0));
		int N; cin >> N;
		for(int i = 0; i < N; ++i){
			int x,y; 
			cin >> x >> y;
			x--,y--;
			dp[x][y] =-1;
		}
		dp[0][0] = 1;
		for(int i = 0; i < a; ++i)for(int j = 0; j < b; ++j){
			if(dp[i][j] == -1) continue;
			if(i+1<a && dp[i+1][j] != -1) dp[i+1][j] += dp[i][j];
			if(j+1<b && dp[i][j+1] != -1) dp[i][j+1] += dp[i][j];
		}
		cout << (dp[a-1][b-1]!=-1?dp[a-1][b-1]:0) <<endl;
	}

	return 0;
}



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

int jyou(int n){
    int ans = 1;
    for(int i = 0; i < n; i++){
        ans = ans*10;
    }
    return ans;
}

int keta(int n){
    int ans = 0;
    while(n > 0){
        n = n / 10;
        ans++;
    }
    return ans;
}

int funk(int n){
    int ke = keta(n);
    int a, b;
    int ans = 0;

    for(int i = 1; i < ke; i++){
        a = n / jyou(i);
        b = n % jyou(i);
        //cout << a << " " << b << endl;
        ans = max(ans,a*b);
    }

    return ans;
}

int main(void){

    //cout << jyou(3) << endl;
    //cout << keta(1024) << endl;
    //cout << funk(1024) << endl;

    int q; cin >> q;

    for(int i = 0; i < q; i++){
        int n; cin >> n;
        vector<bool> used(1000010, false);
        
        int ans = 0;

        while(n >= 10){

            n = funk(n);

            if(used[n] == true){
                cout << -1 << endl;
                break;
            }
            used[n] = true;
            ans++;
        }

        cout << ans << endl;
    }

    return 0;

}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 3e5 + 233;
int n, a[N], ans = 0;
multiset <int> s;
int main(void) {
  read(n);
  rep (i, n) read(a[i]), s.insert(a[i]);
  while (s.size()) {
    int p = *(--s.end()); s.erase(s.find(p));
    int tmp = -1;
    re0 (k, 62) {
      if ((1ll << k) > 2e9) break;
      int opt = (1 << k) - p;
      if (s.find(opt) != s.end()) {
        tmp = max(tmp, opt);
      }
    }
    if (tmp != -1) {
      s.erase(s.find(tmp));
      ++ ans;
    }
    // cout << p << " " << tmp << " " << s.size() << "\n";
  }
  cout << ans << "\n";
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  int a[55];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a, a+N, greater<int>());
  int s = 0;
  for (int i = 0; i < K; i++)
    s += a[i];
  cout << s << endl;
}


Measured memory_bytes: 256
import numpy as np
# 差分の大きい値（移動距離が長い）は駒の数-1でショートカットできる
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
X = np.sort(X)
X = np.diff(X)
X = np.sort(X)
 
ans = 0
if K-N >= 0:
  ans = sum(X[:K-N])
print(ans)  

Measured memory_bytes: 22988
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	int cnt = 0;
	for(auto c:s){
		if(c == 'I')cnt++;
		else cnt--;
		chmax(ans,cnt);
	}
	cout << ans << endl;
	
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc052.contest.atcoder.jp/tasks/abc052_b

Measured memory_bytes: 3612
#include<cstdio>
#include<iostream>
#include<cmath>

#define t(a) (a)*(a)

using namespace std;

int main(){
    double x[3],y[3],a1,a2,b1,b2,c1,c2,rx,ry,r;
    int n;
    cin >> n;
    for(int j=0;j<n;j++){
        for(int i=0;i<3;i++) cin >> x[i] >> y[i];
        a1 = 2*(x[1]-x[0]);
        b1 = 2*(y[1]-y[0]);
        c1 = t(x[0])-t(x[1])+t(y[0])-t(y[1]);
        a2 = 2*(x[2]-x[0]);
        b2 = 2*(y[2]-y[0]);
        c2 = t(x[0])-t(x[2])+t(y[0])-t(y[2]);
        rx = (b1*c2-b2*c1)/(a1*b2-a2*b1);
        ry = (c1*a2-c2*a1)/(a1*b2-a2*b1);
        r=sqrt(t(x[0]-rx)+t(y[0]-ry));
        printf("%.3f %.3f %.3f\n",rx,ry,r);
    }
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep2(i, n, m) for (int i = m; i < (int)(n); i++)
#define rep(i, n) rep2(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;  //
template <typename T>
T sq(T x) {
  return x * x;
}
signed main() {
  int N, K, X, Y;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  int ans = 0;

  if (N > K) {
    rep(i, K) { ans += X; }
    rep2(i, N, K) { ans += Y; }
  } else {
    rep(i, N) { ans += X; }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
# 適当な道に沿って並べていくだけ
# 自然なindexで作ったあと偶数行を反転すればよい

H,W = map(int,input().split())
N = int(input())
A = [int(x) for x in input().split()]

import numpy as np
c = np.zeros(H*W,dtype=np.int32)

first = 0
for i,a in enumerate(A,1):
  c[first:first+a] = i
  first += a
  
c2d = c.reshape((H,W))

c2d[1::2,:] = c2d[1::2,::-1]

for i in range(H):
  print(' '.join(c2d[i].astype(str)))


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	string s,t;
	cin>>s>>t;

	int ans=0;

	for(int i=0; i<len(s); i++)
	{
		if(s[i]!=t[i]) ans++;
	}

	cout << ans << endl;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int pre = -999;
    rep(i,n){
        if(pre<=a[i]-1){
            pre = a[i]-1;
        }else if(pre<=a[i]){
            pre = a[i];
        }else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

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

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


def main():
    n,x = LI()
    a = sorted(LI())
    r = 0
    for c in a:
        if c > x:
            x -= c
            break
        x -= c
        r += 1
    if x > 0:
        r -= 1

    return r


print(main())


Measured memory_bytes: 5588
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	int X;

	int t = 0;

	cin >> X;

	cin >> t;
	int ans = X - t;

	if (ans < 0)
		ans = 0;
	cout << ans;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   long long a,n,m; 
   long long x=0; 
    cin>>n; 
    m=n;
while(n!=0){
	a=n%10;
    n=n/10;
	x+=a;
}
if(m%x==0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    return 0;
}


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

int main()
{
    int N, A, sum=0;

    cin >> N>>A;

    sum = (N % 500) - A;
    //cout << sum << endl;
    if(sum<=0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  cout << n / 3 << endl;
}






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

typedef long long ll;

int mod = 1e9 + 7;
int p = 5e5 + 100;

int main() {	
	vector<ll> com(p + 1);
	vector<ll> inv(p + 1);
	vector<ll> mul(p + 1);
	com[0] = 1;
	for (ll i = 1; i <= p; ++i) {
		com[i] = (com[i - 1] * i) % mod;
	} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	
	
	int n;
	cin >> n;
	set<int> s;
	vector<vector<int>> v(n + n,vector<int> (3,0));
	for (int i = 0; i < n; ++i) {
		cin >> v[i][0] >> v[i][1];
		v[i][2] = 1;
	}
	for (int i = n; i < n + n; ++i) {
		cin >> v[i][0] >> v[i][1];	
	}
	sort(v.begin(),v.end());
	int cnt = 0;
	for (int i = 0; i < n + n; ++i) {
		if (v[i][2] == 1) {
			s.insert(v[i][1]);
			//cout << v[i][1] << endl;
		}else {
			int minn = -1;
			for (auto &x: s) {
				if (x < v[i][1]) {
					minn = max(minn,x);
				}
			//	cout << x << " ";
			}
			//cout << endl;
			if (minn != -1) {
				s.erase(minn);
				cnt++;
			}
		}
	}
	cout << cnt;
}




Measured memory_bytes: 15132
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
//const ll INF = 1LL << 60;
//using mint = modint1000000007;
using mint = modint998244353;
//const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int n,m;
int main(){
    cin>>n>>m;
    dsu d(n+1);
    rep(i,m){
      int a,b;
      --a;--b;
      cin>>a>>b;
      d.merge(a,b);
    }
    map<int,int>kazu;
    for(int i=1;i<=n;i++){
      int t=d.leader(i);
      //cout<<"chouten"<<t<<endl;
      kazu[t]++;
    }
    cout<<kazu.size()-1<<endl;
    return 0;
}

Measured memory_bytes: 7536
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 10000

int main(void) {
  vll a, b, c;
  vll::iterator ait, cit;
  cin >> n;
  FOR(i, 0, n) {
	cin >> temp;
	a.push_back(temp);
  }
  FOR(i, 0, n) {
	cin >> temp;
	b.push_back(temp);
  }
  FOR(i, 0, n) {
	cin >> temp;
	c.push_back(temp);
  }

  sort(ALL(a));
  sort(ALL(c));

  FOR(i, 0, n) {
	ait = lower_bound(ALL(a), b[i]);
	cit = upper_bound(ALL(c), b[i]);
	sum += distance(a.begin(), ait) * distance(cit, c.end());
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
vector<int> divisor(int n) {
    vector<int> res;
    rep(i, 1, sqrt(n) + 1) {
        if(!(n % i)) {
            res.push_back(i);
            if(i * i < n) res.push_back(n / i);
        }
    }
    return res;
}
int sub(string s, string t){
	int res = 0;
	rev(i, s.size()){
		if(i < s.size() - 1){
			if(s[i] != t[i]){
				return INF;
			}
		}else{
			if(s[i] >= t[i]){
				res = s[i] - t[i];
			}else{
				s[i - 1]--;
				res = s[i] - t[i] + 10;
			}
		}
	}
	return res;
}
signed main() {
    INCANT;
    int n, mx, mn, res = INF;
    string s, c = "", mxx, mnn;
    cin>>s;
    n = s.size();
    each(i, divisor(n)){
        if(i == n) continue;
        mxx = mnn = "";
        rep(j, n){
            c += s[j];
            if((j + 1) % i == 0){
                if(mxx == ""){
                    mxx = mnn = c;
                }
                chmax(mxx, c);
                chmin(mnn, c);
                c = "";
            }
        }
        chmin(res, sub(mxx, mnn));
    }
    if(n == 2){
        cout<<res<<endl;
        return 0;
    }
    mx = -(mn = INF);
    rep(i, n){
        c += s[i];
        if(s[i] != '1' || c.size() == 2){
            chmax(mx, (int)atoi(c.c_str()));
            chmin(mn, (int)atoi(c.c_str()));
            c = "";
        }
    }
    if(c != ""){
        chmax(mx, (int)atoi(c.c_str()));
        chmin(mn, (int)atoi(c.c_str()));
    }
    chmin(res, mx - mn);
    cout<<res<<endl;
}



Measured memory_bytes: 3368
def solve(N, A, S):
    dp = []
    for i in reversed(range(N)):
        x = A[i]
        for v in dp:
            x = min(x, v^x)
        if x > 0:
            if S[i] == "0":
                dp.append(x)
            else:
                return 1
    return 0

def main():
    T = int(input())
    ans = [None]*T
    for i in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        ans[i] = solve(N, A, S)
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
package main

import (
	"fmt"
)

func main() {
	var A, B, K, cnt int
	fmt.Scan(&A, &B, &K)
	gcd := gcdof2numbers(A, B)
	for i := gcd; ; i-- {
		if gcd%i == 0 {
			cnt++
		}
		if cnt == K {
			fmt.Println(i)
			return
		}
	}
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,ans=1;
string data;



void solve(){
 for(int i=0;i<n-1;i++){
   if(data.at(i)!=data.at(i+1)){
     ans++;
   }
 }

 cout<<ans<<endl;
}

int main(){
  cin>>n;
  cin>>data;

  solve();
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  priority_queue<tuple<int, int, int>, vector<tuple<int, int, int> >, greater<tuple<int, int, int> > > que;
  tuple<int, int, int> state;
  que.push(make_tuple(1, 0, 0));
  map<pair<int, int>, int> amap;
  int white = 0;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(S[i][j]=='.') white++;
    }
  }
  int x, y, cost;
  while(!que.empty()) {
    state = que.top();que.pop();
    x = get<1>(state);
    y = get<2>(state);
    cost = get<0>(state);
    if(amap[mp(x, y)]>0) continue;
    amap[mp(x, y)] = cost;
    if(x>0 && S[x-1][y]=='.') {
      if(amap[mp(x-1, y)]==0) {
        que.push(make_tuple(cost+1, x-1, y));
      }
    }
    if(x<H-1 && S[x+1][y]=='.') {
      if(amap[mp(x+1, y)]==0) {
        que.push(make_tuple(cost+1, x+1, y));
      }
    }
    if(y>0 && S[x][y-1]=='.') {
      if(amap[mp(x, y-1)]==0) {
        que.push(make_tuple(cost+1, x, y-1));
      }
    }
    if(y<W-1 && S[x][y+1]=='.') {
      if(amap[mp(x, y+1)]==0) {
        que.push(make_tuple(cost+1, x, y+1));
      }
    }
  }
  if(amap[mp(H-1, W-1)]==0) {
    cout<<-1<<endl;
    return 0;
  }
  cout<<white-amap[mp(H-1, W-1)]<<endl;
}



Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll now=1;
  FOR(i,0,100000){
    if(now>=b){
      co(i)
        break;
    }
    else{
      now+=a-1;
    }
  }
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N;
    cin >> N;
    vector<int> imos(100010);
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        imos[l]++;
        imos[r+1]--;
    }
    rep(i, 100010) imos[i+1] += imos[i];
    
    int cnt = 0;
    rep(i, 100010) if (imos[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
loop{
h,w = gets.split.map(&:to_i)
if h == 0 && w == 0
    break
end
i = 0
h.times{
    i += 1
    if i.odd?
        if w.odd?
            puts "#." * (w / 2) + "#"
        elsif w.even?
            puts "#." * (w / 2)
        end
    elsif i.even?
        if w.odd?
            puts ".#" * (w / 2) + "."
        elsif w.even?
            puts ".#" * (w / 2)
        end
    end
}
puts ""
}


Measured memory_bytes: 6940
import java.util.Scanner;
  
public class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int area = a*b;
  int length = 2*a+2*b;
  System.out.println(area+" "+length);
 }
}

Measured memory_bytes: 26068
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getIn = read <$> getLine :: IO Int
getIns = map read . words <$> getLine :: IO [Int]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type Point = (Integer, Integer)

mmm = 1000000007
factorial 0 s = s
factorial n s = factorial (n - 1) (s * n)
fact' n = factorial n 1
fi = fromInteger

-- 
--
--

getdiff ts kazaru num = do
    let small = (V.!?) ts num
    let big = (V.!?) ts (num + kazaru - 1)
    liftM2 (-) big small
main = do
    [tree, kazaru] <- getIns
    trees <- V.fromList . sort <$> replicateM tree getIn
    putStrLn . show . minimum . map fromJust . filter isJust $ map (getdiff trees kazaru) [0..(V.length trees - 1)]


Measured memory_bytes: 67964
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}




int main(void){
    ll N,ans=0;
    cin>>N;
    for(ll i=1;i<=N;i++){
        if(i%3==0 || i%5==0) continue;
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

int main(){
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    double j,k;
    
    j=ceil(c/b);
    k=ceil(a/d);
    
    if (j<=k){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3712
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
    int n;
    long long a[100000+6];
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    int flag=0,temp=0;
    for(int i=1; i<n; i++)
    {
        if(a[i]<a[i-1])
        {
            if(!temp)
            {
                a[i-1]-=1;
                temp=1;
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(a[i]>a[i-1])temp=0;
        if(a[i]<a[i-1])
        {
            flag=1;
            break;
        }
    }
    if(flag)  cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define N 100000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int dd[N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &dd[i]);
	qsort(dd, n, sizeof *dd, compare);
	printf("%d\n", dd[n / 2] - dd[n / 2 - 1]);
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    vector<ll> ab(n);
    for(int i=0; i<n; i++){
        ab[i]=b[i]-a[i];
    }
    sort(ab.begin(),ab.end());
    ll cnt=0,tmp=0;
    for(int i=0; i<n; i++){
        if(ab[i]>0){
            tmp+=ab[i];
            cnt++;
        }
    }
    for(int i=0; i<n; i++){
        if(tmp>0&&ab[i]<0){
            tmp+=ab[i];
            cnt++;
        }
    }
    if(tmp>0) cout<<-1<<endl;
    else cout<<cnt<<endl;
}

Measured memory_bytes: 2560
import java.io.*;
class Main{
	public static void main(String[] args) throws IOException {
		int n;
		String str;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		str = in.readLine();
		n = Integer.parseInt(str);
		System.out.println(n/3600+":"+(n%3600)/60+":"+(n%3600)%60);
	}
}

Measured memory_bytes: 24304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (sS[2] == sS[3] && sS[4] == sS[5]) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
fn main(){
    let h: usize = read_one();
    let w: usize = read_one();
    let wall: Vec<Vec<bool>> = read_char_map(h, |&c| {c == '.'});
    let mut state: Vec<(usize, usize)> = Vec::new();
    let mut fg: Vec<Vec<bool>> = vec![vec![true; w]; h];
    
    let mut path: i64 = 1;
    let mut flag: bool = false;
    state.push((0, 0));
    
    let mut sum: i64 = wall.iter()
        .flat_map(|ref x| {
            x.iter()
                .map(|&y| {
                    if y {1} else {0}
                })
        })
        .sum();
    
    loop {
        path += 1;
        state = state.iter().flat_map(|coord| {
            get_neighbor(coord)
        }).filter(|c| {
            let (x, y) = *c;
            let mut r: bool = false;
            if x < w && y < h && wall[y][x] && fg[y][x] {
                if x == w-1 && y == h-1 {
                    flag = true;
                }
                r = true;
                fg[y][x] = false;
            }
            r
        }).collect();
        if flag {
            break;
        }
        if state.is_empty() {
            path = 1;
            sum = 0;
            break;
        }
    }
    
    println!("{}", sum - path);
}

fn get_neighbor(&(x, y): &(usize, usize)) -> Vec<(usize, usize)> {
    vec![(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
}

use std::io::*;
use std::str::*;

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.trim().parse().ok().unwrap()
}

fn read_chars() -> Vec<char> {
    let s = stdin().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    s
}

fn read_char_map<F, T>(n: usize, f: F) -> Vec<Vec<T>>
    where F: Fn(&char) -> T
{
    (0..n).map(|_| read_chars()).map(|x| {x.iter().map(&f).collect()}).collect()
}

Measured memory_bytes: 4352
package main

import(
    "fmt"
    "sort"
    "strings"
    "strconv"
)



func main() {
    var s string
    fmt.Scan(&s)
    ans := 10000
    for i:=0; i<len(s)-2; i++{
        k,_ := strconv.Atoi(s[i:i+3])
        ans = min32(ans,abs32(753-k))
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

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

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

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = line[0];
            var b = line[1];
            var ans = "";
            if (a + b == 15) ans = "+";
            else if (a * b == 15) ans = "*";
            else ans = "x";

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int d = 0;
        for(int n=1; n<=N; n++){
            if(sc.nextInt()!=n) d++;
        }
        System.out.println(d<=2 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	private void doit(){
		while(true){
			int n = sc.nextInt();
			if(n == 0)break;
			int [] data = new int[n + 1];
			for(int i = 0; i <= n; i++){
				data[i] = sc.nextInt();
			}
			for(int i = 0; i <= n; i++){
				int a = 0, b = 1;
				int diff = 1 << 24;
				boolean flg = false;
				for(;;a++, b++){
					if(a == i){
						if(i ==0){
							b++;
						}
						a++;
					}
					if(b == i) b++;
					if(b > n) break;
					int now = data[b] - data[a];
					if(diff == (1 << 24)){
						diff = now;
					}
					else if(diff != now){
						flg = true;
						break;
					}
				}
				if(! flg){
					System.out.println(data[i]);
					break;
				}
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 35388
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[100004];
set<int>tr;
map<int,int>mert;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        tr.insert(a[i]);
    }
    if(tr.size()==1 && (*tr.begin())==0){
        return puts("Yes"),0;
    }
    if(tr.size()==2){
        if(n%3!=0)return puts("No"),0;
        mert.clear();
        int x=-1;
        for(int i=1;i<=n;i++){
            mert[a[i]]++;
            if(a[i]!=0)x=a[i];
        }
        if(mert[0]==n/3&&mert[x]==n*2/3){
            return puts("Yes"),0;
        }
        else return puts("No"),0;
    }
    if(tr.size()==3){
        if(n%3!=0)return puts("No"),0;
        mert.clear();
        for(int i=1;i<=n;i++){
            mert[a[i]]++;
        }
        int p=0;
        for(int x:tr){
            if(mert[x]!=n/3)return puts("No"),0;
            p^=x;
        }
        if(p)return puts("No"),0;
        else return puts("Yes"),0;
    }
    return puts("No"),0;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool flag=false;
    for(int i=0; i<3; i++) {
        if(s.at(i)=='7') flag=true;
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから
vector<ll>a;
ll n,m;

bool C(ll mid){
  ll sum=0;
  rep(i,n){
    sum+=a.end()-lower_bound(all(a),mid-a[i]);
  }
  return sum>=m;
}

void solve(){
  cin>>n>>m;
  a.resize(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll l=0,r=2e5+1;
  while(r-l>1){
    ll mid=(l+r)>>1;
    if(C(mid))l=mid;
    else r=mid;
  }
  ll ans=0;
  vector<ll>sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  ll cnt=0;
  rep(i,n){
    ll x=l-a[i];
    int pos=lower_bound(all(a),x)-a.begin();
    ans+=sum[n]-sum[pos];
    ans+=(n-pos)*a[i];
    cnt+=(n-pos);
  }
  //cerr<<cnt<<endl;
  cout<<ans-(cnt-m)*l;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    
    bool flg = true;
    rep(i, n){
        ll a;
        cin >> a;

        if(a%2 == 0){
            if(a%3 != 0 && a%5 != 0)flg = false;
        }
    }

    if(flg)cout << "APPROVED";
    else cout << "DENIED";
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let n: usize = read();
    let mut vec: Vec<(f64, f64)> = Vec::new();
    for _ in 0..n {
        vec.push({
            let vec = read_vec();
            (vec[0], vec[1])
        })
    }
    let mut distances: Vec<f64> = Vec::new();
    for i in 0..n {
        for j in (i + 1)..n {
            let (p1, p2) = (vec[i], vec[j]);
            let distance = ((p1.0 - p2.0).powi(2) + (p1.1 - p2.1).powi(2)).sqrt();
            distances.push(distance);
        }
    }
    println!("{}", distances.iter().fold(0f64, |sum, &x| sum + x) * 2f64 / n as f64)
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
<?php
fscanf(STDIN, "%s", $S);
$AA = intval(substr($S, 0, 2));
$BB = intval(substr($S, 2, 2));
$CC = ($AA >= 1 && $AA <= 12) * 2 + ($BB >= 1 && $BB <= 12);
switch ($CC) {
    case 0:
        echo "NA";
        break;
    case 1:
        echo "YYMM";
        break;
    case 2:
        echo "MMYY";
        break;
    case 3:
        echo "AMBIGUOUS";
        break;
}


Measured memory_bytes: 4728
#include <iostream>
#define N 100
#define M 100
using namespace std;
main () {
	int n, m, a[N][M], b[M], c[M] = {};
	cin >> n >> m;
	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++) cin >> a[i][j];
	for (int j=0; j<m; j++) cin >> b[j];

	for (int i=0; i<n; i++)
		for (int j=0; j<m; j++) c[i] += a[i][j] * b[j];

	for (int j=0; j<n; j++) cout << c[j] << endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int dansuu=1;
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0;i<N;i++){cin >> d.at(i);}
  sort(d.begin(), d.end());
  int a=d.at(0);
  for (int i=0;i<N;i++){if (a!=d.at(i)){dansuu++;a=d.at(i);}else if(a==d.at(i)){continue;}}
  cout << dansuu << endl;
}

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

int main() {
	int H, W;
	
	cin >> H >> W;
	cin.ignore();
	string s0;
	vector<int> s(W+2, 0);
	vector<vector<int>> M(H+2,s);
	for (int i = 1; i < H + 1; i++) {
		cin >> s0;
		for (int j = 1; j < W + 1; j++) {
			if (s0.at(j - 1) == '#') {
				M.at(i).at(j) = -10;
			}
		}
	}
	for (int i = 1; i < H + 1; i++) {
		for (int j = 1; j < W + 1; j++) {
			if (M.at(i).at(j) < 0) {
				for (int k = 0; k < 3; k++) {
					for (int l = 0; l < 3; l++) {
						M.at(i - 1 + k).at(j - 1 + l) += 1;
					}
				}
			}
		}
	}
	for (int i = 1; i < H + 1; i++) {
		s0 = "";
		for (int j = 1; j < W + 1; j++) {
			if (M.at(i).at(j) < 0) {
				s0 += '#';
			}
			else {
				s0 += to_string(M.at(i).at(j));
			}
		}
		cout << s0 << endl;
	}
}

Measured memory_bytes: 256