akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
	int N, M, C,ans = 0,sum=0;
	int A[30], B[30];

	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int j = 0; j < N; j++) {
		sum = 0;
		for (int k = 0; k < M; k++) {
			cin >> A[k];
			sum += A[k] * B[k];
		}
		sum += C;
		if (sum > 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;



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


    int r;
    cin >> r;
    cout << 3 * r * r;
    return 0;
}




void print(vector<int> &b) {
    for (auto i : b) {
        cout << i << " ";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int N = scan.nextInt();
	int M = scan.nextInt();
	
	int[] a_ = new int[M];
	int[] b_ = new int[M];

	for(int i = 0; i < M; i++){
	    a_[i] = scan.nextInt();
	    b_[i] = scan.nextInt();
	}

	int[] road_ = new int[N+1];
	for(int i = 0; i < M; i++){
	    road_[a_[i]]++;
	    road_[b_[i]]++;
	}

	for(int i = 1; i <= N; i++){
	    System.out.println(road_[i]);
	}
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  int N, A[200000];
  scanf("%d", &N);
  for (int i=0 ; i<N ; i++) {
    int num;
    scanf("%d", &num);
    A[i] = num - (i+1);
  }
  sort(A, A+N);

  long long  m1, m2;
  long long ans1 = 0, ans2 = 0;
  m1 = A[N/2-1];
  m2 = A[N/2];
  for (int i=0 ; i<N ; i++) {
    ans1 += abs(A[i]-m1);
    ans2 += abs(A[i]-m2);
  }
  if (N % 2 == 0) printf("%lld\n", min(ans1, ans2));
  else printf("%lld\n", ans2);
}


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

using namespace std;

constexpr int N = 1e5 + 10;
constexpr int MOD = 1e9 + 7;

long long n, a[N];

long long mypow (long long a, long long b) {
    return b ? (mypow (a * a % MOD, b >> 1) * (b & 1 ? a : 1)) % MOD : 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        cnt++;
        if (a[i] != a[i + 1]) {
            ans += cnt / 2;
            cnt = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
def solve(i, k, lesser, zero):
	global s, dp

	if k < 0:
		return 0

	if i == len(s):
		return 1 if k == 0 and not zero else 0

	if dp[i][k][lesser][zero] != -1:
		return dp[i][k][lesser][zero]

	if lesser:
		dp[i][k][lesser][zero] = solve(i + 1, k, True, zero)

		for d in range(1, 10):
			dp[i][k][lesser][zero] += solve(i + 1, k - 1, True, False)
	else:
		dp[i][k][lesser][zero] = solve(i + 1, k, 0 < s[i], zero)
		
		for d in range(1, s[i] + 1):
			dp[i][k][lesser][zero] += solve(i + 1, k - 1, d < s[i], False)

	return dp[i][k][lesser][zero]

def main():
	global s, dp

	s = list(input())
	k = int(input())

	for i in range(len(s)):
		s[i] = ord(s[i]) - ord('0')

	dp = [[[[-1, -1], [-1, -1]] for j in range(k + 1)] for i in range(len(s) + 1)]

	print(solve(0, k, False, True))

if __name__ == "__main__":
	main()

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

int main() {
  long long int n, a, b;
  cin >> n >> a >> b;

  if(a > b || (n == 1 && a != b)) cout << 0 << endl;
  else {
  long long int lowLim = a * (n - 1) + b;
  long long int highLim = b * (n - 1) + a;

  cout << highLim - lowLim + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long n, m, ans=0;
    cin >> n >> m;
    if(2*n<=m){
        ans += n;
        m -= 2*n;
        ans += m/4;
    }else{
        ans += m/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;



void dfs(int i, int cnt, string *C){
}

int main(){
    int n, k;
    while(cin>>n>>k, n|k){
        vector<string> C(n);
        REP(j, n) cin >> C[j] ;
        set<string> strs;
        for(int mask=0; mask< (1 << n); mask++){
            int total_1=0;
            for(int i=0; i<n; i++)
                if(mask >> i & 1) total_1++;
            if(total_1 != k) continue;
            vector<string> cards;
            for(int i=0; i<n; i++)
                if(mask >> i & 1) cards.push_back(C[i]);
            sort(ALL(cards));
            do{
                string tmp;
                for( auto num : cards)
                    tmp+=num;
                if(strs.find(tmp)==strs.end())
                    strs.insert(tmp);
            }while(next_permutation(ALL(cards)));
        }
        cout << strs.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.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 RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#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
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int vis[100009];
deque<int> dq;
vector<int> adj[100009];

void dfs1(int x){
	for(int i:adj[x]){
		if(vis[i])continue;
		vis[i]=1;
		dq.PB(i);dfs1(i);break;
	}
}

void dfs2(int x){
	for(int i:adj[x]){
		if(vis[i])continue;
		vis[i]=1;
		dq.push_front(i);dfs2(i);break;
	}
}

int main(){
	DRII(n,m);
	REP(i,m){
		DRII(a,b);a--;b--;
		adj[a].PB(b);adj[b].PB(a);
	}
	dq.PB(0);vis[0]=1;
	dfs1(0);dfs2(0);
	printf("%d\n",SZ(dq));
	for(int i:dq)printf("%d ",i+1);
}


Measured memory_bytes: 9984
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

int MOD=1000000007;

int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B!=C || A==C && A!=B || B==C && B!=A) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
r = [0]*(n+1)
r[1] = 1
b0 = [1]*(n+1)
for i in range(m):
    x,y = map(int, input().split())
    b0[x] -= 1
    b0[y] += 1
    if r[x]:
        r[y] = 1
    if b0[x]==0:
        r[x]=0
ans = 0
for j in range(n+1):
    if r[j]:
        ans += 1
print(ans)


Measured memory_bytes: 4596
#include<stdio.h>

#define BTC2YEN 380000.0

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

    int i;
    double yen = 0.0;
    for(i=0;i<n;i++){
        double money;
        char type[3];
        scanf("%lf%s", &money, &type);
        if (type[0] == 'B')
            yen += money * BTC2YEN;
        else
            yen += money;
    }

    printf("%lf", yen);
    return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(m);
  vector<ll>t={0,2,5,5,4,5,6,3,7,6};
  rep(i,0,m){
    cin>>a[i];
  }
  vector<P>dp(n+1,MP(-1,-1));
  dp[0]=MP(0,0);
  rep(i,0,n){
    if(dp[i].fi==-1)continue;
    rep(j,0,m){
      if(i+t[a[j]]>n)continue;
      chmax(dp[i+t[a[j]]],MP(dp[i].fi+1,a[j]));
    }
  }
  string ret;
  ll now=n;
  //rep(i,0,n)cout<<dp[i]<<endl;
  while(now){
    ret.PB(dp[now].se+'0');
    now-=t[dp[now].se];
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,t,c;
  	cin >> N;
  	
  	t = N;
  
  	while (t > 0) {
    	c += t % 10;
 	    t = t/10;
      	
    }
  	if (N % c == 0){
    	cout << "Yes";
    }
  	else{
    	cout << "No";
    }
}































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


int main()
{

    int n; cin>>n;
    int arr[n];

    long long total=0;

    for (int i = 0; i <n ; ++i)
    {
        cin>>arr[i];
    }

    for(int i=0 ; i< n-1 ; i++)
    {
        for (int j = i+1; j <n ; ++j)
        {
            total+= (arr[i]*arr[j])    ;
        }
    }
    cout<<total<<endl;
}


Measured memory_bytes: 256
from math import ceil
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

lst = [a, b, c, d, e]
v_min = min(lst)
time_slow = ceil(n/v_min)
print(4+time_slow)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}

int main(){
	int n;
	scanf("%d", &n);
	int array[n];
	for(int i=0; i<n; i++){
		scanf("%d", &array[i]);
	}
	qsort(array, n, sizeof(int), compare_int);
	int ok = 0;
	for(int i=0; i<n-1; i++){
		if(array[i+1]==array[i]){
			ok = -1;
			break;
		}
	}
	if(ok == 0) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 1788
N, C = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(N)]
timeTable = [[False for _ in range(10 ** 5)] for _ in range(C)]
time = [0 for _ in range(10 ** 6)]
for q in query:
    s, t, c = q
    for i in range(s - 1, t):
        timeTable[c - 1][i] = True
for channel in timeTable:
    for i in range(10 ** 5):
        if channel[i]:
            time[2 * i - 1] += 1
            time[2 * i] += 1
print(max(time))

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int h,w,k;
    cin>>h>>w>>k;

    int d[6][6] = {};

    rep(i,h)rep(j,w){
        char c;cin>>c;
        if(c == '#')d[i][j]=1;
        else d[i][j]=0;
    }

    bool si[6];
    bool sj[6];

    rep(i , (1<<h)){
        int tmp = i;
        rep(p,h){
            if(tmp%2 == 1)si[p]=true;
            else si[p]=false;
            tmp/=2;
        }

        rep(j , (1<<w)){
            tmp = j;
            int bl = 0;

            rep(q,w){
                if(tmp%2 == 1)sj[q]=true;
                else sj[q]=false;
                tmp/=2;
            }

            rep(p,h)rep(q,w){
                if(si[p] || sj[q])continue;
                if(d[p][q] == 1)bl++;
            }

            if(bl==k)ans++;
        }
    }
    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

class dice
{
private:
    int asp[6];
    string order;
public:
    void setdice( int* j );                         //サイコロの値を格納
    void dice_print();                              //サイコロの値を出力
    void exchange( int& x, int& y );                //サイコロの場所を交換
    void orderX( string x );                        //転がす命令を行う
    void quetion( int x, int y );                   //質問の形にサイコロを動かす関数      
    void top_print(){ cout << asp[0] << endl; }     //上面を出力する関数
    void rig_print(){ cout << asp[2] << endl; }     //右側面を出力する関数
};

void dice::setdice( int* j )
{
    for( int i = 0; i < 6; i++ )
        asp[i] = j[i];
}

void dice::dice_print()
{
    for( int i = 0; i < 6; i++ )
        cout << asp[i] << " ";
    cout << endl;
}

void dice::exchange( int& x, int& y )
{
    int temp;
    temp = x;
    x = y;
    y = temp;
}

void dice::orderX( string x )
{

    for( int i = 0; i < x.size(); i++ )
    {

        if( x[i] == 'E' )
        {
            exchange( asp[0], asp[2] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[3] );
        }
        else if( x[i] == 'N' )
        {
            exchange( asp[0], asp[4] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[1] );
            
        }
        else if( x[i] == 'S' )
        {
            exchange( asp[0], asp[1] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[4] );
        }
        else if( x[i] == 'W' )
        {
            exchange( asp[0], asp[3] );
            exchange( asp[0], asp[5] );
            exchange( asp[0], asp[2] );
        }
        else if( x[i] == 'R' )
        {
            exchange( asp[1], asp[3] );
            exchange( asp[1], asp[4] );
            exchange( asp[1], asp[2] );
        }
        else{}
    }
}

void dice::quetion( int x, int y )
{

    for( int i = 0; i < 3; i++ )
    {
        if( asp[0] == x )
            break;
        else
            orderX("N");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[0] == x )
            break;
        else
            orderX("E");
    }

    for( int i = 0; i < 3; i++ )
    {
        if( asp[1] == y )
            break;
        else
            orderX("R");
    }

}


int main()
{
    int d[6];
    int q;
    int a, b;
    dice dice1;

    for( int i = 0; i < 6; i++ )
        cin >> d[i];
    
    cin >> q;

    for( int i = 0; i < q; i++ )
    {
        cin >> a >> b;

        dice1.setdice( d );                 //サイコロの面をセット
        dice1.quetion( a , b );             //サイコロを質問の状態に転がす
        dice1.rig_print();                  //右面を出力
    }

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(int i = x; i < n; i++) 
#define pb push_back
#define int long long
#define hii cout << "hii" << endl
#define si size()
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()

const int N = 5e5 + 5;


int arr[N];

int n, k;

int cnt[N];



int32_t main()
{
   int a, b, t;
   cin >> a >> b >> t;
   
   cout << ( t / a) * b;
   
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

ll n;
ll ans = 0;

void dfs(ll cur, bool f3, bool f5, bool f7) {
	if (cur > n) return;
	if (f3 && f5 && f7) ans++;	//全て使われている

	dfs(10 * cur + 3, true, f5, f7);	//3を追加
	dfs(10 * cur + 5, f3, true, f7);	//5を追加
	dfs(10 * cur + 7, f3, f5, true);	//7を追加
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> n;
	
	dfs(0, 0, 0, 0);
	
	out(ans);

	return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
 
N, M = map(int, input().split())
A = [-1*int(i) for i in input().split()]

heapify(A)

for i in range(M):
    n = -1 * heappop(A)
    heappush(A, -1*(n//2))
    #print(n, A)
 
print(-1*sum(A))

Measured memory_bytes: 14180
arr = input().split()
a = str(arr[0])
b = str(arr[1])
x = a + b
x = int(x)

flag = False
for i in range(1,x // 2):
    if x % i == 0:
        y = x // i
        if i == y:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans;}
   base *= base;pow/=2;}return ans;}
ll expo1(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}   
ll inv(ll x){return expo1(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){if(k == 0) return 1LL;
    ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

ll dp[123456][3], arr[123456][3];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++) cin >> arr[i][j];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(k == j) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k]+arr[i][j]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 3; i++) ans = max(ans, dp[n][i]);
    cout << ans;
}

Measured memory_bytes: 6400
#include<stdio.h>
int main()
{
	int n, x, i, j, k;
	while (1)
	{
		int way = 0;
		scanf("%d %d", &n, &x);
		if ((n == 0) && (x == 0))
			break;

		for (i = 1; i < n - 1; i++)
		{
			for (j = i + 1; j < n; j++)
			{
				for (k = j + 1; k <= n; k++)
				{
					if ((i != j) && (j != k) && (k != i) && (i + j + k == x))
						way++;
				}
			}
		}
		printf("%d\n", way);
	}

	return(0);

}

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

int main() {
    int a, b, c;
    int x;
    cin >> a >> b >> c;
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    if (b > c) {
        x = b;
        b = c;
        c = x;
    }
    if (a > b) {
        x = a;
        a = b;
        b = x;
    }
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3116
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

struct SegmentTree {
    int N;
    vector<long long> node;
 
    SegmentTree(vector<long long> v) {
        int sz = v.size();
        N = 1; while (N < sz) N *= 2;
        node.assign(2*N,1e18);
 
        for (int i = 0; i < sz; i++) node[i+N] = v[i];
        for (int i = N-1; i >= 1; i--) node[i] = min(node[i<<1|0],node[i<<1|1]);
    }
 
 
    void update(int x, long long val) {
        x += N;
 
        node[x] = val;
        while (x > 1) {
            x >>= 1;
            node[x] = min(node[x<<1|0],node[x<<1|1]);
        }
    }
 
    long long getmin(int a, int b, int k = 1, int l = 0, int r = -1) {
        if (r < 0) r = N;
 
        if (r <= a || b <= l) return 1e18;
 
        if (a <= l && r <= b) return node[k];
 
        long long vl = getmin(a, b, k<<1|0, l, (l+r)/2);
        long long vr = getmin(a, b, k<<1|1, (l+r)/2, r);
        return min(vl,vr);
    }
 
    ll getnum(int a) {
        return node[a+N];
    }    
};
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<tuple<int, int, ll>> Q(M);
    rep(i,M) {
        ll L,R,C; cin >> L >> R >> C;
        L--; R--;
        Q[i] = make_tuple(R,L,C);
    }
 
    sort(all(Q));
 
    vector<ll> dist(N,1e18);
    dist[0] = 0;
    SegmentTree sg(dist);
    rep(i,M) {
        int L,R; ll C;
        tie(R,L,C) = Q[i];
        ll d = sg.getmin(L,R+1);
        if (sg.getnum(R) > d+C) sg.update(R,d+C);
    }
 
    ll ans = sg.getnum(N-1);
    if (ans == 1e18) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
    int n,sum=0;cin>>n;
    REP(i,n){int a;cin>>a;sum+=a-1;}
    cout<<sum<<endl;
}

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

int main(){
  int n,x;
  cin>>n>>x;
  
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    cin>>data.at(i);
  }
  
  sort(data.begin(),data.end());
  
  int sum=0;
  
  for (int i=0;i<n;i++){
    sum+=data.at(i);
  }
  
  int answer=((x-sum)/data.at(0))+n;
  
  cout<<answer<<endl;
  
  
}

  













Measured memory_bytes: 256
eval"N,X,M,V=#{`tr -! ,`}{}"
s=t=0
(V[X]=t
t+=1
$*[X]=s
s+=X
V[X=X*X%M]&&(b=t-V[X]
s+=N/b*(s-$*[X])
N%=b))until 0>N-=1
p s

Measured memory_bytes: 35836
#include <bits/stdc++.h>
using namespace std;
    
int main(){
	long long l,r;
    cin >> l >> r;
    if(r >= l+2019){
    	cout << 0;
    	return 0;
    }
    long long mini = 1000000000;
    for(long long i = l ; i <= r ; i += 1){
    	for(long long j = i+1 ; j <= r ; j += 1){
    		long long val = i*j;
    		val %= 2019;
    		mini = min(mini,val);
    	}
    }
    cout << mini;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 T>
T gcd(T x, T y) {
    if (y==0) return x;
    return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y) {
    T g = gcd(x, y);
    return x / g * y;
}

int main() {
    ll n, m; string s, t;
    cin >> n >> m >> s >> t;

    ll l = lcm(n, m);
    ll g = gcd(n, m);

    vector<char> vs, vt;
    rep(i, n) {
        if (i % (n / g) == 0) vs.push_back(s[i]);
    }
    rep(i, m) {
        if (i % (m / g) == 0) vt.push_back(t[i]);
    }
    bool ok = true;
    rep(i, vs.size()) {
        if (vs[i] != vt[i]) ok = false;
    }
    cout << (ok ? l : -1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    cin >> n;
    ll a, b;

    rep(i, 1, sqrt(n) + 1){
        if(n % i == 0){
            a = i;
            b = n / i;
        }
    }

    cout << a + b -2 << endl;

}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

int[] di = [1, 0, -1, 0];
int[] dj = [0, 1, 0, -1];

void main() {
    int h, w;
    scan(h, w);
    auto ban = iota(h).map!(i => readln.chomp).array;

    int black, white;
    auto visited = new bool[][](h, w);

    // 0 : #, 1 : .
    void dfs(int i, int j, int bh) {
        visited[i][j] = true;
        if (bh) {
            white++;
        }
        else {
            black++;
        }

        foreach (k ; 0 .. 4) {
            int ni = i + di[k];
            int nj = j + dj[k];

            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (visited[ni][nj]) continue;
            if (bh && ban[ni][nj] != '#') continue;
            if (!bh && ban[ni][nj] != '.') continue;
            dfs(ni, nj, bh ^ 1);
        }
    }

    long ans;

    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            if (ban[i][j] == '#' && !visited[i][j]) {
                black = white = 0;
                dfs(i, j, 0);
                debug {
                    writefln("%(%(%b %)\n%)", visited);
                }
                debug {
                    writefln("(%d, %d), %d, %d", i, j, black, white);
                }
                ans += 1L * black * white;
            }
        }
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg ; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg ; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

long powmod(long x, long y, long mod = 1_000_000_007L) {
    long res = 1L;

    while (y > 0) {
        if (y & 1) {
            (res *= x) %= mod;
        }
        (x *= x) %= mod;
        y >>= 1;
    }

    return res;
}

Measured memory_bytes: 13180
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N = int(input())
s = [0]*N
for i in range(N):
    s[i] = int(input())
s.sort()
s.append(sum(s))
    
if s[N]%10!=0:
    print(s[N])
else:
    i = 0
    while i<N and s[i]%10==0:
        i += 1
    print(s[N]-s[i])

Measured memory_bytes: 66232
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
//////////////////////////////////////
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int ans=0;
    rep(i,n)if(s[i]!=t[i])ans++;
    cout<<ans<<endl;
    return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        out.println((n%10==n/100)?"Yes":"No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22484
#include <stdio.h>

int main(){
	int i, n;
	int a[100];
	
	while( scanf("%d", &n) != EOF)

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

	for( i=n; i>0; i--) {
		if(i != n) {
			printf(" ");
		}
		printf("%d", a[i-1]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 600
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    s = input()
    a = [[0, 0] for _ in range(n)]
    if s[0] == '.':
        a[0][0] = 1
    else:
        a[0][1] = 1
    for i in range(1, n):
        if s[i] == '.':
            a[i][0] = a[i - 1][0] + 1
            a[i][1] = a[i - 1][1]
        else:
            a[i][0] = a[i - 1][0]
            a[i][1] = a[i - 1][1] + 1
    min = a[-1][0] if a[-1][0] < a[-1][1] else a[-1][1]
    for i in range(n):
        if min > a[-1][0] - a[i][0] + a[i][1]:
            min = a[-1][0] - a[i][0] + a[i][1]
    print(min)
main()

Measured memory_bytes: 30024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	int cnt = 0;
	
	for(int i = 0; i < n; ++ i)
	{
		for(int j = i + 1; j < n; ++ j)
		{
			int sum = a[i] + a[j];
			int index = lower_bound(a.begin(), a.end(), sum) - a.begin();
			// debug(index);
			int is = index - 1 - j;
			// debug(is);
			cnt += max(0LL, is);
		}
	}
	
	cout << cnt << '\n';
    
    return 0;
}






Measured memory_bytes: 256
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();
		if (a <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}

	}
}

Measured memory_bytes: 21844
//ABC130B
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int n, x;
	scanf("%d %d",&n,&x);
	int l[n];
	int i, j;
	int p[n];
	p[0] = 0;
	int count=1;
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(j=0;j<n;j++){
		p[j+1] = p[j] + l[j];
		if(p[j+1]<=x){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);
    if (a < b){
        printf("a < b\n");
    }else if (a > b){
        printf("a > b\n");
    }else if (a == b){
        printf("a == b\n");
    }else{
        printf("ERROR!\n");
    }

    return 0;
}

Measured memory_bytes: 580
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::VecDeque;

fn main() {
    let n: usize = read();
    let x: usize = read();
    let y: usize = read();
    type Graph = Vec<Vec<usize>>;
    let mut G: Graph = vec![vec![]; n];
    for i in 0..n - 1 {
        G[i].push(i + 1);
        G[i + 1].push(i);
    }
    G[x - 1].push(y - 1);
    G[y - 1].push(x - 1);

    let mut queue: VecDeque<usize> = VecDeque::new();
    let mut dist: Vec<Vec<i32>> = vec![vec![-1; n]; n];
    for i in 0..n {
        dist[i][i] = 0;
        queue.push_back(i);

        while !queue.is_empty() {
            let v = queue.pop_front().unwrap();
            for j in &G[v] {
                if dist[i][*j] == -1 {
                    dist[i][*j] = dist[i][v] + 1;
                    queue.push_back(*j);
                }
            }
        }
    }
    let mut cnt: Vec<i64> = vec![0; n];
    for i in 0..dist.len() {
        let ii = &dist[i];
        for j in 0..ii.len() {
            let jj = ii[j];
            cnt[jj as usize] += 1;
        }
    }

    for i in 0..cnt.len() {
        let ci = cnt[i];
        if i == 0 {
            continue;
        }

        println!("{}", ci / 2);
    }
}


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

using namespace std;
int dp[110000];
    vector<int> gra[110000];

int solve(int a)
{
    if(dp[a]!=-1){
    return dp[a];}
    int ret=0;
    for(int i=0;i<gra[a].size();i++){
    ret=max(ret,solve(gra[a][i])+1);}
    
    

    return dp[a]=ret;
    
    
    
    
}


int main() {
    int n,k;
    cin>>n>>k;
   
    
    for(int i=0;i<k;i++)
{
    int a,b;
    cin>>a>>b;
    gra[a-1].push_back(b-1);
}

 for(int i=0;i<n;i++)
    dp[i]=-1;

int ret=0;
    for(int i=0;i<n;i++){
    ret=max(ret ,solve(i)); }
    

cout<<ret;
    
    
    
    return 0;
}

Measured memory_bytes: 8448
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        BigDecimal aa = sqrt(new BigDecimal(a), 50);
        BigDecimal bb = sqrt(new BigDecimal(b), 50);
        BigDecimal cc = sqrt(new BigDecimal(c), 50);
        aa = aa.add(bb);
        if (aa.compareTo(cc) == -1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static BigDecimal sqrt(BigDecimal a, int scale){

        BigDecimal x = new BigDecimal(Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17){
            x = x.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
            return x;
        }

        BigDecimal b2 = new BigDecimal(2);
        for(int tempScale = 16; tempScale < scale; tempScale *= 2){
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                            x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

static int32_t N, M;
static vector<vector<int32_t>> g;
static vector<bool> used;
static int32_t dfs(int32_t index, int32_t cnt_visit)
{
	if (cnt_visit >= N - 1)
		return 1;

	int32_t res = 0;
	used[index] = true;
	for (size_t i = 0; i < g[index].size(); i++) {
		if (used[g[index][i]])
			continue;
		res += dfs(g[index][i], cnt_visit + 1);
	}
	used[index] = false;
	return res;
}

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

	used.resize(N);
	std::fill(std::begin(used), std::end(used), false);
	g.resize(N);

	for (int32_t i = 0; i < M; i++) {
		int32_t a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	cout << dfs(0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	ll N;
	cin >> N;
	N -= 1;
	string ans = "";
	ll M = 26;
	while(1) {
		int t = N % 26;
		ans = (char)('a' + t) + ans;
		/*if(N % 26 == 0) {
			N /=26;
			N -= 1;
		}
		else N /= 26;
		*/
		N -= M;
		if(N < 0) break;
		N /= 26;
		//if(N >= 26) N -= 1;
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for B - Traveling AtCoDeer Problem
	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	sort.Sort(sort.IntSlice(A))
	fmt.Println(A[len(A)-1] - A[0])
}


Measured memory_bytes: 1840
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            MyDebugger.Test(process, "../TextFile1.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var x = int.Parse(spl[0]);
        var n = int.Parse(spl[1]);
        var ary = ToIntArray(input.ReadLine(), n);

        var hash = new HashSet<int>(ary);

        int min = int.MaxValue;
        int ret = int.MaxValue;

        for(int i=-3; i<103; i++) {
            if(hash.Contains(i)) continue;

            var v = Math.Abs(x-i);
            if(v < min) {
                ret = i;
                min = v;
            }
        }

        return ret;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if(n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27732
#include<cstdio>
using namespace std;
#define ll long long
ll n,x;
ll gcd(ll a,ll b){
	if(a%b==0)return 3*a;
	else return gcd(b,a%b)+(a/b)*3*b;
}
int main(void){
	scanf("%lld%lld",&n,&x);
	printf("%lld",gcd(n-x,x));
	return 0;
}

Measured memory_bytes: 128
PROGRAM piyo
      IMPLICIT NONE
      character(3) :: s
      integer :: ans
      
      read*,s
      
      
      if( s == 'MON' ) ans = 6
      if( s == 'TUE' ) ans = 5
      if( s == 'WED' ) ans = 4
      if( s == 'THU' ) ans = 3
      if( s == 'FRI' ) ans = 2
      if( s == 'SAT' ) ans = 1
      if( s == 'SUN' ) ans = 7
      
      
      print*,ans
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    int mi = 1145141919;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (abs(mi) > abs(0 - (i + l))) mi = i + l;
        ret += i + l;
    }

    cout << ret - mi << endl;
    return 0;
}

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

int n, m, c, p;
std::vector<int> bs;

int main() {
    int ans = 0;
    std::cin >> n >> m >> c;
    bs.assign(m, 0);
    for (int x = 0; x < m; x++) {
        std::cin >> bs[x];
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int x = 0; x < m; x++) {
            std::cin >> p;
            sum += p * bs[x];
        }
        sum += c;
        if (sum > 0) {
            ans++;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <set>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s;
    cin >> s;
    set<char> tree;

    for (auto &&i: s){
        tree.insert(i);
    }
    for (auto j = 'a'; j < 'z'+1; ++j) {
        auto res = tree.find(j);
        if (res == tree.end()){
            cout << j;
            return 0;
        }
    }
    cout << "None";
    return 0;
}

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

vector<vector<int>> graph;
static int N;
static int M;
static map<int, vector<int>> m;

// マップ作製
void makemap () {
  for (int i = 0; i < M; i++) {
    for (int j = 1; j <= N; j++) {
      if (graph[i][0] == j) {
        if (m.count(j) == 0) {
          m[j] = {graph[i][1]};
        } else {
          m[j].push_back(graph[i][1]);
        }
      }
      if (graph[i][1] == j) {
        if (m.count(j) == 0) {
          m[j] = {graph[i][0]};
        } else {
          m[j].push_back(graph[i][0]);
        }
      }      
    }
  }
}

bool findNum (vector<int> vec, int num) {
  bool ret = false;
  for (auto x : vec) {
    if (x == num) {
      ret = true;
      break;
    }
  }
  return ret;
}

int main()
{
  // 入力受け取り
  int g1,g2;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> g1 >> g2;
    graph.push_back({g1,g2});
  }
  
  // 初期化
  makemap();
  
  // カウント
  int counter = 0;
  vector<int> v(N-1);
  iota(v.begin(), v.end(), 2);
  do {
    int before = 1;
    int exist = 1;
    for(auto x : v) {
      if (!findNum(m[before], x)) break;
      exist++;
      before = x;
    }
    if (exist == N) {
      counter++;
    }
  } while( next_permutation(v.begin(), v.end()) ); 
  
  cout << counter << endl;
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
cnt1,cnt2,cnt3,cnt4,cnt5=0,0,0,0,0
for i in s:
    if i[0]=='M':
        cnt1+=1
    elif i[0]=='A':
        cnt2+=1
    elif i[0]=='R':
        cnt3+=1
    elif i[0]=='C':
        cnt4+=1
    elif i[0]=='H':
        cnt5+=1
print(cnt1*cnt2*cnt3+cnt1*cnt2*cnt4+cnt1*cnt2*cnt5+cnt1*cnt3*cnt4+cnt1*cnt3*cnt5+cnt1*cnt4*cnt5+cnt2*cnt3*cnt4+cnt2*cnt3*cnt5+cnt2*cnt4*cnt5+cnt3*cnt4*cnt5)

Measured memory_bytes: 9772