akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())

S = []
for _ in range(H):
    tmp = list(input())
    S.append(tmp)

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            # 上
            if h > 0 and S[h-1][w] == '#':
                continue
            # 下
            elif h < H-1 and S[h+1][w] == '#':
                continue
            # 左
            elif w > 0 and S[h][w-1] == '#':
                continue
            # 右
            elif w < W-1 and S[h][w+1] == '#':
                continue
            print('No')
            exit(0)

print('Yes')



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  static int k, s;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    k = sc.nextInt();
    s = sc.nextInt();

    long count = 0;
    for(int x = 0; x <= k; x++){
      if(x > s){
        continue;
      }
      for(int y = 0; y <= k; y++){
        int z = s - (x + y);
        if(z >= 0 && z <= k){
          ++count;
        }
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21840
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
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;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

/*考えを書くスペース

*/
//main.cpp----------------------------
#define max_n 200000

void solve();

ll n, m;
ll k[31];
ll a[31][31];
ll c[31];

int main() {
  cin >> n >> m;
  rep(i, n) {
    cin >> k[i];
    rep(j, k[i]) {
      cin >> a[i][j];
      c[a[i][j]] += 1;
    }
  }

  solve();

  return 0;
}

void solve() {
  ll cnt = 0;
  rep(i, 31) {
    if(c[i]>=n) {
      cnt += 1;
    }
  }

  cout << cnt << endl;
}


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

typedef long long ll;

const int MAX_N=1010;
const int MAX_M=2020;
const ll INF=1000000000000000;

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

ll d[MAX_N];
int N,M;

edge es[MAX_M];

ll Bellman_Ford(int s){
    ll ans;
    for(int i=0;i<N;i++){
        d[i]=INF;
    }
    d[s]=0;
    for(int i=0;i<N-1;i++){
        for(int i=0;i<M;i++){
            edge e=es[i];
            if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
            }
        }
    }
    return ans=d[N-1];
}

bool negative[MAX_N];

bool find(){
    for(int i=0;i<N;i++) negative[i]=false;
    for(int i=0;i<N;i++){
        for(int i=0;i<M;i++){
            edge e=es[i];
            if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                negative[e.from]=true;
            }
            if(negative[e.from]==true){
                negative[e.to]=true;
            }
        }
    }
    return negative[N-1]==true;
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        c*=-1;
        es[i].from=a;
        es[i].to=b;
        es[i].cost=c;
    }
    ll ans=Bellman_Ford(0);
    if(find()){
        cout << "inf" << endl;
        return 0;
    }
    cout << -1*ans << endl;
}


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

int main() {
  int N;
  string S;
  cin >>N;
  
  int i=0;
  for(;i<N;i++){
  cin >> S;
    if(S=="Y"){
      cout << "Four"<< endl;
      break;
    }
  }
  if(i==N)
    cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

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

const int maxn = 200010;

int n, m;
int a[maxn];
vector<int> g[maxn];
int comp[maxn], cnt = 0;
int vis[maxn];

void dfs(int u) {
	vis[u] = 1;
	comp[u] = cnt;
	for(int v : g[u]) {
		if(!vis[v]) {
			dfs(v);
		}
	}
}


int32_t main () {
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin>>n>>m;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	for(int i=1; i<=m; i++) {
		int x, y; cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i=1; i<=n; i++) {
		if(!vis[i]) {
			cnt++;
			dfs(i);
		}
	}
	int c = 0;
	for(int i=1; i<=n; i++) {
		c += int(comp[i] == comp[a[i]]);
	} cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 11264
/**
 * Title: E - Knapsack 2
 * Url: https://atcoder.jp/contests/dp/tasks/dp_e
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define INF 1000000000

const int MAX_N = 100;
const int MAX_V = 1000;

int N, W;
ll dp[MAX_N+1][MAX_N*MAX_V+1];
ll w[MAX_N+1], v[MAX_N+1];

int main() {
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];
    fill(dp[0], dp[0]+MAX_N*MAX_V+1, INF);
    dp[0][0] = 0;
    if(N==1) {
        cout << v[0] << endl;
        return 0;
    }
    for(int i=0; i<N; i++) {
        for(int j=0; j<=MAX_N*MAX_V; j++) {
            if(j<v[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            }
        }
    }
    ll res = 0;
    for(int i=0; i<=MAX_N*MAX_V; i++) {
        if(dp[N][i]<=W) res = i;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<cmath> 
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<unordered_map>
#include<cstring>
#include<stack>
#include<queue>
#include<climits>

using namespace std;

#define ll long long

const int INF = 1e9+7;
const int mod = 1e9+7;
const int MAX = 1e5+5;




int main(){
	//freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;

    if(a+b+c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans;
  if(a<c){
    if(d<=b) ans=d-c;
    if(c<b&&d>b) ans=b-c;
    if(c>=b) ans=0;
  }
  else{
    if(b<=d) ans=b-a;
    if(a<d&&b>=d) ans=d-a;
    if(a>=d) ans=0;
  }
  cout<<ans<<endl;
}
    

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

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();
        int c = sc.NextInt();

        int[] b = sc.IntArray();

        int answer = 0;

        for (int i = 0; i < n; i++)
        {
            int sum = 0;
            for (int j = 0; j < m; j++)
            {
                sum += sc.NextInt() * b[j];
            }
            sum += c;
            if (sum > 0)
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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;
  cout << n*n*n << endl;

  return 0;
}

Measured memory_bytes: 256
def main(n):
	odd = "1"
	even= "0"
	if(n[0] =="0"):
		# zero mode
		odd = "0"
		even= "1"
	#return sum((((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n)))
	a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n),2))
	b = sum((((i % 2 == 0) and n[i] == even)) for i in range(0, len(n),2))
	return a+b

print(main(input()))
#assert(1 == main("000"))
#assert(3 == main("10010010"))
#assert(0 == main("0"))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N,A,B;cin>>N>>A>>B;
  int cnt=0;
  for(int i=1; i<=N;i++){
    int x= keta_wa(i);
    if(x>=A&&x<=B)cnt+=i;
  }
  cout<<cnt<<endl;
}







Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int x = sc.nextInt();
        
        while (n != 0 || x != 0) {
            int sum = 0;
            
            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            sum++;
                        }
                    }
                }
            }
            
            System.out.println(sum);
            
            n = sc.nextInt();
            x = sc.nextInt();
        }
    }
}

Measured memory_bytes: 26152
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;

int main()
{
 string a;
 cin >> a;
 
 a[3] = '8';
 
 cout << a;
 
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    // bitset<1000000000> s;
    unordered_set<int> s;

    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        // s.flip(a-1);
        if (s.count(a-1)) {
            s.erase(a-1);
        } else {
            s.insert(a-1);
        }
    }
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
 
ll mod = 1000000007;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
//ll x[500005],y[500005],z[500005];
ll vertex[500005],dist[500005],co[500005];
ll color_table[500005][12];
bool kakutei[500005];
bool dame;

void init(){

    return ;
}

void dfs(ll v,ll d,ll color,ll parent){
    if(d < 0)return;
    if(color_table[v][d] == 0){
        for(int k=d;k>=0;k--){
            if(color_table[v][k] == 0)color_table[v][k] = color;
        }
    }else{
        return;
    }
    for(int i=0;i<G[v].size();i++){
        ll nv = G[v][i];
        if(nv == parent)continue;
        dfs(nv,d-1,color,v);
    }
    return;
}

void paint(ll v,ll d,ll color){
    dfs(v,d,color,-1);
}

int main(){
    cin >> n >> m;
    init();
    for(i=0;i<m;i++){
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    cin >> k;
    for(i=0;i<k;i++){
        cin >> vertex[i] >> dist[i] >> co[i];
    }
    for(int i=k-1;i>=0;i--){
        paint(vertex[i],dist[i],co[i]);
    }
    for(i=1;i<=n;i++){
        p(color_table[i][0]);
    }

    
    return 0;
}












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

using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;

    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0)
            k--;
        if (!k)
            return cout << i << "\n", 0;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            AAirConditioner solver = new AAirConditioner();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class AAirConditioner {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            w.println(s.nextInt() >= 30 ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25680
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int64

let rec solver s m i =
    if i = N then s
    elif A.[i] < m then solver (s + m - A.[i]) m (i + 1)
    else solver s A.[i] (i + 1)

solver 0L A.[0] 1 |> stdout.WriteLine


Measured memory_bytes: 47248
N, W = map(int, input().split())

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

memo = {}
def dp(i, capacity):
    if i == N:
        return 0
    if (i, capacity) in memo:
        return memo[(i, capacity)]
    ret = dp(i+1, capacity)
    w, v = WVs[i]
    if w <= capacity:
        ret2 = dp(i+1, capacity - w) + v
        ret = ret if ret > ret2 else ret2
    memo[(i, capacity)] = ret
    return ret

print(dp(0, W))


Measured memory_bytes: 24712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		int a,b;
		Scanner sc = new Scanner(System.in);
		
		a=sc.nextInt();
		b=sc.nextInt();
		
		String s = ""+a+b;
		int i = Integer.parseInt(s);//parse:分析する string⇨intにする
		//System.out.println(i);
		if( Math.floor(Math.sqrt(i)) * Math.floor(Math.sqrt(i)) ==i ) 
		{
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(c > a + b) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3608
use std::cmp::min;
use std::io::{Read, StdinLock};
use std::str::{from_utf8, FromStr};
use std::vec::Vec;

struct StdinReader<'a> {
    reader: StdinLock<'a>,
}

impl<'a> StdinReader<'a> {
    pub fn new(reader: StdinLock<'a>) -> StdinReader {
        StdinReader { reader: reader }
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        fn is_whitespace(ch: u8) -> bool {
            ch == 0x20 || ch == 0x0a || ch == 0x0d
        }

        let token: Vec<u8> = self.reader
            .by_ref()
            .bytes()
            .map(|ch| ch.expect("failed to read a byte"))
            .skip_while(|ch| is_whitespace(*ch))
            .take_while(|ch| !is_whitespace(*ch))
            .collect();
        let token_str = from_utf8(&token)
            .unwrap_or_else(|_| panic!(format!("invalid utf8 sequence: {:?}", token)));
        token_str
            .parse()
            .unwrap_or_else(|_| panic!(format!("failed to parse input: {}", token_str)))
    }
}

static VALUES: [i32; 4] = [1, 5, 10, 50];

fn main() {
    let stdin = std::io::stdin();
    let mut reader = StdinReader::new(stdin.lock());

    let mut first_case = true;
    loop {
        // 入力
        let target = reader.read::<i32>() / 10;
        if target == 0 { break; }
        let coins: Vec<i32> = (0..4).map(|_| reader.read()).collect();

        // 財布の中の硬貨を全部使って払う
        let total = coins.iter().zip(VALUES.iter())
            .fold(0, |sum, (n, v)| sum + n * v);
        let mut answer = coins.clone();

        // 返ってくる硬貨を計算する
        let mut diff = total - target;
        let mut returned = vec![0; 4];
        for i in (0..4).rev() {
            returned[i] = diff / VALUES[i];
            diff -= returned[i] * VALUES[i];
        }

        // 支払った硬貨と返ってきた硬貨との間に重複があれば取り除く
        for i in 0..4 {
            answer[i] -= min(answer[i], returned[i]);
        }

        // 出力
        if first_case {
            first_case = false;
        } else {
            println!();
        }
        for i in 0..4 {
            if answer[i] > 0 {
                println!("{} {}", VALUES[i] * 10, answer[i]);
            }
        }
    }
}



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

int main(){
	int n, h;
	string str, str1, str2;
	while(1){
		cin >> str;
		if(str == "-")	break;
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> h;
			string str1 = str.substr(0,h);
			string str2 = str.substr(h,str.length()-1);
			str = str2 + str1;
		}
		cout << str << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1000000007;
int tree[444444],a[444444],f[444444],lst[444444],l[444444];
int lowbit(int x)
{
	return x&-x;
}
void upd(int x,int w)
{
	int i;
	for(i=x;i<=2e5;i+=lowbit(i))
		tree[i]+=w,tree[i]%=INF;
}
int query(int x)
{
	int i;
	int ans=0;
	for(i=x;i>0;i-=lowbit(i))
		ans+=tree[i],ans%=INF;
	return ans;
}
int main()
{
	int n,i,ans=0,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=a[cnt])
			a[++cnt]=a[i];
	}
	n=cnt;
	for(i=1;i<=n;i++)
		lst[i]=l[a[i]],l[a[i]]=i;
	f[0]=1;
	ans++;
	upd(1,f[0]);
	for(i=1;i<=n;i++)
	{
		if(lst[i])
		{
			f[i]=query(lst[i]+1);
//			printf("%d %d\n",i,f[i]);
			upd(i+1,f[i]);
			ans=(ans+f[i])%INF;
		}
	}
	printf("%d\n",ans);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  FOR(i,n){
    if(s[i]!=s[k-1]){
      s[i]='*';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
// Try NIKKEI Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let a = get!();
    let b = get!();
    
    let max = std::cmp::min(a, b);
    let min = std::cmp::max(0, (a + b) - n);
    
    println!("{} {}", max, min);
}

Measured memory_bytes: 4352
# main

while true
  i = gets.strip.to_i
  break if i == 0

  as = gets.strip.split(' ').map{|s| s.to_i}

  hn = 32
  j = 0

  while hn > 0
    # ichiro
    hn -= (hn - 1) % 5
    puts hn

    # jiro
    hn -= (hn < as[j]) ? hn : as[j]
    j = (j + 1) % i
    puts hn
  end
end

Measured memory_bytes: 6096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), t = in.nextInt();
        int[] a = new int[n], b = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int min = Integer.MAX_VALUE, max = 0;
        for(int i = 0; i < n; i++) {
            min = Math.min(min, a[i]);
            b[i] = a[i] - min;
            max = Math.max(max, b[i]);
        }
        final int ans = max;
        System.out.println(Arrays.stream(b).filter(num -> num == ans).count());

    }
}

Measured memory_bytes: 51856
class abc_166:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        ans= "ARC" if S=="ABC" else "ABC"
        print(ans)
    
    def B(self):
        NK=list(map(int,input().split()))
        d=[]
        A=[]
        
        for i in range(NK[1]):
            d=int(input())
            a = list(map(int,input().split()))
            A.extend(a)
        
        print(NK[0]-len(list(set(A))))  
            
    def C(self):
        NM=list(map(int,input().split()))
        H=list(map(int,input().split()))
        A=[list(map(int,input().split())) for i in range(NM[1])]
        memo=[0]*(NM[0])
        count=0
        
        #メモ配列初期化
        for i in range(len(memo)):memo[i]=H[i]
        #メモ化処理
        for i in A:
            if H[i[0]-1]>H[i[1]-1]:memo[i[1]-1]=H[i[0]-1]
            elif H[i[0]-1]<H[i[1]-1]:memo[i[0]-1]=H[i[1]-1]
            else:
                memo[i[0]-1]=0
                memo[i[1]-1]=0
                
        for i in range(NM[0]):
            if H[i]==memo[i]:count+=1
            else:pass
        print(count)
    
    
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_166()
    obj.C()

Measured memory_bytes: 93688
/*  Author: Simanta Deb Turja 
    Website: https://simantaturja.github.io
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    string s;
    cin >> n >> s;
    int r = 0, g = 0, b = 0;
    for ( int i = 0; i < n; ++i ) {
        if ( s[i] == 'R' ) ++r;
        else if ( s[i] == 'G' ) ++g;
        else ++b;
    }
    ll cnt = (ll)r * (ll)g * (ll)b;

    for ( int i = 0; i < n; ++i ) {
        for ( int j = i + 1; j < n; ++j ) {
            if ( s[i] != s[j] && 2*j - i < n && s[i] != s[2*j - i] && s[j] != s[2*j - i] ) --cnt;
        }
    }

    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBuildStairs solver = new CBuildStairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBuildStairs {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] h = in.readIntArray(n);

            boolean answer = true;
            for (int i = n - 1; i > 0; i--) {
                if (h[i - 1] > h[i]) {
                    h[i - 1]--;
                }
                answer &= h[i - 1] <= h[i];
            }

            out.println(answer ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



Measured memory_bytes: 39468
//author: dazhong_feliks

#include <bits/stdc++.h>
using namespace std;

int main() {
  int a,b;
  string op;
  cin >> a >> op >> b;

  if ( op == "+"){
      cout << a + b ;    
  }

  else {
      cout << a - b << endl;
  }

}



Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
# X >= Yとしたい。
if X < Y:
  A, B = B, A
  X, Y = Y, X
else:
  pass
if A + B <= 2 * C:
  print(A * X + B * Y)
else:
    if A >= 2 * C:
      print(C * 2 * X)
    else:
      print(A * (X - Y) + C * 2 * Y)
      

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

int main(){
    int n; ll d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(d*d >= x*x + y*y) ans++;
    }
    cout << ans << endl;
}

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), cnt(int(1e5 + 1));
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		cnt[a[i]]++;
	}
	int q;
	cin >> q;
	vector<int> b(q), c(q);
	for (int i = 0; i < q; i++)
		cin >> b[i] >> c[i];
	for (int i = 0; i < q; i++) {
		sum += cnt[b[i]] * (c[i] - b[i]);
		cnt[c[i]] += cnt[b[i]];
		cnt[b[i]] = 0;
		cout << sum << '\n';
	}
}



Measured memory_bytes: 4756
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    int a[10][10] = {0};
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        string s = to_string(i);
        int first = s[0]-'0';
        int second = s[s.size()-1] - '0';
        a[first][second]++;
    }
    
    int ans = 0;
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            ans+=a[i][j]*a[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  int N;
  int W[101];
  int S1[101] = {0};
  int S2[101] = {0};
  int sa = 100000;
  
  cin >> N;
  
  for(int i = 1;i <= N;i++){
    cin >> W[i];
  }
  
  for(int i = 1;i <=N;i++){
    for(int j = 1;j <=i;j++){
      S1[i] += W[j];
    } 
    for(int j = i+1;j <= N;j++){
      S2[i] += W[j];
    }
    if(sa > abs(S1[i] - S2[i])){
      sa = abs(S1[i] - S2[i]);
    }
  }

  cout << sa;
}

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

#define NIL 2000000001
#define MAX 500001

class Node
{
    public:
    int key, l = MAX, r = MAX;
};
vector<Node> nodes(MAX);
int p = 0, root = 0;

void insert(int key)
{
    nodes.at(p).key = key;
    if (p == 0) {
        p++;
        return;
    }
    int *cur = &root;
    while (MAX != *cur) {
        if (nodes.at(*cur).key > key) cur = &nodes.at(*cur).l;
        else cur = &nodes.at(*cur).r;
    }
    *cur = p++;
}

void inorder(int cur)
{
    if (MAX == cur) return;
    inorder(nodes.at(cur).l);
    cout << " " << nodes.at(cur).key;
    inorder(nodes.at(cur).r);
}

void preorder(int cur)
{
    if (MAX == cur) return;
    cout << " " << nodes.at(cur).key;
    preorder(nodes.at(cur).l);
    preorder(nodes.at(cur).r);
}

int main()
{
    int n, key;
    string command;
    cin >> n;
    while (n--) {
        cin >> command;
        if ("insert" == command) {
            cin >> key;
            insert(key);
        }
        if ("print" == command) {
            inorder(0);
            cout << endl;
            preorder(0);
//            for (int i = 0; i < p; i++) {
//                cout << " " << nodes.at(i).key;
//            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8468
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

class Union_Find{
  private:
    vector<int> par;// parent
    vector<int> rank;// depth

  public:
    Union_Find(int N){
      par.resize(N);
      rank.resize(N);
      for(int i=0; i<N; ++i){
        par[i] = i;
        rank[i] = 0;
      }
      return;
    };

    ~Union_Find(void){
      return;
    };

    //search the root
    int find(int x){
      if(par[x] == x){
        return x;
      }else{
        return par[x] = find(par[x]);
      }
    };

    //merge the sets x or y belong
    void unite(int x, int y){
      x = find(x);
      y = find(y);
      if(x == y) return;

      if(rank[x] < rank[y]){
        par[x] = y;
      }else{
        par[y] = x;
        if(rank[x] == rank[y]){
          rank[x]++;
        }
      }
      return;
    };

    //judge x and y belong the same set or not
    bool same(int x, int y){
      return find(x) == find(y);
    };
};

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> p(N);
  rep(i, 0, N){
    cin >> p[i];
    p[i]--;
  }

  ll x, y;
  Union_Find que(N);
  rep(i, 0, M){
    cin >> x >> y;
    x--;
    y--;
    que.unite(p[x], p[y]);
  }

  ll count = 0;
  rep(i, 0, N){
    if(que.same(i, p[i])){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int H, W;
char field[1000][1100];

int dp[1100][1100];

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void solve() {

	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j + 1 < W && field[i][j + 1] == '.') add(dp[i][j + 1], dp[i][j]);
			if (i + 1 < H && field[i + 1][j] == '.') add(dp[i + 1][j], dp[i][j]);
		}
	}
	printf("%d\n", dp[H - 1][W - 1]);
}

int main(void){
	cin>>H>>W;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) cin>>field[i][j];

	solve();
	
	return 0;
}

Measured memory_bytes: 5632
using System.Numerics;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = BigInteger.Parse(line[0]);
        var b = int.Parse(line[1].Replace(".", ""));
        BigInteger ans = a * b / 100;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27900
//Math.
#include<iostream>
#include<cmath>
using namespace std;
typedef long long     llong;

int main(){
	llong n;
	cin>>n;
	
	if(n<2 or n%2){
		cout<<0<<endl;
		return 0;
	}
	
	n/=2;
	llong num=5;
	llong sum=0;
	while(num<=n){
		sum+=floor((long double)n/num);//point!
		num*=5;
	}
	
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] = (a[i] - 1) % k;
    }
    vector<ll> sum(n+1);
    sum[0] = 0;
    rep(i, n) {
        sum[i+1] = (sum[i] + a[i]) % k;
    }
    ll ans = 0;
    map<int, int> mp;
    rep(i, n+1) {
        if (i<k) {
            ans += mp[sum[i]];
            mp[sum[i]]++;
        }
        else {
            mp[sum[i-k]]--;
            ans += mp[sum[i]];
            mp[sum[i]]++;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>

int main(void){
	int a, b;
	char op;
	
	a = 0;
	b = 0;
	
	do{
		scanf("%d %c %d", &a, &op, &b);
		if(op == '+'){
			printf("%d\n", (a+b));
		}else if(op == '-'){
			printf("%d\n", (a-b));
		}else if(op == '*'){
			printf("%d\n", (a*b));
		}else if(op == '/'){
			printf("%d\n", (a/b));
		}else if(op == '?'){
			break;
		}
	}while(op != '?');
	
	return(0);

}

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

int main() {
  	string s;
  	int ans=0;
	cin >> s;
  
	if(s[0] == '1')	ans++;
	if(s[1] == '1')	ans++;
  	if(s[2] == '1')	ans++;
  
  cout << ans << endl;

}

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

int odd(int x){
    int cnt = 0;
    while (x){
        x /= 10;
        cnt++;
    }
    return (cnt % 2 );
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = n; i >= 1; i--)
        ans += odd(i);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
S=input()
W=[0]*(len(S)+1)
W[0]=1
words=['dream','dreamer','erase','eraser' ]
for i in range(len(S)):
  if W[i]==0:
    continue
  for k in words:
    if S[i:i+len(k)]==k:
      W[i+len(k)]=1
if W[len(S)]==1:
  print("YES")
  exit()
else:
  print("NO")


Measured memory_bytes: 9796
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int N,K,s=1;
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++){
		if(s<=K) s=2*s;
		else s=s+K;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;
int ans = 0;


signed main(void) {
    cin >> N;
    rep(i,N){
        int a;
        cin >> a;
        ans += a-1;
    }


    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> A;
    A.push_back(0);
    REP(i, n){
        int a;
        cin >> a;
        A.push_back(a);
    }
    A.push_back(0);

    int sum = 0;
    for(int i = 1; i < A.size(); i++){
        sum += abs(A[i] - A[i - 1]);
    }

    for(int i = 1; i < A.size() - 1; i++){
        int diff = 0;
        if(A[i - 1] <= A[i] and A[i] <= A[i + 1]);
        else if(A[i - 1] >= A[i] and A[i] >= A[i + 1]);
        else{
            diff = abs(abs(A[i + 1] - A[i]) + abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i - 1]));
        }
        cout << sum - diff << endl;
    }

    return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[410];
int num[410];

int dp[410][410];//[l,r]のスライムが一匹にまとまっているとき、それを分解するのに必要な最小コスト

int DP(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l==r)return 0;
	int res=INF;
	for(int i=l;i<r;i++){
		res=min(res,DP(l,i)+DP(i+1,r));
	}
	return dp[l][r]=res+(num[r+1]-num[l]);
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		num[i+1]=num[i]+A[i];
	}
	REP(i,410)REP(j,410){
		dp[i][j]=-1;
	}
	cout<<DP(0,N-1)<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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

using namespace std;

int main() {
	#ifdef HOME
	freopen("input.txt", "rt", stdin);
	#endif  //  HOME
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x;
	cin >> n >> x;
	int ans = 0;
	while (n >= x) {
		ans += 1;
		n /= x;
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int n;
int sum;

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		int l,r;
		scanf("%d%d",&l,&r);
		sum+=r-l+1;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    int k,x;
    cin >> k >> x;
    if (k*500 < x){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256