akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

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

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

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

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

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

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

int n, m;
int e[100010];

signed main() {
    int n, m; cin >> n >> m;
    rep(i,0,m) cin >> e[i];
    set<int> s;
    repr(i,m-1,0) {
        if(s.count( e[i] )) continue;
        cout << e[i] << endl;
        s.insert(e[i]);
    }
    repq(i,1,n) {
        if(!s.count(i)) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 8532
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[0]*(m-1)
for i in range(0,m-1):
  b[i]=a[i+1]-a[i]
c=sorted(b)
s=a[m-1]-a[0]
if m>n:
  for i in range(0,n-1):
  	s=s-c[m-i-2]
else:
  s=0
print(s)

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

using namespace std;

int n, k;
int a[101];
int dp[101][100001];
int d= 1e9 + 7;

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

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

    int sum = 0;
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j <= k; j++)
        {
            if(i-1 >= 0 && j-a[i]-1 >= 0) sum -= dp[i-1][j-a[i]-1];
            sum = (sum + d) % d;
            if(i-1 >= 0) sum += dp[i-1][j];
            sum = sum % d;
            dp[i][j] = sum;
        }
        sum = 0;
    }

    // for(int i = 0; i < n; i++)
    // {
    //     for(int j = 0; j <= k; j++)
    //     {
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << dp[n-1][k] << endl;
}

Measured memory_bytes: 39296
use proconio::{input, fastout};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    xl: [(i64, i64);n]
  };

  let mut xl = xl;
  // xl.sort_by_cached_key(|t| t.0 + t.1);
  xl.sort_by_key(|t| t.0 + t.1);
  let mut idx = std::i64::MIN;
  let mut ans = 0;
  for (x, l) in xl {
    if idx <= x - l {
      idx = x+l;
      ans += 1;
    }
  }
  echo!(ans);
}


Measured memory_bytes: 6224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    if(S == "SUN")cout << 7 << endl;
    if(S == "MON")cout << 6 << endl;
    if(S == "TUE")cout << 5 << endl;
    if(S == "WED")cout << 4 << endl;
    if(S == "THU")cout << 3 << endl;
    if(S == "FRI")cout << 2 << endl;
    if(S == "SAT")cout << 1 << endl;

}

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

int A[SIZE];
char str[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",&str);
	bool up=true;
	for(int i=0;i<n;i++)
	{
		A[i]=str[i]-'0';
		A[i]--;
		if(A[i]==1) up=false;
	}
	if(up)
	{
		for(int i=0;i<n;i++) A[i]/=2;
	}
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(((n-1)&i)==i)
		{
			ret^=A[i]%2;
		}
	}
	if(up) ret*=2;
	printf("%d\n",ret);
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

class FordFulkerson{
  vector<vector<int>> e;
  vector<bool> usd;
  int n,s,t;
public:
  FordFulkerson(vector<vector<int>> &v,int ss,int tt){
    e=v,s=ss,t=tt,n=v.size();
  }
  int solve(){
    int ans=0,ret;
    usd=vector<bool>(n,false);
    while(1){
      usd=vector<bool>(n,false);
      ret=dfs(s);
      if(ret==0) break;
      else ans+=ret;
    }
    return ans;
  }
  int dfs(int x,int d=INF){
    usd[x]=true;
    int ret;
    for(int i=0;i<n;i++){
      if((!usd[i])&&e[x][i]>0){
        if(i==t){
          ret=min(d,e[x][i]);
          e[x][i]-=ret;
          e[i][x]+=ret;
          return ret;
        }else{
          ret=dfs(i,min(d,e[x][i]));
          if(ret>0){
            e[x][i]-=ret;
            e[i][x]+=ret;
            return ret;
          }
        }
      }
    }
    return 0;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> e(n,vector<int>(n,0));
  int u,v,c;
  for(int i=0;i<m;i++){
    cin >> u >> v >> c;
    e[u][v]=c;
  }
  FordFulkerson solver(e,0,n-1);
  cout << solver.solve() << endl;
  return 0;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    vector<int> ans;
    rep(i, N){
        string S; cin >> S;
        int lenS = S.length();
        set<string> st;
        for(int i = 1; i < lenS; i++){
            string L = S.substr(0, i);
            string R = S.substr(i);
            st.insert(L+R);
            st.insert(R+L);
            reverse(L.begin(),L.end());
            st.insert(L+R);
            st.insert(R+L);
            reverse(R.begin(),R.end());
            st.insert(L+R);
            st.insert(R+L);
            reverse(L.begin(),L.end());
            st.insert(L+R);
            st.insert(R+L);
        }
        ans.push_back(st.size());
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

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

    int a,b;
    // 引数の受け取り
    //
    cin >> a >> b;
    a+=b;
    if(a<10){

    cout << a  << endl;
    }else{
    cout << "error"  << endl;
    
    }
    // 出力
    return 0;
}



Measured memory_bytes: 256
include Math

# 1000000000000001 < 26^11

N = gets.to_i

a = "abcdefghijklmnopqrstuvwxyz"

iter = 0
sta = 1
fin = 26
11.times do |i|
  if (sta <= N) and (N <= fin)
    iter = i+1
    break
  end
  sta = fin + 1
  fin = sta + 26**(i+2) - 1
end

x = N - sta

ans = []
ans = ans.fill('a',0..iter-1)

tmp = 0
iter.times do |n|
  tmp = x % 26
  x /= 26
  # tmpの値に応じて上からa-zを割り振る
  ans[n] = a[tmp]
end

ans = ans.reverse
ans.each do |a|
  print a
end

Measured memory_bytes: 14344
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

int main() {
	int N; cin >> N;
	map<int, int> x;
	vector<pair<string, int>> a(N);

	for (int i = 0; i < N; i++) {
		int b;
		cin >> a[i].first >> b;
		a[i].second = 100 - b;
		x[a[i].second] = i+1;
	}
	sort(a.begin(), a.end());

	for (int i = 0; i < N; i++) {
		cout << x[a[i].second] << endl;
	}

}




Measured memory_bytes: 256
#include<stdio.h>

int rec(int,int);
int a[2000],n;

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    switch(rec(0,m)){
    case 1:printf("yes\n");
      break;
    case 0:printf("no\n");
      break;
    }
  }
  return 0;
}

int  rec(int i,int m){
  int ans;
  if(m==0)return 1;
  if(i>=n)return 0;
  ans=rec(i+1,m)||rec(i+1,m-a[i]);
  return ans;
}



Measured memory_bytes: 2144
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
s = 0
i = 0
while i < n-1:
  k = i+1
  while k < n:
    s += li[i] * li[k]
    k += 1
  i += 1
print(s)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>

using namespace std;

int main(void) {
    vector<int> ABC(3);
    int K;

    for (int i = 0; i < 3; i++) {
        cin >> ABC[i];
    }
    sort(ABC.begin(), ABC.end(), greater<int>());

    cin >> K;
    ABC[0] *= pow(2.0, K);

    cout << ABC[0] + ABC[1] + ABC[2] << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<double> ai(n);
  for (int i = 0; i < n; i++) {
    cin >> ai.at(i);
  }
  
  double denomi = 0;
  for (double a : ai) {
    denomi += 1.0/a;
  }
  cout << 1.0/denomi << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
 
using namespace std;
 
int main(){
	double a,b,x;
  	cin >>a>>b>>x;
  	double theta1,theta2,min_theta=0;
  
  	theta1 = atan(  2*(a*a*b-x) / (a*a*a) ) * 180/M_PI;
  	theta2 = atan( ( (a*b*b) / (2*x) )) * 180/M_PI;
  
  	if( x > (a*a*b/2))	min_theta = theta1;
  	else min_theta = theta2;
  
  	cout << setprecision(10) << min_theta <<endl;
  	
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int i;
    char s[21];
    
    scanf("%s",s);
    
    for(i=0;s[i]!='\0';i++);
    i--;
    
    for(;i>=0;i--)
        printf("%c",s[i]);
            
        
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main() {
    uint64_t N;
    std::cin >> N;

    std::size_t max = 0, cnt = 0, H = 0, prevH = 0;
    for (std::size_t i = 0; i < N; ++i) {
        std::scanf("%lu", &H);
        
        if (prevH == 0) {
            prevH = H;
            continue;
        }

        if (H <= prevH) {
            ++cnt;
        } else {
            if (max < cnt) {
                max = cnt;
            }
            cnt = 0;
        }
            
        prevH = H;
    }

    if (max < cnt) {
        max = cnt;
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
long long multiply( long long a, long long b )
{
  if ( log10(a) + log10(b) > 18 || a*b > 1000000000000000000 )
    return -1;
  else if ( a == 0 || b == 0 )
  	return 0;
  return a*b;
}
 
int main(void)
{
  long long a, b;
  int n;
  cin>>n>>a;
  for(int i=1; i<n; i++)
  {
  	cin>>b;
    a = multiply(a,b);
	if ( a <= -1 )
      a = -1;
    else if ( a == 0 )
      break;
  }
  cout << a;
}

Measured memory_bytes: 3972
N,A,B,C=map(int,input().split())
l = [int(input()) for i in range(0,N)]
INF = 10**9

def dcm(cou,a,b,c):
    if cou == N:
        if min(a,b,c)>0:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return INF
    
    case0 = dcm(cou+1,a,b,c)
    case1 = dcm(cou+1,a+l[cou],b,c)+10
    case2 = dcm(cou+1,a,b+l[cou],c)+10
    case3 = dcm(cou+1,a,b,c+l[cou])+10
    
    return min(case0,case1,case2,case3)
        
print(dcm(0,0,0,0))

Measured memory_bytes: 3064
// Warshall-floyd
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 114514810

int n, a, b, c, v, d[11][11];// v: num of nodes

void init()
{
    for(int i=0; i<11; i++) {
        for(int j=0; j<11; j++) {
            if(i==j)// If not exist cost, cost=INF
                d[i][j] = 0;
            else
                d[i][j] = INF;
        }
    }
}

int main(void)
{
    ios::sync_with_stdio(false);
    while(1) {
        cin >> n;
        if(n == 0) break;
        init();

        v = -1;
        for(int i=0; i<n; i++) {
            cin >> a >> b >> c;
            d[a][b] = c; d[b][a] = c;
            v = max(v, max(a, b));
        }
        v++;

        for(int k=0; k<v; k++) {
            for(int i=0; i<v; i++) {
                for(int j=0; j<v; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }


        int city, dist = INF;
        for(int i=0; i<v; i++) {
            int sum = 0;
            for(int j=0; j<v; j++) {
                sum += d[i][j];
            }
            if(sum < dist) {
                dist = sum;
                city = i;
            }
        }
        cout << city << " " << dist << endl;
    }

    return 0;
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  long long n, m, mod = 1e9+7;
  cin >> n >> m;
  if(n == 1){
    cout << (m+1)%mod << endl;
    return 0;
  }
  long long t = m/(n-1);
  using mint = modint<(int)1e9+7>;
  mint N = n, M = m, T = t;
  mint ans = (M+1)*T - (N-1)*(T*(T+1)/2);
  ans *= 2;
  ans += m + 1;
  cout << ans << endl;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
    int n,m,i,j;
    int A[100][100]={{}};
    int b[100]={};
    cin >>n >>m;
    int a;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a;
            A[i][j]=a;
        }
    }
    for(j=0;j<m;j++){
        int c;
        cin>>c;
        b[j]=c;
    }
    for(i=0;i<n;i++){
        int x=0;
        for(j=0;j<m;j++) x+=A[i][j]*b[j];
        cout << x <<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a,b,c,d = inp
1000000.times do
  c -= b
  if(c <= 0)
    puts "Yes"
    exit
  end
  a -= d
  if(a <= 0)
    puts "No"
    exit
  end
end

Measured memory_bytes: 14316
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let N = get!(usize);
    let Ws = get!(isize |);
    let mut min = std::isize::MAX;
    for i in 1..(Ws.len()) {
        min = std::cmp::min(min,
                            (Ws.iter().take(i).fold(0, |acc, x| acc + x) -
                             Ws.iter().skip(i).fold(0, |acc, x| acc + x)).abs())
    }
    println!("{}", min);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef long long ll;
const int INF=0x3f3f3f3f;
const double PI=3.1415926;
const int MOD=1e9+7;
const double eps=1e-8;
const int N=2e3+5;
int cnt[N][N],s[N][N];
int n,k;
inline int S(int i,int j)
{
    return (i>=0&&j>=0)?s[min(k*2-1,i)][min(k*2-1,j)]:0;
}
inline int sum(int i,int j)
{
    return S(i,j)-S(i-k,j)-S(i,j-k)+S(i-k,j-k);
}
int main()
{
    while(cin>>n>>k)
    {
        mem(cnt,0);
        rep(i,0,n)
        {
            int x,y;
            char ch;
            cin>>x>>y>>ch;
            if(ch=='B') x+=k;
            x%=(k*2);
            y%=(k*2);
            cnt[x][y]++;
        }
        rep(i,0,k*2)
            rep(j,0,k*2) s[i][j]=S(i,j-1)+cnt[i][j];
        rep(i,0,k*2)
        rep(j,0,k*2) s[i][j]+=S(i-1,j);
        int ans=0;
        for(int i=0;i<2*k;i++)
            for(int j=0;j<2*k;j++)
            ans=max(ans,sum(i,j)+
                    sum(i-k,j-k)+sum(i-k,j+k)+sum(i+k,j-k)+sum(i+k,j+k)+sum(i+k*2,j)+sum(i,j+k*2));
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

void solve() {
	int64 s;
	cin >> s;

	int64 cur = s;
	int pos = 1;
	std::set<int64> used;

	while(!used.count(cur)) {
		used.insert(cur);

		if(cur & 1)
			cur = 3 * cur + 1;
		else
			cur /= 2;

		++pos;
	}

	cout << pos << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


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

const ll MOD = 1e9+7;

int* Eratosthenes(int N){
    int* arr = new int[N];

    for(int i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    return arr;
}

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

int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    int g = A[0];
    FOR(i, 1, N) g = gcd(g, A[i]);
    if(g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    int* v = Eratosthenes(1e3+9);
    v[0] = 0;
    v[1] = 0;
    vector<int> B(1e6+9, 0);
    vector<int> pl;
    rep(i, 1e3+2) {
        if (v[i] == 1) pl.push_back(i);
    }

    int max_s = 0;

    rep(i, N) {
        int tmp = A[i];
        for(int j : pl) {
            if (tmp == 1) break;
            if (tmp % j != 0) continue;
            B[j]++;
            while(tmp % j == 0) {
                tmp /= j;
            }
        }
        if (tmp > 1) B[tmp]++;
    }

    FOR(i, 2, 1e6+2) {
        max_s = max(max_s, B[i]);
    }

    if (max_s <= 1) cout << "pairwise coprime" << endl;
    else cout << "setwise coprime" << endl;

    return 0;
}


Measured memory_bytes: 11020
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    
    if (500 * K >= X) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

vector<int> mt;
vector<char> used;
vector< vector<int> > g;

bool try_kuhn (int v) {
	if (used[v])  return false;
	used[v] = true;
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (mt[to] == -1 || try_kuhn (mt[to])) {
			mt[to] = v;
			return true;
		}
	}
	return false;
}

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

    vector<int> a(n), b(n), c(n), d(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>c[i]>>d[i];
    }

    g.resize(n);
    mt.assign (n, -1);

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if (a[i] < c[j] && b[i] < d[j])
            {
                g[i].push_back(j);
            }
        }
    }

    for (int v=0; v<n; ++v) {
		used.assign (n, false);
		try_kuhn (v);
	}

	int res = 0;
    for (int i=0; i<n; ++i)
    {
        if (mt[i] != -1)
            res++;
    }
    cout << res;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int x,y,z,k;
ll a[1252], b[1252], c[1252];

int main(){
  scanf("%d%d%d%d",&x,&y,&z,&k);
  REP(i,x)scanf("%lld",a+i);
  REP(i,y)scanf("%lld",b+i);
  REP(i,z)scanf("%lld",c+i);
  multiset<ll> Q;
  Q.insert(0);
  int aaa[] = {x,y,z};
  ll *bbb[] = {a,b,c};
  REP(t,3){
    int n = aaa[t];
    ll *ar = bbb[t];
    multiset<ll> R;
    while(Q.size()){
      ll v = *Q.begin(); Q.erase(Q.begin());
      REP(i,n){
        R.insert(v+ar[i]);
      }
      while(R.size() > k){
        R.erase(R.begin());
      }
    }
    Q = R;
  }
  auto it = Q.rbegin();
  while(it != Q.rend()){
    printf("%lld\n", *it); it++;
  }
  return 0;
}


Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = new long[87];
            list[0] = 2;
            list[1] = 1;
            for (var i = 2; i < n + 1; i++)
            {
                list[i] = list[i - 1] + list[i - 2];
            }

            Console.WriteLine(list[n]);
        }
    }
}


Measured memory_bytes: 27280
#前計算
#素数のリスト作成
N = 10 ** 5 + 10
def primes(n):
    import math
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_lst = primes(N)
# print (prime_lst, len(prime_lst))
count_lst = [0] * (N + 1)

def check(n):
    if n%2 == 0:
        return False
    if not n  in prime_lst:
        return False
    if not ((n + 1)//2) in prime_lst:
        return False
    return True


for i in range(3, N + 1):
    if check(i):
        count_lst[i] = count_lst[i - 1] + 1
    else:
        count_lst[i] = count_lst[i - 1]

# print (count_lst)

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print (count_lst[r] - count_lst[l - 1])

Measured memory_bytes: 52184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

int main(){

  ll A,B,M;
  cin >> A >> B >> M;
  vector<ll> a(A),b(B);
  FOR(i,0,A)cin>>a[i];
  FOR(i,0,B)cin>>b[i];
  ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  FOR(i,0,M){
    ll x,y,c;
    cin >> x >> y >> c;
    ans = min(a[x-1]+b[y-1]-c,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

void solve() {
	ll n;
	cin >> n;
	ll s = (n * (n + 1)) / 2;
	s -= 5 * ((n / 5) * (n / 5 + 1)) / 2;
	s -= 3 * ((n / 3) * (n / 3 + 1)) / 2;
	s += 15 * ((n / 15) * (n / 15 + 1)) / 2;
	cout << s;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 


ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}


int main(void){

 string s;
 cin>>s;
 int len = s.size()-1;
 int ans = 0;
 int max;
 if(len%2==0) max = len/2;
 else max = len/2+1; 

 for(int i=0;i<max;i++){
   if(s[i] != s[len])ans++;
   len--;
 }
 cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a==b&&b==c) || (b==c&&c==d)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
n, x, y = list(map(int, input().split()))

l = [0] * n

for i in range(1, n):
  for j in range(i+1, n+1):
    c = min(j-i, abs(x-i)+1+abs(y-j))
    l[c] += 1
for k in l[1:]:
  print(k)

Measured memory_bytes: 3444
#include <stdio.h>

int main(){
    int day;

    scanf("%d",&day);

    switch(day){
        case 25:
            puts("Christmas");
            break;
        case 24:
            puts("Christmas Eve");
            break;
        case 23:
            puts("Christmas Eve Eve");
            break;
        case 22:
            puts("Christmas Eve Eve Eve");
            break;
    }
    return 0;
}

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

int main(){
    string s ; cin >> s;
    ll n = s.size();
    char tar = 'g';
    ll ret=0;
    rep(i,0,n){
        if(s[i]=='g' && tar=='p') ret++;
        else if(s[i]=='p' && tar=='g') ret--;

        if(tar == 'g') tar = 'p';
        else if(tar == 'p') tar = 'g';
    }
    cout << ret << endl;
}

Measured memory_bytes: 3712
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, k = MII()
    snk = [0]*n
    for i in range(k):
        d = II()
        aa = MIIZ()
        for a in aa:
            snk[a] = 1
    z = [1 for s in snk if s == 0]
    print(sum(z))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9504
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main() {
	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}



	return 0;
}

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

#define MAX 100
#define INF 10000007

#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)

int main() {
  int n, k, c[MAX], pr, c1, c2, mi, ma;
  while(cin >> n >> k && n && k) {
    for(int i=0; i<n; ++i) cin >> c[i];
    pr = 1; c1 = 0; c2 = 0;
    for(int i=0; i<k-1; ++i) pr *= c[i];
    for(int i=0; i<n-k+1; ++i) {
      pr *= c[i+k-1];
      c1 = max(c1, pr);
      mi = INF; ma = 0;
      for(int j=0; j<n; ++j) {
        if(i<=j && j<i+k) mi = min(mi, c[j]);
        else ma = max(ma, c[j]);
      }
      c2 = max(c2, pr*ma/mi);
      pr /= c[i];
    }
    if(c2<c1) {
      cout << (k>1 ? "0" : "NO GAME") << endl;
    }else cout << c2 - c1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    int n=sz(s); string res;

    rep(i,n){
        if(s[i]=='0' || s[i]=='1') res.pb(s[i]);
        else if(res.size()!=0) res.erase(res.size()-1,1);
    }   
    cout<<res<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int main() {


    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            graph[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j){
                printf(" ");
            }
            printf("%d",graph[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

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

  int r = 0;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'R') {
      r++;
    } else {
      ans = max(r, ans);
      r = 0;
    }
  }
  ans = max(r, ans);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3224
//
//  main.c
//  Hellow World
//
//  Created by 郷田将 on 2018/02/06.
//  Copyright © 2018年 郷田将. All rights reserved.
//


#include <stdio.h>
#include <stdlib.h>

void watch(int second)
{
    int hour;
    int min;
    int sec;
    
    char time[50];
    
    hour    = (int)(second / 3600);
    min     = (int)(second / 60 - hour * 60);
    sec     = (int)(second % 60);
    
    sprintf(time,"%d:%d:%d",hour,min,sec);
    printf("%s\n",time);

    return;
}

int main()
{

    int second;
    
    scanf("%d",&second);
    watch(second);
    
    return 0;
}



Measured memory_bytes: 2728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result[2]={0},x;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&n,&m,&x);
  rep(i,m){
    scanf("%d",&a[i]);
    if(x < a[i]) result[0]+=1;
    else if(x > a[i]) result[1]+=1;
  }
  printf("%lld", min(result[0],result[1]));
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int h,w;
    cin>>h>>w;
    char s[h+1][w+1];
    rep(i,h){
        rep(j,w){
            cin>>s[i+1][j+1];
        }
    }
    vector<vector<int>> dp(h+1,vector<int>(w+1,100000));
    if (s[1][1]=='#'){
        dp[1][1]=1;
    }
    else{
        dp[1][1]=0;
    }
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            if (i==1 && j==1){
                continue;
            }
            if (s[i][j]!='#'){
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            }
            else{
                int b1=0,b2=0;
                if (s[i-1][j]!='#'){
                    b1=1;
                }
                if (s[i][j-1]!='#'){
                    b2=1;
                }
                dp[i][j]=min(dp[i-1][j]+b1,dp[i][j-1]+b2);
            }
        }
    }
    cout<<dp[h][w]<<endl;


    return 0;
}

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

char s[100010];
int n;


int d[100010];

string p[] = {
  "dream", "dreamer", "erase", "eraser"
};

int f(int x) {
  if (x == n) return 1;
  int &r = d[x];
  if (r >= 0) return r;
  REP(i, 4) {
    if (strncmp(s + x, p[i].c_str(), p[i].size()) == 0 && f(x + p[i].size()))
      return r = 1;
  }
  return r = 0;
}

int main() {
  scanf("%s", &s);
  n = strlen(s);
  memset(d, -1, sizeof d);
  puts(f(0) ? "YES" : "NO");
  return 0;
}



Measured memory_bytes: 1792
# Complete Binary Tree
N = int(input())
heap = list(map(int, input().split()))

for i, a in enumerate(heap, start=1):
    print(f'node {i}: key = {a}, ', end='')
    if (i // 2 != 0): # 親がいる場合のみ出力
        print(f'parent key = {heap[i//2-1]}, ', end='')
    if 2 * i <= N: # 左子が存在する場合のみ出力
        print(f'left key = {heap[2*i - 1]}, ', end='')
    if 2 * i + 1 <= N: # 右子が存在する場合のみ出力
        print(f'right key = {heap[2*i]}, ', end='')
    print()


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

int main()
{
  int x,a,b;
  cin >> x >> a >> b;
  int r = b - a;
  if(r <= 0) cout << "delicious" << endl;
  else if(r <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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

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

    cout<<360/__gcd(x,360)<<endl;
}


Measured memory_bytes: 3552
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[100100];
ll d[100100];

int main() {
	clr(dp,0);
	dp[0] = 1;
	clr(d,0);
	ll n,m;
	cin>>n>>m;
	rep(i,0,m){
		ll a;
		cin>>a;
		d[a]=1;
	}
	rep(i,0,n+10){
		if(d[i+1]==0&&d[i+2]==0){
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
		}
		else if(d[i+1]==0){
			dp[i+1] += dp[i];
		}
		else if(d[i+2]==0){
			dp[i+2] += dp[i];
		}
		dp[i+1] %= MOD;
		dp[i+2] %= MOD;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
count = 0

def merge(A, left, mid, right):
    global count
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxint)
    R.append(sys.maxint)
    i = 0
    j = 0
    for k in xrange(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(raw_input())
S = map(int, raw_input().split())
mergeSort(S, 0, n)
print ' '.join(map(str, S))
print count

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 998244353
#define Mod2 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)

bool compare (const pair<int,int> &a, const pair<int, int> &b) {
	
	return (a.second < b.second) || (a.second == b.second && a.first > b.first);
}

void solve() {

	int n;
	cin >> n;
	string str;
	vector< pair < int, int > > open, close;
	
	rep (i, n) {
		
		cin >> str;
		int left = 0, right = 0;
		
		rep(j, str.size()) {
			if (str[j] == '(') {
				right++;
			}
			else {
				if (right == 0)
					left++;
				else
					right--;
			}
		
		}
		
		if (right > left)
			open.pb({right, left});
		else
			close.pb({left, right});
	}
		
	sort(all(open), compare);
	sort(all(close), compare);
	int o = 0, c = 0;
	rep(i, open.size()) {
		
		o -= open[i].ss;
		if (o < 0) {
			cout << "No";
			return;
		}
		o += open[i].ff;
	}
	
	rep(i, close.size()) {
		
		c -= close[i].ss;
		if (c < 0) {
			cout << "No";
			return;
		}
		c += close[i].ff;
	}
	
	if (o == c)
		cout << "Yes";
	else
		cout << "No";
}

int main()
{
    fastio;
//    T
    solve();
	//code
	return 0;
}


Measured memory_bytes: 11200
<?php
  fscanf(STDIN,'%d%d%d',$A,$B,$C);
  if($B>=$C){
   echo 'delicious'; 
  }elseif($A>=($C-$B)){
   echo 'safe'; 
  }else{
    echo 'dangerous';
  }
  
  
  
  
  ?>

Measured memory_bytes: 3576
MOD = 10 ** 9 + 7

S = input()

N = len(S)
dp = [[0] * 4 for _ in range(N + 1)]
dp[N][3] = 1

for i in reversed(range(N)):
    for j in reversed(range(4)):
        dp[i][j] = dp[i + 1][j] * (3 if S[i] == "?" else 1)
        if j < 3 and (S[i] == "?" or S[i] == "ABC"[j]):
            dp[i][j] += dp[i + 1][j + 1]
        dp[i][j] %= MOD

print(dp[0][0])


Measured memory_bytes: 27612
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
/* contest template */
int N, num1, num2,m;
string sex1, sex2, sex3;

int main()
{
    cin>>N;
    cout<<0<<endl;
    cin>>sex1;
    if(sex1=="Vacant") return 0;
    sex2=sex1;
    num1=0;
    num2=N;
    while(true){
        m=(num2+num1)/2;
        cout<<m<<endl;
        cin>>sex3;
        if(sex3=="Vacant") break;
        if((sex1==sex3 && (m-num1+1)%2==0) || (sex1!=sex3 && (m-num1+1)%2!=0)){
            num2=m;
            sex2=sex3;
        }else{
            num1=m;
            sex1=sex3;
        }
    }
    return 0;
}

Measured memory_bytes: 852