akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    ll odd_num = 0;
    ll even_num = 0;
    
    FOR(i, 0, N){
        ll a;
        cin >> a;
        if(a%2==0){
            even_num++;
        }else{
            odd_num++;
        }
    }

    ll answer = pow(3, N);
    answer -= pow(2, even_num);
    p(answer);
    
    return 0;
}

Measured memory_bytes: 256
""" AtCoder """

A = input()
B = input()

if len(A) == len(B):
    if A > B:
        print("GREATER")
    elif A < B:
        print("LESS")
    else:
        print("EQUAL")
elif len(A) > len(B):
    print("GREATER")
else:
    print("LESS")


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

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 
 
int main()
{
    fastio();
    int n,a,b; cin>>n>>a>>b; int arr[n]={0};
    int k=0,countb=0; string s; cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='a' && k<a+b) {++k; arr[i]=1;}
        if(s[i]=='b' && k<a+b && countb<b) {++k; ++countb; arr[i]=1;}
    }
    for(int i=0;i<n;i++)
    {
        string sd=(arr[i]==1)?"Yes":"No"; cout<<sd<<endl;
    }
    return 0;
}

Measured memory_bytes: 1232
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int four = 0;
		int two = 0;
		int other = 0;
		for (int i = 0; i < n; i++) {
		    int a = sc.nextInt();
		    if (a % 4 == 0) {
		        four++;
		    } else if (a % 2 == 0) {
		        two++;
		    } else {
		        other++;
		    }
		}
		boolean flag;
		if (four == 0) {
		    if (other == 0 && two >= 2) {
		        flag = true;
		    } else {
		        flag = false;
		    }
		} else if (four - other >= 0) {
		    flag = true;
		} else if (four - other >= -1) {
		    if (two == 0) {
		        flag = true;
		    } else {
		        flag = false;
		    }
		} else {
		    flag = false;
		}
		if (flag) {
	        System.out.println("Yes");
	    } else {
	        System.out.println("No");
		}
	}
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin >> a >> b;
	cout << (a ^ b ^ 3 ^ 2 ^ 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll a,b,c,k,ans;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k),ans=a-b;
	if ((k%2)==0) printf("%lld",ans);else printf("%lld",-ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    double L;
    cin >> L;
    cout << fixed;
    cout << setprecision(8) << (L / 3) * (L / 3) * (L / 3);
    return 0;
}


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

int main(){
    int a,b;
    string as="",bs="";

    cin>>a>>b;
    for(int i = 0;i<b;i++){
        as+=a+'0';
    }
    for(int i=0;i<a;i++){
        bs+=b+'0';
    }

    if(as<bs){
        cout<<as<<endl;
    }else{
        cout<<bs<<endl;
    }
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint a,b,x;
    cin >> a >> b >> x;
    lint ans=0;
    lint aa, bb;
    aa = (a-1) / x +1;
    bb = b / x   +1;
    aa *= !((a-1) == -1);
    ans = bb - aa;

    cout << ans << "\n";
    return 0;
}

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

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

    std::vector<std::int32_t> As(N);
    for(auto& A : As)
    {
        std::cin >> A;
    }
    std::sort(As.begin(), As.end());

    std::vector<bool> sieve(As.back()+1, true);
    for(const auto A : As)
    {
        if(not sieve[A]) {continue;}
        for(std::size_t i=2*A; i<sieve.size(); i += A)
        {
            sieve[i] = false;
        }
    }

    std::unordered_map<std::int32_t, std::size_t> dup;
    std::size_t answer = 0;
    for(const auto A : As)
    {
        if(sieve.at(A))
        {
            answer += 1;
            if(dup.count(A) == 0)
            {
                dup[A] = 1;
            }
            else
            {
                dup[A] += 1;
            }
        }
    }

    for(const auto& [i, n] : dup)
    {
        if(1 < n)
        {
            answer -= n;
        }
    }

    std::cout << answer << std::endl;

    return 0;
}


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

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

int main(){
    int n; ll s; cin >> n >> s;
    vector<ll> x(n);
    for(int i=0; i<n; ++i){cin >> x[i];}
    vector<ll> d(n);
    for(int i=0; i<n; ++i){d[i] = abs(s-x[i]);}
    ll res = d[0];
    for(int i=1; i<n; ++i){
        ll di = d[i];
        res = gcd(di, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  if(a <= c && c <= b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())

s = ['']*n
t = ['']*n
for i in range(n):
    s[i], t[i] = input().split()
    
    
x = input()

p = s.index(x)
total = 0
for i in range(p+1, n):
    total += int(t[i])
print(total)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

const ll infty = 1e+18 + 1;

int main() {
	int N, M, a, b;
	ll c;
	vector<ll> dist;
	vector<pair<int, int>> edge;
	map<pair<int, int>, ll> weight;

	cin >> N >> M;

	dist.push_back(0);
	REP(i, N - 1) {
		dist.push_back(infty);
	}
	REP(i, M) {
		cin >> a >> b >> c;
		pair<int, int> p(a - 1, b - 1);
		edge.push_back(p);
		weight[p] = -1 * c;
	}


	int u, v;
	ll w;
	REP(i, N - 1) {
		REP(j, M) {
			u = edge[j].first;
			v = edge[j].second;
			w = weight[make_pair(u, v)];
			if (dist[v] > dist[u] + w && dist[u] != infty) {
				dist[v] = dist[u] + w;
			}
		}
	}


	bool f[1000];
	REP(i, N) {
		f[i] = false;
	}
	REP(i, N) {
		REP(j, M) {
			u = edge[j].first;
			v = edge[j].second;
			w = weight[make_pair(u, v)];
			if (dist[v] > dist[u] + w && dist[u] != infty) {
				dist[v] = dist[u] + w;
				f[v] = true;
			}
			if (f[a]) {
				f[b] = true;
			}
		}
	}



	if (f[N - 1]) {
		cout << "inf" << endl;
		return 0;
	}
	
	cout << -1 * dist[N - 1] << endl;




	return 0;
}

Measured memory_bytes: 384
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto s=readln.chomp.to!(char[]);

  auto e=new int[](n+1), w=new int[](n+1);
  foreach(i; 0..n){
    if(s[i]=='E') e[i+1]++;
    else w[i+1]++;
  }
  foreach(i; 0..n){
    e[i+1]+=e[i];
    w[i+1]+=w[i];
  }
  int mn=n;
  foreach(i; 0..n){
    int k=w[i]+(e[n]-e[i+1]);
    mn=min(mn, k);
  }
  writeln(mn);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 4348
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

can = true
if n > 1
    (1..n-1).each do |i|
        if h[i-1] > h[i]
            can = false
        elsif h[i-1] < h[i]
            h[i] -= 1
        end
    end
end

puts can ? "Yes" : "No"

Measured memory_bytes: 9604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int h, w;
	cin >> h >> w;
	char ans1[505][505], ans2[505][505];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(j == 0 || (i % 2 == 0 && j != w - 1)){
				ans1[i][j] = '#';
				ans2[i][j] = '.';
			} else {
				ans1[i][j] = '.';
				ans2[i][j] = '#';
			}
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char a;
			cin >> a;
			if(a == '#'){
				ans1[i][j] = '#';
				ans2[i][j] = '#';
			}
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ans1[i][j];
		}
		cout << endl;
	}
	cout << endl;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ans2[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int a, b;
	cin >> a >> b;
	if(a+b==3) cout << 3 << endl;
	else if(a+b==4) cout << 2 << endl;
	else if(a+b==5) cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<std::pair<int64_t, int>> p(N+M);
  for(int i = 0; i < N; ++i) {
    std::cin >> p[i].first;
    p[i].second = 1;
  }
  for(int i = 0; i < M; ++i) std::cin >> p[N+i].second >> p[N+i].first;
  std::sort(p.begin(), p.end(), std::greater<std::pair<int64_t,int>>());
  int count = 0;
  int64_t ans = 0;
  for(auto const& v: p) {
    if(count + v.second <= N) {
      ans += v.first*v.second;
      count += v.second;
    } else {
      ans += v.first*(N-count);
      fin(ans);
    }
  }
  return 0;
}


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

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

  ll ans = 0, cnt = 0;
  for (auto c : s) {
    if (c == 'B')
      cnt++;
    else
      ans += cnt;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  int n,k; cin >> n >> k;
  vector<int> l(n);
  for(int i=0;i<n;++i) cin >> l[i];
  sort(l.begin(),l.end(),greater<int>());
  int ans=0;
  for(int i=0;i<k;++i) ans+=l[i];
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int in;
  int i;
  int jou[10]={1,2,4,8,16,32,64,128,256,512};

  while(scanf("%d",&in)!=EOF){
    int c=0;
    int han[10]={0};
    for(i=9;i>=0;i--){
      if(han[i]==1)
	continue;
      if(jou[i]<=in){
	han[i]=1;
	in-=jou[i];
      }
    }
    for(i=0;i<10;i++){
      if(han[i]==1){
	if(c==0){
	  printf("%d",jou[i]);
	  c=1;
	}else{
	  printf(" %d",jou[i]);
	}
      }
    }
    putchar('\n');
  }

  return 0;
}

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

int main(){
    int N,l,r,seet,spectator;
    scanf("%d", &N);
    spectator = 0;
    for(int i = 0; i < N; i++){
        cin >> l >> r;
        seet = r - l + 1;
        spectator += seet;
    }
    cout << spectator << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,m;
int i,j,k,ans;
int main(){
	cin>>a>>b>>c>>n;
	for (int i=0;i<=a;i++){
		for (int j=0;j<=b;j++){
			for (int k=0;k<=c;k++){
				if(500*i+100*j+50*k==n)ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque


N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    a -= 1; b -= 1
    edge[a].append(b)
    edge[b].append(a)

path = [float('inf')] * N
q = deque()
q.append((0, 0))
path[0] = 0
while q:
    p, step = q.popleft()
    for np in edge[p]:
        nstep = step + 1
        if path[np] > nstep and nstep <= 2:
            q.append((np, nstep))
            path[np] = nstep

ans = 'POSSIBLE' if path[N - 1] == 2 else 'IMPOSSIBLE'
print(ans)


Measured memory_bytes: 52984
//cool
#include <iostream>
#include <fstream>
#include <set>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lli;
typedef int ll;
#define lp(i, wwww) for(int i=0; i<wwww; i++)
#define lp2(i, a, b) for(int i=a; i<b; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define clean(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pb push_back

lli a, b, c;

ll main(){
	IOS;
	cin >> a >> b >> c;
	cout << min(a*b, c);
}



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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int H,W;

bool move(vector<vector<char>> &m, vector<vector<int>> &seen, int y, int x) {
    if (y>=H || y<0 || x>=W || x<0) {
        return false;
    }
    else if (m[y][x] == '#') {
        return false;
    }
    else if (seen[y][x]!=-1) {
        return false;
    }
    else {
        return true;
    }
}

int bfs(vector<vector<char>> &m, vector<vector<int>> &seen, int y, int x) {
    queue<P> n;
    n.push(make_pair(y,x));
    seen[y][x] = 0;

    int step = 0;
    while(n.size()) {
        auto tmp = n.front();
        n.pop();
        y = tmp.first;
        x = tmp.second;
        rep(i,4) {
            if (move(m,seen,y+dy[i],x+dx[i])) {
                n.push(make_pair(y+dy[i],x+dx[i]));
                seen[y+dy[i]][x+dx[i]] = seen[y][x] + 1;
                step = max(step,seen[y+dy[i]][x+dx[i]]);
            }
        }
    }
    return step;
    
}

int main(){
    cin >> H >> W;
    vector<vector<char>> m(H,vector<char> (W));
    vector<P> S;
    rep(i,H) {
        string tmp;
        cin >> tmp;
        rep(j,W){
            m[i][j] = tmp[j];
            if (tmp[j] == '.') {
                S.push_back(make_pair(i,j));
            }
        }
    }

    int ans = 0;

    for (auto s:S) {
        vector<vector<int>> seen(H,vector<int>(W,-1));
        ans = max(ans,bfs(m,seen,s.first,s.second));
    }
    cout << ans << endl;

}    



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    int one, two;
    for (auto i = 0; i < n; i++)
    {
        int a_i;
        cin >> a_i;
        a[i] = a_i;
        b[i] = a_i;
    }

    sort(b.begin(), b.end());
    one = b[n - 1];
    two = b[n - 2];

    for (auto i = 0; i < n; i++)
    {
        if(a[i] == one){
            cout << two << endl;
        }else{
            cout << one << endl;
        }
    }
    
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main() {
  int n;cin >> n;
  int a[4];
  int i=0;
  while(i<4){
    a[3-i]=n%10;
    n/=10;
    i++;
  }
  if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3]))cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
height1 = gets.chomp.to_i
height2 = gets.chomp.to_i
height3 = gets.chomp.to_i
height4 = gets.chomp.to_i
height5 = gets.chomp.to_i
height6 = gets.chomp.to_i
height7 = gets.chomp.to_i
height8 = gets.chomp.to_i
height9 = gets.chomp.to_i
height10 = gets.chomp.to_i
a=[height1, height2, height3, height4, height5, height6, height7, height8, height9, height10]
b=a.sort
puts b[9]
puts b[8]
puts b[7]

Measured memory_bytes: 6096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int h,w; cin >>h>>w;
    vector<string> s(h); REP(i,h) cin >> s[i];

    vector<vector<int> > res(h, vector<int>(w, -1));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                res[i][j] = 0;
                for (int x = -1; x <= 1; x++) {
                    for (int y = -1; y <= 1; y++) {
                        if (0 <= i + x && i + x < h && 0 <= j + y && j + y < w && s[i+x][j+y] == '#') {
                            res[i][j]++;
                        } 
                    }
                }
            } 
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (res[i][j] < 0) {
                cout << '#';
            } else {
                cout << to_string(res[i][j]);
            } 
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
x = sorted(list(map(int, input().split())))
sum = 0
if len(x) < n:
    print('No')
else:
    for i in range(0, len(x) - 1):
        sum += x[i]
    if sum > x[len(x) - 1]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n,k;
    cin>>n>>k;
    VI ar(n);
    for(int i=0;i<n;i++)cin>>ar[i];
    sort(all(ar));
    if(n<=k)cout<<"0"<<endl;
    else
    {  int sum=0;
        for(int i=0;i<n-k;i++)sum+=ar[i];
        cout<<sum<<endl;
    }
}


return 0;
}





Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int a , b , takasa = 0;
  scanf("%d %d",&a ,&b);
  
  for(int i = 1;i < b-a;i ++){
    takasa += i;
  }
  
  printf("%d",takasa - a);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    int a, b;
    char op;
    int c;

    cin >> a >> op >> b;

    if(op == '+'){
        c = a + b;
    }else if(op == '-'){
        c = a -b;
    }

    cout << c << endl;


}

Measured memory_bytes: 256
using System;

class Bingo{
  static void Main(){
      int[,] card = new int [3,3]; 
      int[,] check = new int[3,3]{
          {0,0,0},
          {0,0,0},
          {0,0,0},
      };
      var ans  = "No";
      
      for(var i  = 0 ;i < 3 ;i++){
          var input = Console.ReadLine().Split(' ');
          for(var j = 0; j < 3 ;j++){
              card[i,j] = int.Parse(input[j]);
          }
      }
      
      var times = int.Parse(Console.ReadLine());
      for(var i = 0 ;i < times ;i++){
          int number = int.Parse(Console.ReadLine());
          
          for(var j = 0; j < 3;j++){
              for(var k = 0;k < 3 ;k++){
                  if(card[j,k] == number){
                      check[j,k] =1;
                  }
              }
          }
      }
      
     for(var i = 0; i < 3 ;i++){
         int count_w = 0;
         int count_l = 0;
         for(var j = 0; j < 3; j++){
             if(check[i,j] == 1){
                 count_w++;
             } 
             if(check[j,i] == 1){
                 count_l++;
             }
             if(count_w == 3 || count_l == 3){
                 ans = "Yes";
                 break;
             }
         }
     }
     
     if((check[0,0] == 1 && check[1,1] == 1 && check[2,2] == 1)|| (check[0,2] == 1 && check[1,1] == 1 && check[2,0] == 1)){
         ans = "Yes";
     }
     
     Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	double a, b;
	cin >> a >> b;
	cout << fixed << setprecision(6) << a/b << endl;
	
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    if (n < 105) println(0)
    else {
        if (n%2==0) n--
        var ans = 0
        while (n > 103) {
            var cnt = 0
            for (i in 1..n) {
                if (n%i == 0) {
                    cnt++
                }
            }
            if (cnt == 8) ans++
            n-=2
        }
        println (ans)
    }
}


Measured memory_bytes: 31752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  
  int i=n/111;
  if(n%111==0) {
    cout << n<< endl;
    return 0;
  }else {
    ++i;
    cout << i*111 << endl;
    return 0;
  }
}
  


Measured memory_bytes: 256
<?php
    while(true){
        list($height, $width) = explode(" ",trim(fgets(STDIN)));

        if($height == 0 && $width == 0) exit;
    
        $bar = "";
        for($i = 0; $i < $width; $i++){
            $bar .= "#";
        }
    
        for($j = 0; $j < $height; $j++){
            print $bar."\n";
        }

        print "\n";
    }    

Measured memory_bytes: 15408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

class Calc_Mod{//calculate mod
    public:
        unsigned int mod=1000000007;
        ll plus_mod(ll a,ll b){
            return (a+b)%mod;
        }
        ll minus_mod(ll a,ll b){
            return (a-b)%mod;
        }
        ll multi_mod(ll a,ll b){
            return a*b%mod;
        }
        ll LSM(ll a,int b){//a^b%mod
            queue<int> q;
            while(b>=1){
                q.push(b%2);
                b/=2;
            }
            ll ans=1;
            while(!q.empty()){
                if(q.front()==1){
                    ans=multi_mod(ans,a);
                }
                a=multi_mod(a,a);
                q.pop();
            }
            return ans;
        }
        ll div_mod(ll a,ll b){// a/b
            return multi_mod(a,LSM(b,mod-2));
        }
        ll combi(ll a,ll b){//aCb
            ll ans=1;
            ll kaijo=1;
            rep(i,b){
                ans=multi_mod(ans,a-i);
                kaijo=multi_mod(kaijo,b-i);
            }
            ans=div_mod(ans,kaijo);
            return ans;
        }
        
};

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

    ll ans;
    ll eight=1;ll ten=1;
    ll nine=1;
    rep(i,n){
        nine*=9;nine%=MAX;
        eight*=8;eight%=MAX;
        ten*=10;ten%=MAX;
    }
    eight%=MAX;nine%=MAX;ten%=MAX;
    nine*=2;
    nine%=MAX;
    ans=(ten-(nine-eight)%MAX)%MAX;
    if(ans<0){
        ans+=MAX;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3684
#include <stdio.h>

#define N	8
#define MD	1000000007

long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }

int cnt[N + 1];

void init() {
	int i;

	cnt[1] = 9;
	for (i = 2; i <= N; i++)
		cnt[i] = cnt[i - 1] * 10;
}

long long power(int a, int k) {
	long long p = 1, b = a;

	while (k) {
		if (k & 1)
			p = p * b % MD;
		b = b * b % MD;
		k >>= 1;
	}
	return p;
}

int main() {
	int s, l1, l2, r1, a, ans;

	init();
	scanf("%d", &s);
	ans = (s - 1) / N;
	for (l1 = 1; l1 <= N; l1++) {
		int s_;

		if (s % l1 == 0 && cnt[l1] >= s / l1)
			ans = (ans + cnt[l1] - s / l1 + 1) % MD;
		s_ = s;
		for (l2 = l1 + 1; l2 <= N; l2++) {
			long long lower, upper;

			lower = (max(s_ - (long long) cnt[l2] * l2, 1) + l1 - 1) / l1;
			upper = min((s_ - l2) / l1, cnt[l1]);
			if (lower <= upper)
				for (r1 = 1; r1 <= l2; r1++)
					if ((s_ - r1 * l1) % l2 == 0)
						ans = (ans + (upper + l2 - r1) / l2 - (lower - 1 + l2 - r1) / l2) % MD;
			if (s_ / l2 < cnt[l2])
				break;
			s_ -= cnt[l2] * l2;
		}
	}
	for (a = 1; a <= s / a; a++)
		if (s % a == 0) {
			if (a > N)
				ans = (ans + power(10, a - 1) * 9 - s / a) % MD;
			if (a != s / a && s / a > N)
				ans = (ans + power(10, s / a - 1) * 9 - a) % MD;
		}
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define int64_t pp;
const int mod = 1000000007;
/* ll eval(ll x)
{
	
		return ((x * eval(x-2)));
}*/ 

int main()
{
	ll n,t,count;
	cin>>n;
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	

	count = 0;
	n /= 2;
	while(n){
		count += n / 5;
		n /= 5;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import math

n, m = map(int,input().split())

def combinations_count(n, r):
    if n-r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a = combinations_count(n, 2)
b = combinations_count(m, 2)

print(a+b)

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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int n,k;
		cin >> n;
		vector<int> a;
		int count = 0;
		string s;
		cin >> s;
		for(int i=0;i<n;i++){
				a.push_back(s[i]);
				if (i != 0 && s[i] == 'E') count += 1;
		}
		int ans = count;
		for(int i=1;i<n;i++){
				if(a[i] == 'E') count -= 1;
				if(a[i-1] == 'W') count += 1;
				if(ans > count) ans = count;
		}
		cout << ans << endl;
}


Measured memory_bytes: 6776
n = int(input())
a = [int(i) for i in input().split()]

def calc(sign) :
    pre_sign = sign
    s = 0
    ret = 0
    for ai in a :
        if ai + s > 0 :
            cur_sign = 1
        elif ai + s < 0 :
            cur_sign = -1
        else :
            cur_sign = 0
        
        if pre_sign * cur_sign < 0 :
            s += ai
        else :
            ret += abs((pre_sign * -1) - (ai + s))
            s = pre_sign * -1
        pre_sign *= -1
        
    return ret
    
print(min(calc(1), calc(-1)))

Measured memory_bytes: 63216
#include<iostream>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    cout << a-1 << " " << b << endl;
  }
  else if(t==u){
    cout << a << " " << b-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)//2)
'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> X(N), Y(N);
    rep(i, 0, N) {
        cin >> A[i];
        vector<int> x(A[i]), y(A[i]);
        rep(j, 0, A[i]) {
            cin >> x[j] >> y[j];
            --x[j];
        }
        X[i] = x;
        Y[i] = y;
    }
    int ans = 0;
    rep(mask, 0, 1 << N) {
        // 1が正直者
        bool is_ok = true;
        vector<int> state(N, -1);
        rep(i, 0, N) {
            if ((mask >> i) & 1) {
                rep(j, 0, A[i]) {
                    if (state[X[i][j]] >= 0) {
                        if (state[X[i][j]] != Y[i][j]) {
                            is_ok = false;
                        }
                    }
                    else {
                        state[X[i][j]] = Y[i][j];
                    }
                }
            }
        }
        if (!is_ok) continue;
        rep(i, 0, N) {
            if (state[i] < 0) continue;
            if (((mask >> i) & 1) != state[i]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            ans = max(ans, __builtin_popcount(mask));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

vector<vector<pair<ll, ll>>> g;
vector<ll> seen;
void dfs(int v, int p=-1, int c=1){
    seen[v] = c;
    for(auto x: g[v]){
        if(x.first==p) continue;
        if(x.second%2==0) dfs(x.first, v, c);
        else dfs(x.first, v, 1-c);
    }
}
int main(){
    int n;  cin >> n;
    g.resize(n); seen.assign(n, -1);
    REP(i, n-1){
        ll a, b, w;    cin >> a >> b >> w;
        a--;    b--;
        g[a].push_back({b, w});
        g[b].push_back({a, w});
    }
    dfs(0);
    REP(i, n) cout << seen[i] << endl;
}

Measured memory_bytes: 10752
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int DEBUG = 0;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l;
  int n;
  cin >> l >> n;
  VL x(n);
  REP(i, 0, n) cin >> x[i];
  VL accl(n + 1, 0), accr(n + 1, 0);
  REP(i, 0, n) accl[i + 1] = accl[i] + x[i];
  REP(i, 0, n) accr[i + 1] = accr[i] + (l - x[n - 1 - i]);
  if (DEBUG) {
    REP(i, 0, n + 1) cerr << " " << accl[i];
    cerr << endl;
    REP(i, 0, n + 1) cerr << " " << accr[i];
    cerr << endl;
  }
  ll ma = max(x[n - 1], l - x[0]);
  REP(i, 0, n - 1) {
    int cnt = min(i, n - 2 - i);
    int cntl = i > cnt ? cnt + 1 : cnt;
    ll tmp = 2 * (accr[n - 1 - i] - accr[n - 1 - i - cnt - 1] + accl[i] - accl[i - cntl]) + x[i];
    if (DEBUG) {
      DEBUGP(i);
      DEBUGP(cnt);
      DEBUGP(tmp);
    }
    ma = max(ma, tmp);
  }
  REP(i, 0, n - 1) {
    int cnt = min(i, n - 2 - i);
    int cntl = i > cnt ? cnt + 1 : cnt;
    ll tmp = 2 * (accl[n - 1 - i] - accl[n - 1 - i - cnt - 1] + accr[i] - accr[i - cntl]) + (l - x[n - 1 - i]);
    if (DEBUG) {
      DEBUGP(i);
      DEBUGP(tmp);
    }
    ma = max(ma, tmp);
  }
  cout << ma << endl;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;
const int INF = 1e9 + 7;

int n, k;
int a[N], dp[N];

int main() {

	FAST;

	cin >> n >> k;
	a[n + 1] = 1;
	for (int i = n; i >= 1; i --) {
		// intt maxsum = (1LL * n * (n + 1) / 2 - 1LL * (n - i) * (n - i + 1) / 2) % INF;
		// maxsum can also be written as
		intt maxsum = (1LL * n * i - 1LL * (i - 1) * i / 2) % INF;
		intt minsum = (1LL * (i - 1) * i / 2) % INF;
		a[i] = (maxsum - minsum + 1) % INF;
		if (a[i] < 0) a[i] += INF; 
	}
	for (int i = n + 1; i >= 1; i --) {
		dp[i] = 1LL * (a[i] + dp[i + 1]) % INF;
	}
	cout << dp[k] << '\n';
	return 0;
}

Measured memory_bytes: 5140
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()

prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]

d = {}  # d[p] = Nがpで最大何回割り切れるか
for p in prime:
    r = 0
    for i in range(1,7):
        r += N//(p**i)
    d[p] = r

A = 0  # d[p] >= 74 たるpの個数
B = 0  # d[p] >= 24 たるpの個数
C = 0  # d[p] >= 14 たるpの個数
D = 0  # d[p] >= 4 たるpの個数
E = 0  # d[p] >= 2 たるpの個数

for p in prime:
    if d[p] >= 74:
        A += 1
    if d[p] >= 24:
        B += 1
    if d[p] >= 14:
        C += 1
    if d[p] >= 4:
        D += 1
    if d[p] >= 2:
        E += 1

# 順に、p**74,p**24×q**2,p**14×q**4,p**4×q**4×r**2 の個数を加える

print(A+B*(E-1)+C*(D-1)+((D*(D-1))//2)*(E-2))

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {

			if (k & 1) res *= tmp;

			tmp *= tmp;
			k >>= 1;
		}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

using M = Mint<ll>;

vector<ll> S, T;
M dp[2005][2005];
int main() {
	ll N, M;

	cin >> N >> M;
	S.resize(N), T.resize(M);
	rep(i, N) {

		cin >> S[i];
	}


	rep(i, M) {

		cin >> T[i];

	}



	dp[0][0] = (S[0] == T[0]) ? 2 : 1;

	for(int j = 1; j < M; j++) {
		dp[0][j] = dp[0][j-1] + ((S[0] == T[j]) ? 1 : 0);
	}

	for (int i = 1; i < N; i++) {
		dp[i][0] = dp[i-1][0] + ((S[i] == T[0]) ? 1 : 0);
	}
	for(int i = 1; i < N; i++) {
		for(int j = 1; j < M; j++) {

			
			dp[i][j] = ((S[i] == T[j]) ? dp[i - 1][j - 1] : 0) + (dp[i][j - 1] + dp[i - 1][j]) - dp[i-1][j-1];
			


		}
	}

	
	cout << dp[N - 1][M - 1].v << endl;

	return 0;
}

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

typedef long long ll;

int main(){
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	
	if(v<=w)puts("NO");
	else {
		if(t*(v-w)>=abs(a-b))puts("YES");
		else puts("NO");
	}
}


Measured memory_bytes: 3636
l=gets.chomp.split("")
s1=[]
size=0
deep=0
res=[]
down=0
up=0
us=0
ds=0
h=0
maxh=0
under=0
flag=false
l.each{|i|
  if i=="\\"
    s1<<i
    down+=1
    h-=1
  elsif i=="/"
    s1<<i
    up+=1
    h+=1
  elsif i=="_"
    s1<<i
    under+=1
  end
  maxh=h if maxh<h
  size=0
  if maxh==up-down && up!=0 && down!=0 && s1.include?("\\") && s1.include?("/")
    while 1 do
      i=s1.pop
      if i=="\\"
        deep=deep-1
        size+=0.5+deep
        us+=1
      elsif i=="/"
        size+=0.5+deep
        deep+=1
        ds+=1
      elsif i=="_"
        size+=deep
      end
      break if us==ds && us!=0 && ds!=0
    end
    res<<size
    size=0
    deep=0
    us=0
    ds=0
  end
}
size=0
deep=0
us=0
ds=0
res2=[]
while i = s1.pop do
  if i=="/"
    size+=0.5+deep
    deep+=1
    ds+=1
    while i=s1.pop do
      if i=="\\"
        deep=deep-1
        size+=0.5+deep
        us+=1
      elsif i=="/"
        size+=0.5+deep
        deep+=1
        ds+=1
      elsif i=="_"
        size+=deep
      end
      if us==ds && us!=0 && ds!=0
        flag=true
        break
      end
    end
    res2<<size if flag
    size=0
    deep=0
    us=0
    ds=0
    flag=false
  end
end
ans1=(res.sum+res2.sum).to_i
ans2=res.size+res2.size
#ans3=res.map(&:to_i).join(" ")+" "+ res2.map(&:to_i).reverse.join(" ")
#puts ans1
#puts "#{ans2} #{ans3}"
res2=res2.reverse
res.push(res2)
res.flatten!
res=res.map(&:to_i)

puts ans1
print ans2
if res.size > 0
    puts " #{res.join(" ")}"
else
    print "\n"
end


Measured memory_bytes: 8276
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;
const ll N=1e5+5;
bool x[N+1]={false};
ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a)%Mod;
        if(n%2==0)
        {
            return (((res%Mod)*(res%Mod))%Mod);
        }
        else{
            return (((((res%Mod)*a)%Mod)*res)%Mod);
        }
    }
}

int main()
{
   ll a,b;
   cin>>a>>b;
   ll p=a-1,q=b-1;
   if(q%p==0)
    cout<<q/p;
   else
    cout<<(q/p)+1;




}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}



  
int main() {

string S;
cin >> S;
int cnt = 0;


for(int i = 0; i < S.size(); i++){ 
   for(int j = 0; j < S.size(); j++){ 
      if(S.at(i) == S.at(j)) cnt++;
   }
}

if(cnt == 8) yes;
else no;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
vector<Int> A;
vector<vector<int>> G;
Int recur(int node, int prev) {
    Int maxc = 0, sumc = 0, num = 0;
    for (auto next : G[node]) if (next != prev) {
        num++;
        Int c = recur(next, node);
        maxc = max(maxc, c);
        sumc += c;
    }
    if (num == 0) {
        return A[node];
    }
    Int y = sumc - A[node];
    Int x = A[node] - y;
    if (x >= 0 && y >= 0 && y <= sumc - maxc) {
        return x;
    }
    cout << "NO" << '\n';
    exit(0);
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    A = vector<Int>(N); for (auto &a : A) cin >> a;
    G = vector<vector<int>>(N);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (N == 2) {
        cout << (A[0] == A[1] ? "YES" : "NO") << '\n';
        return 0;
    }
    for (int i = 0; i < N-1; i++) {
        if (G[i].size() == 1) continue;
        cout << (recur(i, -1) == 0 ? "YES" : "NO") << '\n';
        break;
    }
    return 0;
}


Measured memory_bytes: 14464
N, M = gets.split(' ').map(&:to_i)

@par = (0..N).to_a

def root(i)
	if @par[i] == i
		return i
	end
	@par[i] = root(@par[i])
end

def same(i, j)
	root(i) == root(j)
end

@size = [1] * (N + 1)
def size(i)
	@size[i] = @size[root(i)]
end

@rank = [1] * (N + 1)
def unite(i, j)
	i = root(i)
	j = root(j)
	if i != j
		if @rank[i] > @rank[j]
			@par[j] = i
			@size[i] += @size[j]
		else
			@par[i] = j
			@size[j] += @size[i]
			if @rank[i] == @rank[j]
				@rank[j] += 1
			end
		end
	end
end

bridge = []
M.times do
	x, y = gets.split(' ').map(&:to_i)
	bridge.unshift([x, y])
end

cnt = N * (N - 1) / 2
inconv = []
bridge.each do |a, b|
	inconv.unshift(cnt)
	if !same(a, b)
		cnt -= size(a) * size(b)
		unite(a, b)
	end
end

puts inconv

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

int main() {

  int N;
  cin >> N;

  vector<int> B(N);
  for (int i = 1; i < N; i++) {
    cin >> B[i];
  }

  vector<int> A(N+1);
  
  A[1] = B[1];

  for (int i = 1; i < N; i++) {
    A[i + 1] = B[i];
    if (B[i] < A[i]) {
      A[i] = B[i];
    }
  }

  int m = 0;

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

  cout << m << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef int64_t ll;
typedef long double ld;
using namespace std;
const ll mod=1000000007;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll H,N;cin>>H>>N;
    vector<ll>weight(N);
    vector<ll>value(N);
    rep(i,N)cin>>weight[i]>>value[i];
    ll MAX=2*pow(10,4);
    vector<vector<ll>>dp(N+1,vector<ll>(MAX,INF));

    rep(i,N)dp[i][0]=0;

    for (int i = 0; i < N; ++i) {
        for (int w = 0; w < MAX; ++w) {
            dp[i + 1][w] = min(dp[i + 1][w], dp[i][w]);
            if (w >= weight[i]) dp[i + 1][w] = min(dp[i + 1][w], dp[i + 1][w - weight[i]] + value[i]);
        }
    }
    ll ans=INF;
    for(int i=H;i<MAX;i++){
      ans=min(ans,dp[N][i]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 160640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] H = new int[N];
    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt();
    }

    for (int i = N-2; i >= 0; i--) {
      if (H[i] - H[i+1] > 1) {
        System.out.println("No");
        return;
      }
      if (H[i] > H[i+1]) {
        H[i]--;
      }
    }
    System.out.println("Yes");
  }  
}

Measured memory_bytes: 49808
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(c&&a){
    c=c-b;
    if(c<=0){
      cout<<"Yes";
      break;
    }
    a=a-d;
    if(a<=0){
      cout<<"No";
      break;
    }
  }
  return 0;
 }
    

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; string op; cin >> A >> op >> B;
  int result = op == "+" ? A+B : A-B;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256