akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    LL N;
    cin >> N;
    LL a[N];
    REP(i,N) cin >> a[i];
    LL sum=0;
    REP(i,N) sum+=a[i];
    LL ans=10000000000;
    LL tmp=0;
    LL res=0;
    for(int i=0;i<N;++i){
        tmp+=a[i];
        res=sum-tmp;
        if(i+1<N)
        ans=min(ans,abs(res-tmp));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
def input_undirected_graph(V: int, E: int, origin: int = 1):
    graph = [list() for _ in range(V)]
    for i in range(E):
        u, v = [int(x) for x in input().split()]
        u -= origin
        v -= origin
        graph[u].append(v)
        graph[v].append(u)
    return graph


def main():
    N, Q = [int(x) for x in input().split()]
    graph = input_undirected_graph(N, N-1)

    vals = [0] * N
    for _ in range(Q):
        p, x = [int(x) for x in input().split()]
        vals[p-1] += x
    
    ans = [0] * N
    stack = [(0, -1, 0)]  # node, par, val
    while stack:
        node, par, val = stack.pop()
        ans[node] += vals[node] + val

        for child in graph[node]:
            if child == par:
                continue
            stack.append((child, node, ans[node]))

    for i in range(N):
        print(ans[i])
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Measured memory_bytes: 61872
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n,m;
    while(cin>>n>>m){
        if(n==0 && m==0)break;
        
        vi in;
        rep(i,n){
            int a;
            cin>>a;
            in.pb(a);
        }
        rep(i,m){
            int a;
            cin>>a;
            in.pb(a);
        }
        in.pb(0);
        
        sort(all(in));
        
        int maxi=-1;
        rep(i,in.size()-1){
            maxi=max(maxi,in[i+1]-in[i]);
        }
        
        cout<<maxi<<endl;
        
    }

    return 0;
}

Measured memory_bytes: 1348
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll A[200010], B[200010];
ll cntA[200010] = {}, cntB[200010] = {};
vector<ll> pos[200010];

void solve(){
    ll N;
    cin >> N;
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];
    rep(i,0,N){
        pos[A[i]].push_back(i);
    }

    rep(i,0,N){
        cntA[A[i]]++;
        cntB[B[i]]++;
    }
    rep(i,0,N+1){
        if(cntA[i] + cntB[i] > N){
            print("No");
            return;
        }
    }
    vector<lpair> lp;
    rep(i,0,N+1){
        if(cntA[i] > 0 && cntB[i] > 0){
            lp.push_back({N - cntA[i] - cntB[i], i});
        }
    }

    sort(lp.begin(), lp.end(), [&](lpair l1, lpair l2){
        if(l1.first == l2.first){
            return cntB[l1.second] < cntB[l2.second];
        }
        return l1.first < l2.first;
    });

    queue<ll> que;
    vector<lpair> v;
    if(lp.size() == 0){
        print("Yes");
        printa(B,N);
        return;
    }
    rep(i,0,N){
        if(A[i] != lp[0].second){
            v.push_back({N- cntB[A[i]], i});
        }
    }
    sort(v.begin(), v.end());
    for(auto &e: v){
        que.push(e.second);
    }
    ll ans[200010] = {};
    ll idx = 0;
    for(auto &e: lp){
        // print(e.second);
        // printa(ans, N);
        ll n = cntB[e.second];
        vector<ll> mine;
        while(n--){
            ll q;
            while(true){
                q = que.front();
                if(A[q] == e.second){
                    que.push(q);
                    que.pop();
                }else{
                    que.pop();
                    break;
                }
            }
            // ll q = que.front();
            // if(A[q] == e.second){

            // }
            // que.pop();
            ans[q] = e.second;
        }
        if(idx == 0){
            for(auto &f: pos[e.second]){
                if(ans[f] == 0){
                    que.push(f);
                }
            }
        }
        idx++;
    }
    stack<ll> st;

    rep(i,0,N){
        if(cntA[B[i]] == 0 && cntB[B[i]] > 0){
            st.push(B[i]);
        }
    }
    rep(i,0,N){
        if(ans[i] == 0){
            ans[i] = st.top();
            st.pop();
        }
    }
    print("Yes");
    printa(ans, N);

    

}

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


Measured memory_bytes: 29648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n;
	cin >> n;
	cout << (n+1)/2*(n/2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;
  for(i=0;i<k;i++){
    sum+=vec.at(i);
  }
  cout << sum;
}
    
  

Measured memory_bytes: 256
#include <iostream>
using namespace	std;
int main(){

  int n,c[600],s[600],f[600];
  cin>>n;
  for(int i=0;i<n-1;i++) cin>>c[i]>>s[i]>>f[i];
  for(int i=0;i<n-1;i++){
    int r=0;
    for(int j=i;j<n-1;j++){
      int ne=s[j];
      for(;r>ne;ne+=f[j]);
      r=ne;
      r+=c[j];
    }
    cout<<r<<endl;
  }
  cout<<0<<endl;
  return 0;
}





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

using namespace std;
typedef long long ll;
ll v[2000005],nr,f[2000005],n,k;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        f[v[i]]++;
    }
    for(int i=1;i<=n;i++)
        nr=nr+f[i]*(f[i]-1)/2;
    for(int i=1;i<=n;i++)
    {
        k=v[i];
        nr-=f[k]*(f[k]-1)/2;
        nr+=(f[k]-1)*(f[k]-2)/2;
        cout<<nr<<'\n';
        nr-=(f[k]-1)*(f[k]-2)/2;
        nr+=f[k]*(f[k]-1)/2;
    }
    return 0;
}


Measured memory_bytes: 7296
/*  CREATED BY
    STREAM_CIPHER
    7-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n,k;
        cin>>n>>k;
        vector<int>a(n);
        for(auto &i:a)
            cin>>i;
        int dp[n+1];
        memset(dp,inf,sizeof dp);
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(int i=1;i<n;i++)
        {
            for(int j=max(0ll,i-k);j<i;j++)
                dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
        }
        cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4784
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    ll N,a;
    set<ll> A;
    cin >> N;
    bool f = true;
    for (auto i = 0; i < N; i ++) {
        cin >> a;
        if (A.find(a) != A.end()) {
            f = false;
            break;
        }
        A.insert(a);
    }
    if (f) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 9600
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var count = 0;

            var N = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            var z = 10;

            

            for (var x = 1; x <= N; x = x + 1)
            {
                var sum = 0;
                var n = x;
                for (var i = 1; i <= x.ToString().Length; i = i + 1)
                {
                    sum = sum + (n % 10);
                    n = n / 10;
                }

                if (a <= sum && sum <= b)
                {
                    count = count + x;
                }
            }

            WriteLine(count.ToString());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 29280
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            cnt +=1;
        }
    }
    cout << cnt << endl;
    return 0;
}
    




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

#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 3e5 + 5;

inline void solve() {
	int n, ans(0);
	cin >> n;
	vector < int > v(n);
	for (auto &i : v) {
		cin >> i;
	}
	sort(v.begin(), v.end());
	if (n & 1) {
		cout << 0;
		return;
	}
	int x = n / 2 - 1;
	if(v[x+1] - v[x]) {
		cout << v[x+1] - v[x];
	}
	else {
		cout << 0;
	}
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t; while(t--)
                solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k,x;cin>>k>>x;
    if(500*k>=x)cout<<"Yes";
    else cout<<"No";
    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);
        //1 ~ 10^5
        int N = sc.nextInt();

        if (N==1){System.out.println(0);}
        else{
            int Ans = 0;
            int Temp = 0;
            int[] H = new int[N];
            for(int i=0;i<N;i++){H[i]=sc.nextInt();}
            for(int i=0;i<N-1;i++){
                if(H[i]>=H[i+1]){Temp += 1;}
                if((H[i]<H[i+1])|(i == N-2)){
                    if(Ans < Temp){Ans = Temp;}
                    Temp = 0;
                }
            }
            System.out.println(Ans);
            
        }
        sc.close();
    }
}

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	int k; string s;cin>>k>>s;
	if(s.size()<=k) cout<<s<<endl;
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...\n";
	}	
}

Measured memory_bytes: 3604
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL num[200005];

int main()
{
	int n;
	scanf("%d", &n);
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &num[i]);
		sum += num[i];
	}

	LL now = 0;
	LL ans = ABS(num[0] - (sum - num[0]));
	for (int i = 0; i < n - 1; i++) {
		now += num[i];
		ans = MIN(ans, ABS(now - (sum - now)));
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,a[20],b[20],c[19],cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        cnt+=b[a[i]-1];
        if(i>0 && a[i]-a[i-1]==1)
            cnt+=c[a[i-1]-1];
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int Q;
	cin >> Q;
	int rsl[100001];
	memset(rsl, 0, sizeof(rsl));
	rep(i, 1, 100001) {
		if((i + 1) % 2 != 0) continue;
		if(is_prime(i) and is_prime((i + 1) / 2)) {
			rsl[i]++;
		}
	}

	rep(i, 1, 100000) {
		rsl[i + 1] += rsl[i];
	}

	vector<int> ans;
	rep(i, 0, Q) {
		int l, r;
		cin >> l >> r;
		ans.push_back(rsl[r] - rsl[l - 1]);
	}

	rep(i, 0, ans.size()) cout << ans[i] << endl;
}


Measured memory_bytes: 1528
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    
    int s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct EDGE
{
	int u, v, w;

	EDGE (const int &u0 = 0, const int &v0 = 0, const int &w0 = 0) : u(u0), v(v0), w(w0) {}

	bool operator < (const EDGE &t) const {return w < t.w;}
};

struct UNION
{
	int fa[MX];

	UNION () {for(int i=1; i<MX; i++) fa[i] = i;}

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

int n, m;
ll X, val[MX];
EDGE e[MX];

ll qpow(ll x, ll t)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		t >>= 1;
	}
	return ret;
}

ll mst(int force)
{
	ll ret = 0;
	UNION u;
	u.fa[e[force].u] = e[force].v, ret += e[force].w;
	for(int i=1; i<=m; i++)
	{
		if(u.id(e[i].u) != u.id(e[i].v))
		{
			u.fa[u.id(e[i].u)] = u.id(e[i].v);
			ret += e[i].w;
		}
	}
	return ret;
}

void input()
{
	read(n), read(m), read(X);
	for(int i=1; i<=m; i++)
	{
		int a, b, c;
		read(a), read(b), read(c);
		e[i] = EDGE(a, b, c);
	}
	sort(e+1, e+m+1);
}

void work()
{
	int sma = 0, big = 0, eqa = 0;
	for(int i=1; i<=m; i++) val[i] = mst(i);
	for(int i=1; i<=m; i++)
	{
		sma += (val[i]<X);
		eqa += (val[i]==X);
		big += (val[i]>X);
	}
	if(val[1] > X) printf("0\n");
	else if(val[1] == X) printf("%lld\n", (qpow(2, eqa)-2+MOD)*qpow(2, big)%MOD);
	else printf("%lld\n", 2*(qpow(2, eqa)-1)*qpow(2, big)%MOD);
}

int main()
{
	input();
	work();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

map<ll, int> prime_factor(ll n){
    map<ll, int> res;
    for(ll i = 2; i*i <= n; i++){
        while (n % i == 0){
            // pr(n, i);  
            res[i]++;
            n /= i;
        }
    }
    return res;
}

int main(void)
{
    ll N,P;
    cin >> N >> P;

    if(N >= P){
        pr(1);
        return 0;
    }
    if(N == 1){
        pr(P);
        return 0;
    }
    if(P == 1){
        pr(1);
        return 0;
    }
    auto d = prime_factor(P);

    ll ans = 1;
    for(auto&& i : d) {
        // pr(i.fi, i.se);
        // pr(i.fi, i.se);
        ans *= pow(i.fi, i.se/N);
        // while(i.se >= N){
        //     ans *= i.fi;
        //     i.se -= N;
        // }
    }


    pr(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int INF = 1000*20000;

struct Edge{
  int to;
  int cost;
  Edge():to(0),cost(0){}
  Edge(int to, int cost):to(to),cost(cost){}
  bool operator<(const Edge& e)const{
    return cost < e.cost;
  }
};

void dijkstra(const int start, const vector< vector<Edge> >& G1, vector< vector<int> >& G2){
  for(int i = 0;  i < G2[start].size(); i++){
    G2[start][i] = INF;
  }

  G2[start][start] = 0;

  priority_queue< P > que; //cost, pos
  que.push(P(0, start));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int pos = p.second;
    int cost = p.first;
    if(G2[start][pos] < cost) continue;
    for(int i = 0; i < G1[pos].size(); i++){
      int to = G1[pos][i].to;
      if(G2[start][to] > G2[start][pos] + G1[pos][i].cost){
        G2[start][to] = G2[start][pos] + G1[pos][i].cost;
        que.push(P(G2[start][to], to));
      }
    }
  }
}

int main(void){
  int verts, edge, envelop, start; cin >> verts>> edge>> envelop>> start; start--;
  vector< vector<Edge> > G1(verts);
  vector< vector<int> > G2(verts, vector<int>(verts, INF));
  vector<int> S(envelop);
  vector<int> T(envelop);
  for(int i = 0; i < edge; i++){
    int x, y, w; cin >> x >> y >> w;
    x--; y--;
    G1[x].push_back( Edge(y, w) );
    G1[y].push_back( Edge(x, w) );
  }
  for(int i = 0; i < envelop; i++){
    cin >> S[i] >> T[i];
    S[i]--; T[i]--;
  }

  dijkstra(start, G1, G2);
  for(int i = 0; i < envelop; i++){
    dijkstra(S[i], G1, G2);
    dijkstra(T[i], G1, G2);
  }

  /*
  for(int i = 0; i < verts; i++){
    for(int j = 0; j < verts; j++){
      cout << G2[i][j] << " ";
    }
    cout << endl;
  }
  */

  vector< vector<int> > G3(16, vector<int>(16, INF));
  for(int i = 0; i < envelop; i++){
    for(int j = i; j < envelop; j++){
      G3[i][j] = G3[j][i] = G2[S[i]][S[j]];
      G3[i][j+envelop] = G3[j+envelop][i] = G2[S[i]][T[j]];
      G3[i+envelop][j] = G3[j][i+envelop] = G2[T[i]][S[j]];
      G3[i+envelop][j+envelop] = G3[j+envelop][i+envelop] = G2[T[i]][T[j]];
    }
  }

  /*
  for(int i = 0; i < 16; i++){
    for(int j = 0; j < 16; j++){
      cout << G3[i][j] << " ";
    }
    cout << endl;
  }
  */

  vector< vector<int> > dp(1<<16, vector<int>(16, INF));
  for(int i = 0; i < envelop; i++){
    dp[1<<i][i] = G2[start][S[i]];
  }

  for(int i = 0; i < (1<<(2*envelop)); i++){
    for(int j = 0; j < 2*envelop; j++){
      if(dp[i][j] != INF){
        for(int k = 0; k < 2*envelop; k++){
          if(G3[j][k] != INF && (k < envelop || ((i>>(k-envelop))&1))){
            
              if(dp[i|(1<<k)][k] > dp[i][j] + G3[j][k]){
                dp[i|(1<<k)][k] = dp[i][j] + G3[j][k];
              }
          }
        }
      }
    }
  }

  /*
  for(int i = 0; i < (1<<16); i++){
    for(int j = 0; j < 16; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */

  int ans = INF;
  for(int i = 0; i < 2*envelop; i++){
    int v = dp[(1<<(2*envelop))-1][i];
    ans = min(ans, v);
  }
  if(ans == INF) cout << "Cannot deliver" << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 13688
import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)+1):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
      loss = 0
  
print(min(ll))

Measured memory_bytes: 14432
#include <stdio.h>
#include <iostream>

//  A... Z  a... z
// 65...90 97...122

int main() {
    char ch;
    int alpha[26] = {0};
    while ((ch = getchar()) != EOF) {
        if (ch >= 97 && ch <= 122) alpha[ch - 97] += 1;
        else if (ch >= 65 && ch <= 90) alpha[ch - 65] += 1;
    }
    for (int i=0;i<26;++i)
        std::cout << (char)(i + 97) << " : " << alpha[i] << std::endl;
    
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 998244353;
 
int dx[]={-1, 0, 1, 0,1,-1,1,-1};
int dy[]={0, -1, 0, 1,1,-1,-1,1};




int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 
 


int n,m;
cin>>n>>m;
int sum=0;

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

sort(v.begin(),v.end());
if(v[n-m]*4*m>=sum)
{
    cout<<"Yes\n";
}
else cout<<"No\n";



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

P valid(string s) {
  int depth = 0;
  rep(i,sz(s)) {
    if(s[i] == '(') {
      depth++;
    } else {
      depth--;
    }
    if(depth < 0) return P(0,-1);
  }
  if(depth != 0) return P(-1,sz(s));
  return P(-1,-1);
}
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  P pos = valid(s);
  while(pos.first != -1 || pos.second != -1) {
    if(pos.first != -1) {
      s.insert(pos.first,"(");
    } else {
      s.insert(pos.second,")");
    }
    pos = valid(s);
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int W, H, x, y, r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    if(x-r < 0||x+r > W){
        printf("No\n");
    }
    else if(y-r < 0||y+r > H){
        printf("No\n");
    }
    else if(x-r >= 0&&x+r <= W){
        printf("Yes\n");
    }
    else if(y-r >= 0&&y+r <= H){
        printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
     lint k;
     lint ans=0;
     cin>>k;
     repp(i,1,k+1){
         repp(j,1,k+1){
             repp(l,1,k+1){
                 lint f=gcd(i,j);
                 f=gcd(f,l);
                 ans+=f;
                 //cout<<f<<endl;
             }
         }
     }
     cout<<ans;
  }
  
     


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
main () {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.6f\n", sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

Measured memory_bytes: 3204
#include<iostream>
using namespace std;
void convert(int x, int b) {
	if (x == 0)
		return;
	int p, l = x % 10;
	if (l < 0)
		l *= -1;
	if (l == 0) {
		p = 0;
	} else if (x * b < 0) {
		p = 10 - l;
		x -= b * 10;
	} else {
		p = l;
	}
	convert(x / 10, b * (-1));
	cout << p;
}
int main() {
	int x;
	while(cin >> x && x ) {
		convert(x, 1);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
from functools import reduce

def solve():
    MOD = 10**9 + 7

    def gcd(a, b):
        while b:
            a, b = b, a%b
        return a
    def lcm(a, b):
        return a // gcd(a, b) * b

    N = int(input())
    As = list(map(int, input().split()))

    lcmA = reduce(lcm, As)
    #print('lcmA:', lcmA)

    ans = 0
    for A in As:
        ans += lcmA // A
    ans %= MOD

    print(ans)

solve()


Measured memory_bytes: 4708
s = list(input())
n = len(s)
ans = [0]*n
r = 0
for i in range(n):
    if s[i]=="R":
        r +=1
    else:
        a = r//2
        b = r-a
        ans[i] += a
        ans[i-1] += b
        r = 0
l = 0
for i in reversed(range(n)):
    if s[i]=="L":
        l+=1
    else:
        a = l//2
        b = l-a
        ans[i] += a
        ans[i+1] +=b
        l = 0
print(*ans)


Measured memory_bytes: 7208
N = int(input())
a, b = [], []
for i in range(N):
    a.append(list(map(int, input().split())))
for i in range(N):
    b.append(list(map(int, input().split())))
b.sort()
ans = 0
ls = []
for y in b:
    c = []
    for x in a:
        if x[0] < y[0] and x[1] < y[1] and not x in ls:
            c.append(x)
    if len(c) != 0:
        c.sort(key=lambda x: x[1], reverse=True)
        ls.append(c.pop(0))
        ans += 1
print(ans)


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

int main() {
int N;
  int i;
  cin >> N >> i;
string S;
  cin >> S;
  if ( S.at(i-1) == 'A'){
    S.at(i-1)='a';
  }
    if ( S.at(i-1) == 'B'){
    S.at(i-1)='b';
  }
    if ( S.at(i-1) == 'C'){
    S.at(i-1)='c';
  }
cout << S << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int seisuu1,seisuu2;
	int answer;
        scanf("%d", &seisuu1);
        scanf("%d", &seisuu2);
          
         if (seisuu1<=9 && seisuu2<=9){
			answer = seisuu1*seisuu2;
         }
		else{
			answer=-1;
		}

	printf("%d",answer);

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n,q,ans;
char s[305];
int dp[305][305][305];
int main(void){
    cin>>s>>q;
    n=strlen(s);
    for(int i=0;i<n;i++)dp[q][i][i]=1;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1])dp[q][i][i+1]=2;
        else dp[q][i][i+1]=1;
    }
    for(int i=0;i<n-1;i++)if(s[i]!=s[i+1]&&q>0)dp[q-1][i][i+1]=2;
    for(int k=1;k<n;k++){
        for(int i=0;i+k<n;i++){
            int l=i,r=i+k;
            for(int j=0;j<=q;j++){
                if(s[l]==s[r]){
                    dp[j][l][r]=max(dp[j][l][r],dp[j][l+1][r-1]+2);
                }else if(j<q){
                    dp[j][l][r]=max(dp[j][l][r],dp[j+1][l+1][r-1]+2);
                }
                dp[j][l][r]=max(dp[j][l][r],max(dp[j][l+1][r],dp[j][l][r-1]));
            }
        }
    }
    for(int i=0;i<=q;i++)ans=max(ans,dp[i][0][n-1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 110848
# kotae mita
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
def main():
    N = int(input())
    l = []
    for i in range(N):
        x, y = map(int, input().split())
        l.append((x,y,i))
    X = sorted(l, key=lambda x:x[0])
    Y = sorted(l, key=lambda x:x[1])
    d = {}
    for i in range(N-1):
        p = max(X[i][2], X[i+1][2])
        q = min(X[i][2], X[i+1][2])
        if (p, q) in d:
            d[(p, q)] = min(d[(p,q)], abs(X[i][0] - X[i+1][0]))
        else:
            d[(p, q)] = abs(X[i][0] - X[i+1][0])
        p = max(Y[i][2], Y[i+1][2])
        q = min(Y[i][2], Y[i+1][2])
        if (p, q) in d:
            d[(p, q)] = min(d[(p,q)], abs(Y[i][1] - Y[i+1][1]))
        else:
            d[(p, q)] = abs(Y[i][1] - Y[i+1][1])
    p = []
    q = []
    w = []
    for i in d:
        p.append(i[0])
        q.append(i[1])
        w.append(d[i])
    csr = csr_matrix((w, (p,q)), shape=(N,N))
    return int(minimum_spanning_tree(csr).sum())
print(main())



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


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

    //azzel z<->p e<->l 
    //apple
    map<char,char> ms;
    map<char,char> mt;

    //aappa
    //ppaap に対応できない

    //入れ替えるものの個数が互いに同じか
    //aappa a3p2
    //ppaap p3a2
    //abcde
    //fghij

    //aaaacccc
    //cacacaca これに対応できない a<->c,a

    // bool ok = true;
    // FOR(i,0,s.length()){
    //     if(ms[s[i]]==mt[t[i]]&&ms[t[i]]==mt[s[i]])continue; 
    //     ok = false;
    //     break;
    // }
    bool ok = true;

    FOR(i,0,s.length()){
        if(!ms[s[i]])ms[s[i]]=t[i];
        else if(ms[s[i]]!=t[i]){
            ok = false;
            break;
        }
        if(!mt[t[i]])mt[t[i]]=s[i];
        else if(mt[t[i]]!=s[i]){
            ok = false;
            break;
        }
    }

    if(ok){
        PRINT("Yes");
    }else{
        PRINT("No");
    }

}



Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll ans=0;
    rep(i,n){
        ans+=min(2*x[i],2*abs(k-x[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
from collections import defaultdict

N = int(input())

polls = defaultdict(int)

max_poll = 0

for _ in range(N):
  k = input()
  polls[k] += 1
  max_poll = max(max_poll, polls[k])
  
for k in sorted([k for k in polls.keys() if polls[k] == max_poll]):
  print(k)
  
  


Measured memory_bytes: 99416
#include <cstdio>
#include <cassert>

using namespace std;

int field[52][52];
int pats[4][3][3];
int h;
int w;

bool is_ok(int x, int y){
  if(field[x][y] == 0){
    return true;
  }
  for(int i=0; i < 4; i++){
    bool ok = true;
    for(int u=0; u < 3; u++){
      for(int v=0; v < 3; v++){
        if(pats[i][u][v] == 1 && field[x + (u-1)][y + (v-1)] == 0){
          ok = false;
        }
      }
    }
    if(ok){
      return true;
    }
  }
  return false;
}

int main(){
  for(int i=0; i < 4; i++){
    for(int x=0; x < 3; x++){
      for(int y=0; y < 3; y++){
        pats[i][x][y] = 0;
      }
    }
  }

  // int smallpats[4][2][2];
  // for(int i=0; i < 4; i++){
  //   for(int x=0; x < 2; x++){
  //     for(int y=0; y < 2; y++){
  //       smallpats[i][x][y] = 0;
  //     }
  //   }
  // }
  // // 0 is NE, 1 is ES, 2 is SW, 3 is WN  
  // smallpats[0][0][0] = 1; smallpats[0][0][1] = 1; smallpats[0][1][1] = 1;
  // smallpats[1][0][0] = 1; smallpats[1][1][0] = 1; smallpats[1][0][1] = 1;
  // smallpats[2][0][0] = 1; smallpats[2][1][0] = 1; smallpats[2][1][1] = 1;
  // smallpats[3][1][0] = 1; smallpats[3][0][1] = 1; smallpats[3][1][1] = 1;
  // for(int x=0; x < 2; x++){
  //   for(int y=0; y < 2; y++){
  //     for(int i=0; i < 4; i++){
  //       for(int u=0; u < 2; u++){
  //         for(int v=0; v < 2; v++){
  //           pats[i + 4*y + 8*x][x+u][y+v] = smallpats[i][u][v];
  //         }
  //       }
  //     }
  //   }
  // }

  // NESW
  pats[0][1][0] = 1; pats[0][1][1] = 1;
  pats[1][1][1] = 1; pats[1][2][1] = 1;
  pats[2][1][1] = 1; pats[2][1][2] = 1;
  pats[3][0][1] = 1; pats[3][1][1] = 1;
  
  for(int x=0; x < 52; x++){
    for(int y=0; y < 52; y++){
      field[x][y] = 0;
    }
  }
  scanf("%d %d", &h, &w);
  char temp;
  for(int y=0; y < h; y++){
    scanf("%c", &temp);
    if(temp != '\n'){
      assert(false);
    }
    for(int x=0; x < w; x++){
      scanf("%c", &temp);      
      switch(temp){
      case '#':
        field[x+1][y+1] = 1;
        break;
      case '.':
        field[x+1][y+1] = 0;
        break;
      default:
        assert(false);
      }
    }
  }

  bool ok = true;
  for(int x=0; x < w; x++){
    for(int y=0; y < h; y++){
      // printf("debug! x%d, y%d, !%d\n", x, y, is_ok(x+1, y+1)); 
      ok = ok && is_ok(x+1, y+1);
    }
  }

  if(ok){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String lastWeek = sc.nextLine();
        String thisWeek;
        if(lastWeek.equals("ARC")) {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }
}

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

int main(){
    int n, m, a[1000];
    cin >> n >> m;

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

    int sum = 0;
    for (int i = 0; i < n; ++i) sum += a[i];

    sort(a, a + n, greater<int>());

    if (a[m-1] * 4 * m >= sum ) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

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

fn main() {
    let n: usize = read();
    let mut cnt = 0;
    for i in 1..n + 1{
        if i % 2 == 0 {
            continue;
        }
        let mut tmp = 0;
        for j in 1..n + 1 {
            if i % j == 0 {
                tmp += 1;
            }
        }
        if tmp == 8 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	const vector<string> v = { "Sunny", "Cloudy", "Rainy" };
	auto k = find(v.begin(), v.end(), S) - v.begin();
	auto &ans = v[(k + 1) % v.size()];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int t, x;
  cin >> t >> x;

  cout << t * 1.0 / x << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
long long x[110][110], y[110][110], z[110][110];
for(int i=1; i<=a; i++){
	for(int j=1; j<=b; j++){
		cin>>x[i][j];
	}
}
for(int i=1; i<=b; i++){
	for(int j=1; j<=c; j++){
		cin>>y[i][j];
	}
}
for(int i=1; i<=a; i++){
	for(int j=1; j<=b; j++){
		for(int k=1; k<=c; k++){
			z[i][k]= z[i][k] + (x[i][j]*y[j][k]);
		}
	}
}

for(int i=1; i<=a; i++){
	for (int j=1; j<=c; j++){
		if(j!=1){
			cout<<' ';
		}
		cout<<z[i][j];
	}
	cout<<endl;
	}
}


Measured memory_bytes: 3348
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int a, b, c, d;
signed main()
{
	cin >> a >> b >> c >> d;

	int taka = (b + c - 1) / b;
	int ao = (a + d - 1) / d;

	if (taka <= ao) { 
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
s.sort()
#print(sum(s))
if sum(s) % 10 != 0:
    print(sum(s))
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(sum(s) - s[i])
            exit()
    print(0)


Measured memory_bytes: 2940
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
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 ll  long long 
const ll INF=1LL<<60;
const ll MOD=1000000007;
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
ll dp[2001];
int main(){
    ll a,x=1;cin>>a;
    bool g=true;
    vector<ll>b(a),c(a);
    pair<ll,ll>d,e;
    d.first=0;d.second=0;
    e.second=0;e.first=0;
    rep(i,a){
        cin>>b[i];
        if(i!=0)if(b[i]==b[i-1])x++;
        else {
            if(d.first<x){
                d.first=x;
                d.second=b[i-1];
            }x=1;
        }
    }
    x=1;
    rep(i,a){
        cin>>c[i];
                if(i!=0)if(c[i]==c[i-1])x++;
        else {
            if(e.first<x){
            e.first=x;
            e.second=c[i-1];
            }
            x=1;
        }
    }
    /*if(d.first>a/2&&e.first>a/2&&d.second==e.second){
        cout<<"No";
        return 0;
    }*/
    reverse(c.begin(),c.end());
    rep(i,a){
        if(b[i]==c[i]){
            g=true;
            rep(j,a){
                if(b[i]!=c[j]&&b[j]!=c[i]){
                    swap(c[i],c[j]);
                    g=false;
                    break;
                }
            }
            if(g){cout<<"No";
            return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    rep(i,a)cout<<c[i]<<" ";
}

Measured memory_bytes: 6356
N = list(input())

N.reverse()

ans = 0
flag = False
L = len(N)
for i,s in enumerate(N):
    n = int(s)
    
    if flag:
        n += 1
    
    if n<5:
        ans += n
        flag = False
    elif n>5:
        ans += 10-n
        flag = True
    else:
        if i==L-1:
            ans += n
            flag = False
            break
            
        if int(N[i+1])<5:
            ans += n
            flag = False
        else:
            ans += 10-n
            flag = True

if flag:
    ans += 1
    
print(ans)
        
        
    
    

Measured memory_bytes: 12856