akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  ll a, b;
  cin >> a >> b;
  if (a<=0 && b>=0) {
    puts("Zero");
    return 0;
  } else if (a > 0) {
    puts("Positive");
  } else if (b < 0) {
    if ((b - a + 1) % 2 == 0) puts("Positive");
    else puts("Negative");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5 + 10;
 
int n, kol;
string a[N], s;
 
void f(int x, int m, int e)
{
	
    if (x == m + 1)
    {
        kol += 1;
        //a[kol] = s;
        if (kol == n){cout << s << endl;
        exit(0);
        }
 //       cout <<x <<" " <<m <<" " <<e <<endl;
    } else
    {
        if (e == -1)
        {
            for (int i = 1; i <= 9; i++)
            {
                s += char('0' + i);
                f(x + 1, m, i);
                s.pop_back();
            }
        } else
        {
            for (int i = max(0, e - 1); i <= min(9, e + 1); i ++)
            {
                s += char('0' + i);
                f(x + 1, m, i);
                s.pop_back();
            }
        }
    }
}
 
int main ()
{
    cin >>n;
    f(1, 1, -1);
    f(1, 2, -1);
    f(1, 3, -1);
    f(1, 4, -1);
    f(1, 5, -1);
    f(1, 6, -1);
    f(1, 7, -1);
    f(1, 8, -1);
    f(1, 9, -1);
    f(1, 10, -1);
    cout <<a[n];
    return 0;
}

Measured memory_bytes: 1024
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e5 + 5,M=50 + 1;
int arr[N];
ll dp[N];
ll OO=1e12; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX;
ll l,r,mid;
ll a,b,c,d;

ll Solve(int idx){
	ll &ret = dp[idx];
	if(~ret)
		return ret;
		
	if(idx >= n)
		return ret = (idx == n) ? 0 : OO;
	
	
	ll x = abs(arr[idx] - arr[idx+1]) + Solve(idx+1);
	ll y = abs(arr[idx] - arr[idx+2]) + Solve(idx+2);
	
	return ret = min(x,y);
}



 
 
int main(){
	
	memset(dp, -1 ,sizeof dp);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>arr[i];

	cout<<Solve(1)<<endl;
	

	


}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

constexpr int MOD = 1e+9 + 7;

// Greatest Common Multiple (GCD)
// 2数の最大公約数 by ユークリッド互助法
template <typename T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    else return gcd<T>(b, a % b);
}

// 繰り返し二乗法(Exponentiation by squaring)
// n^8 = ((n^2)^2)^2 を利用する
template <typename T>
T pow_mod(T n, T p, T m)
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N;
    cin >> N;
    map<pair<long long,long long>, pair<int,int>> P;
    int num_zeros = 0;
    REP(i, N){
        long long A, B;
        cin >> A >> B;
        if(A == 0 and B == 0){ // (0, 0) は全てのイワシと仲が悪い
            ++num_zeros;  
            continue;
        }
        // (0, □) は (□, 0) の全てのイワシと仲が悪い
        if(A == 0){
            P[make_pair(A, 1)].first++;
            continue;
        }
        if(B == 0){
            P[make_pair(B, 1)].second++;
            continue;
        }
        // A/B の組を記録
        long long GCD = gcd<long long>(A, B);
        A /= GCD;
        B /= GCD;
        if(B < 0){  // A < 0 となるようにする
            A = -A;  
            B = -B;
        }
        // A の正負で first, second を分類
        if(A > 0) P[make_pair(A, B)].first++;
        else P[make_pair(B, -A)].second++;
    }

    long long ans = 1;
    for(auto p: P){
        int num_i = p.second.first;
        int num_j = p.second.second;
        long long num_pairs = pow_mod<long long>(2, num_i, MOD) + pow_mod<long long>(2, num_j, MOD) - 1;
        ans *= num_pairs%MOD;
        ans %= MOD;
    }
    cout << (ans+num_zeros-1+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 15972
#include <cstdio>
#include <vector>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))

void merge(vector<pair<int,int> >& w, int left, int mid, int right) {
	vector<pair<int,int> > L,R;
	int n1=mid-left;
	int n2=right-mid;
	int i=0,j=0,k;
	L.resize(n1+1);
	R.resize(n2+1);
	for(i=0; i<n1; ++i) {
		L[i]=w[left+i];
	}
	L[n1].first = -1;
	L[n1].second = 1000000001;
	for(i=0; i<n2; ++i) {
		R[i]=w[mid+i];
	}
	R[n2].first = -1;
	R[n2].second = 1000000001;

	i=j=0;
	for(k=left; k<right; ++k) {
		if(L[i].second < R[j].second) {
			w[k]=L[i];
			++i;
		} else {
			w[k]=R[j];
			++j;
		}
	}
	return;
}

void mergeSort(vector<pair<int,int> >& w, int left, int right) {
	if(left+1<right) {
		int mid=left+(right-left)/2;
		mergeSort(w,left,mid);
		mergeSort(w,mid,right);
		merge(w,left,mid,right);
	}
	return;
}

int main() {
	int n;
	int i,j;
	int total=0;
	int subtotal,c;
	vector<int> checker;
	vector<pair<int,int> > w; // first=original_index, second =weight_value will be sorted.
	scanf("%d",&n);
	w.resize(n);
	checker.resize(n);
	for(i=0; i<n; ++i) {
		checker[i]=0;
		w[i].first=i;
		scanf("%d",&w[i].second);
	}
	mergeSort(w,0,n);
	for(i=0; i<n; ++i) {
		if(checker[i]==1 || w[i].first==i) {
			continue; // already checked or unmoved
		}
		c=subtotal=0;
		checker[i]=1;
		j=w[i].first;
		while(j!=i) {
			subtotal+=w[i].second+w[j].second;
			checker[j]=1;
			j=w[j].first;
			++c;
		}
		total+=MIN(subtotal,subtotal-w[j].second*(c-2)+w[0].second*(c+2));
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 2760
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;


const int kInf = 1e9;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int> > A(N, vector<int>(M));
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    for (int j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }

  int min_c_total = kInf;
  for (int b = 0; b < (1<<N); ++b) {
    int c_total = 0;
    vector<int> r(M);
    for (int i = 0; i < N; ++i) {
      if (((b>>i) & 1) == 1) {
	c_total += C[i];
	for (int j = 0; j < M; ++j) {
	  r[j] += A[i][j];
	}
      }
    }
    bool valid = true;
    for (int j = 0; j < M; ++j) {
      if (r[j] < X) {
	valid = false;
	break;
      }
    }
    if (valid) {
      min_c_total = min(min_c_total, c_total);
    }
  }
  
  if (min_c_total == kInf) {
    cout << -1 << endl;
  } else {
    cout << min_c_total << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end(), greater<int>());
    LL sum = 0;
    for (int i = K; i < N; ++i) sum += H[i];

    cout << sum << endl;

    return 0;
}


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

using ll = long long;
using P = pair<int, int>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define zarray(x,n) x[n+1]; rep1(i,n) {x[i]=0;} 

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

    string alpha = "abcdefghijklmnopqrstuvwxyz----------";
    string ans = "";

    while (n > 0) {
        int mod = (n-1) % 26;
        ans += alpha[mod];
        //cerr << "ans:" << alpha[mod] << endl;
        n = (n-1) / 26;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}


Measured memory_bytes: 3628
from collections import deque
s = input()
q = int(input())

s = deque(s)
flip = False

for i in range(q):
    Q = list(input().split())
    if int(Q[0]) == 1:
        flip = not flip
    else:
        if int(Q[1]) == 1:
            if not flip:
                s.appendleft(Q[2])
            else:
                s.append(Q[2])
        else:
            if not flip:
                s.append(Q[2])
            else:
                s.appendleft(Q[2])

ans = ''

for _ in range(len(s)):
    if not flip:
        ans += s.popleft()
    else:
        ans += s.pop()

print(ans)
 

Measured memory_bytes: 6288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int H,W,K;

bool check(int i,int j,int K,vector<string> c){
    //cをi,j塗りつぶして黒がK残ったらtrueを返す
    bool res = false;
    int tmp=0;
    rep(l,H){
        if(i&1<<l){
            rep(m,W){
                if(j&1<<m){
                    if(c[l][m]=='#'){
                        tmp++;
                    }
                }
            }
        }
    }
    if(tmp==K){
        res=true;
    }
    return res;
}

int main(){

    cin>>H>>W>>K;
    vector<string> c;
    rep(i,H){
        string t;
        cin>>t;
        c.push_back(t);
    }
    //全パターン試す(2^12)
    int ans =0;
    rep(i,pow(2,H)){
        rep(j,pow(2,W)){
            if(check(i,j,K,c)){
                ans++;
            }
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 4084
#include<stdio.h>
#include <stdlib.h>
int max(int a, int b){return a > b ? a : b;}

int main(void){
    int n;
    scanf("%d", &n);
    char a[30001] = {};
    scanf("%s", a);

    int ans = 0;
    for(int i = 0;i < 10; i++){
        for(int j = 0;j < 10;j++){
            for(int k = 0; k < 10; k++){
                int cnt;
                cnt = 0;
                for(int l = 0;l < n;l++){
                    if(a[l] == i + '0' && cnt == 0){
                        cnt++;
                    }else if(a[l] == j + '0' && cnt == 1){
                        cnt++;
                    }else if(a[l] == k + '0' && cnt == 2){
                        cnt++;
                    }
                    if(cnt == 3){
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}



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

int main(){
  
  int n,q;
  string s;
  cin >> n >> q >> s;
  int a;
  int b;
  int cnt;
  int sum[n+10] = {0};
  
  for(int i=0; i<n; i++){
    if(s[i] == 'A' && s[i+1] == 'C' && i+1<n){
    	sum[i+1] = sum[i] + 1; 
    }else{
     	sum[i+1] = sum[i]; 
    }
    
  }
  for(int i=0; i<q; i++){
    cin >> a >> b;
    cout << sum[b-1] - sum[a-1] << endl;
  }
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

if n==1:
    print(1)
    exit()

maxa=max(a)
dp=[0]*(maxa+100)
for num in a:
    for i in range(2,10**10):
        if num*i > (maxa+50):
            break
        dp[num*i]=1

import collections
c = collections.Counter(a)

aa=[]
for itm in c.items():
    num,cnt=itm
    if cnt==1:
        aa.append(num)

ans=0
for num in aa:
    if dp[num]==0:
        ans+=1
print(ans)

Measured memory_bytes: 124156
import numpy as np

def solve():
    dp = np.zeros((2, N+1))
#    print(dp)
    ac = 0
    wa = 0
    for i in range(M): 
        if (dp[0][S[i][0]] == 0):
            if(S[i][1] == "WA"):
                dp[1][S[i][0]] += 1
            elif(S[i][1] == "AC"):
                ac += 1
                dp[0][S[i][0]] = 1
                wa += dp[1][S[i][0]]
    print(ac, int(wa))

if __name__=="__main__":

    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        a,b = input().split()
        S.append([int(a), b])
#    print(S)
    
    solve()
    




Measured memory_bytes: 32252
#include <stdio.h>
long long int n1[100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&n1[i]);
int zr =0;
for(int i=0;i<n;i++)if(n1[i]==0) zr ++;
if(zr >0){
printf("0\n");
return 0;
}
long long int pro =1;
for(int i=0;i<n;i++)
{
if(n1[i]<=1000000000000000000/pro )
    {
      pro*=n1[i];
    }
else
    {
       printf("-1\n");
       return 0;
    }
}
printf("%lld\n",pro);
}


Measured memory_bytes: 2508
#include <iostream>
using namespace std;
string u[257];
string t;
int n,m;
bool door;
void check(string s){
	for(int i=0;i<n;i++){
		if(u[i]==s){
			if(door){
				door=false;
				cout <<"Closed by " ;
			}else{
				door=true;
				cout <<"Opened by " ;
			}
			cout << s<<endl;
			return;
		}
	}
	cout << "Unknown "<< s <<endl;
}





int main(){
	door=false;
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>u[i];
	}
	cin >>m;
	for(int i=0;i<m;i++){
		cin >>t;
		check(t);
	}
	return 0;
}

Measured memory_bytes: 3196
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	x := a * b
	if a < b {
		a, b = b, a
	}

	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}

	fmt.Println(x / b)
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<ll> D(N);
    rep(i,N)
    {
        cin >> D[i];
    }

    ll M;
    cin >> M;

    multiset<ll> T;
    set<ll> t;
    rep(i,M)
    {
        ll tmp;
        cin >> tmp;
        T.insert(tmp);
        t.insert(tmp);
    }
    sort(all(D));

    ll key = 0;
    for( multiset<ll>::iterator itr = t.begin(); itr != t.end(); ++itr)
    {
        ll tmp = 0;
        bool flag = false;
        size_t cnt = T.count(*itr);
        for( key; key < N;key++)
        {
            //cout << *itr << " " << D[key] << " " << tmp << " " << cnt << endl;
            if( D[key] == *itr )
            {
                tmp++;
            }
            if( tmp >= cnt )
            {
                flag = true;
                break;
            }
        }
        if(!flag)
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int X,Y;
    cin >> X >> Y;
    ll ans = 0;
    if(X < 4) ans += (4-X) * 100000;
    if(Y < 4) ans += (4-Y) * 100000;
    if(X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool cantake[310][310];
int dp[310][310];

int main() {
  while(1){
    int n; cin >> n;
    if(n==0) break;
    int w[n+2];
    MEMSET(cantake,false);
    MEMSET(dp,0);
    w[0] = 1001001001;
    w[n+1] = 1001001001;
    FOR(i,1,n) cin >> w[i];

    FOR(wid,2,n+1){
      FOR(i,1,n){
        int j = i+wid-1;
        if(j>=n+1) continue;

        if(dp[i+1][j-1]==wid-2 && abs(w[i]-w[j])<=1) dp[i][j]=wid;
        FOR(k,i,j){
          chmax(dp[i][j], dp[i][k] + dp[k+1][j]);
        }
      }
    }
    cout << dp[1][n] << "\n";
  }

}


Measured memory_bytes: 3568
import scala.collection.mutable.HashMap
import scala.annotation.tailrec

object Main extends App {
  val Array(n, k) = io.StdIn.readLine.split(" ").map(_.toLong)
  val arr = Array.ofDim[Long](100001)
  Iterator.continually(io.StdIn.readLine)
    .take(n.toInt)
    .map(_.split(" "))
    .foreach(e => arr(e(0).toInt) += e(1).toLong)

  def f(arr:Array[Long], k:Long):Int = {

    @tailrec
    def rec(acc:Long, index:Int, k:Long ):Int = {
      val res = acc + arr(index)
      if(res >= k) index
      else rec(res, index+1, k)
    }

    rec(0L, 1, k)
  }

  println(f(arr, k))
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,n; cin>>a>>b>>n;
  ll x=min(b-1,n);
  ll ans=(a*x/b)-a*(x/b);
  cout<<ans<<endl;
}

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> g(n, vector<int>());
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    vector<vector<int>> blc(n, vector<int>());
    for (int i=0; i<k; i++) {
        int c, d;
        cin >> c >> d;
        blc[c-1].push_back(d-1);
        blc[d-1].push_back(c-1);
    }

    // 連結成分のサイズを求める
    int gsize[n];
    vector<bool> visited(n, false);
    vector<int> type(n, -1);
    int t = 0;
    for (int i=0; i<n; i++) {
        if (!visited[i]) {
            queue<int> q;
            q.push(i);
            int cnt = 1;
            visited[i] = true;
            type[i] = t;
            while (!q.empty()) { // bfs
                int u = q.front(); q.pop();
                for (int v=0; v<g[u].size(); v++) {
                    int p = g[u][v];
                    if (!visited[p]) {
                        cnt++;
                        visited[p] = true;
                        type[p] = t;
                        q.push(p);
                    }
                }
            }
            gsize[t] = cnt;
            t++;
        }
    }

    for (int i=0; i<n; i++) {
        int total = gsize[type[i]] - 1;
        int ncnt = g[i].size();
        for (int j=0; j<blc[i].size(); j++) {
            int v = blc[i][j];
            if (type[i] == type[v]) total--;
        }
        cout << total - ncnt << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cerr << "[" << #x << " " << x << "]\n";
// #define int ll

ll power(ll x, ll y) {
     ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*================================================================*/




void solve() {
    ll n;
    cin >> n;
    ll a = n/3, b = n/5, c = n/15;
    deb(a);deb(b);deb(c);
    cout << (n*(n+1))/2 + (15*(c*(c+1)))/2 - (3*(a*(a+1)))/2 - (5*(b*(b+1)))/2;
}

signed main() {
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3600
#include <stdio.h>

int main() {
  int j, i, a[1000000];
  scanf("%d", a);
  for (j = 1; j > 0; j++) {
    a[j] = (a[j-1] % 2 == 0) ? a[j-1] / 2 : 3*a[j-1] + 1;
    for (size_t k = 0; k < j; k++) {
      if (a[k] == a[j]) {
        i = k;
        break;
      }
    }
    if (a[i] == a[j]) {
      break;
    }
  }
  printf("%d\n", j+1);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ld> x;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    x.assign(n, 0.0);
    F0R(i, n) cin >> x[i];
    ld res = 0;
    F0R(i, n) res += 1/x[i];
    cout << setprecision(10) << fixed << 1/res;
    return 0;
}

Measured memory_bytes: 256
from collections import deque, Counter
N, X, Y = map(int, input().split())

G = [[] for _ in range(N)]
for i in range(N - 1):
  G[i].append([i + 1, 1])
  G[i + 1].append([i, 1])

iX = X - 1
iY = Y - 1
G[iX].append([iY, 1])
G[iY].append([iX, 1])

d = {}
for i in range(N):
  d[i] = 0

for i in range(N):
  to_see_queue = deque()
  to_see_queue.append(i)
  costs = [-1] * N
  costs[i] = 0

  while to_see_queue:
    cur = to_see_queue.popleft()
    for node_next, cost_nn in G[cur]:
      if costs[node_next] == -1:
        costs[node_next] = costs[cur] + cost_nn
        to_see_queue.append(node_next)
  
  for nn in range(i + 1, N): 
    d[costs[nn]] += 1

for i in range(1, N):
  print(d[i])


Measured memory_bytes: 50140
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	int A,B;
	cin >> A >> B;
	if (A!=1 && B!=1) {
		cout << 1;
	} else if (A!=2 && B!=2) {
		cout << 2;
	} else if (A!=3 && B!=3) {
		cout << 3;
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

Measured memory_bytes: 3608
h, w = map(int, input().split())
M = [input() for _ in range(h)]

ng = False
for i in range(h):
    for j in range(w):
        if M[i][j]  == '.':
            continue

        for mi, mj in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            ni = i + mi; nj = j + mj
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue

            if M[ni][nj] == '#':
                break
        else:
            ng=True
    if ng:
        break

if ng:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,t;cin >> a>>b>>t;
  int i=1;
  int cnt=0;
  while(i <= t){
    if (i%a == 0) cnt += b;
    i++;
  }
  cout << cnt << endl;
}


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

using namespace std;

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

    vector<int> a(s.length());

    for(int i = 0; i < s.length() - 2; i++) {
        a[i] = (s[i] -'0') * 100 + (s[i+1] -'0') * 10 + (s[i+2] -'0');
    }

    vector<int> ans(s.length());

    for(int i = 0; i < s.length(); i++) {
        ans[i] = abs(753 - a[i]);
    }

    sort(ans.begin(), ans.end());

    cout << ans[0] << endl;


    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

ll lca(ll a, ll b) {
    ll a_ogn = a, b_ogn = b;
    ll r = a % b;
    while (r) {
        a = b, b = r, r = a % b;
    }
    return a_ogn / b * b_ogn;
}


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

    ll N, M;
    cin >> N >> M;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[i] = a / 2;
    }

    ll l = 1;
    for (int i = 0; i < N; i++) {
        l = lca(l, A[i]);
    }

    bool ok = true;
    for (int i = 0; i < N; i++) {
        if (l / A[i] % 2 == 0) {
            ok = false;
            break;
        }
    }

    if (!ok) {
        cout << 0 << endl;
        return 0;
    }

    cout << M / l - M / l / 2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define All(v) (v).begin(),(v).end()
int main() {
    string s,t;
    int ans=0;
    cin>>s>>t;
    rep(i,3){
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int[][][] floor = new int[4][3][10];

        int count = Integer.parseInt(br.readLine());
        int[] num = new int[4];
        for(int i=0; i<count; i++){
            String[] str = br.readLine().split(" ");
            for(int k=0; k<4; k++){
                num[k] = Integer.parseInt(str[k]);
            }
            floor[num[0] -1][num[1] -1][num[2] -1] += num[3];
        }

        for(int b=0; b<4; b++){
            for(int f=0; f<3; f++){
                for(int r=0; r<10; r++){
                    if(r == 0)sb.append(" ");
                    sb.append(floor[b][f][r]);
                    if(r != 9)sb.append(" ");
                }
                sb.append("\n");
            }
            if(b<3){
                sb.append("####################").append("\n");
            }
        }
        System.out.print(sb);

    }
}

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

int main() {

    int arr[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
    int n ;
    cin >>  n ;
    cout << arr[n-1] << endl ;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  // j - i = Ai + Aj
  // Ai + i = j - Aj
  unordered_map<int,int> table;
  long long ans = 0;
  rep(i, n) {
    int a; cin >> a;
    ans += table[i - a];
    ++table[a + i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 18508
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,a,b;cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
    return 0;
}

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

string judge(int x, int y);
int main()
{
  int a,b;
  cin >> a >> b;
  cout << judge(a,b) << endl;
  return 0;
}

string judge(int x, int y)
{
  if(x > y) return "a > b";
  else if(x < y) return "a < b";
  else return "a == b";
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s.size()==3) reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

inline unsigned count(
  const std::vector< std::vector<unsigned> > &sum,
  unsigned left, unsigned right, unsigned top, unsigned bottom 
)
{
  return sum[bottom][right]
       + sum[top][left]
       - sum[bottom][left]
       - sum[top][right];
}

int main(int argc, char **argv)
{
  unsigned N, K;
  std::cin >> N >> K;
  
  unsigned M = 2 * K;
  
  std::vector< std::vector<unsigned> > table(M);
  for (unsigned m = 0; m < M; ++m) {
    table[m] = std::vector<unsigned>(M, 0);
  }
  
  for (unsigned n = 0; n < N; ++n) {
    unsigned x, y;
    char color;
    std::cin >> x >> y >> color;
    
    ++table[(y + (color == 'W' ? K : 0)) % M][x % M];
  }
  
  std::vector< std::vector<unsigned> > sum(M + 1);
  for (unsigned m = 0; m < M + 1; ++m) {
    sum[m] = std::vector<unsigned>(M + 1, 0);
  }
  
  for (unsigned y = 0; y < M; ++y) {
    for (unsigned x = 0; x < M; ++x) {
      sum[y + 1][x + 1] = table[y][x]
                        + sum[y + 1][x] 
                        + sum[y][x + 1] 
                        - sum[y][x];
    }
  }
  
  unsigned max = 0;
  
  for (unsigned py = 0; py < K; ++py) {
    for (unsigned px = 0; px < K; ++px) {
      unsigned S = 0;
      
      /*
      S += count(sum, 0, px, py, py + K);
      S += count(sum, px, px + K, 0, py);
      S += count(sum, px, px + K, py + K, M);
      S += count(sum, px + K, M, py, py + K);
      */
      
      S += count(sum, 0, px, 0, py);
      S += count(sum, 0, px, py + K, M);
      S += count(sum, px, px + K, py, py + K);
      S += count(sum, px + K, M, 0, py);
      S += count(sum, px + K, M, py + K, M);
      
      max = std::max(max, std::max(S, N - S));
    }
  }
  
  std::cout << max << std::endl;
  
  return 0;
}

Measured memory_bytes: 31616
//tokenakatta this is incorrect.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;

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

    if(n%2!=0) {
        cout << 0 << endl;
        return 0;
    }

    // n>=1 n==even
    ll ans=0LL;
    ll tmp=n;
    for(ll i=1; (ll)pow(5,i)<=n; i++){
        ll divt = 2LL*(ll)pow(5, i);
        ans += n/divt;
    }

    cout << ans  << endl;

}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m, d = map(int, input().split())
    if d == 0:
        print((m - 1) / n)
    else:
        print((m - 1) * 2 * (n - d) / n ** 2)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9132
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

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

	public void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Num[] numarr = new Num[N + 1];
		for (int i = 1; i <= N; i++) {
			int n = sc.nextInt();
			Num num = new Num(n, i);
			numarr[n] = num;
		}
		sc.close();

		long ans = 0;
		TreeSet<Num> t = new TreeSet<>();
		for (int i = 1; i < numarr.length; i++) {
			Num co = numarr[i];
			Num lo = t.floor(co);
			Num ro = t.ceiling(co);
			int l = (lo == null) ? 0 : lo.pos;
			int r = (ro == null) ? N + 1 : ro.pos;
			long min = Math.min(co.pos - l, r - co.pos);
			long max = Math.max(co.pos - l, r - co.pos);
			ans += i * min * (min + 1) / 2;
			ans += i * min * (max - min);
			ans += i * (r - l - 1 - max) * (r - l - max) / 2;
			//System.out.println("i:" + i + ",l:" + l + ",r:" + r + ",min:" + min + ",max:" + max + ",ans:" + ans);
			t.add(numarr[i]);
		}

		System.out.println(ans);
	}

	class Num implements Comparable<Num> {
		int a = 0;
		int pos = 0;

		Num(int a, int pos) {
			this.a = a;
			this.pos = pos;
		}

		@Override
		public int compareTo(Num o) {
			return pos - o.pos;
		}
	}
}


Measured memory_bytes: 92032
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n >= 30){
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
}

Measured memory_bytes: 3572
n, y = map(int, input().split())

ans = '-1 -1 -1'
for a in range(n+1):
    for b in range(n+1):
        rem = y - 10000*a - 5000*b
        if rem < 0:
            continue
        c = rem // 1000
        if a + b + c == n:
            ans = '{} {} {}'.format(a, b, c)
            break
print(ans)

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

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

  long long  l[100];

  l[0] = 2;
  l[1] = 1;

  for(int i = 2;i < n+1;i++){
    l[i] = l[i-1]+l[i-2];
  }

  cout << l[n] <<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
for _ in range(n):
    l.append(list(map(int,input().split())))
l.sort()
s=0
i=0
while m>0:
    s+=min(l[i][1],m)*l[i][0]
    m-=min(l[i][1],m)
    i+=1
print(s)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
   int H, W;
   cin >> H >> W;
   vector<vector<int>> a(H, vector<int>(W));
   rep(y, 0, H) rep(x, 0, W) cin >> a.at(y).at(x);

   vector<tuple<int, int, int, int>> ans;
   rep(y, 0, H) rep(x, 0, W - 1) {
      if (a.at(y).at(x) % 2 == 1) {
          a.at(y).at(x)--;
          a.at(y).at(x + 1)++;
          ans.push_back(make_tuple(y, x, y, x + 1));
      }
   }
   rep(y, 0, H - 1) {
       if (a.at(y).at(W-1) % 2 == 1) {
           a.at(y).at(W - 1)--;
           a.at(y + 1).at(W - 1)++;
           ans.push_back(make_tuple(y, W - 1, y + 1, W - 1));
       }
   }
   cout << ans.size() << endl;
   for (auto t : ans) {
      int a, b, c, d;
      tie(a, b, c, d) = t;
      cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
   }
 }


Measured memory_bytes: 5232
//***********************************************************************************************************//
//    TOPIC :
//***********************************************************************************************************//
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define ll long long int
#define ull unsigned long long int
#define INF 99999999
ll mod = 1e9 + 7;

// int mod = 1e9 + 7;
#define fr(a, b, c) for (int a = b; a < c; a++)
#define fre(a, b, c) for (int a = b; a <= c; a++)

class Timer
{
public:
    clock_t starting;
    Timer()
    {
        cout << "**..** Timer clock init **..**" << endl;
    }
    void start()
    {
        starting = clock();
    }
    void end()
    {
        double duration = (clock() - this->starting) / (double)CLOCKS_PER_SEC;
        cout << "**..** Time taken is " << duration << endl;
    }
};

void the_martian()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll powm(ll a, ull b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

vector<vector<ll>> dp;
void init(int n)
{
    vector<vector<ll>> d(n + 1);

    for (int i = 0; i < n + 1; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            d[i].pb(-1);
        }
    }
    dp = d;
}

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

    vector<vector<int>> v(n);
    init(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int l;
            cin >> l;
            v[i].pb(l);
        }
    }

    int k;

    dp[0][0] = v[0][0], dp[0][1] = v[0][1], dp[0][2] = v[0][2];
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = v[i][0] + max(dp[i - 1][1], dp[i - 1][2]);

        dp[i][1] = v[i][1] + max(dp[i - 1][0], dp[i - 1][2]);

        dp[i][2] = v[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
    }

    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return (0);
}


Measured memory_bytes: 3616
import java.util.*;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    String T = sc.nextLine();
    int count = 0;
    for(int i=0;i<S.length();i++){
      if(S.charAt(i) != T.charAt(i)){
        count++;
      }
      
    }
    System.out.println(count);
    }
}

Measured memory_bytes: 42692
N,T=map(int,input().split())
d=[None]*N
for i in range(N):
  a,b=map(int,input().split())
  d[i]=[a,b]

import numpy as np
d=sorted(d,key=lambda x:x[0])
dp=np.zeros(T,dtype=int)
ans=0
for i in range(len(d)):
  t=d[i][0]
  v=d[i][1]
  ans=max(ans,dp.max()+v)
  np.maximum(dp[:-t]+v,dp[t:],out=dp[t:])

print(ans)


Measured memory_bytes: 12860
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{	
	int num;
	int val[10000] = { 0 };
	int mem_max = -1000000, mem_min = 10000000;
	long sum = 0;

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

	for (int i = 0; i < num; i++)
	{
		if (val[i] > mem_max)
			mem_max = val[i];
		if (val[i] < mem_min)
			mem_min = val[i];

		sum += val[i];
	}

	printf("%d %d %Ld\n", mem_min, mem_max, sum);



}

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

const int INF = 2000000000;

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

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
int main(){
    ll m;
    ll n;
    cin >> m >> n;
    mint x(m);
    mint ans = x.pow(n);
    cout << ans.x << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    double r;cin>>r;
    cout<<2*pi*r<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    //int i=1;
    while(t--)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>

int main(void){
    int n,count,status,i;
    char buf[3];
    while(scanf("%d",&n),n){
        count=0;
        status=0;
        for(i=0;i<n;i++){
            scanf("%s",buf);
            if(buf[0]=='r'){
                if(buf[1]=='u'){
                    status|=1;
                }else{
                    status^=1;
                }
            }else{
                if(buf[1]=='u'){
                    status|=2;
                }else{
                    status^=2;
                }
            }
            if(count%2){
                if(status==0) count++;
            }else{
                if(status==3) count++;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

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

char s[101];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	int an = 1e9;
	f(c, 0, 26){
		bool ok = false;
		f(i, 0, n)if (s[i] == c + 'a') { ok = true; break; }
		if (!ok)continue;
		string a = s;
		int z = 0;
		while (true){
			bool ok = true;
			f(i, 0, a.size())if (a[i] != c + 'a') { ok = false; break; }
			if (ok)break;
			++z;
			f(i, 1, a.size())if (a[i] == c + 'a')a[i - 1] = c + 'a';
			a.pop_back();
		}
		an = min(an, z);
	}
	printf("%d\n", an);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#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()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	string s;
	ll n;
	cin >> s >> n;;
	ll keta;
	ll total = 0;
	int ans;
	int flag = 0;
	REP(i, SZ(s)) {
		//cout << total << endl;
		keta = 1;
		ans = s[i] - '0';
		if (ans == 1) {
			keta = 1;
		}
		else {
			for (ll j = 0; j < 5000000000000000; j++) {
				keta *= ans;
				if (total + keta >= n) {
					break;
					flag = 1;
				}
			}
		}
		if (flag == 1|| total + keta >= n) {
			break;
		}
		total += keta;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256