akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
	
int main(){
	int a,b,c;
	
	cin >> a >> b >> c ;
	
	if(a < b && b < c){
		cout << "Yes" <<endl;
	}		
	else{
		cout << "No" <<endl;	
	}		
	

 
	
	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b; std::cin >> a >> b;
  int ans = 0;
  auto check = [&](int tn) {
    int num = (tn - 1) * (a - 1) + a;
    if (tn == 0) num = 1;
    return num >= b;
  };
  while (!check(ans)) ans++;
  std::cout << ans << "\n";
}


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

int main() {
  // ここにプログラムを追記
  string s;
  int ans = 0;
  cin >> s;
  if(s[0]=='1') ans++;
  if(s[1]=='1') ans++;
  if(s[2]=='1') ans++;
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    string s;
    string a[3]={"Sunny","Cloudy","Rainy"};
    cin>>s;
    if(s==a[0])
    {
        cout<<a[1];
    }
    else if(s==a[1])
    {
        cout<<a[2];
    }
    else
    {
        cout<<a[0];
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>  
using namespace std;  
int main()  
{  
    long long int n,c=1,m,t,temp;  
    cin>>n;  
    for(int i=0;i<n;i++)  
    {  
        cin>>t;  
        if(t>c)  
        {  
            temp=c;  
            c=t;  
            t=temp;  
        }  
        long long int k,l;  
        k=t;  
        l=c;  
        while(t!=0)  
        {  
            temp=c%t;  
            c=t;  
            t=temp;  
        }  
        c=l/c*k;//数据太大，所以先除后乘  
    }     
    cout<<c<<endl;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    ll n; cin>>n;
    for(ll i=100000; i>=1; i--){
        ll num=i*i;
        if(num<=n){
            cout << num << endl;
            return 0;
        }
    }
}

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

int main(int argc, const char * argv[]) {
    
    int a[10];
    int n;
    int counter=0;
    int all=1;
    int minus=1;
    
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            counter++;
        }
    }
    
    
    
    for(int i=0;i<n;i++){
        all=all*3;
    }
    
    for(int i=0;i<counter;i++){
        minus=minus*2;
    }
    
    cout << all-minus << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI A(N);
  rep(i,N) cin>>A[i];
  priority_queue<int> P;
  rep(i,N) P.push(A[i]);
  rep(i,M){
    int X=P.top();
    P.pop();
    P.push(X/2);
  }
  ll ans=0;
  rep(i,N){
    ans+=P.top();
    P.pop();
  }
  cout<<ans<<endl;
}






Measured memory_bytes: 1276
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
T = [(i != j, i) for i, j in zip(T, [None] + T)]
A = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(T, A):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		else:
			if(q[1] < p[1]):
				print(0)
				exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7)
print(P) 

Measured memory_bytes: 26304
let () =
  try
    while true do
      let l = Array.init 10 (fun _ -> Scanf.scanf "%d," (fun i -> 2000*i)) in
      let (v1, v2) = Scanf.scanf"%d,%d "(fun v1 v2 -> v1, v2) in
      let x = v1 * (Array.fold_left (+) 0 l / (v1 + v2)) in
      let rec doit i z =
        let z = z + l.(i) in
        if x <= z then i + 1
        else doit (i + 1) z in
      doit 0 0 |> Printf.printf "%d\n"
    done
  with _ -> ()

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

using namespace std;

#define PI 3.14159265358979323846264338327950L


char solve(string S,int index){
    


}

int main(void)
{

    string T, ans;

    cin >> T;

    ans = T;



    for (int i = 0; i < T.size() ; i++)
    {
        if(T[i] == '?'){
            ans[i] = 'D';
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3788
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  string s;
  ll k;
  cin>>s>>k;
  bool ans=true;
  REP(i,k){
    if(s[i]=='1'){continue;}
    else{cout<<s[i]<<endl;ans=false;break;}
  }
  if(ans){cout<<'1'<<endl;}
}


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

int main(){
    int N,D;
    double dist;
    double dist_temp=0;
    int count = 0;

    cin >> N >> D;
    vector<vector<int>> data(N, vector<int>(D));
 
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
        cin >> data.at(i).at(j);
        }
    }

    for(int k = 0; k<N;k++){
        for(int l = k+1; l<N; l++){
            for(int m = 0;m < D;m++){
                dist_temp += pow((data.at(k).at(m)-data.at(l).at(m)) ,2);
            }
            dist = sqrt(dist_temp);
            if(ceil(dist) == floor(dist)){
                count += 1;
            }
            dist_temp = 0;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long lbase = 0;
        long rbase = 0;
        PriorityQueue<Long> lindex = new PriorityQueue<>(Collections.reverseOrder());
        PriorityQueue<Long> rindex = new PriorityQueue<>();
        long[] l = new long[N];
        long[] w = new long[N];
        for(int i=0;i<N;++i){
            l[i] = scan.nextLong();
            w[i] = scan.nextLong()-l[i];
        }
        lindex.add(l[0]);rindex.add(l[0]);
        long ans = 0;
        for(int i=1;i<N;++i){
            lbase += w[i];
            rbase += w[i-1];
            if(lindex.peek() >= (l[i]+lbase)){
                lindex.add(l[i]+lbase);
                lindex.add(l[i]+lbase);
                ans += Math.abs(lindex.peek()-(l[i]+lbase));
                rindex.add(lindex.poll()-lbase-rbase);
            }else if(rindex.peek() <= (l[i]-rbase)){
                rindex.add(l[i]-rbase);
                rindex.add(l[i]-rbase);
                ans += Math.abs(rindex.peek()-(l[i]-rbase));
                lindex.add(rindex.poll()+lbase+rbase);
            }else{
                lindex.add(l[i]+lbase);
                rindex.add(l[i]-rbase);
            }
        }
        System.out.println(ans);
    }
}

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

int main(void)
{
    string s;
    getline(cin, s);  // 1行読み込む
    for(int i = 0; i < s.size(); i++) {
        char c = s[i];
        if ('A' <= c && c <= 'Z') {
            //c = tolower(c);
            c = c + 32;
        }
        else if('a' <= c && c <= 'z') {
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 3192
//Mandelbrot: z(n+1) = (z(n))^2 + c
//Rick: I programmed you to believe that
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 998244353
#define Q 1000000006
#define inf 1e18
#define N 1000005
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);



void solve(){

    ll n,k;
    cin>>n>>k;
    vl a(n);
    f(i,0,n) cin>>a[i];
    sort(all(a));
    ll sum=0;
    f(i,0,k) sum +=a[i];
    cout<<sum;
}

signed main() {
    teevra_gati
    
    
    solve();
    return 0;
}

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

#define ll long long
using namespace std;
const int N = 3000 + 5, mod = 998244353;
int dp[N][N][2], s, a[N], n;
int solve(int idx, int sum, int st) {
    if (sum > s) return 0;
    if (st == 2) return (sum == s);
    if (idx == n) return 0;
    int &ret = dp[idx][sum][st];
    if (~ret) return ret;
    if (st == 0) {
        ret = solve(idx, sum, 1);
        ret += solve(idx + 1, sum, 0) % mod;
        ret %= mod;
    } else if (st == 1) {
        ret = solve(idx + 1, sum, st);
        ret += solve(idx + 1, sum + a[idx], st) % mod;
        ret %= mod;
        ret += solve(idx + 1, sum + a[idx], 2) % mod;
        ret %= mod;
        ret += solve(idx, sum, 2);
        ret %= mod;
    }
    return ret;
}
int main() {
    memset(dp ,-1, sizeof dp);
    cin >> n >> s;
    for(int i = 0 ; i < n ; i++) cin >> a[i];
    cout << solve(0, 0, 0);
    return 0;
}


Measured memory_bytes: 70912
n = gets.to_i
nums = gets.split.map(&:to_i)
colors = Hash.new(0)
nums.each do |num|
  if num < 400
    colors[:gray] = 1
  elsif num < 800
    colors[:brown] = 1
  elsif num < 1200
    colors[:green] = 1
  elsif num < 1600
    colors[:aqua] = 1
  elsif num < 2000
    colors[:blue] = 1
  elsif num < 2400
    colors[:yellow] = 1
  elsif num < 2800
    colors[:orange] = 1
  elsif num < 3200
    colors[:red] = 1
  else
    colors[:rainbow] += 1
  end
end
max = colors.values.inject(:+)
min = [max - colors[:rainbow], 1].max
puts "#{min} #{max}"


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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> use;
    use.push_back(1);

    int base6 = 6;
    while(base6 <= n){
        use.push_back(base6);
        base6 *= 6;
    }

    int base9 = 9;
    while(base9 <= n){
        use.push_back(base9);
        base9 *= 9;
    }

    sort(use.begin(), use.end());
    
    const int INF = 1001001001;
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    dp[1] = 1;
    for(int i = 2; i < n+1; ++i){
        for(int val: use){
            if(i-val >= 0) dp[i] = min(dp[i], dp[i-val] + 1);
        }
    }

    cout << dp[n] << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
int N, K;

int cal(int tmp)
{
  	int i = 0;
	while(tmp < K){
        tmp *= 2; 
    	i++;
    }
  return i;
}
void solve()
{
  	double sum = 0;
  
	for(int i = N; i > 0; i--){
		sum += pow(0.5, cal(i));
    }
  	sum = sum/N;
  	printf("%0.9f\n", sum);
}
int main()
{
  	scanf("%d %d", &N, &K);
  	solve();
	return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char A[n][n],B[m][m];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>A[i][j];
    for(int i=0; i<m; i++)
        for(int j=0; j<m; j++)
            cin>>B[i][j];
    bool f = false;
    for(int i=0; i<n-m+1; i++)
    {

        for(int j=0; j<n-m+1; j++)
        {
            f = true;
            for(int k=i; k<i+m; k++)
            {
                for(int l=j; l<j+m; l++)
                {
                    //cout<<"A: "<<A[k][l]<<"B :"<<B[k-i][l-j]<<endl;
                    if(A[k][l]!=B[k-i][l-j])
                    {
                        f = false;
                        break;
                    }

                }
                if(!f)
                    break;
            }
            if(f)
                break;
        }
        if(f)
            break;

    }
    if(f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    ll k;
    vector<ll> a,b;
    cin >> n >> m >> k;
    a.resize(200006);
    b.resize(200006);
    vector<ll> sum_a(200006,0);
    vector<ll> sum_b(200006,0);
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum_a[i+1] = sum_a[i]+a[i];
    }
    for(int j=0; j<m; j++){
        cin >> b[j];
        sum_b[j+1] = sum_b[j]+b[j];
    } 
    ll ans=0;
    ll j=m;
    for(ll i=0; i<=n; i++){
        if(sum_a[i]>k) break;
        ll temp_max=k-sum_a[i];
        while(sum_b[j]>temp_max) j--;
        ans = max(ans,i+j);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9548
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    int l,r;
    VI ru(n);
    REP(i,1,n) {
        ru[i] = ru[i-1];
        if (s[i] == 'C' && s[i-1] == 'A') ++ru[i]; 
    }
    REP(i,0,q) {
        cin >> l >> r;
        --l; --r;
        cout << ru[r] - ru[l] << endl;
    }
}

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

Measured memory_bytes: 1536
// Last Change: 04/15/2019 19:26:51.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
} 
//誤作動防止のためtemplateは使わない
//引数の型が違う場合には静的キャストして
int gcd(int, int);
long long gcd(long long, long long);

//実装部
int gcd(int a, int b) {
  if (a == 0 and b == 0)
    return 0;
  a = abs(a);
  b = abs(b);
  if (b == 0)
    return a;
  else
    return NS::gcd(b, a % b);
}
long long gcd(long long a, long long b) {
  if (a == 0 and b == 0)
    return 0;
  a = abs(a);
  b = abs(b);
  if (b == 0)
    return a;
  else
    return NS::gcd(b, a % b);
}
} // namespace NS

int main() {
  ll N, X;
  cin >> N >> X;
  // vector<ll> x(N);

  ll ipt,ans;
  cin >> ipt;
  ans = abs(ipt - X);
  for (int i = 1; i < N; ++i) {
    cin >> ipt;
    ans = NS::gcd(ans, abs(ipt - X));
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
package main

import "fmt"

func function1(n int64) int64 {

	ans := int64(0)
	k := int64(10)
	for n >= k {
		ans += n / k
		k *= 5
	}
	return ans

}

func main() {

	var ans, n int64

	fmt.Scan(&n)

	ans = 0

	if n%2 == 0 {
		ans = function1(n)

	}
	fmt.Print(ans)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    
    for (ll i = 2; (i * i) <= n; i++) {
        if (n % i) {
            continue;
        }
        
        res.emplace_back(i, 0);
        
        while((n % i) == 0) {
            n /= i;
            res.back().second++;
        }
    }
    
    if (n != 1) {
        res.emplace_back(n, 1);
    }
    
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    set<ll> s;
    auto f = factorize(n);
    s.insert(1);
    ll ans = 0;
    for (auto x : f) {
        rep(i, x.second) {
            vector<ll> p;
            for (auto y : s) {
                p.push_back(y * x.first);
            }
            rep(ii, sz(p)) s.insert(p[ii]);
        }
    }
    for (auto x : s) {
        if (x <= 2) continue;
        if ((n / (x - 1)) != (n % (x - 1))) continue;
        ans += x - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <iomanip>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	long double ans = 0;
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	std::sort(a.begin(), a.end());
	ans = a[0];
	for(int i = 1; i < n; i++) {
		ans = (ans + a[i]) / 2;
	}
	std::cout << std::fixed << std::setprecision(10) << ans << '\n';
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<string> s(N);
  REP(i, N) cin >> s[i];

  int ans = 0;
  vector<pair<int, int>> plus, minus;

  REP(i, N){
    int cnt = 0;
    int MIN = INF;
    REP(j, s[i].size()){
      if(s[i][j] == '(') cnt++;
      else cnt--;
      chmin(MIN, cnt);
    }

    if(MIN >= 0) ans += cnt;
    else{
      if(cnt >= 0) plus.emplace_back(cnt, MIN);
      else minus.emplace_back(cnt, MIN);
    }
  }


  bool flag = true;
  sort(ALL(plus), [](pair<int, int> const & l, pair<int, int> const & r){
      return l.second > r.second;
      });
  REP(i, plus.size()){
    if(ans+plus[i].second < 0) flag = false;
    ans += plus[i].first;
  }

  sort(ALL(minus), [](pair<int, int> const & l, pair<int, int> const & r){
      return l.first-l.second > r.first-r.second;
      });
  REP(i, minus.size()){
    if(ans+minus[i].second < 0) flag = false;
    ans += minus[i].first;
  }

  if(ans != 0) flag = false;
  flag? Yes: No;

  return 0;
}

Measured memory_bytes: 42808
#include <iostream>
#include <vector>
#include <math.h>
#include <iterator>

using namespace std;

const int max_n = 1000005;

int main(){
	int n;
	cin >> n;
	int count = 0;
	vector<int> dp(max_n);
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	
	for(int num : a){
		if(dp.at(num) != 0){
			dp.at(num) = 2;
			continue;
		}
		for(int j = num; j < max_n; j+=num){
			dp.at(j)++;
		}
	}
	
	for(int num : a){
		if(dp.at(num) == 1) count++;
	}
	
	cout << count << endl;
}

Measured memory_bytes: 8000
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val d = sc.nextInt()
  val n = sc.nextInt()

  var nn = n
  if (n == 100) {
    nn = 101
  }

  if (d == 0) {
    println(nn)
    return
  }

  val tmp = Math.pow(100.0, d.toDouble()).toInt()
  println(tmp * nn)
}

Measured memory_bytes: 31276
#include <stdio.h>

int main(void)
{
	long pow = 1;
	int n, i;
	
	scanf("%d", &n);
	
	for(i=1; i<=n; i++){
		pow = (pow*i)%1000000007;
	}
	
	printf("%ld\n", pow);
	
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
   char a,b;
   scanf("%c %c",&a,&b);
    if(a-b==0)
       printf("=\n");
    else if(a-b<0)
       printf("<\n");
    else if(a-b>0)
       printf(">\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		do{
			int x = i;
			if ( x % 3 == 0 ){
				System.out.print(" " + i);
			}else{
				do{
					if ( x % 10 == 3 ){
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				}while (x != 0);
			}
		}while (++i <= n);
		System.out.print("\n");
	}
}

Measured memory_bytes: 24512
N = int(input())
S = input()
T = input()
C = 10**9+7

flag = [False]*N
if S[0] == T[0]:
    ct = 3
    flag[0] = True
    i = 1
else:
    ct = 6
    i = 2
while i < N:
    if S[i] == T[i]:
        flag[i] = True
        if flag[i-1]:
            ct *= 2
        i += 1
    else:
        if flag[i-1]:
            ct *= 2
        else:
            ct *= 3
        i += 2
    ct = ct % C
    # print(i,ct)
print(ct)


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;

  for (int i = a; i <= b; i++) {
    int first = i % 10;
    int fifth = i / 10000 % 10;
    int second = i / 10 % 10;
    int fourth = i / 1000 % 10;
    if (first == fifth && second == fourth) ++ans;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#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)

const int INF = 1e9;

int main(void){

	int R, G; cin >> R >> G;
	cout << 2*G - R << endl;


	return 0;

}


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

int main() {
  int N;
  cin >> N;
  vector<double> vec(N);
  for(x:vec){
    cin >> x;
  }
  sort(vec.begin(),vec.end());
  double ans=vec.at(0);
  for(x:vec){
    ans = (ans + x)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x > 0; --x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)
#define foreach(i, x) for (int i = start[x]; i; i = e[i].l)
const int maxN = 100005;
char s[maxN];
int n, ans;

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	rep(i, n) if (s[i] != s[i - 1])
		++ans;
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;

 long long modpow( long long a,  long long n,  long long mod) {
     long long res = 1;
    while (n > 0) {
        if (n & 1) res = res%mod * a % mod;
        a = a%mod * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
     long long N;
    cin >> N;
     long long answer = 0;
    if(N==1) answer = 0;
    if(N>=2){
        answer = (modpow(10,N,1000000007)-2*modpow(9,N,1000000007)%1000000007+modpow(8,N,1000000007))%1000000007;
    }
    answer=(answer+1000000007)%1000000007;
  cout << answer << endl;
    return 0;
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    ll a[n][3];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    ll ans=-1e18;
    for(ll bit=0;bit<(1<<3);bit++){
        vector<ll> vec;
        for(ll i=0;i<n;i++){
            ll s=0;
            for(ll j=0;j<3;j++){
                if(bit&(1<<j)) s+=a[i][j];
                else s-=a[i][j];
            }
            vec.push_back(s);
        }
        sort(vec.begin(),vec.end(),greater<ll>());
        ll res=0;
        for(ll i=0;i<m;i++) res+=vec[i];
        ans=max(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int n;
    cin >> n;
    vector<ll> a;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(x);
    }
    string s;
    cin >> s;
    if (s.back() == '1') {
        cout << "1\n";
        return;
    }
    ll b[60] = {};
    for (int i = n - 1; i >= 0; --i) {
        ll x = a[i];
        for (int j = 59; j >= 0; --j)
            if (x & (1ll << j))
                x ^= b[j];
        if (x) {
            if (s[i] == '0') {
                b[__lg(x)] = x;
            } else {
                cout << "1\n";
                return;
            }
        }
    }
    cout << "0\n";
}
int main()
{
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}


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

int main()
{
	int k, a, b;
	cin >> k >> a >> b;
	bool flag = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			flag = true;
		}
	}
	cout << (flag ? "OK" : "NG") << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int X[100], Y[100];
	int inin;
	for (int i = 0; i < n; ++i)
	{
		cin >> X[i];
	}
	for (int i = 0; i < m; ++i)
	{
		cin >> Y[i];
	}
	sort(X, X+n);
	sort(Y, Y+m);
	bool ok = 0;
	for (int i = x+1; i <= y; ++i)
	{
		if (i > X[n-1] && i <= Y[0])
		{
			ok = 1;
		}
	}
	cout << (ok?"No War":"War") << endl;
 
	return 0;
}

Measured memory_bytes: 256
alphabet = [chr(i) for i in range(97, 97+26)]
ans = []
N = int(input())


def makeS(S, now):
    if len(S) == N:
        ans.append(S)
        return
    for i, c in enumerate(alphabet[:now+1]):
        if i == now:
            makeS(S+c, now + 1)
        else:
            makeS(S+c, now)


makeS('a', 1)
for s in sorted(ans):
    print(s)


Measured memory_bytes: 13560
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for(j = p ; j < r ; j++){
    if(A[j] <= x){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

int main(){
  int i, q;

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

  q = partition(0, n-1);

  for(i = 0 ; i < n ; i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d", A[i]);
    if(i == q) printf("]");
  }

  printf("\n");

  return 0;
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int x[105];
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    sum +=x[i];
  }
  int d=sum/n;
  int f=d+1;
  int e=0;
  int g=0;
  for(int i=0;i<n;i++){
     e +=(d-x[i])*(d-x[i]);
     g +=(f-x[i])*(f-x[i]);
  }
  if(e<=g){
  cout<<e;
}else{
  cout<<g;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i = 0; i < (int)(n); ++i)
#define mod 1000000007
#define bigger(a,b) (a>b?a:b)
#define smaller(a,b) (a<b?a:b)
#define mem(A,g) memset(A,g,sizeof(A))
#define gc getchar_unlocked
#define positive(a) (bigger(a,-a))

const int INF = 1e9 + 5;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n;
cin>>n;
vector<int>h;
for(int i=0;i<n;i++){
	int input;
	cin>>input;
	h.push_back(input);
}
vector<int>dp(n,INF);
dp[0] = 0;
dp[1] = abs(h[1]-h[0]);
for(int i=2;i<n;i++){
	dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]) , dp[i-2] + abs(h[i]-h[i-2]));
}
cout<<dp[n-1]<<"\n";

return 0;
}

Measured memory_bytes: 1272
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
	int N = V.size();
	REP(i,N){
		os << V[i];
		if (i!=N-1) os << " ";
	}
	os << "\n";
	return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
	os << "(";
	os << P.first;
	os << " , ";
	os << P.second;
	os << ")";
	return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
	auto it=S.begin();
	while(it!=S.end()){
		os << *it;
		os << " ";
		it++;
	}
	os << "\n";
	return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
	for(auto it=q.begin();it<q.end();it++){
		os<<*it;
		os<<" ";
	}
	 os<<endl;
	return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

bool is_ok(int dif,string c1,string c2){
	if ((dif&1) ^ (c1==c2)) return true;
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string c;
	int up,low;
	string c1,c2;
	cout << 0 << endl;
	cin >> c1;
	if (c1=="Vacant") return 0;
	cout << N/2 << endl;
	cin >> c2;
	if (c2=="Vacant") return 0;
	string L,H;
	if(is_ok(N/2-0,c1,c2)) up=N,low=N/2+1,L=c2,H=c1;
	else up=N/2,low=1,L=c1,H=c2;

	REP(i,20){
		int mid = (up+low)/2;
		// debug(mid)
		cout << mid << endl;
		cin >> c;
		if (c=="Vacant") return 0;
		if (is_ok(mid-low+1,L,c)) low = mid+1, L=c;
		else up = mid, H=c;
	}
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();

    ll n;
    cin >> n;
    str s;
    cin >> s;
    ll t=0;
    for(ll i=0;i<n;){
        char ch=s[i];
        ll j=i;
        while(ch==s[j]){
            j++;
        }
        t++;
        i=j;
    }
    cout<<t;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	static int MOD = 1000000007;

	public static void main(String[] args) {
		FastScanner in = new FastScanner();
		int n = in.nextInt();
		int m = in.nextInt();
		char[][] c = new char[n][m];
		for (int i = 0; i < n; i++) {
			String s = in.next();
			for (int j = 0; j < m; j++) {
				c[i][j] = s.charAt(j);
			}
		}
		int flag1 = 0;
		int dp[][] = new int[n][m];
		for (int i = 0; i < n; i++) {
			if (c[i][0] == '#') {
				flag1 = 1;
			} else {
				if (flag1 == 0)
					dp[i][0] = 1;
				else
					dp[i][0] = 0;
			}
		}
		int flag2 = 0;
		for (int j = 0; j < m; j++) {
			if (c[0][j] == '#') {
				flag2 = 1;
			} else {
				if (flag2 == 0)
					dp[0][j] = 1;
				else
					dp[0][j] = 0;
			}
		}
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {

				dp[i][j] = 0;
				if (c[i - 1][j] != '#') {
					dp[i][j] = (dp[i - 1][j] % MOD);
				}
				if (c[i][j - 1] != '#') {
					dp[i][j] += (dp[i][j - 1] % MOD);
				}
				dp[i][j] = dp[i][j] % MOD;
			}
		}
		if (dp[n - 1][m - 1] != 0) {
			System.out.println(dp[n - 1][m - 1]);
		} else if (dp[n - 1][m - 1] == 0) {
			System.out.println(0);
		}

	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 44140
#!/usr/bin/env python3
import sys


def solve(S: int):
    previous = ''
    for s in list(str(S).zfill(4)):
        if previous == s:
            print('Bad')
            return
        previous = s

    print('Good')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))

A = sorted(A)
plus = []
minus = []

for i in range(N):
    if i == 0:
        minus.append(A[i])
    elif i == N-1:
        plus.append(A[i])
    else:
        if A[i] > 0:
            plus.append(A[i])
        else:
            minus.append(A[i])

print(sum(plus)-sum(minus))
tmp = minus[0]
for i in range(len(plus)-1):
    print(tmp,plus[i])
    tmp -= plus[i]

minus[0] = tmp
tmp2 = plus[-1]
for i in range(len(minus)):
    print(tmp2,minus[i])
    tmp2 -= minus[i]
    



Measured memory_bytes: 14144
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

typedef pair<string, int> psi;

signed main() {
    string s; int n;
    vector<psi> vs;
    while(cin >> s >> n) {
        cin.ignore();
        vs.push_back(make_pair(s, n));
    }
    sort(vs.begin(), vs.end());
    string prev = "A";
    rep(i,0,vs.size()) {
        if(prev != vs[i].first) {
            if(prev != "A") cout << endl;
            cout << vs[i].first << endl;
            printf("%lld", vs[i].second);
            prev = vs[i].first;
        }
        else printf(" %lld", vs[i].second);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3220
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = map(int,input().split())


#root[n] -> nからいけるlist
roots = defaultdict(set)

#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #

	roots[u].add((v,a,b))
	roots[v].add((u,a,b))
		
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global weight_yen
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[1]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global weight_snu
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[2]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_snu[i] = w

#q = 次に探索する(確定する)もの q[0]=[w,n]
q = [[0,s]]
heapq.heapify(q)
			
while q:
	w,n = heapq.heappop(q)
	search_yen(n,w)
	
heapq.heappush(q, [0,t])
	
while q:
	w,n = heapq.heappop(q)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print(10**15 - ans_li[N-i-1])


Measured memory_bytes: 74612
<?php
  $dice = explode(" ", trim(fgets(STDIN)));
  $count = trim(fgets(STDIN));
  $action = array();
  for($i=0;$i<$count;$i++){
    array_push($action, explode(" ", trim(fgets(STDIN))));
  }
  $upper  = $dice[0];
  $side   = array($dice[2], $dice[1], $dice[3], $dice[4]);
  $bottom = $dice[5];
  $aaa = 0;
  foreach($action as $val){
    $n = 0;
    while (true) {
      if ($val[0] == $upper) {
        while (true) {
          if ($val[1] == $side[1]) {
            if (count($action) == ($aaa+1)) {
              print(reset($side));
            } else {
              print(reset($side) . "\n");
            }
            break 1;
          } else {
            $z = array_shift($side);
            array_push($side, $z);
          }
        }
        break 1;
      }
      if ($n < 3) {
        $b = $bottom;
        $u = $upper;
        $upper = $side[2];
        $bottom = $side[0];
        $side[2] = $b;
        $side[0] = $u;
      } else if ($n > 2) {
        $b = $bottom;
        $u = $upper;
        $upper = $side[1];
        $bottom = $side[3];
        $side[1] = $b;
        $side[3] = $u;
      }
      $n++;
    }
    $aaa++;
  }
?>

Measured memory_bytes: 6644
#include <iostream>
#include <math.h>
#include <algorithm>
#include <list>
using namespace std;

int q = 0, t[1000000] = {}, f[1000000] = {};
char c[1000000] = {};
string s = {};
list<char> str = {}, head = {}, back = {};
bool opposite = false, finallyOpposite = false;

int main() {
	cin >> s >> q;
	for (int i = 0; s[i] != 0; i++) {
		str.push_back(s[i]);
	}

	for (int i = 0; i < q; i++) {
		cin >> t[i];
		if (t[i] == 1) {
			if (opposite) {
				opposite = false;
			}
			else {
				opposite = true;
			}
		}
		else {
			cin >> f[i] >> c[i];
		}
	}

	finallyOpposite = opposite;

	for (int i = 0; i < q; i++) {
		if (t[i] == 1) {
			if (opposite) {
				opposite = false;
			}
			else {
				opposite = true;
			}
		}
		else {
			if (opposite) {
				if (f[i] == 1) {
					f[i] = 2;
				}
				else {
					f[i] = 1;
				}
			}

			if (f[i] == 1) {
				head.push_front(c[i]);
			}
			else {
				back.push_back(c[i]);
			}
		}
	}

	while (!head.empty()) {
		cout << head.front();
		head.pop_front();
	}
	if (finallyOpposite) {
		while (!str.empty()) {
			cout << str.back();
			str.pop_back();
		}
	}
	else {
		while (!str.empty()) {
			cout << str.front();
			str.pop_front();
		}
	}
	while (!back.empty()) {
		cout << back.front();
		back.pop_front();
	}

	return 0;
}


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

const int MAXN = 2e3 + 10;

vector<string> grid;
int pref1[MAXN][MAXN], pref2[MAXN][MAXN], pref3[MAXN][MAXN];

int main(){

	//freopen("sample_input.txt", "r", stdin);
	//freopen("sample_output.txt", "w", stdout);

	int t = 1;
	//cin>> t;
	while(t--){
		//memset(grid, 0, sizeof grid);
		memset(pref1, 0, sizeof pref1);
		memset(pref2, 0, sizeof pref2);
		memset(pref3, 0, sizeof pref3);
		int n, m, q, ran;
		cin>> n >> m >> q;
		grid.clear();
		/*for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				string s;
				cin>> s;
				grid.push_back(s);
			}
			//cout<<endl;
		}*/
		for(int i = 0; i < n; i++){
			string s;
			cin>> s;
			grid.push_back(s);
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				pref1[i+1][j+1] = pref1[i][j+1] + pref1[i+1][j] - pref1[i][j] + (grid[i][j]=='1');
				if(j != m - 1)
					pref2[i+1][j+1] = pref2[i][j+1] + pref2[i+1][j] - pref2[i][j] + (grid[i][j]=='1' and grid[i][j+1]=='1');
				if(i != n - 1)
					pref3[i+1][j+1] = pref3[i][j+1] + pref3[i+1][j] - pref3[i][j] + (grid[i][j]=='1' and grid[i+1][j]=='1');
			}
		}
		//cin>> q >> ran;
		while(q--){
			int x1, y1, x2, y2;
			cin>> x1 >> y1 >> x2 >> y2;
			x1--; y1--;
			int ans = pref1[x2][y2] - pref1[x1][y2] - pref1[x2][y1] + pref1[x1][y1];
			ans -= pref2[x2][y2-1] - pref2[x1][y2 - 1] - pref2[x2][y1] + pref2[x1][y1];
			ans -= pref3[x2-1][y2] - pref3[x1][y2] - pref3[x2 - 1][y1] + pref3[x1][y1];
			//cout<< x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << ans << endl;
			cout<< ans << endl;
		}
	}
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int f=1,a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		if (a%2==0)
		{
			if (a%3==0||a%5==0)
			{
				continue;
			}
			f=0;
		}
	}
	if (f==1)
	{
		cout<<"APPROVED\n";
	}
	else
	{
		cout<<"DENIED\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <regex>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    smatch m;
    if (regex_match(s, m, regex("A[a-z]+C[a-z]+"))) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    long long N,M,indexs=1,indexe;
    cin>>N>>M;
    indexe=N;
    REP(i,M){
        long long L,R;
        cin>>L>>R;
        if(L>indexs)indexs=max(indexs,L);
        if(R<indexe)indexe=min(indexe,R);
    }
    if(indexs!=indexe&&indexs>indexe) cout<<0<<endl;
    else cout<<indexe-indexs+1<<endl;
}

Measured memory_bytes: 256
from itertools import product
n = int(input())
i = len(str(n))

cnt = 0
for j in range(3, i+1):
    for k in product(["3", "5", "7"], repeat=j):
        if len(set(k)) != 3:
            continue
        if int("".join(k)) <= n:
            cnt += 1

print(cnt)

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

int main(void) {
    int N;cin>>N;
    set<int> s;
    for (int i = 0; i < N; i++) {
        int d;cin>>d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256