akhauriyash/Code-Regression huggingface dataset:
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n;
    in n;
    vector<int> a(n);
    rep(i,n)in a[i];
    bool flag=true;
    int ans=0;
    while(flag)
    {
        rep(i,n)
        {
            if(a[i]%2==0)a[i]/=2;
            else flag=false;
        }
        ans++;
    }
    cout<<ans-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

string X = "aiueo";

void solve(char c){
    REP(i, SZ(X)) {
        if (c == X[i]) {
            cout << "vowel" << endl;
            return;
        }
    }
    cout << "consonant" << endl;        
}


int main(){	
	char c;
	cin >> c;
	solve(c);
	return 0;
}



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

int main() {
  int H,W;
  cin >> H >> W;
  int h=H; 
  vector<vector<char>> a(H, vector<char>(W));
  for(int i=0;i<H;i++) {
      for(int j=0;j<W;j++) {
          cin >> a.at(i).at(j);
      }
  }

  vector<bool> counti(H,false);
  vector<bool> countj(W,false);

  for(int i=0;i<H;i++) {
      for(int j=0;j<W;j++) {
          if(a.at(i).at(j)=='#') counti.at(i)=true;
      }
  }

  for(int j=0;j<W;j++) {
      for(int i=0;i<H;i++) {
          if(a.at(i).at(j)=='#') countj.at(j)=true;
      }
  }

  for(int i=0;i<H;i++) {
      for(int j=0;j<W;j++) {
          if(counti.at(i)&&countj.at(j)) cout << a.at(i).at(j);
      }
      if(counti.at(i)) cout << endl;
  }

  /*for(int i=0;i<H;i++) {
      int count=0;
      for(int j=0;j<W;j++) {
          if(a.at(i).at(j)=='#') count++;
      }

      if(count==0) {
          for(int j=0;j<W;j++) {
              if(H==1) {
                  break;
              }
              for(int k=i;k<H-1;k++){
                  a.at(k).at(j)=a.at(k+1).at(j);
              }
          }
          i--;
          H--;
      }
  }

  for(int i=0;i<W;i++) {
      int count=0;
      for(int j=0;j<H;j++) {
          if(a.at(j).at(i)=='#') count++;
      }
      if(count==0) {
          for(int j=0;j<H;j++) {
              a.at(j).at(i)=a.at(j).at(i+1);
          }
          i--;
          W--;
      }
  }

  cout << H << " " << W << endl;

  for(int i=0;i<H;i++) {
      for(int j=0;j<W;j++) {
          cout << a.at(i).at(j);
      }
      cout << endl;
  }*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;

using Graph = vector<vector<char>>;

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

Measured memory_bytes: 3592
K = int(input())
if K <= 50:
    a = [50]*K + [0]*(50-K)
    print(50)
    print(*a)
    exit()

d,m = divmod(K,50)
if m==0:
    a = [d+49] * 50
    print(50)
    print(*a)
    exit()

a = [d+50] * 50
rem = 50 - m
for i in range(m):
    a[i] += rem
for i in range(m,50):
    a[i] -= (m+1)
print(50)
print(*a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> M;
    vector<ll> d(M), c(M);
    for (int i = 0; i < M; i++)
        cin >> d[i] >> c[i];
    vector<ll> t(10);
    vector<ll> tn(10, 0);
    vector<vector<pair<int, int>>> v(10);
    for (int n = 0; n < 10; n++) {
        int tmp = n;
        int num = 0;
        bool flag = 1;
        while (tmp != n || flag == 1) {
            flag = 0;
            tmp += n;
            num++;
            if (tmp >= 10) {
                tmp = tmp / 10 + tmp % 10;
                tn[n]++;
                v[n].push_back({tmp, 2});
            } else {
                v[n].push_back({tmp, 1});
            }
        }
        t[n] = num;
        tn[n] += num;
    }
    dump(v);
    dump(t);
    vi x;
    for (int i = 0; i < M; i++) {
        int n = d[i];
        c[i]--;
        if (n == 0) {
            ans += c[i];
            x.push_back(0);
            continue;
        }
        ans += c[i] / t[n] * tn[n];
        int tmp = c[i] % t[n];
        dump(tmp);
        for (int j = 0; j < tmp; j++) {
            ans += v[n][j].second;
        }
        if (tmp > 0)
            x.push_back(v[n][tmp - 1].first);
        else
            x.push_back(n);
    }
    dump(x);
    int tmp = x[0];
    for (int i = 1; i < x.size(); i++) {
        tmp += x[i];
        if (tmp >= 10) {
            tmp = tmp / 10 + tmp % 10;
            ans += 2;
        } else {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5496
N, K = map(int, input().split())
MOD = 1000000007

min_ = sum([i for i in range(K)])
max_ = sum([i for i in range(N, N - K, -1)])

right = K - 1
left = N - (K - 1)

cnt = 0
for k in range(K, N + 2):
    cnt += max_ - min_ + 1

    right += 1
    left -= 1

    min_ += right
    max_ += left

print(cnt % MOD)


Measured memory_bytes: 16884
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

template <typename T>
T gcd(T a, T b){ return b%a==0 ? a : gcd(b%a, a); }

template <typename T>
T lcm(T a, T b){ return (a/gcd(a, b))*b; }

int main()
{   
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n,0);
    rep(i,n)
    {
        if(s.substr(i,1)=="1")
            a[i] = 1;
        else
            a[i] = 0;
    }

    int m = n/2 + int(n%2==1);
    int kf = m;

    for(int i=m+1;i<=n;++i)
    {
        if(a[i-1]!=a[m-1]) break;
        kf = i;
    }

    int kb = m;
    for(int i=m+1;i<=n;++i)
    {
        if(a[n-i]!=a[n-m]) break;
        kb = i;
    }

    cout << min(kf,kb) << endl;
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int main(){
    char a[5];
    int n;
    
    scanf("%s",a);
    
    if(a[0]=='7' || a[1]=='7' || a[2]=='7'){
        printf("Yes\n");
    }
    
    else{
        printf("No\n");
    }
    
    
    return 0;
}

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

using namespace std;

typedef pair<int, int> pii;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<n; i++)

pair<pii, pii> cut(pii& p, int s) {
    int w = p.first, d = p.second;
    s %= 2*w + 2*d;
    pii a, b;
    if(s < w) {
        a = {s, d};
        b = {w-s, d};
    } else if(s < w+d) {
        a = {w, s-w};
        b = {w, d-s+w};
    } else if(s < w+d+w) {
        a = {s-w-d, d};
        b = {w-s+w+d, d};
    } else {
        a = {w, s-w-w-d};
        b = {w, d-s+w+w+d};
    }
    if(a.first*a.second < b.first*b.second)
        return {a, b};
    return {b, a};
}

int main() {
    while(1) {
        int n, w, d; cin >> n >> w >> d;
        if(n==0 && w==0 && d==0) break;

        vector<pii> ps;
        ps.push_back({w, d});

        rep(i, n) {
            int t, s; cin >> t >> s;
            t -= 1;
            pair<pii, pii> ret = cut(ps[t], s);
            ps.erase(ps.begin()+t);
            ps.push_back(ret.first);
            ps.push_back(ret.second);
            if(ret.first.first*ret.first.second < 0 || ret.second.first*ret.second.second<0) {
                cout << i << endl;
            }
        }

        vector<int> v;
        for(auto p : ps) {
            v.push_back(p.first*p.second);
        }
        sort(v.begin(), v.end());
        rep(i, v.size()-1)
            cout << v[i] << " ";
        cout << v.back() << endl;
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;
ll lcm(ll x,ll y){
  ll z;
  z=x/__gcd(x,y)*y;
  return z;
}

int main() {
  ll n;
  cin>>n;
  vector<ll> t(n);
  rep(i,n) cin>>t[i];
  /////lcm
  ll ans=1;
  rep(i,n){
    ans=lcm(ans,t[i]); 
  }
  
  
  
  
  cout<<ans<<endl;
}

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

using namespace std;


int main(int argc, char const *argv[])
{
	int a,b,c,k;

	scanf("%d%d%d\n%d",&a,&b,&c,&k);

	int mul = pow(2,k);

	int maxi = max(a, max(b,c));
	if(maxi==a)
		printf("%d\n",a*mul+b+c);
	else if (maxi==b)
	{
		printf("%d\n",b*mul+a+c);
	}else{
		printf("%d\n",c*mul+b+a);
	}

	return 0;
}

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


int A[100100];

int main(){
	int n,x=0,cnt=1;
	bool ok=false;
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	
	
	for(int i=1;i<n;i++){
		if(i==1+x){
			if(A[i]>A[i-1]) ok=true;
			else if(A[i]<A[i-1]) ok=false;
			else x++;
		}
		
		if(ok){
			if(A[i]<A[i-1]){
				cnt++;
				int y=1;
				aa:;
				if(i+y<n){
					if(A[i+y]<A[i]) ok=false;
					else if(A[i+y]==A[i]){
						y++;
						goto aa;
					}
				}
			}
		}
		else{
			if(A[i]>A[i-1]){
				cnt++;
				int y=1;
				bb:;
				if(i+y<n){
					if(A[i+y]>A[i]) ok=true;
					else if(A[i+y]==A[i]){
						y++;
						goto bb;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int a[5];
    int minr = 9;
    int min_index = 0;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(minr > a[i]%10 && a[i]%10 != 0){
            minr = a[i]%10;
            min_index = i;
        }
    }
    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(i==min_index){
            ans += a[i];
        }else{
            ans += a[i];
            int r = a[i]%10;
            if(r != 0){
                ans += 10-r;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.strip.split.map(&:to_i)
b = 0
c = 0
while c == 0

    if  a.all?{|x| x % 2 == 0} then
    b += 1
    for i in 0..N-1
        a[i] /= 2
    end
else
    c += 1
end
end

puts b

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	long long a,i,c=0,d=0,e=0;
	char b[100010];
	scanf("%s",b);
	c=strlen(b);
	for(i=0;i<c;i=i+2){
		if(b[i]=='0'){
			d++;
		}
	}
	for(i=1;i<c;i=i+2){
		if(b[i]=='1'){
			d++;
		}
	}
	printf("%lld\n",min(d,c-d));
	return 0;
}


Measured memory_bytes: 256
main = do
  inputs <- getContents
  let n = read $ head . lines $ inputs :: Int
  let ept = reverse $ map (\xs -> map read (words xs)) $ take n $ tail $ lines inputs :: [[Int]]
  let prf = map (\xs -> map read (words xs)) $ take n $ reverse $ lines inputs :: [[Int]]
  let mpt = map (toBin 10) [1..1023] :: [[Int]]
  let epr = zip ept prf
  print $ maximum $ map sum $ [ map (dj xs) epr | xs <- mpt ]

toBin :: Int -> Int -> [Int]
toBin digit n = map read $ reverse $ toBin' digit n
  where
    toBin' 0 _ = []
    toBin' d n = (show (n `mod` 2)) : toBin' (d - 1) (n `div` 2)

dj mpt (ept, prf) = prf !! (sk mpt ept)
  where
    sk _ [] = 0
    sk (x:xs) (y:ys)
      | x == 1 && y == 1 = 1 + (sk xs ys)
      | otherwise        = sk xs ys

Measured memory_bytes: 1916
class SWAG():
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.fold_r=[unit]
        self.fold_l=[unit]
        self.data_r=[]
        self.data_l=[]
        sep=len(data)//2
        *_,=map(self.append,data[sep:])
        *_,=map(self.appendleft,data[sep-1::-1])
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.__init__(self.unit,self.f,self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.__init__(self.unit,self.f,self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 120508
#include <stdio.h>

int searchMax(int *,int);

int main(void){
  int i;
  int N,a[100] = {'0'};
  int crd;
  int p_a = 0,p_b = 0;
  
  scanf("%d",&N);	crd = N;
  for(i = 0;i < N; ++i)	scanf(" %d",&a[i]);
  
  for(i = 0; crd ; ++i){
    if(!(i % 2)) p_a += searchMax(a,N);
    else p_b += searchMax(a,N);
    --crd;
  }
  printf("%d\n",p_a - p_b);
  return 0;
}

int searchMax(int *a,int N){
  int k,max,kmax;
  max = 0;
  
  for(k = 0;k < N; ++k){
    if(max < a[k]){
      max = a[k];
      kmax = k;
    }
  }
  
  a[kmax] = 0;
  
  return max;
}


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


void solve(long long N, std::string S){
    int ans = 0;
    for(int a = 0;a < N-2;a++){
        if(S[a] == 'A' && S[a+1] == 'B' && S[a+2] == 'C'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

int main(){
    int N, K, A[500];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];
    int S = accumulate(A, A+N, 0);
    
    vector<int> divs;
    for(int i=1; i*i<=S; i++) if(S%i == 0){
        divs.push_back(i);
        divs.push_back(S/i);
    }
    sort(divs.rbegin(), divs.rend());

    for(int d : divs){
        vector<int> nums;
        for(int i=0; i<N; i++) nums.push_back(A[i]%d);
        sort(nums.begin(), nums.end());
        int cost1 = 0, cost2 = 0;
        int r = N-1;
        for(int l=0; l<N; l++){
            cost1 += nums[l];
            while(cost1 > cost2){
                cost2 += d - nums[r];
                r--;
            }
            if(l >= r) break;
        }
        if(cost1 <= K){
            cout << d << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b, c;
    cin >> a >> b >> c;
    if (a==b)cout << c << endl;
    else if (a==c)cout << b << endl;
    else cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int N;
string s;

int main()
{
    cin >> N >> s;
    int cnt = 0, r = 0, b = 0;

    rep(i, N)
    {
        if (s[i] == 'R')
        {
            r++;
        }
    }
    b = r - 1;
    // cout << b << endl;
    for (int i = 0; i < N; i++)
    {
        if (i <= b && s[i] == 'W')
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> dist; // dist[n] = ノードnまでのの重み
  vector<ll> parent;

  graph(ll n){ //グラフ生成時
    N = n+1;
    G.resize(N); //Edge情報
    dist.resize(N); //Node情報,ans
    parent.resize(N);
    rep(i,N){dist[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    edge E; E.to=t; E.cost=cost;
    G[s].emplace_back(E);
  }

  void dijkstra(ll s){
    rep(i,N){dist[i] = INF;}
    dist[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //ansが小さい順に出る
    que.push(P(0,s)); // P < ans , Node >
    while(!que.empty()){
      P p = que.top(); que.pop(); //pに <ans,Node> 入れる
      ll v = p.second; //vに Node 入れる
      if(dist[v] < p.first) continue; //すでに良い数値が入っているならパス
      for(auto E : G[v]){
        if(dist[E.to] > dist[v] + E.cost){ //更新するなら
          dist[E.to] = dist[v]+ E.cost;
          parent[E.to] = v;
          que.push(P(dist[E.to], E.to));
        }
      }
    }

  }
};

void Main(){

  ll N,M;

  cin>>N>>M;

  graph g(N);
  rep(i,M){
    int a,b,cost;
    cin>>a>>b>>cost;
    g.add_edge(a-1,b-1,cost);
    g.add_edge(b-1,a-1,cost);
  }

  set<pair<ll,ll>> se;

  rep(i,N){
    g.dijkstra(i);

    rep(j,N){
      if(i==j) continue;
      ll now=j;
      while(now!=i){
        ll pare=g.parent[now];
        se.insert({max(pare,now),min(pare,now)});
        now=pare;
      }
    }

  }

  cout << M-se.size() <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int A, B ,T;
    cin >> A >> B>> T;

    int t = floor( T + 0.5) ;    
    int sum = 0;
    for(int i = A; i <= t; i = i + A){
        sum += B;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string w;
	int m, h, i, k, s;

	while( true )
	{
		cin >> w;
		if(w == "-")
			break;

		k = 0;
		s = w.size();

		cin >> m;
		for(i = 0; i < m; ++i){
			cin >> h;
			k += h;
			if( k >= s ) k -= s;
		}

		for(i = 0; i < s; ++i)
			cout << w[(i+k)%s];
	
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int sum;
	cin>>sum;
	float dim = sum/3.0;
	// cout<<dim*dim*dim<<endl;
	// use this to avoid e format output, . represents decimals and 12 represents 12 characters of the output
	printf("%.12f\n",(double)dim*dim*dim);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m),num(m-1);
	rep(i, 0, m)cin >> x[i];
	int ans = 0;
	if (n < m){
		sort(x.begin(), x.end());
		rep(i, 0, m - 1) num[i] = x[i + 1] - x[i];
		sort(num.begin(), num.end());
		rep(i, 0, m - n) {
			ans += num[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

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



int main()
{

int n ,r ;
cin>>n>>r;

if(n<10)
    cout<<r+100*(10-n)<<endl;
else
    cout<<r<<endl;

 return 0;
}


Measured memory_bytes: 3604
n = list(input())
X = 753
ans = X
# n = [1,2,3,4,5,6,7]
for i in range(len(n)-2):
    tmp = []
    for k in range(i, i+3):
        tmp.append(n[k])
    s = int(''.join(map(str, tmp)))
    temp = abs(s - X)
    if temp <= ans:
        ans = temp

print(ans)

Measured memory_bytes: 3060
N=int(input())

if N==1:
    print(input().count("AB"))
    exit()

BA=0
B_=0
_A=0
cnt=0

for i in range(N):
    s=input()

    if s[0] == "B" and s[-1] == "A":
        BA += 1
    elif s[0] == "B" and s[-1] != "A":
        B_ += 1
    elif s[-1] != "B" and s[-1] == "A":
        _A += 1

    cnt += s.count("AB")


if _A==0 and B_==0:
    ans=max(0,BA-1)+cnt
elif (_A!=0 and B_==0) or (_A==0 and B_!=0):
    ans=BA+cnt

else:
    ans=BA+1+min(_A-1,B_-1)+cnt

print(ans)



Measured memory_bytes: 3064
import sys

n = int(input())
alist = [ int(x) for x in input().split() ]
product = 1

if 0 in alist:
    print(0)
    sys.exit()

for index in range(len(alist)):
    product = product * alist[index]
    if product > 10**18:
        print(-1)
        sys.exit()

print(product)


Measured memory_bytes: 21648
#include <algorithm>
#include <cstdio>
#include <cstdlib>
const int INFN = 1e9+7;
const int MAXN = 1e5+5;
int dp[MAXN];
int H[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
    dp[i] = INFN;
  }
  dp[1] = 0;
  for (int i = 1; i < N; ++i) {
    dp[i+1] = std::min(dp[i] + std::abs(H[i] - H[i+1]), dp[i+1]);
    if (i+2 > N) continue;
    dp[i+2] = std::min(dp[i] + std::abs(H[i] - H[i+2]), dp[i+2]);
  }
  printf("%d\n", dp[N]);
  return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
	int N;
	map<int, int> A;
	cin >> N;
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		A[tmp] = i;
	}

	for (int i = 0; i < N; i++) {
		cout << A[i + 1] + 1;
		cout << " ";
	}
}


Measured memory_bytes: 5504
n = gets.to_i

hash = {}

(1..n).each do
  m, i = gets.split
  hash[m + i] = 1
end

%w[S H C D].each do |m|
  (1..13).each do |i|
    is_absent = !hash.key?(m + i.to_s)
    puts "#{m} #{i}" if is_absent
  end
end



Measured memory_bytes: 6872
N, K = map(int, input().split())
Hi = []
for i in range(N):
    h = int(input())
    Hi.append(h)
Hi.sort()
min_diff = 100000000000
start_idx = 0
for i in range(N - K + 1):
    diff = Hi[i + K - 1] - Hi[i]
    if diff < min_diff:
        min_diff = diff
        start_idx = i
print(Hi[start_idx + K - 1] - Hi[start_idx])

Measured memory_bytes: 7384
#include"bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main (){
    int K,X;

    cin >> K >> X;
    
    if(K * 500 >= X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;;
    }
    
    
}



Measured memory_bytes: 256
/*
        Oink!Oink!!
▂╱▔▔╲╱▔▔▔▔╲╱▔▔╲▂
╲┈▔╲┊╭╮┈┈╭╮┊╱▔┈╱
┊▔╲╱▏┈╱▔▔╲┈▕╲╱▔┊
┊┊┊┃┈┈▏┃┃▕┈┈┃┊┊┊
┊┊┊▏╲┈╲▂▂╱┈╱▕┊┊┊

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <random>
#include <valarray>
//#include <fstream>
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

int main()
{
    
    long long int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<long long int> red(a,0);
    vector<long long int> green(b,0);
    vector<long long int> col(c,0);
    
    for(long long int i=0;i<a;i++)
        cin>>red[i];

    for(long long int i=0;i<b;i++)
        cin>>green[i];
    
    for(long long int i=0;i<c;i++)
        cin>>col[i];


    sort(red.begin(),red.end(),greater<long long int> ());
    sort(green.begin(),green.end(),greater<long long int> ());
    sort(col.begin(),col.end(),greater<long long int> ());

    vector<long long int> ans;

   for(long long int i=0;i<x;i++)
    ans.pb(red[i]);

   for(long long int i=0;i<y;i++)
    ans.pb(green[i]);
    
    
    for(long long int i=0;i<min((x+y),c);i++)
    ans.pb(col[i]);
    
    sort(ans.rbegin(),ans.rend());
    
    long long int sum=0;
    for(long long int i=0;i<x+y;i++)
    {       
        sum+=ans[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 8304
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//æ˜‡é †

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vi X(n+1);vi Y(m+1);
    rep(i,n)cin >> X[i];
    rep(i,m)cin >> Y[i];
    X[n]=x;Y[m]=y;
    SORT(X);SORT(Y);
    if(X[n]<Y[0])
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

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

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
int c[514], s[514], f[514];
signed main() {
	scanf("%lld", &n);
	rep(i, n - 1) {
		scanf("%lld %lld %lld", &c[i], &s[i], &f[i]);
	}
	rep(i, n) {
		int t = 0;
		for (int j = i; j < n - 1; j++) {
			if (t < s[j]) {
				t = s[j];
			}
			else if (t % f[j]) {
				t = t + f[j] - t % f[j];
			}
			t += c[j];
		}
		printf("%lld\n", t);
	}
}

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

int main(){
	int h , w ;
	while(cin >> w >> h , w){
		int dp[102][102][2][2] = {0};
	
		dp[1][1][0][0] = 1;
		dp[1][1][0][1] = 1;
		
		for(int y = 1 ; y <= h ; y++){
			for(int x = 1 ; x <= w ; x++){
				dp[y][x][0][0] %= 100000;
				dp[y][x][0][1] %= 100000;
				dp[y][x][1][0] %= 100000;
				dp[y][x][1][1] %= 100000;
				
				dp[y][x+1][0][0] += dp[y][x][1][0];
				dp[y+1][x][0][1] += dp[y][x][1][1];
				
				dp[y][x+1][0][0] += dp[y][x][0][0];
				dp[y+1][x][0][1] += dp[y][x][0][1];
				
				if(x != 1 || y != 1) dp[y+1][x][1][1] += dp[y][x][0][0];
				if(x != 1 || y != 1) dp[y][x+1][1][0] += dp[y][x][0][1];
				
			}
		}
		cout << (dp[h][w][0][0] + dp[h][w][1][1] + dp[h][w][0][1] + dp[h][w][1][0]) % 100000 << endl;
	}

	
}

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

int main()
{
    long x,ans,tm;

    while(cin>>x){
    ans = 0;
    tm = 0;
    for(int i=1; i<=x; i++)
    {
        if(ans<x){
        ans+=i;
        tm++;
        }
        if(ans>=x)
            break;
    }
    cout<<tm<<endl;

    }
}


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

int main(){
  int n;
  cin>>n;
  vector<double> vec(n);
  rep(i,n) cin>>vec[i];
  sort(vec.begin(),vec.end());
  rep(i,n-1){
    vec[0]=(vec[0]+vec[i+1])/2;
  }
  cout<<vec[0]<<endl;
}
    
    

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

int main() {
  string S;

  cin >> S;
  
  sort(S.begin(), S.end());

  if (S == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b; cin >> a >> b;
  if (a > 8 || b > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}

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

const int mod = 1000003;
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;
    }
};
struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int Q;
combination c(1000002);
mint solve(ll x,ll d,ll n){
    mint ans=0;
    if(d==0)return mint(x).pow(n);
    else{
        mint q=mint(x)/d;
        if(q.x==0||q.x+n-1>=mod)return mint(0);
        int f1=int(q.x+n)-1;
        int f2=int(q.x)-1;
        ans+=c.fact[f1]*c.ifact[f2];
        ans*=mint(d).pow(n);
    }
    return ans;
}

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

    cin>>Q;
    rep(i,Q){
     ll x,d,n;
     cin>>x>>d>>n;
    cout<<solve(x,d,n).x<<endl;
    }
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, K;
  vector<llong> P, C;

  cin >> N >> K;
  P.resize(N + 1);
  C.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> P[i];
  }
  for (int i = 1; i <= N; i++) {
    cin >> C[i];
  }

  llong ans = LLONG_MIN;
  for (int i = 1; i <= N; i++) {
    vector<llong> used(N + 1, 0);
    llong now = i;
    llong res = 0;
    llong cnt = 0;
    while (cnt < K && !used[now]) {
      used[now]++;
      cnt++;
      res += C[P[now]];
      now = P[now];
      ans = max(ans, res);
    }
    if (cnt < K && res > 0) {
      if (K % cnt == 0) {
        res += res * (K / cnt - 2);
        cnt += cnt * (K / cnt - 2);
        // cerr << res << " " << cnt << endl;
      }
      else {
        res *= K / cnt;
        cnt *= K / cnt;
      }
      ans = max(ans, res);
      while (cnt < K) {
        cnt++;
        res += C[P[now]];
        now = P[now];
        ans = max(ans, res);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3752
using System;
using System.Text.RegularExpressions;

namespace Range{
	class class1{
		static void Main(string[] args){
			string input = Console.ReadLine();
			Match m = Regex.Match(input,@"(?<a>\d+) (?<b>\d+) (?<c>\d+)$");
			int a = int.Parse(m.Groups["a"].Value),b = int.Parse(m.Groups["b"].Value),c = int.Parse(m.Groups["c"].Value);
			if(a < b && b < c){
				Console.Write("Yes\n");
			}
			else{
				Console.Write("No\n");
			}
		}
	}
}

Measured memory_bytes: 11672
#include <stdio.h>

int main(void){
    int N, M;
    int votes[100], sum_votes, count, i;
    sum_votes = 0;
    count = 0;

    scanf("%d%d", &N, &M);
    for(i = 0; i < N; i++){
        scanf("%d", &votes[i]);
        sum_votes += votes[i];
    }

    for(i = 0; i < N; i++){
        if(votes[i] >= (sum_votes/(4.0*M)))
            count++;
    }
    
    if(count >= M)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 1000000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int n,rt,du[MAXN+5];LL d[MAXN+5],a[MAXN+5];
vector<int> G[MAXN+5];

void dfs(int x,int fa){
	if(du[x]==1){d[x]=a[x];return ;}
	LL sum=0,mx=0;
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==fa)continue;
		dfs(v,x);
		sum+=d[v],mx=max(mx,d[v]);
	}
	d[x]=2*a[x]-sum;
	if(d[x]<0||d[x]>a[x]||mx>a[x])puts("NO"),exit(0);
}

int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(); 
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		du[u]++,du[v]++;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(n==2){printf("%s",(a[1]!=a[2])?"NO":"YES");return 0;}
	for(int i=1;i<=n;i++)
	if(du[i]!=1)rt=i;
	dfs(rt,0);
	printf("%s",d[rt]?"NO":"YES");
}

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

using namespace std;
#define int long long
int n,a[10005],f[3005][3005];
int F(int i,int j)
{
	if(f[i][j]!=-1) return f[i][j];
	else if(i>j)
	{
		return 0;
	}
	else
	{
		int res;
		if((i-1+n-j)%2==0)
		{
			res=max(F(i+1,j)+a[i],F(i,j-1)+a[j]);
		}
		else 
		{
			res=min(F(i+1,j)-a[i],F(i,j-1)-a[j]);
		}
		f[i][j]=res;
		return res;
	}
	
}
main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	memset(f,-1,sizeof(f));
	cout<<F(1,n);
}

Measured memory_bytes: 70912
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		StringBuilder sb = new StringBuilder(S);
		String ans = S.replace("eraser", "")
				.replace("erase", "")
				.replace("dreamer", "")
				.replace("dream", "");
		System.out.println(ans.equals("") ? "YES" :"NO");
	}
}

Measured memory_bytes: 28608
import math
#数値ひとつ
I = int(input())
#数値欲しいとき
#H, W = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#listA = list(N)
a = 0
a = 2*I*3.14
print(a)

Measured memory_bytes: 9084
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
le = [[p[0]-p[1], p[0]+p[1]] for p in xl]
le.sort(key = lambda x : x[1])

ans = 0
right = -(10 ** 9) - 1
for i in range(n):
    if right <= le[i][0]:
        ans += 1
        right = le[i][1]
print(ans)

Measured memory_bytes: 42792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m=0,a=0,r=0,c=0,h=0;
  cin >>n;
  string s;
  for(ll i=0;i<n;i++) {
    cin >>s;
    if(s[0]=='M') m++;
    if(s[0]=='A') a++;
    if(s[0]=='R') r++;
    if(s[0]=='C') c++;
    if(s[0]=='H') h++;
  }
cout <<m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int n;
  cin >> n;
  ll ans;
  lvec l(n + 1);
  l[0] = 2;
  l[1] = 1;
  FOR(i, 2, n + 1) { l[i] = l[i - 1] + l[i - 2]; }
  ans = l[n];
  print(ans);
  return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
  
var bfr=[];
for(var i=0;i<4;i++){
   bfr.push([]);
   for(var j=0;j<3;j++){
      bfr[i].push([]);
      for(var k=0;k<10;k++){
         bfr[i][j].push(0);
      }
   }
}
  
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(" ").map(Number);
var b=arr[0]-1;
var f=arr[1]-1;
var r=arr[2]-1;
var v=arr[3];
bfr[b][f][r]=bfr[b][f][r]+v;
if(bfr[b][f][r]>9)bfr[b][f][r]=9;
if(bfr[b][f][r]<0)bfr[b][f][r]=0;
}
  
for(var i=0;i<4;i++){
   for(var j=0;j<3;j++){
   console.log(" "+bfr[i][j].join(" "));
   }
   if(i!==3)console.log("####################");
}

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

using namespace std;

int main()
{
  int s, d, m;
  while(cin >> s >> d >> m){
    vector<pair<int, int> > vec[101];
    for(int i = 0; i < s; i++){
      int k; cin >> k;
      for(int j = 0; j < k; j++){
	int w, p;
	cin >> w >> p;
	vec[i].push_back(make_pair(w, p));
      }
    }
    int dp[301];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for(int i = 0; i < d; i++){
      int f; cin >> f;
      for(int j = 0; j < vec[f].size(); j++){
	for(int k = m; k >= 0; k--){
	  if(k < vec[f][j].second) continue;
	  dp[k] = max(dp[k], dp[k - vec[f][j].second] + vec[f][j].first);
	}
      }
    }
    int ansidx = 0;
    for(int i = 1; i <= m; i++){
      if(dp[i] > dp[ansidx]) ansidx = i;
    }
    cout << dp[ansidx] << " " << ansidx << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<cstdio>

using namespace std;

const int mo=998244353;

int n,m,a[301][301],r=0,b[301][301];
bool f[301];

int mi(int o,int p)
{
	int u=1;
	while(p>0)
	{
		if(p&1) u=1ll*u*o%mo;
		o=1ll*o*o%mo;
		p>>=1;
	}
	return u;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=m;j>=1;j--)
			if(a[i][j])
			{
				if(!f[j]) 
				{
					for(int k=1;k<=m;k++) b[j][k]=a[i][k];
					f[j]=1;r++;
					break;
				}else
				{
					for(int k=1;k<=m;k++) a[i][k]^=b[j][k];
				}
			}
	cout<<((mi(2,n+m-1)-mi(2,n+m-1-r)+mo)%mo)<<endl;
	return 0;
}

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

void solve(std::istream& ist, std::ostream& ost)
{
    /* ------- 宣言と入力 ------- */

    long long N, A, B;

    ist >> N >> A >> B;

    /* ------- 計算 ------- */

    long long sum = A + B;

    long long ans = 0;

    ans += N / sum * A;

    if (N % sum < A)
    {
        ans += N % sum;
    }
    else
    {
        ans += A;
    }

    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define intpow(a, n) (int)pow((long double) a, (long double) n)
#define int long long

signed main(){
    string n; cin >> n;
    rep(i,3){
        if(n[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

type Perm struct {
	num int
	idx int
}

type Perms []Perm

func (p Perms) Len() int {
	return len(p)
}

func (p Perms) Less(i, j int) bool {
	return p[i].num < p[j].num
}

func (p Perms) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func swaps(n int, a, b []int) bool {
	ap := make(Perms, n)
	bp := make(Perms, n)
	for i := 0; i < n; i++ {
		ap[i] = Perm{idx: i, num: a[i]}
		bp[i] = Perm{idx: i, num: b[i]}
	}
	sort.Sort(ap)
	sort.Sort(bp)

	for i := 0; i < n; i++ {
		if ap[i].num > bp[i].num {
			return false
		}
	}

	for i := 0; i < n-1; i++ {
		if ap[i+1].num <= bp[i].num {
			return true
		}
	}

	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[ap[i].idx] = bp[i].idx
	}

	s := make(map[int]struct{})
	for i, m := 0, 0; i < n; i++ {
		s[m] = struct{}{}
		m = p[m]
	}

	if len(s) < n {
		return true
	}
	return false
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)

	n, err := strconv.Atoi(readLine(reader))
	checkError(err)
	a := make([]int, n)
	ss := strings.Split(readLine(reader), " ")
	for i := range ss {
		a[i], err = strconv.Atoi(ss[i])
		checkError(err)
	}

	b := make([]int, n)
	ss = strings.Split(readLine(reader), " ")
	for i := range ss {
		b[i], err = strconv.Atoi(ss[i])
		checkError(err)
	}

	if swaps(n, a, b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 10368