akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

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

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define l first
#define r second
#define INF (1e9)
using namespace std;
typedef pair <int,int> P;
int ans=1,m,n,used[101],memo[101][101];
P cmd[101][101];

int check(int a,int b){
  if(memo[a][b]!=-1) return memo[a][b];
  for(int i=0;i<n;i++)
    if(cmd[a][i].l>cmd[b][i].r) return memo[a][b]=0;
  return memo[a][b]=1;
}

int solve(){
  memset(memo,-1,sizeof(memo));
  int flg=1,cnt=0;
  while(flg--)
    for(int i=0,j;i<m&&!flg;i++){
      for(j=0;j<m&&!used[i];j++)if(!used[j]&&!check(i,j))break;
      if(j==m) flg=used[i]=1,cnt++;
    }
  return cnt/m;
}

int main(){
  for(int i=0;i<101;i++)
    for(int j=0;j<101;j++)cmd[i][j]=P(-INF,INF);

  cin>>m>>n;
  for(int i=0,k;i<m;i++){
    cin>>k;
    while(k--){
      string cond;
      int s,t;
      cin>>s>>cond>>t;
      s--;
      if(cond=="<=")cmd[i][s].r=min(cmd[i][s].r,t);
      if(cond==">=")cmd[i][s].l=max(cmd[i][s].l,t);
      if(cmd[i][s].l>cmd[i][s].r)ans=0;
    }
  }

  cout << (ans*solve()? "Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 1336
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<ll> X(n), Y(n);
    rep(i, n) cin >> X[i] >> Y[i];

    map<pll, int> mp;
    rep(i, n){
        rep(j, n){
            if(i==j)continue;
               mp[{X[j]-X[i], Y[j]-Y[i]}]++;
        }
    }
    int mx = 0;
    for(auto m: mp){
        //cout << m.first.first << " " << m.first.second << " " << m.second << ln;
        chmax(mx, m.second);
    }
    cout << n - min(mx, n-1) << ln;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);

int main(){
    unordered_map<ll,ll> map;
    unordered_set<ll> set;
    ll n;
    cin>>n;
    vector<ll> vec(n);
    rep(i,n){
        cin>>vec[i];
        if(set.count(vec[i])){
            map[vec[i]]++;
        }else{
            set.insert(vec[i]);
            map[vec[i]]=1;
        }
    }
    ll ans=0;
    for(auto it=set.begin();it!=set.end();it++){
        ans+=(ll)(map[*it]*(map[*it]-1))/2;
    }
    rep(i,n){
        cout<<ans-map[vec[i]]+1<<endl;
    }
}

Measured memory_bytes: 16016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    
    int p = n;
    ll ans = 0;
    auto x = [&](int i){ return max(0, i-p); };
    Rof(i, n){
        if(x(i) > a[i]) Return(-1);
        if(x(i) < a[i]){
            ans += a[i];
            p = i - a[i];
            if(p < 0) Return(-1);
        }
    }
    Cout(ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string x,a;
    int i,j,c=0;
    cin>>x>>a;
    for(i=0;i<a.length();i++)
    {
      if(x[i]!=a[i])
        c++;
    }
    cout<<c<<endl;
}

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

int solve(int n, int k, vector<int>h){
  vector<int>dp(n, INF);
  dp[0] = 0;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<=i+k; j++){
      if (j<n){
        dp[j] = min(
          dp[j],
          dp[i] + abs( h[i] - h[j] )
        );
      }
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  cout << solve(n,k,h);
}

Measured memory_bytes: 4536
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];
        arr[0] = sc.nextInt();
        arr[1] = sc.nextInt();
        arr[2] = sc.nextInt();

        Arrays.sort(arr);

        System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
    }
}


Measured memory_bytes: 26104
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;
long long m,a,b,n,res,k,g;
long long gru[100000];
long long sma,lar;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>k;
	for(int i=0;i<k;i++){
		cin>>gru[i];
	}
	sma=lar=2;
	for(int i=k-1;i>=0;i--){
		g=gru[i];
		if(sma%g!=0)
			sma=sma-sma%g+g;
		lar-=lar%g;
		lar=lar+g-1;
	}
	if(sma<=lar)
	cout<<sma<<" "<<lar<<endl;
	else
	cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

graph = [[] for _ in range(N * N)]
ins = [0] * (N * N)

for i, nodes in enumerate(X):
    for j1, j2 in zip(nodes[:-1], nodes[1:]):
        n1 = max(i, j1 - 1) * N + min(i, j1 - 1)
        n2 = max(i, j2 - 1) * N + min(i, j2 - 1)
        graph[n1].append(n2)
        ins[n2] += 1

dist = [0] * (N * N)
visited = [False] * (N * N)
q = deque()
for i in range(N):
    visited[N * i + i] = True

for i, v in enumerate(ins):
    if v == 0:
        q.append((i, 1))

while q:
    u, d = q.popleft()
    visited[u] = True
    dist[u] = d

    for v in graph[u]:
        if visited[v]:
            continue
            
        ins[v] -= 1
        if ins[v] == 0:
            q.append((v, d + 1))
            
print(max(dist) if all(visited) else -1)



Measured memory_bytes: 197748
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 

int main(){
    long long N; 
    cin >> N;
    long long n = N-1;

    cout << (n * (n+1)) / 2  <<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e5+5;
ll m=1e9+7,f[N],inv[N];

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

ll ncr(ll n,ll r)
{
	if(r<0||r>n)return 0;
	ll ans=(f[n]*inv[r])%m;
	ans=(ans*inv[n-r])%m;
	return ans;
}

int main()
{ios_base::sync_with_stdio(false);
f[0]=1;
rep(i,1,N-1)f[i]=(f[i-1]*1ll*i)%m;
inv[N-1]=p(f[N-1],m-2);
ren(i,N-2,0)inv[i]=(inv[i+1]*1ll*(i+1))%m;

ll n,k;
cin>>n>>k;

ll ans=0,sum=0;
rep(i,0,k-1)
{
	ans-=i;
	ans%=m;
}
ren(i,n,n-k+1)
{
	ans+=i;
	ans%=m;
}
ans++;
sum=ans;
//ol(sum);on;
rep(i,k+1,n+1)
{
	sum+=(n-2*i+2);
	//o2(i,sum);on;
	sum%=m;
	ans=(ans+sum)%m;
}
ol((ans+m)%m);
return 0;
}



Measured memory_bytes: 8340
sx, sy, tx, ty = map(int, input().split())
x = tx- sx 
y = ty - sy
ans = 'R'*x+'U'*y+'L'*x+'D'*y+'L'+'U'*(y+1)+'R'*(x+1)+'D'+'R'+'D'*(y+1)+'L'*(x+1)+'U'
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    vector<ll> v(5);
    rep(i, 0, 5) cin >> v[i];
    ll idx = -1, cnt = 10;
    rep(i, 0, 5) {
        ll tmp = v[i] % 10;
        if (tmp == 0) continue;
        if (cnt > tmp) idx = i, cnt = tmp;
    }
    ll ans = 0;
    rep(i, 0, 5) {
        if (i == idx) ans += v[i];
        else if (v[i] % 10 == 0) ans += v[i];
        else ans += (v[i]/10 + 1) * 10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
int n,a,b,i,s=0;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a>>b;
        s+=b-a+1;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int r, d, x;
  cin >> r >> d >> x;
  REP(i,10){
    x = r*x - d;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    string S;
    cin >> S;
 
    int Q;
    cin >> Q;
 
    int rev = 0;
    string head = "";
    string tail = "";

    for(int i=0; i<Q; i++)
    {
        int t,f;
        string c;
        cin >> t;
      	if (t==1)
        {
            //reverse(S.begin(), S.end());
            rev = 1 - rev;
        }
        if (t==2)
        {
            cin >> f >> c;
            if (f==1)
            {
                if (rev==0)
                    //S = c+S;
                    head = c+head;
                else
                    //S = S+c;
                    tail = tail+c;
            }
            else
            {
                if (rev==0)
                    //S = S+c;
                    tail = tail+c;
                else
                    //S = c+S;
                    head = c+head;
            }
        }        
    }

    S=head+S+tail;
    if (rev==1)
        reverse(S.begin(), S.end());
    cout << S << endl;
 
    return 0;
}


Measured memory_bytes: 1512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D;
  
  E=A+B;
  F=C+D;
  
  if (E>F){
    cout<<"Left"<<endl;
  }
  
  else if (E<F){
    cout<<"Right"<<endl;
  }
  
  else{
    cout<<"Balanced"<<endl;
  }  
}


Measured memory_bytes: 256
S = input()
 
if int(S[:2]) > 12 or int(S[:2]) == 0:
  if int(S[2:]) > 12 or int(S[2:]) == 0: print('NA')
  else: print('YYMM')
else:
  if int(S[2:]) > 12 or int(S[2:]) == 0: print('MMYY')
  else: print('AMBIGUOUS')

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);
const int MAX_K = 105;
const int SQ = 112345;
ll dp[MAX_K][SQ];
ll ac[MAX_K][SQ];

int main2() {
  CLR(dp, 0);
  CLR(ac, 0);
  int N = nextInt();
  int K = nextInt();

  vector<int> v;
  v.push_back(0);
  for (int i = 1; i <= N; i++) {
    v.push_back(i);
    if (i < N/i) {
      v.push_back(N/i);
    } else break;
  }
  sort(ALL(v));

  const int M = v.size() - 1;
  for (int j = 1; j <= M; j++) {
    dp[1][j] = v[j]-v[j-1];
    ac[1][j] = (ac[1][j-1] + dp[1][j]) % MOD;
  }

  for (int i = 2; i <= K; i++) {
    for (int j = 1; j <= M; j++) {
      int op = lower_bound(ALL(v), N/v[j]) - v.begin();
      dp[i][j] = (v[j]-v[j-1]) * ac[i-1][op] % MOD;
      ac[i][j] = (ac[i][j-1] + dp[i][j]) % MOD;
    }
  }
  ll ans = ac[K][M];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 184960
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){
  int n, k;
  std::cin >> n >> k;

  std::vector<int> H(n);
  for(int i=0; i<n; i++){
    std::cin >> H[i];
  }

  std::sort(H.begin(), H.end(), std::greater<int>());

  for(int i=0; i<std::min(k, n); i++){
    H[i]=0;
  }

  auto sum = std::accumulate(H.begin(), H.end(), 0LL);

  std::cout << sum << std::endl;

  

  return 0;
}


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

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

  vector<int> d(n);
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    s.insert(d[i]);
  }

  cout << s.size() << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
mod = 10**9+7
g = [[] for _ in range(n)]
for i in range(n-1):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)

dp = [[1, 1] for _ in range(n)]
# dp[v][0]: white
# dp[v][1]: black

s = []
order = []
par = [-1]*n
s.append(0)
while s:
    v = s.pop()
    order.append(v)
    flag = True
    for u in g[v]:
        if u == par[v]:
            continue
        flag = False
        par[u] = v
        s.append(u)

order.reverse()
for v in order:
    if par[v] == -1:
        continue
    dp[par[v]][0] *= (dp[v][0]+dp[v][1])%mod
    dp[par[v]][1] *= dp[v][0]%mod
ans = dp[0][0]+dp[0][1]
#print(dp)
print(ans%mod)

Measured memory_bytes: 39364
# 頂点と辺の数を入力する
N, M = map(int, input().split())
# 隣接リストを作成する
list_adjlist = [[] for _ in range(N + 1)]
# 辺のリストを作成する
list_edge = []
# 辺を入力し、隣接リストおよび辺のリストに格納する
for _ in range(M):
    a, b = map(int, input().split())
    list_edge.append((a, b))
    list_adjlist[a].append(b)
    list_adjlist[b].append(a)
    
# 橋の数bridgeを設定する
bridge = 0

# aとbを結ぶ辺について、その辺を通らずにaからbにたどり着けるかを調べる
for a, b in list_edge:
    # これから訪問する頂点のリストlist_nodeを初期化する
    list_node = list_adjlist[a].copy()
    list_node.remove(b)
    # これまでに訪問した頂点の集合set_visit_nodeを初期化する
    set_visit_node = {a}
    # 繰り返し
    while True:
        # 次に訪問可能な頂点の集合set_next_nodeを設定する
        set_next_node = set()
        # list_node内の頂点vに訪問する
        for v in list(list_node):
            # vと隣接している頂点をset_next_nodeに格納する
            set_next_node |= set(list_adjlist[v])
        # set_visit_nodeを更新する
        set_visit_node |= set(list_node)
        # set_next_nodeの全要素がset_visit_nodeに含まれる場合、、
        if set_next_node.issubset(set_visit_node):
            break
        # set_next_nodeの要素にset_visit_nodeに含まれない要素が存在する場合、、
        else:
            # list_nodeを更新する
            list_node = list(set_next_node - set_visit_node)
    # set_visit_nodeにbが含まれない場合（＝aからbにたどり着けない場合）
    if b not in set_visit_node:
        bridge += 1

# 結果を出力する
print(bridge)

Measured memory_bytes: 3192
//#define _XCODE_DEBUG

#include <iostream>
#include <vector>
#include <algorithm>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

using ll = long long;

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    
    // input data
    int N;
    std::cin >> N;
    ll X, L;
    std::vector<std::pair<ll, ll>> pair_vec;
    for (int i=0; i<N; ++i) {
        std::cin >> X >> L;
        pair_vec.push_back(std::make_pair(X-L,X+L));
    }
    // sort vector
    std::sort(pair_vec.begin(), pair_vec.end(), [](auto &left, auto &right){
        return left.second < right.second;
    });
    
    int ans = 1;
    ll bp = pair_vec[0].second;
    for (int i=1; i<N; ++i) {
        if (bp <= pair_vec[i].first){
            ++ans;
            bp = pair_vec[i].second;
        }
    }
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,d;
  cin>>n>>d;
  int ans;
  if((n%(2*d + 1))==0)
    ans=0;
  else 
    ans=1;
  ans+=(n/(2*d+1));
 cout<<ans<<endl;




}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
  
typedef struct dice{
    int face[6];
}dice;
  
void rotate(dice *d, char dir)
{
    int temp;
    switch(dir) {
    case 'N':
        temp=d->face[0];
        d->face[0]=d->face[1];
        d->face[1]=d->face[5];
        d->face[5]=d->face[4];
        d->face[4]=temp;
        break;
    case 'E':
        temp=d->face[0];
        d->face[0]=d->face[3];
        d->face[3]=d->face[5];
        d->face[5]=d->face[2];
        d->face[2]=temp;
        break;
    case 'W':
        temp=d->face[0];
        d->face[0]=d->face[2];
        d->face[2]=d->face[5];
        d->face[5]=d->face[3];
        d->face[3]=temp;
        break;
    case 'S':
        temp=d->face[0];
        d->face[0]=d->face[4];
        d->face[4]=d->face[5];
        d->face[5]=d->face[1];
        d->face[1]=temp;
        break;
    }
}
  
int isSame(dice d1, dice d2)
{
    static const char dir[]="NNNESSSWNNNESSSWNNNESSSW";
    int i, j;
    for(i=0; i<24; i++) {
        for(j=0; j<6 && d1.face[j]==d2.face[j]; j++);
        if(j==6) return 1;
        rotate(&d2, dir[i]);
    }
    return 0;
}
  
int main()
{
    dice d[100];
    int i, j, n;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        for(j=0; j<6; j++) {
            scanf("%d", &d[i].face[j]);
        }
        for(j=0; j<i; j++) {
            if(isSame(d[i], d[j])) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 584
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < 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 debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for(int i = a;i<=b;i++) {
        if(i%k==0) {
            print("OK");
            return 0;
        }
    }
    print("NG");
    return 0;
}


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

using namespace std;
int main() {
  int K,S;
  cin>>K>>S;
  int sum=0;
  for(int i=0;i<=K;++i){
      for(int j=0;j<=K;++j){
          if(0<=(S-i-j)&&(S-i-j)<=K){
              sum++;
          }
      }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a, const void *b) { return *(int*)a - *(int*)b; }
void Initialization(int[]);
long long Sum(int[], int);
int main() {
	int t[10000], n, i;
	long long tsum;
	while (~scanf("%d", &n)&&n!=0) {
		Initialization(t);
		i = tsum = 0;
		while (i<n) scanf("%d", &t[i++]);
		qsort(t,n, sizeof(int), comp);
		for (i = 1; i<n; ++i)	tsum+=Sum(t,i-1);
		printf("%lld\n", tsum);
	}
	return 0;
}

void Initialization(int t[]){
	int i;
	for (i = 0; i < 10000; i++)t[i] = 0;
}

long long Sum(int t[], int n){
	long long sum = 0, i;
	for (i = 0; i <= n; i++)sum += t[i];
	return sum;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> hvec(h);
    vector<bool> hbool(h,false);
    vector<bool> wbool(w,false);
    for(int i=0;i<h;i++){
        cin >> hvec[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(hvec[i][j] == '#'){
               hbool[i] = true;
               wbool[j] = true;
            }
                
            }
        }
     for(int i=0;i<h;i++){
         if(hbool[i] == true){
        for(int j=0;j<w;j++){
            if(wbool[j] == true){
                cout << hvec[i][j];
            }
            
            
        }
        cout << endl;
     }
     }
    
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        
	        
	        long ans=0;
	        for(int i=0;i<=N;i++) {
	        	if(i%3!=0&&i%5!=0) {
	        		ans=ans+i;
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
}


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

int main() {
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W>=x+r && H>=y+r && x>=r && y>=r){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main()
{
    int i,len,coun=0,n,N;
    string S;
    cin>>N>>S;
    n=S.find("ABC");
    for(;n!=-1;n=S.find("ABC")){
        coun+=1;
        S[n]='v';
    }
    cout<<coun;
}

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

bool palindrom(int x)
{
	string s = "";
	while( x > 0 )
	{
		s = (char)(x%10+'0') + s;
		x /= 10;
	}
	for(int i = 0; i < s.size()/2; i++)
		if( s[i] != s[s.size()-1-i] )
			return false;
	return true;
}

int main()
{
	int a, b;
	int sum = 0;
	cin >> a >> b;
	for(int i = a; i <= b; i++)
		if( palindrom(i) )
			sum++;
	cout << sum;
}

Measured memory_bytes: 3636
inp = input().split(" ")
A, B = (int(inp[0]), int(inp[1]))
kouhoB = []
if A % 2 == 1:
    kouhoA = list(range(int(A * 12.5 + 1), int((A + 1) * 12.5)))
else:
    kouhoA = (list(range(int(A * 12.5), int((A + 1) * 12.5 + 1))))
num = B*10
while num <= B*10+9:
    kouhoB.append(num)
    num += 1
dottimo = list(set(kouhoA) & set(kouhoB))
if len(dottimo) >= 1:
    print(min(list(set(kouhoA) & set(kouhoB))))
else:
    print(-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    long long n , m;
    cin >> n >> m;
    priority_queue<long long>pq;
    vector<long long>a(n);
    for(long long i = 0; i < n; ++i){
        cin >> a[i];
        pq.push(a[i]);
    }

    for(long long i = 0; i < m; ++i){
        long long p = pq.top();pq.pop();
        p /= 2;
        pq.push(p);
    }
    long long total = 0;
    while(!pq.empty()){
        total += pq.top();pq.pop();
    }
    cout << total << "\n";


return 0;}


Measured memory_bytes: 2168
G = [[] for i in range(4)]
for i in range(3):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)
GL = [len(x) for x in G]
GL.sort()
if GL[0] == 1 and GL[1] == 1 and GL[2] == 2 and GL[3] == 2:
    print('YES')
else:
    print('NO')

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

int prime[1000000];

int main()
{
  int n;
  for (int i = 0; i < 1e6; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 2; i < 1000000; i++){
    if (prime[i] == 1){
      for (int j = 2 * i; j < 1000000; j += i){
        prime[j] = 0;
      }
    }
  }
  for (int i = 0; i < 1000000; i++){
    prime[i + 1] += prime[i];
  }
  while (cin >> n){
    cout << prime[n] << endl;
  }

  return 0;
}

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

using namespace std;


int main()
{
  int N;
  cin >> N;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    ret += b - a + 1;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stdio.h>

void selectionSort(int A[], int N)
{
  int swapCount = 0;
  for (int i = 0; i <= N - 1; i++)
  {
    int mini = i;
    for (int j = i; j <= N - 1; j++)
    {
      if (A[j] < A[mini])
      {
        mini = j;
      }
    }
    std::swap(A[i], A[mini]);
    if (i != mini)
      swapCount++;
  }

  for (int k = 0; k < N; k++)
  {
    std::cout << A[k];
    if (k != N - 1)
    {
      std::cout << " ";
    }
  }
  std::cout << std::endl;
  std::cout << swapCount << std::endl;
}

int main(int argc, char *argv[])
{
  int N, i, j;
  int A[100];

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

  selectionSort(A, N);

  return 0;
}



Measured memory_bytes: 3232
#include <stdio.h>
#define MAX 100000
int parent(int i);
int left(int i);
int right(int i);

int main(void){
	int H,i,A[MAX+1];
	scanf("%d",&H);
	
	for(i=1;i<=H;i++){
		scanf("%d",&A[i]);
	}
	
	for(i=1;i<=H;i++){
		printf("node %d: key = %d, ",i,A[i]);
		if(parent(i)>=1){
			printf("parent key = %d, ",A[parent(i)]);
		}
		if(left(i)<=H){
			printf("left key = %d, ",A[left(i)]);
		}
		if(right(i)<=H){
			printf("right key = %d, ",A[right(i)]);
		}
		
		printf("\n");
	}
	return 0;
}


int parent(int i){
	return i/2;
}

int left(int i){
	return i*2;
}
int right(int i){
	return i*2+1;
}


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

using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int ans=0;
	int a=0,b=0;
	while(a<s.size()){
		while(a<s.size()&&s[a]=='1')
			a++;
		ans=max(ans,a-b);
		while(a<s.size()&&s[a]=='0')
			a++;
		--k;
		if(k<0){
			while(b<s.size()&&s[b]=='1')
				b++;
			while(b<s.size()&&s[b]=='0')
				b++;
		}
		ans=max(ans,a-b);
	}
	cout<<ans;
	return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int s,w;
    cin >> s>> w;
    if(w>=s)cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3632
const int N = 4e5;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

void __fast_IO()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
}

//##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**
//##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**##**

ll n, m;
ll a[N], b[N];

signed main()
{
    __fast_IO();
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 1; i < n; i++) a[i] += a[i - 1];
    for (int i = n - 2; i >= 0; i--) b[i] += b[i + 1];
    for (int i = 0; i < n; i++) m = max(m, a[i] + b[i]);
    cout << m;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 2304
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, X, Y;
    intmax_t tmp, d[(int)2e3] = {};

    scanf("%jd%jd%jd", &N, &X, &Y);

    for (size_t i = 1; i <= N; i++) {
        for (size_t j = i + 1; j <= N; j++) {
            tmp = j - i;
            if ((i > X) && (j < Y)) {
                if (tmp > ((i - X) + 1 + (Y - j)))
                    tmp = (i - X) + 1 + (Y - j);
            } else if ((i <= X) && (j >= Y)) {
                if (tmp > ((X - i) + (j - Y) + 1))
                    tmp = (X - i) + (j - Y) + 1;
            } else if ((i > X) && (j >= Y)) {
                if (tmp > ((i - X) + 1 + (j - Y)))
                    tmp = (i - X) + 1 + (j - Y);
            } else {
                if (tmp > ((X - i) + 1 + (Y - j)))
                    tmp = (X - i) + 1 + (Y - j);
            }
            d[tmp]++;
        }
    }

    for (size_t i = 1; i < N; i++) {
        printf("%jd\n", d[i]);
    }

    return 0;
}


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

using namespace std;

const int MAX = 30;

int c[MAX][MAX];

int main() {
  int h, w;
  cin >> h >> w;
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < a; ++i)
    for (int j = 0; j < w; ++j)
      c[i][j] = 1;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < b; ++j)
      c[i][j] = 1;
  int ans = 0;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      ans += c[i][j] == 0;
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int A[100][100];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    int b[100];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }

    int c[100];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            c[i] += A[i][j]*b[j];
        }
    }

    for(int i = 0; i < n; i++){
        cout << c[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int N , X;
    cin >> N >> X;
    vector <int> m(N);
    for(int i = 0; i < N; i++){
        cin >> m.at(i);
    }
    sort(m.begin(), m.end());
    int use = 0;
    for(int i = 0; i < N; i++){
        use+=m.at(i);
    }
    int left = X - use;
    cout << N + left / m.at(0) << endl;
}


Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Date: Jul 16th, 2018
 * Prob: ARC080 F
 * Email: hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define x first
#define y second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
	static int _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 105, maxm = 1e7 + 9, M = 1e7 + 5, maxe = maxn * maxn;

int n, mk[maxm], vis[maxn], beg[maxn], v[maxe], nex[maxe], pr[maxm], np[maxm], prs, tot1, tot2, S[maxn << 1], T[maxn << 1], e, cnt, mat[maxn];

inline void init(int N)
{
	np[1] = 1;
	For(i, 2, N) {
		if (!np[i]) pr[++ prs] = i;
		for (register int j = 1; j <= prs && pr[j] * i <= N; ++ j) {
			np[pr[j] * i] = 1;
			if (!(i % pr[j])) break;
		}
	}
}

inline void add(int uu, int vv) { v[++ e] = vv, nex[e] = beg[uu], beg[uu] = e; }

int dfs(int u) {
	for (register int i = beg[u]; i; i = nex[i])
		if (!vis[v[i]]) {
			vis[v[i]] = 1;
			if (!mat[v[i]] || dfs(mat[v[i]])) { mat[v[i]] = u; return 1; }
		}
	return 0;
}

int main()
{
#ifdef hany01
	File("arc080f");
#endif

	n = read(), init(M);
	For(i, 1, n) mk[read()] = 1;
	For(i, 1, M) if (mk[i] != mk[i - 1])
		(i & 1) ? (S[++ tot1] = i) : (T[++ tot2] = i);

	For(i, 1, tot1) For(j, 1, tot2)
		if (!np[abs(S[i] - T[j])]) add(i, j);

	For(i, 1, tot1) {
		Set(vis, 0);
		if (dfs(i)) ++ cnt;
	}
	printf("%d\n", cnt + ((tot1 - cnt) >> 1) * 2 + ((tot2 - cnt) >> 1) * 2 + (((tot1 - cnt) & 1)) * 3);

    return 0;
}

Measured memory_bytes: 82176
from sys import stdin
N = (stdin.readline().rstrip())
ans = 0
if len(N) == 1:
    print(N)

elif set(N) == {"9"}:
    ans = len(N) * 9
    print(ans)
    
elif set(N[1:]) == {"9"}:
    ans = (len(N)-1) * 9 + int(N[0])
    print(ans)

else:
    ans += (int(N[0]))
    ans += ((len(N)-1)*9)
    ans -= 1
    print(ans)

Measured memory_bytes: 3064
#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>;

ll dp[100100];
const int mod = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (dp[i] == -1)
            continue;
        if (dp[i - 1] != -1)
        {
            dp[i] += dp[i - 1];
        }
        if (i > 1 && dp[i - 2] != -1)
        {
            dp[i] += dp[i - 2];
        }
        dp[i] %= mod;
    }
    // rep(i, n + 1) cout << i << " : " << dp[i] % mod << endl;
    cout << dp[n] << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	char  s[5]; cin >> s;

	if (s[0] != s[1] || s[1] != s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  vector<ll> a(n); REP(i,n) cin >> a[i];
  ll mi = INF, ma = 0;
  REP(i,n) {
    chmin(mi, a[i]);
    chmax(ma, a[i]);
  }
  cout << ma - mi << endl;
  return 0;
}


Measured memory_bytes: 256
import fractions

N = int(input())
A = list(map(int, input().split(' ')))

lcm = 1
for a in A:
    lcm *= (a // fractions.gcd(lcm, a)) % (10**9 + 7)

for i in range(len(A)):
    A[i] = lcm // A[i]

print(sum(A) % (10**9 + 7))

Measured memory_bytes: 264120
#include <iostream>
#define N 1000000
using namespace std;
char grade_char(int);
int main()
{
  int m,f,r,j;
  char C[N];
  while(1)
    {
      cin >> m >> f >> r;
      if(m==-1&&f==-1&&r==-1) break;
      else if(m==-1||f==-1) C[j]=grade_char(0);
      else if((m+f>=30&&m+f<50)&&r>=50)  C[j]=grade_char(50);
      else if((m+f>=30&&m+f<50)&&r>=50)  C[j]=grade_char(49);
      else   C[j]=grade_char(m+f);
      j++;
    }
  for(int i=0;i<j;i++)
    {
      cout << C[i] << endl;
    }
  return 0;
}
char grade_char(int score)
{
  if(0<=score&&score<30) return 'F';
  else if(30<=score&&score<50) return 'D';
  else if(50<=score&&score<65) return 'C';
  else if(65<=score&&score<80) return 'B';
  else return 'A';
}

Measured memory_bytes: 3100
#include <string.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define INT_MIN_A -999999

using namespace std;

int main (void){
    
    char str[2001];
    gets(str);
    char tango[1000][33];
    int i = 0,j = 0,k = 0,l = 0, temp = 0,m = 0;
    int max_l = INT_MIN_A;
    int max_numer = 0;
    int yokuderu = 0;
    int yokuderu_temp = 0;
    int yokuderu_number = 0;
    while(str[i++] != '\0')
    {
        if(str[i-1] == ' ')
        {
            if((i-1)-temp>max_l)
            {
                max_l = (i-1) -temp;
                max_numer = j;
            }
            while(temp<i-1)
                tango[j][l++] = str[temp++];
            temp = i;
            j++;
            l = 0;
        }
    }
    
 
        if((i-1)-temp>max_l)
        {
            max_l = (i-1) -temp;
            max_numer = j;
        }
        while(temp<i-1)
            tango[j][l++] = str[temp++];
        temp = i;
        j++;
        l = 0;
    /*???????????§??????????????????*/
    //cout <<"number is " << j << endl;
    
    for(int m = 0; m < j;m++)
    {
        for(int k = 0; k<j;k++)
        {
            if(m != k)
            {
                if(strcmp(tango[m], tango[k]) == 0)
                {
                    yokuderu_temp++;
                }
            }
        }
        if(yokuderu_temp >= yokuderu)
        {
            yokuderu = yokuderu_temp;
            yokuderu_number = m;
        }
        yokuderu_temp = 0;
    }
    cout << tango[yokuderu_number] << " " << tango[max_numer] << endl;
    return 0;
}

Measured memory_bytes: 1132
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
ans = 0
for i in range(k):
    if t[i] == "r":
        ans += p
    elif t[i] == "s":
        ans += r
    else:
        ans += s
for i in range(k, n):
    if t[i] != t[i - k]:
        if t[i] == "r":
            ans += p
        elif t[i] == "s":
            ans += r
        else:
            ans += s
    else:
        t[i] = ""

print(ans)

Measured memory_bytes: 9964
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author i.mekni
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner read = new Scanner(System.in);

        PrintWriter write = new PrintWriter(System.out);

        String t = read.nextLine();
        if(t.charAt(2)==t.charAt(3) && t.charAt(4)==t.charAt(5)) write.println("Yes");
        else  write.println("No");
        write.close();
    }

}


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

int main() {
  int N;
  long long Ans=1,B=1000000000000000000;
  cin>>N;
  vector<long long> vec(N);
    rep(i,N){cin>>vec.at(i);
            if(vec.at(i)==0){Ans=0;break;}
            }
  
  rep(i,N){if(Ans==0){break;}
            if(B/Ans>=vec.at(i)){Ans*=vec.at(i);}
            else{Ans=-1;break;}}
  cout<<Ans<<endl;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define LL long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const int maxn=1<<17;
const int N=1e5+10,M=N<<2;
int n,m;
int main()
{
    cin>>n;
    cout<<(n/2+n%2);
    return 0;
}
/*
4 4
0000
0110
0110
0011
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		//static int[] parent;
		static void Main(string[] args)
		{
			int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = input[0];
			int K = input[1];
			input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			// 操作A,Bを合わせてi回すると、C,Dは最大K-i回できる
			int maxValue = 0;
			for(int i=0; i<=Math.Min(K,N); i++)
			{
				// 操作Aをj回した時、操作Bはi-j回
				for(int j=0; j<=i; j++)
				{
					//Console.WriteLine(i + " " + j + " " + (K-i));
					// 操作A,B後に持っている宝石の価値の合計は
					int value = 0;
					List<int> minusV = new List<int>(); // 価値がマイナスの宝石を貯める
					for(int a = 0; a<j; a++)
					{
						value += input[a];
						if(input[a] < 0)
							minusV.Add(input[a]);
					}
					for(int b=0; b<i-j; b++)
					{
						//Console.WriteLine("in b " + b + " " + (N-1-b));
						value += input[N-1-b];
						if(input[N-1-b]<0)
							minusV.Add(input[N-1-b]);
					}

					minusV.Sort();
					for(int c = 0; c<Math.Min(K-i,minusV.Count); c++)
					{
						//Console.WriteLine(c + " in c " + minusV.Count + " " + minusV[c]);
						value -= minusV[c];
					}

//Console.WriteLine("Aを " + j + " 回 Bを" + (i-j) + "回行った時 " + value + " minusV.count " + minusV.Count);
					if(maxValue < value)
						maxValue = value;
					// 操作A,Bをi回した後C,Dを行う
				}
			}
			Console.WriteLine(maxValue + "") ;
		}
	}
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  
  // ここにプログラムを追記
}

Measured memory_bytes: 256